diff --git a/src/chatlog/content/filetransferwidget.cpp b/src/chatlog/content/filetransferwidget.cpp index 6bbb56af6..f6196ebf1 100644 --- a/src/chatlog/content/filetransferwidget.cpp +++ b/src/chatlog/content/filetransferwidget.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file) @@ -34,6 +34,7 @@ FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file) , ui(new Ui::FileTransferWidget) , fileInfo(file) , lastTick(QTime::currentTime()) + , color(Style::getColor(Style::LightGrey)) { ui->setupUi(this); @@ -47,12 +48,14 @@ FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file) ui->progressLabel->setText("0kiB/s"); ui->etaLabel->setText(""); - colorAnimation = new QPropertyAnimation(this, "color"); + colorAnimation = new QVariantAnimation(this); colorAnimation->setDuration(500); colorAnimation->setEasingCurve(QEasingCurve::OutCubic); - connect(colorAnimation, &QPropertyAnimation::valueChanged, this, [this] { update(); }); + connect(colorAnimation, &QVariantAnimation::valueChanged, this, [this](const QVariant& val) { + color = val.value(); + update(); + }); - setProperty("color", Style::getColor(Style::LightGrey)); setColor(Style::getColor(Style::LightGrey), false); 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) { - colorAnimation->setStartValue(property("color").value()); + colorAnimation->setStartValue(color); colorAnimation->setEndValue(c); colorAnimation->start(); @@ -143,7 +146,7 @@ void FileTransferWidget::paintEvent(QPaintEvent *) // required by Hi-DPI support as border-image doesn't work. QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); - painter.setBrush(QBrush(property("color").value())); + painter.setBrush(QBrush(color)); painter.setPen(Qt::NoPen); qreal s = static_cast(geometry().height()) / static_cast(geometry().width()); diff --git a/src/chatlog/content/filetransferwidget.h b/src/chatlog/content/filetransferwidget.h index bf6abcfe6..395932355 100644 --- a/src/chatlog/content/filetransferwidget.h +++ b/src/chatlog/content/filetransferwidget.h @@ -28,7 +28,7 @@ namespace Ui { class FileTransferWidget; } -class QPropertyAnimation; +class QVariantAnimation; class QPushButton; class FileTransferWidget : public QWidget @@ -69,7 +69,8 @@ private: ToxFile fileInfo; QTime lastTick; qint64 lastBytesSent = 0; - QPropertyAnimation* colorAnimation = nullptr; + QVariantAnimation* colorAnimation = nullptr; + QColor color; static const uint8_t TRANSFER_ROLLING_AVG_COUNT = 4; uint8_t meanIndex = 0;