qt: Make OverviewPage aware of runtime palette change

This change fixes the GUI when changing appearance on macOS.
This commit is contained in:
Hennadii Stepanov 2021-04-08 20:42:03 +03:00
parent d05f1b278d
commit 97a6b5e06a
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
2 changed files with 19 additions and 1 deletions

View file

@ -78,6 +78,7 @@ public:
{
QIcon iconWatchonly = qvariant_cast<QIcon>(index.data(TransactionTableModel::WatchonlyDecorationRole));
QRect watchonlyRect(boundingRect.right() + 5, mainRect.top()+ypad+halfheight, 16, halfheight);
iconWatchonly = platformStyle->TextColorIcon(iconWatchonly);
iconWatchonly.paint(painter, watchonlyRect);
address_rect_min_width += 5 + watchonlyRect.width();
}
@ -143,6 +144,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent)
ui(new Ui::OverviewPage),
clientModel(nullptr),
walletModel(nullptr),
m_platform_style{platformStyle},
txdelegate(new TxViewDelegate(platformStyle, this))
{
ui->setupUi(this);
@ -150,7 +152,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent)
m_balances.balance = -1;
// use a SingleColorIcon for the "out of sync warning" icon
QIcon icon = platformStyle->SingleColorIcon(":/icons/warning");
QIcon icon = m_platform_style->SingleColorIcon(QStringLiteral(":/icons/warning"));
ui->labelTransactionsStatus->setIcon(icon);
ui->labelWalletStatus->setIcon(icon);
@ -298,6 +300,17 @@ void OverviewPage::setWalletModel(WalletModel *model)
updateDisplayUnit();
}
void OverviewPage::changeEvent(QEvent* e)
{
#ifdef Q_OS_MACOS
if (e->type() == QEvent::PaletteChange) {
QIcon icon = m_platform_style->SingleColorIcon(QStringLiteral(":/icons/warning"));
ui->labelTransactionsStatus->setIcon(icon);
ui->labelWalletStatus->setIcon(icon);
}
#endif
}
void OverviewPage::updateDisplayUnit()
{
if(walletModel && walletModel->getOptionsModel())

View file

@ -45,6 +45,9 @@ Q_SIGNALS:
void transactionClicked(const QModelIndex &index);
void outOfSyncWarningClicked();
protected:
void changeEvent(QEvent* e) override;
private:
Ui::OverviewPage *ui;
ClientModel *clientModel;
@ -52,6 +55,8 @@ private:
interfaces::WalletBalances m_balances;
bool m_privacy{false};
const PlatformStyle* m_platform_style;
TxViewDelegate *txdelegate;
std::unique_ptr<TransactionFilterProxy> filter;