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 "editaddressdialog.h"
|
||||
#include "guiutil.h"
|
||||
#include "optionsmodel.h"
|
||||
#include "scicon.h"
|
||||
#include "platformstyle.h"
|
||||
#include "transactiondescdialog.h"
|
||||
#include "transactionfilterproxy.h"
|
||||
#include "transactionrecord.h"
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <QUrl>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
TransactionView::TransactionView(QWidget *parent) :
|
||||
TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *parent) :
|
||||
QWidget(parent), model(0), transactionProxyModel(0),
|
||||
transactionView(0)
|
||||
{
|
||||
@@ -44,27 +44,28 @@ TransactionView::TransactionView(QWidget *parent) :
|
||||
|
||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
||||
hlayout->setContentsMargins(0,0,0,0);
|
||||
#ifdef Q_OS_MAC
|
||||
hlayout->setSpacing(5);
|
||||
hlayout->addSpacing(26);
|
||||
#else
|
||||
hlayout->setSpacing(0);
|
||||
hlayout->addSpacing(23);
|
||||
#endif
|
||||
|
||||
if (platformStyle->getUseExtraSpacing()) {
|
||||
hlayout->setSpacing(5);
|
||||
hlayout->addSpacing(26);
|
||||
} else {
|
||||
hlayout->setSpacing(0);
|
||||
hlayout->addSpacing(23);
|
||||
}
|
||||
|
||||
watchOnlyWidget = new QComboBox(this);
|
||||
watchOnlyWidget->setFixedWidth(24);
|
||||
watchOnlyWidget->addItem("", TransactionFilterProxy::WatchOnlyFilter_All);
|
||||
watchOnlyWidget->addItem(SingleColorIcon(":/icons/eye_plus"), "", TransactionFilterProxy::WatchOnlyFilter_Yes);
|
||||
watchOnlyWidget->addItem(SingleColorIcon(":/icons/eye_minus"), "", TransactionFilterProxy::WatchOnlyFilter_No);
|
||||
watchOnlyWidget->addItem(platformStyle->SingleColorIcon(":/icons/eye_plus"), "", TransactionFilterProxy::WatchOnlyFilter_Yes);
|
||||
watchOnlyWidget->addItem(platformStyle->SingleColorIcon(":/icons/eye_minus"), "", TransactionFilterProxy::WatchOnlyFilter_No);
|
||||
hlayout->addWidget(watchOnlyWidget);
|
||||
|
||||
dateWidget = new QComboBox(this);
|
||||
#ifdef Q_OS_MAC
|
||||
dateWidget->setFixedWidth(121);
|
||||
#else
|
||||
dateWidget->setFixedWidth(120);
|
||||
#endif
|
||||
if (platformStyle->getUseExtraSpacing()) {
|
||||
dateWidget->setFixedWidth(121);
|
||||
} else {
|
||||
dateWidget->setFixedWidth(120);
|
||||
}
|
||||
dateWidget->addItem(tr("All"), All);
|
||||
dateWidget->addItem(tr("Today"), Today);
|
||||
dateWidget->addItem(tr("This week"), ThisWeek);
|
||||
@@ -75,11 +76,11 @@ TransactionView::TransactionView(QWidget *parent) :
|
||||
hlayout->addWidget(dateWidget);
|
||||
|
||||
typeWidget = new QComboBox(this);
|
||||
#ifdef Q_OS_MAC
|
||||
typeWidget->setFixedWidth(121);
|
||||
#else
|
||||
typeWidget->setFixedWidth(120);
|
||||
#endif
|
||||
if (platformStyle->getUseExtraSpacing()) {
|
||||
typeWidget->setFixedWidth(121);
|
||||
} else {
|
||||
typeWidget->setFixedWidth(120);
|
||||
}
|
||||
|
||||
typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES);
|
||||
typeWidget->addItem(tr("Received with"), TransactionFilterProxy::TYPE(TransactionRecord::RecvWithAddress) |
|
||||
@@ -102,11 +103,11 @@ TransactionView::TransactionView(QWidget *parent) :
|
||||
#if QT_VERSION >= 0x040700
|
||||
amountWidget->setPlaceholderText(tr("Min amount"));
|
||||
#endif
|
||||
#ifdef Q_OS_MAC
|
||||
amountWidget->setFixedWidth(97);
|
||||
#else
|
||||
amountWidget->setFixedWidth(100);
|
||||
#endif
|
||||
if (platformStyle->getUseExtraSpacing()) {
|
||||
amountWidget->setFixedWidth(97);
|
||||
} else {
|
||||
amountWidget->setFixedWidth(100);
|
||||
}
|
||||
amountWidget->setValidator(new QDoubleValidator(0, 1e20, 8, this));
|
||||
hlayout->addWidget(amountWidget);
|
||||
|
||||
@@ -121,11 +122,11 @@ TransactionView::TransactionView(QWidget *parent) :
|
||||
vlayout->setSpacing(0);
|
||||
int width = view->verticalScrollBar()->sizeHint().width();
|
||||
// Cover scroll bar width with spacing
|
||||
#ifdef Q_OS_MAC
|
||||
hlayout->addSpacing(width+2);
|
||||
#else
|
||||
hlayout->addSpacing(width);
|
||||
#endif
|
||||
if (platformStyle->getUseExtraSpacing()) {
|
||||
hlayout->addSpacing(width+2);
|
||||
} else {
|
||||
hlayout->addSpacing(width);
|
||||
}
|
||||
// Always show scroll bar
|
||||
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||
view->setTabKeyNavigation(false);
|
||||
|
||||
Reference in New Issue
Block a user