mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-08 11:44:14 +01:00
qt: Introduce PlatformStyle
Introduce a PlatformStyle to handle platform-specific customization of the UI. This replaces 'scicon', as well as #ifdefs to determine whether to place icons on buttons. The selected PlatformStyle defaults to the platform that the application was compiled on, but can be overridden from the command line with `-uiplatform=<x>`. Also fixes the warning from #6328.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#include "guiconstants.h"
|
||||
#include "guiutil.h"
|
||||
#include "optionsmodel.h"
|
||||
#include "scicon.h"
|
||||
#include "platformstyle.h"
|
||||
#include "transactionfilterproxy.h"
|
||||
#include "transactiontablemodel.h"
|
||||
#include "walletmodel.h"
|
||||
@@ -25,7 +25,9 @@ class TxViewDelegate : public QAbstractItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TxViewDelegate(): QAbstractItemDelegate(), unit(BitcoinUnits::BTC)
|
||||
TxViewDelegate(const PlatformStyle *platformStyle):
|
||||
QAbstractItemDelegate(), unit(BitcoinUnits::BTC),
|
||||
platformStyle(platformStyle)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -43,7 +45,7 @@ public:
|
||||
int halfheight = (mainRect.height() - 2*ypad)/2;
|
||||
QRect amountRect(mainRect.left() + xspace, mainRect.top()+ypad, mainRect.width() - xspace, halfheight);
|
||||
QRect addressRect(mainRect.left() + xspace, mainRect.top()+ypad+halfheight, mainRect.width() - xspace, halfheight);
|
||||
icon = SingleColorIcon(icon, SingleColor());
|
||||
icon = platformStyle->SingleColorIcon(icon);
|
||||
icon.paint(painter, decorationRect);
|
||||
|
||||
QDateTime date = index.data(TransactionTableModel::DateRole).toDateTime();
|
||||
@@ -101,11 +103,12 @@ public:
|
||||
}
|
||||
|
||||
int unit;
|
||||
const PlatformStyle *platformStyle;
|
||||
|
||||
};
|
||||
#include "overviewpage.moc"
|
||||
|
||||
OverviewPage::OverviewPage(QWidget *parent) :
|
||||
OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::OverviewPage),
|
||||
clientModel(0),
|
||||
@@ -116,13 +119,13 @@ OverviewPage::OverviewPage(QWidget *parent) :
|
||||
currentWatchOnlyBalance(-1),
|
||||
currentWatchUnconfBalance(-1),
|
||||
currentWatchImmatureBalance(-1),
|
||||
txdelegate(new TxViewDelegate()),
|
||||
txdelegate(new TxViewDelegate(platformStyle)),
|
||||
filter(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// use a SingleColorIcon for the "out of sync warning" icon
|
||||
QIcon icon = SingleColorIcon(":/icons/warning");
|
||||
QIcon icon = platformStyle->SingleColorIcon(":/icons/warning");
|
||||
icon.addPixmap(icon.pixmap(QSize(64,64), QIcon::Normal), QIcon::Disabled); // also set the disabled icon because we are using a disabled QPushButton to work around missing HiDPI support of QLabel (https://bugreports.qt.io/browse/QTBUG-42503)
|
||||
ui->labelTransactionsStatus->setIcon(icon);
|
||||
ui->labelWalletStatus->setIcon(icon);
|
||||
|
||||
Reference in New Issue
Block a user