Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing lock icon view in coincontrol #1129

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions src/qt/platformstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -59,18 +72,31 @@ QIcon ColorizeIcon(const QIcon& ico, const QColor& colorbase)
return new_ico;
}


QImage ColorizeImage(const QString& filename, const QColor& colorbase)
{
QImage img(filename);
MakeSingleColorImage(img, 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)));
}

}


Expand Down Expand Up @@ -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());
Expand Down
3 changes: 3 additions & 0 deletions src/qt/platformstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down