diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 80fa634d69..7dcc253c62 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -274,7 +274,7 @@ void CoinControlDialog::lockCoin() COutPoint outpt(uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); model->lockCoin(outpt); contextMenuItem->setDisabled(true); - contextMenuItem->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed")); + contextMenuItem->setIcon(COLUMN_CHECKBOX, platformStyle->LockIcon(":/icons/lock_closed")); updateLabelLocked(); } @@ -778,7 +778,7 @@ void CoinControlDialog::updateView() COutPoint outpt(txhash, out.i); coinControl->UnSelect(outpt); // just to be sure itemOutput->setDisabled(true); - itemOutput->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed")); + itemOutput->setIcon(COLUMN_CHECKBOX, platformStyle->LockIcon(":/icons/lock_closed")); } // set checkbox diff --git a/src/qt/platformstyle.cpp b/src/qt/platformstyle.cpp index 3d67196a4a..dc8084b256 100644 --- a/src/qt/platformstyle.cpp +++ b/src/qt/platformstyle.cpp @@ -46,6 +46,19 @@ void MakeSingleColorImage(QImage& img, const QColor& colorbase) } } +void MakeLockColorImage(QImage& img, const QColor& colorbase) +{ + img = img.convertToFormat(QImage::Format_ARGB32); + for (int x = img.width(); x--; ) + { + for (int y = img.height(); y--; ) + { + const QRgb rgb = img.pixel(x, y); + img.setPixel(x, y, qRgba(colorbase.red(), colorbase.green(), colorbase.blue(), qAlpha(rgb))); + } + } +} + QIcon ColorizeIcon(const QIcon& ico, const QColor& colorbase) { QIcon new_ico; @@ -59,6 +72,7 @@ QIcon ColorizeIcon(const QIcon& ico, const QColor& colorbase) return new_ico; } + QImage ColorizeImage(const QString& filename, const QColor& colorbase) { QImage img(filename); @@ -66,11 +80,23 @@ QImage ColorizeImage(const QString& filename, const QColor& colorbase) return img; } +QImage ColorizeLockImage(const QString& filename, const QColor& colorbase) +{ + QImage img(filename); + MakeLockColorImage(img, colorbase); + return img; +} + QIcon ColorizeIcon(const QString& filename, const QColor& colorbase) { return QIcon(QPixmap::fromImage(ColorizeImage(filename, colorbase))); } +QIcon ColorizeLockIcon(const QString& filename, const QColor& colorbase) +{ + return QIcon(QPixmap::fromImage(ColorizeLockImage(filename, colorbase))); +} + } @@ -120,6 +146,13 @@ QIcon PlatformStyle::SingleColorIcon(const QIcon& icon) const return ColorizeIcon(icon, SingleColor()); } +QIcon PlatformStyle::LockIcon(const QString& filename) const +{ + if (!colorizeIcons) + return QIcon(filename); + return ColorizeLockIcon(filename, SingleColor()); +} + QIcon PlatformStyle::TextColorIcon(const QString& filename) const { return ColorizeIcon(filename, TextColor()); diff --git a/src/qt/platformstyle.h b/src/qt/platformstyle.h index 4e763e760e..0a01aa6a18 100644 --- a/src/qt/platformstyle.h +++ b/src/qt/platformstyle.h @@ -39,6 +39,9 @@ class PlatformStyle /** Colorize an icon (given object) with the text color */ QIcon TextColorIcon(const QIcon& icon) const; + /** Coincontrol lock icon */ + QIcon LockIcon(const QString& filename) const; + private: PlatformStyle(const QString &name, bool imagesOnButtons, bool colorizeIcons, bool useExtraSpacing);