mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
FTW: Replaced QPropertyAnimation by QVariantAnimation
This commit is contained in:
parent
b9dcb3bd9b
commit
6b605fbdc3
|
@ -26,7 +26,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPropertyAnimation>
|
#include <QVariantAnimation>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
|
FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
|
||||||
|
@ -34,6 +34,7 @@ FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
|
||||||
, ui(new Ui::FileTransferWidget)
|
, ui(new Ui::FileTransferWidget)
|
||||||
, fileInfo(file)
|
, fileInfo(file)
|
||||||
, lastTick(QTime::currentTime())
|
, lastTick(QTime::currentTime())
|
||||||
|
, color(Style::getColor(Style::LightGrey))
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -47,12 +48,14 @@ FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
|
||||||
ui->progressLabel->setText("0kiB/s");
|
ui->progressLabel->setText("0kiB/s");
|
||||||
ui->etaLabel->setText("");
|
ui->etaLabel->setText("");
|
||||||
|
|
||||||
colorAnimation = new QPropertyAnimation(this, "color");
|
colorAnimation = new QVariantAnimation(this);
|
||||||
colorAnimation->setDuration(500);
|
colorAnimation->setDuration(500);
|
||||||
colorAnimation->setEasingCurve(QEasingCurve::OutCubic);
|
colorAnimation->setEasingCurve(QEasingCurve::OutCubic);
|
||||||
connect(colorAnimation, &QPropertyAnimation::valueChanged, this, [this] { update(); });
|
connect(colorAnimation, &QVariantAnimation::valueChanged, this, [this](const QVariant& val) {
|
||||||
|
color = val.value<QColor>();
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
|
||||||
setProperty("color", Style::getColor(Style::LightGrey));
|
|
||||||
setColor(Style::getColor(Style::LightGrey), false);
|
setColor(Style::getColor(Style::LightGrey), false);
|
||||||
|
|
||||||
connect(Core::getInstance(), &Core::fileTransferInfo, this, &FileTransferWidget::onFileTransferInfo);
|
connect(Core::getInstance(), &Core::fileTransferInfo, this, &FileTransferWidget::onFileTransferInfo);
|
||||||
|
@ -118,7 +121,7 @@ void FileTransferWidget::acceptTransfer(const QString &filepath)
|
||||||
|
|
||||||
void FileTransferWidget::setColor(const QColor &c, bool whiteFont)
|
void FileTransferWidget::setColor(const QColor &c, bool whiteFont)
|
||||||
{
|
{
|
||||||
colorAnimation->setStartValue(property("color").value<QColor>());
|
colorAnimation->setStartValue(color);
|
||||||
colorAnimation->setEndValue(c);
|
colorAnimation->setEndValue(c);
|
||||||
colorAnimation->start();
|
colorAnimation->start();
|
||||||
|
|
||||||
|
@ -143,7 +146,7 @@ void FileTransferWidget::paintEvent(QPaintEvent *)
|
||||||
// required by Hi-DPI support as border-image doesn't work.
|
// required by Hi-DPI support as border-image doesn't work.
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
painter.setBrush(QBrush(property("color").value<QColor>()));
|
painter.setBrush(QBrush(color));
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
|
|
||||||
qreal s = static_cast<qreal>(geometry().height()) / static_cast<qreal>(geometry().width());
|
qreal s = static_cast<qreal>(geometry().height()) / static_cast<qreal>(geometry().width());
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Ui {
|
||||||
class FileTransferWidget;
|
class FileTransferWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class QPropertyAnimation;
|
class QVariantAnimation;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
|
||||||
class FileTransferWidget : public QWidget
|
class FileTransferWidget : public QWidget
|
||||||
|
@ -69,7 +69,8 @@ private:
|
||||||
ToxFile fileInfo;
|
ToxFile fileInfo;
|
||||||
QTime lastTick;
|
QTime lastTick;
|
||||||
qint64 lastBytesSent = 0;
|
qint64 lastBytesSent = 0;
|
||||||
QPropertyAnimation* colorAnimation = nullptr;
|
QVariantAnimation* colorAnimation = nullptr;
|
||||||
|
QColor color;
|
||||||
|
|
||||||
static const uint8_t TRANSFER_ROLLING_AVG_COUNT = 4;
|
static const uint8_t TRANSFER_ROLLING_AVG_COUNT = 4;
|
||||||
uint8_t meanIndex = 0;
|
uint8_t meanIndex = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user