Merge pull request #6487

eec7757 qt: Introduce PlatformStyle (Wladimir J. van der Laan)
This commit is contained in:
Wladimir J. van der Laan 2015-07-31 10:01:30 +02:00
commit 9848d4297b
No known key found for this signature in database
GPG key ID: 74810B012346C9A6
37 changed files with 462 additions and 318 deletions

View file

@ -185,13 +185,13 @@ BITCOIN_QT_H = \
qt/paymentrequestplus.h \ qt/paymentrequestplus.h \
qt/paymentserver.h \ qt/paymentserver.h \
qt/peertablemodel.h \ qt/peertablemodel.h \
qt/platformstyle.h \
qt/qvalidatedlineedit.h \ qt/qvalidatedlineedit.h \
qt/qvaluecombobox.h \ qt/qvaluecombobox.h \
qt/receivecoinsdialog.h \ qt/receivecoinsdialog.h \
qt/receiverequestdialog.h \ qt/receiverequestdialog.h \
qt/recentrequeststablemodel.h \ qt/recentrequeststablemodel.h \
qt/rpcconsole.h \ qt/rpcconsole.h \
qt/scicon.h \
qt/sendcoinsdialog.h \ qt/sendcoinsdialog.h \
qt/sendcoinsentry.h \ qt/sendcoinsentry.h \
qt/signverifymessagedialog.h \ qt/signverifymessagedialog.h \
@ -273,10 +273,10 @@ BITCOIN_QT_CPP = \
qt/optionsdialog.cpp \ qt/optionsdialog.cpp \
qt/optionsmodel.cpp \ qt/optionsmodel.cpp \
qt/peertablemodel.cpp \ qt/peertablemodel.cpp \
qt/platformstyle.cpp \
qt/qvalidatedlineedit.cpp \ qt/qvalidatedlineedit.cpp \
qt/qvaluecombobox.cpp \ qt/qvaluecombobox.cpp \
qt/rpcconsole.cpp \ qt/rpcconsole.cpp \
qt/scicon.cpp \
qt/splashscreen.cpp \ qt/splashscreen.cpp \
qt/trafficgraphwidget.cpp \ qt/trafficgraphwidget.cpp \
qt/utilitydialog.cpp qt/utilitydialog.cpp

View file

@ -441,6 +441,9 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-min", _("Start minimized")); strUsage += HelpMessageOpt("-min", _("Start minimized"));
strUsage += HelpMessageOpt("-rootcertificates=<file>", _("Set SSL root certificates for payment request (default: -system-)")); strUsage += HelpMessageOpt("-rootcertificates=<file>", _("Set SSL root certificates for payment request (default: -system-)"));
strUsage += HelpMessageOpt("-splash", _("Show splash screen on startup (default: 1)")); strUsage += HelpMessageOpt("-splash", _("Show splash screen on startup (default: 1)"));
if (showDebug) {
strUsage += HelpMessageOpt("-uiplatform", "Select platform to customize UI for (one of windows, macosx, other; default: platform compiled on)");
}
} }
return strUsage; return strUsage;

View file

@ -14,14 +14,14 @@
#include "csvmodelwriter.h" #include "csvmodelwriter.h"
#include "editaddressdialog.h" #include "editaddressdialog.h"
#include "guiutil.h" #include "guiutil.h"
#include "scicon.h" #include "platformstyle.h"
#include <QIcon> #include <QIcon>
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) : AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode mode, Tabs tab, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::AddressBookPage), ui(new Ui::AddressBookPage),
model(0), model(0),
@ -30,17 +30,17 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac if (!platformStyle->getImagesOnButtons()) {
ui->newAddress->setIcon(QIcon()); ui->newAddress->setIcon(QIcon());
ui->copyAddress->setIcon(QIcon()); ui->copyAddress->setIcon(QIcon());
ui->deleteAddress->setIcon(QIcon()); ui->deleteAddress->setIcon(QIcon());
ui->exportButton->setIcon(QIcon()); ui->exportButton->setIcon(QIcon());
#else } else {
ui->newAddress->setIcon(SingleColorIcon(":/icons/add")); ui->newAddress->setIcon(platformStyle->SingleColorIcon(":/icons/add"));
ui->copyAddress->setIcon(SingleColorIcon(":/icons/editcopy")); ui->copyAddress->setIcon(platformStyle->SingleColorIcon(":/icons/editcopy"));
ui->deleteAddress->setIcon(SingleColorIcon(":/icons/remove")); ui->deleteAddress->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
ui->exportButton->setIcon(SingleColorIcon(":/icons/export")); ui->exportButton->setIcon(platformStyle->SingleColorIcon(":/icons/export"));
#endif }
switch(mode) switch(mode)
{ {

View file

@ -9,6 +9,7 @@
class AddressTableModel; class AddressTableModel;
class OptionsModel; class OptionsModel;
class PlatformStyle;
namespace Ui { namespace Ui {
class AddressBookPage; class AddressBookPage;
@ -39,7 +40,7 @@ public:
ForEditing /**< Open address book for editing */ ForEditing /**< Open address book for editing */
}; };
explicit AddressBookPage(Mode mode, Tabs tab, QWidget *parent); explicit AddressBookPage(const PlatformStyle *platformStyle, Mode mode, Tabs tab, QWidget *parent);
~AddressBookPage(); ~AddressBookPage();
void setModel(AddressTableModel *model); void setModel(AddressTableModel *model);

View file

@ -15,6 +15,7 @@
#include "intro.h" #include "intro.h"
#include "networkstyle.h" #include "networkstyle.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "platformstyle.h"
#include "splashscreen.h" #include "splashscreen.h"
#include "utilitydialog.h" #include "utilitydialog.h"
#include "winshutdownmonitor.h" #include "winshutdownmonitor.h"
@ -241,6 +242,7 @@ private:
WalletModel *walletModel; WalletModel *walletModel;
#endif #endif
int returnValue; int returnValue;
const PlatformStyle *platformStyle;
void startThread(); void startThread();
}; };
@ -310,6 +312,22 @@ BitcoinApplication::BitcoinApplication(int &argc, char **argv):
returnValue(0) returnValue(0)
{ {
setQuitOnLastWindowClosed(false); setQuitOnLastWindowClosed(false);
// UI per-platform customization
// This must be done inside the BitcoinApplication constructor, or after it, because
// PlatformStyle::instantiate requires a QApplication
#if defined(Q_OS_MAC)
std::string platformName = "macosx";
#elif defined(Q_OS_WIN)
std::string platformName = "windows";
#else
std::string platformName = "other";
#endif
platformName = GetArg("-uiplatform", platformName);
platformStyle = PlatformStyle::instantiate(QString::fromStdString(platformName));
if (!platformStyle) // Fall back to "other" if specified name not found
platformStyle = PlatformStyle::instantiate("other");
assert(platformStyle);
} }
BitcoinApplication::~BitcoinApplication() BitcoinApplication::~BitcoinApplication()
@ -330,6 +348,8 @@ BitcoinApplication::~BitcoinApplication()
#endif #endif
delete optionsModel; delete optionsModel;
optionsModel = 0; optionsModel = 0;
delete platformStyle;
platformStyle = 0;
} }
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
@ -346,7 +366,7 @@ void BitcoinApplication::createOptionsModel()
void BitcoinApplication::createWindow(const NetworkStyle *networkStyle) void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
{ {
window = new BitcoinGUI(networkStyle, 0); window = new BitcoinGUI(platformStyle, networkStyle, 0);
pollShutdownTimer = new QTimer(window); pollShutdownTimer = new QTimer(window);
connect(pollShutdownTimer, SIGNAL(timeout()), window, SLOT(detectShutdown())); connect(pollShutdownTimer, SIGNAL(timeout()), window, SLOT(detectShutdown()));
@ -421,6 +441,8 @@ void BitcoinApplication::initializeResult(int retval)
returnValue = retval ? 0 : 1; returnValue = retval ? 0 : 1;
if(retval) if(retval)
{ {
// Log this only after AppInit2 finishes, as then logging setup is guaranteed complete
qWarning() << "Platform customization:" << platformStyle->getName();
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
PaymentServer::LoadRootCAs(); PaymentServer::LoadRootCAs();
paymentServer->setOptionsModel(optionsModel); paymentServer->setOptionsModel(optionsModel);
@ -432,7 +454,7 @@ void BitcoinApplication::initializeResult(int retval)
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if(pwalletMain) if(pwalletMain)
{ {
walletModel = new WalletModel(pwalletMain, optionsModel); walletModel = new WalletModel(platformStyle, pwalletMain, optionsModel);
window->addWallet(BitcoinGUI::DEFAULT_WALLET, walletModel); window->addWallet(BitcoinGUI::DEFAULT_WALLET, walletModel);
window->setCurrentWallet(BitcoinGUI::DEFAULT_WALLET); window->setCurrentWallet(BitcoinGUI::DEFAULT_WALLET);

View file

@ -13,8 +13,8 @@
#include "openuridialog.h" #include "openuridialog.h"
#include "optionsdialog.h" #include "optionsdialog.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "platformstyle.h"
#include "rpcconsole.h" #include "rpcconsole.h"
#include "scicon.h"
#include "utilitydialog.h" #include "utilitydialog.h"
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
@ -60,7 +60,7 @@
const QString BitcoinGUI::DEFAULT_WALLET = "~Default"; const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) : BitcoinGUI::BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
clientModel(0), clientModel(0),
walletFrame(0), walletFrame(0),
@ -98,7 +98,8 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
notificator(0), notificator(0),
rpcConsole(0), rpcConsole(0),
prevBlocks(0), prevBlocks(0),
spinnerFrame(0) spinnerFrame(0),
platformStyle(platformStyle)
{ {
GUIUtil::restoreWindowGeometry("nWindow", QSize(850, 550), this); GUIUtil::restoreWindowGeometry("nWindow", QSize(850, 550), this);
@ -130,12 +131,12 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
setUnifiedTitleAndToolBarOnMac(true); setUnifiedTitleAndToolBarOnMac(true);
#endif #endif
rpcConsole = new RPCConsole(0); rpcConsole = new RPCConsole(platformStyle, 0);
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if(enableWallet) if(enableWallet)
{ {
/** Create wallet frame and make it the central widget */ /** Create wallet frame and make it the central widget */
walletFrame = new WalletFrame(this); walletFrame = new WalletFrame(platformStyle, this);
setCentralWidget(walletFrame); setCentralWidget(walletFrame);
} else } else
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
@ -175,7 +176,7 @@ BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks); QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
frameBlocksLayout->setContentsMargins(3,0,3,0); frameBlocksLayout->setContentsMargins(3,0,3,0);
frameBlocksLayout->setSpacing(3); frameBlocksLayout->setSpacing(3);
unitDisplayControl = new UnitDisplayStatusBarControl(); unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
labelEncryptionIcon = new QLabel(); labelEncryptionIcon = new QLabel();
labelConnectionsIcon = new QLabel(); labelConnectionsIcon = new QLabel();
labelBlocksIcon = new QLabel(); labelBlocksIcon = new QLabel();
@ -247,36 +248,36 @@ void BitcoinGUI::createActions()
{ {
QActionGroup *tabGroup = new QActionGroup(this); QActionGroup *tabGroup = new QActionGroup(this);
overviewAction = new QAction(SingleColorIcon(":/icons/overview"), tr("&Overview"), this); overviewAction = new QAction(platformStyle->SingleColorIcon(":/icons/overview"), tr("&Overview"), this);
overviewAction->setStatusTip(tr("Show general overview of wallet")); overviewAction->setStatusTip(tr("Show general overview of wallet"));
overviewAction->setToolTip(overviewAction->statusTip()); overviewAction->setToolTip(overviewAction->statusTip());
overviewAction->setCheckable(true); overviewAction->setCheckable(true);
overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1)); overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
tabGroup->addAction(overviewAction); tabGroup->addAction(overviewAction);
sendCoinsAction = new QAction(SingleColorIcon(":/icons/send"), tr("&Send"), this); sendCoinsAction = new QAction(platformStyle->SingleColorIcon(":/icons/send"), tr("&Send"), this);
sendCoinsAction->setStatusTip(tr("Send coins to a Bitcoin address")); sendCoinsAction->setStatusTip(tr("Send coins to a Bitcoin address"));
sendCoinsAction->setToolTip(sendCoinsAction->statusTip()); sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
sendCoinsAction->setCheckable(true); sendCoinsAction->setCheckable(true);
sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2)); sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
tabGroup->addAction(sendCoinsAction); tabGroup->addAction(sendCoinsAction);
sendCoinsMenuAction = new QAction(TextColorIcon(":/icons/send"), sendCoinsAction->text(), this); sendCoinsMenuAction = new QAction(platformStyle->TextColorIcon(":/icons/send"), sendCoinsAction->text(), this);
sendCoinsMenuAction->setStatusTip(sendCoinsAction->statusTip()); sendCoinsMenuAction->setStatusTip(sendCoinsAction->statusTip());
sendCoinsMenuAction->setToolTip(sendCoinsMenuAction->statusTip()); sendCoinsMenuAction->setToolTip(sendCoinsMenuAction->statusTip());
receiveCoinsAction = new QAction(SingleColorIcon(":/icons/receiving_addresses"), tr("&Receive"), this); receiveCoinsAction = new QAction(platformStyle->SingleColorIcon(":/icons/receiving_addresses"), tr("&Receive"), this);
receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and bitcoin: URIs)")); receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and bitcoin: URIs)"));
receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip()); receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
receiveCoinsAction->setCheckable(true); receiveCoinsAction->setCheckable(true);
receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3)); receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
tabGroup->addAction(receiveCoinsAction); tabGroup->addAction(receiveCoinsAction);
receiveCoinsMenuAction = new QAction(TextColorIcon(":/icons/receiving_addresses"), receiveCoinsAction->text(), this); receiveCoinsMenuAction = new QAction(platformStyle->TextColorIcon(":/icons/receiving_addresses"), receiveCoinsAction->text(), this);
receiveCoinsMenuAction->setStatusTip(receiveCoinsAction->statusTip()); receiveCoinsMenuAction->setStatusTip(receiveCoinsAction->statusTip());
receiveCoinsMenuAction->setToolTip(receiveCoinsMenuAction->statusTip()); receiveCoinsMenuAction->setToolTip(receiveCoinsMenuAction->statusTip());
historyAction = new QAction(SingleColorIcon(":/icons/history"), tr("&Transactions"), this); historyAction = new QAction(platformStyle->SingleColorIcon(":/icons/history"), tr("&Transactions"), this);
historyAction->setStatusTip(tr("Browse transaction history")); historyAction->setStatusTip(tr("Browse transaction history"));
historyAction->setToolTip(historyAction->statusTip()); historyAction->setToolTip(historyAction->statusTip());
historyAction->setCheckable(true); historyAction->setCheckable(true);
@ -300,46 +301,46 @@ void BitcoinGUI::createActions()
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
quitAction = new QAction(TextColorIcon(":/icons/quit"), tr("E&xit"), this); quitAction = new QAction(platformStyle->TextColorIcon(":/icons/quit"), tr("E&xit"), this);
quitAction->setStatusTip(tr("Quit application")); quitAction->setStatusTip(tr("Quit application"));
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
quitAction->setMenuRole(QAction::QuitRole); quitAction->setMenuRole(QAction::QuitRole);
aboutAction = new QAction(TextColorIcon(":/icons/about"), tr("&About Bitcoin Core"), this); aboutAction = new QAction(platformStyle->TextColorIcon(":/icons/about"), tr("&About Bitcoin Core"), this);
aboutAction->setStatusTip(tr("Show information about Bitcoin Core")); aboutAction->setStatusTip(tr("Show information about Bitcoin Core"));
aboutAction->setMenuRole(QAction::AboutRole); aboutAction->setMenuRole(QAction::AboutRole);
aboutQtAction = new QAction(TextColorIcon(":/icons/about_qt"), tr("About &Qt"), this); aboutQtAction = new QAction(platformStyle->TextColorIcon(":/icons/about_qt"), tr("About &Qt"), this);
aboutQtAction->setStatusTip(tr("Show information about Qt")); aboutQtAction->setStatusTip(tr("Show information about Qt"));
aboutQtAction->setMenuRole(QAction::AboutQtRole); aboutQtAction->setMenuRole(QAction::AboutQtRole);
optionsAction = new QAction(TextColorIcon(":/icons/options"), tr("&Options..."), this); optionsAction = new QAction(platformStyle->TextColorIcon(":/icons/options"), tr("&Options..."), this);
optionsAction->setStatusTip(tr("Modify configuration options for Bitcoin Core")); optionsAction->setStatusTip(tr("Modify configuration options for Bitcoin Core"));
optionsAction->setMenuRole(QAction::PreferencesRole); optionsAction->setMenuRole(QAction::PreferencesRole);
toggleHideAction = new QAction(TextColorIcon(":/icons/about"), tr("&Show / Hide"), this); toggleHideAction = new QAction(platformStyle->TextColorIcon(":/icons/about"), tr("&Show / Hide"), this);
toggleHideAction->setStatusTip(tr("Show or hide the main Window")); toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
encryptWalletAction = new QAction(TextColorIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this); encryptWalletAction = new QAction(platformStyle->TextColorIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet")); encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
encryptWalletAction->setCheckable(true); encryptWalletAction->setCheckable(true);
backupWalletAction = new QAction(TextColorIcon(":/icons/filesave"), tr("&Backup Wallet..."), this); backupWalletAction = new QAction(platformStyle->TextColorIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
backupWalletAction->setStatusTip(tr("Backup wallet to another location")); backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
changePassphraseAction = new QAction(TextColorIcon(":/icons/key"), tr("&Change Passphrase..."), this); changePassphraseAction = new QAction(platformStyle->TextColorIcon(":/icons/key"), tr("&Change Passphrase..."), this);
changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption")); changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
signMessageAction = new QAction(TextColorIcon(":/icons/edit"), tr("Sign &message..."), this); signMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/edit"), tr("Sign &message..."), this);
signMessageAction->setStatusTip(tr("Sign messages with your Bitcoin addresses to prove you own them")); signMessageAction->setStatusTip(tr("Sign messages with your Bitcoin addresses to prove you own them"));
verifyMessageAction = new QAction(TextColorIcon(":/icons/verify"), tr("&Verify message..."), this); verifyMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/verify"), tr("&Verify message..."), this);
verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified Bitcoin addresses")); verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified Bitcoin addresses"));
openRPCConsoleAction = new QAction(TextColorIcon(":/icons/debugwindow"), tr("&Debug window"), this); openRPCConsoleAction = new QAction(platformStyle->TextColorIcon(":/icons/debugwindow"), tr("&Debug window"), this);
openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console")); openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console"));
usedSendingAddressesAction = new QAction(TextColorIcon(":/icons/address-book"), tr("&Sending addresses..."), this); usedSendingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Sending addresses..."), this);
usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels")); usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
usedReceivingAddressesAction = new QAction(TextColorIcon(":/icons/address-book"), tr("&Receiving addresses..."), this); usedReceivingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Receiving addresses..."), this);
usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels")); usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
openAction = new QAction(TextColorIcon(":/icons/open"), tr("Open &URI..."), this); openAction = new QAction(platformStyle->TextColorIcon(":/icons/open"), tr("Open &URI..."), this);
openAction->setStatusTip(tr("Open a bitcoin: URI or payment request")); openAction->setStatusTip(tr("Open a bitcoin: URI or payment request"));
showHelpMessageAction = new QAction(TextColorIcon(":/icons/info"), tr("&Command-line options"), this); showHelpMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/info"), tr("&Command-line options"), this);
showHelpMessageAction->setMenuRole(QAction::NoRole); showHelpMessageAction->setMenuRole(QAction::NoRole);
showHelpMessageAction->setStatusTip(tr("Show the Bitcoin Core help message to get a list with possible Bitcoin command-line options")); showHelpMessageAction->setStatusTip(tr("Show the Bitcoin Core help message to get a list with possible Bitcoin command-line options"));
@ -650,7 +651,7 @@ void BitcoinGUI::setNumConnections(int count)
case 7: case 8: case 9: icon = ":/icons/connect_3"; break; case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
default: icon = ":/icons/connect_4"; break; default: icon = ":/icons/connect_4"; break;
} }
labelConnectionsIcon->setPixmap(SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelConnectionsIcon->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count)); labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count));
} }
@ -691,7 +692,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate)
if(secs < 90*60) if(secs < 90*60)
{ {
tooltip = tr("Up to date") + QString(".<br>") + tooltip; tooltip = tr("Up to date") + QString(".<br>") + tooltip;
labelBlocksIcon->setPixmap(SingleColorIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if(walletFrame) if(walletFrame)
@ -737,7 +738,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate)
tooltip = tr("Catching up...") + QString("<br>") + tooltip; tooltip = tr("Catching up...") + QString("<br>") + tooltip;
if(count != prevBlocks) if(count != prevBlocks)
{ {
labelBlocksIcon->setPixmap(SingleColorIcon(QString( labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(QString(
":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0'))) ":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
.pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES; spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
@ -931,7 +932,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
break; break;
case WalletModel::Unlocked: case WalletModel::Unlocked:
labelEncryptionIcon->show(); labelEncryptionIcon->show();
labelEncryptionIcon->setPixmap(SingleColorIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>")); labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
encryptWalletAction->setChecked(true); encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true); changePassphraseAction->setEnabled(true);
@ -939,7 +940,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
break; break;
case WalletModel::Locked: case WalletModel::Locked:
labelEncryptionIcon->show(); labelEncryptionIcon->show();
labelEncryptionIcon->setPixmap(SingleColorIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>")); labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
encryptWalletAction->setChecked(true); encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true); changePassphraseAction->setEnabled(true);
@ -1041,7 +1042,7 @@ void BitcoinGUI::unsubscribeFromCoreSignals()
uiInterface.ThreadSafeMessageBox.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3)); uiInterface.ThreadSafeMessageBox.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
} }
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() : UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
optionsModel(0), optionsModel(0),
menu(0) menu(0)
{ {
@ -1056,7 +1057,7 @@ UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() :
} }
setMinimumSize(max_width, 0); setMinimumSize(max_width, 0);
setAlignment(Qt::AlignRight | Qt::AlignVCenter); setAlignment(Qt::AlignRight | Qt::AlignVCenter);
setStyleSheet(QString("QLabel { color : %1 }").arg(SingleColor().name())); setStyleSheet(QString("QLabel { color : %1 }").arg(platformStyle->SingleColor().name()));
} }
/** So that it responds to button clicks */ /** So that it responds to button clicks */

View file

@ -22,6 +22,7 @@ class ClientModel;
class NetworkStyle; class NetworkStyle;
class Notificator; class Notificator;
class OptionsModel; class OptionsModel;
class PlatformStyle;
class RPCConsole; class RPCConsole;
class SendCoinsRecipient; class SendCoinsRecipient;
class UnitDisplayStatusBarControl; class UnitDisplayStatusBarControl;
@ -47,7 +48,7 @@ class BitcoinGUI : public QMainWindow
public: public:
static const QString DEFAULT_WALLET; static const QString DEFAULT_WALLET;
explicit BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent = 0); explicit BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent = 0);
~BitcoinGUI(); ~BitcoinGUI();
/** Set the client model. /** Set the client model.
@ -117,6 +118,8 @@ private:
int prevBlocks; int prevBlocks;
int spinnerFrame; int spinnerFrame;
const PlatformStyle *platformStyle;
/** Create the main UI actions. */ /** Create the main UI actions. */
void createActions(); void createActions();
/** Create the menu bar and sub-menus. */ /** Create the menu bar and sub-menus. */
@ -215,7 +218,7 @@ class UnitDisplayStatusBarControl : public QLabel
Q_OBJECT Q_OBJECT
public: public:
explicit UnitDisplayStatusBarControl(); explicit UnitDisplayStatusBarControl(const PlatformStyle *platformStyle);
/** Lets the control know about the Options Model (and its signals) */ /** Lets the control know about the Options Model (and its signals) */
void setOptionsModel(OptionsModel *optionsModel); void setOptionsModel(OptionsModel *optionsModel);

View file

@ -9,7 +9,7 @@
#include "bitcoinunits.h" #include "bitcoinunits.h"
#include "guiutil.h" #include "guiutil.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "scicon.h" #include "platformstyle.h"
#include "txmempool.h" #include "txmempool.h"
#include "walletmodel.h" #include "walletmodel.h"
@ -35,10 +35,11 @@ QList<CAmount> CoinControlDialog::payAmounts;
CCoinControl* CoinControlDialog::coinControl = new CCoinControl(); CCoinControl* CoinControlDialog::coinControl = new CCoinControl();
bool CoinControlDialog::fSubtractFeeFromAmount = false; bool CoinControlDialog::fSubtractFeeFromAmount = false;
CoinControlDialog::CoinControlDialog(QWidget *parent) : CoinControlDialog::CoinControlDialog(const PlatformStyle *platformStyle, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::CoinControlDialog), ui(new Ui::CoinControlDialog),
model(0) model(0),
platformStyle(platformStyle)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -280,7 +281,7 @@ void CoinControlDialog::lockCoin()
COutPoint outpt(uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); COutPoint outpt(uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt());
model->lockCoin(outpt); model->lockCoin(outpt);
contextMenuItem->setDisabled(true); contextMenuItem->setDisabled(true);
contextMenuItem->setIcon(COLUMN_CHECKBOX, SingleColorIcon(":/icons/lock_closed")); contextMenuItem->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed"));
updateLabelLocked(); updateLabelLocked();
} }
@ -791,7 +792,7 @@ void CoinControlDialog::updateView()
COutPoint outpt(txhash, out.i); COutPoint outpt(txhash, out.i);
coinControl->UnSelect(outpt); // just to be sure coinControl->UnSelect(outpt); // just to be sure
itemOutput->setDisabled(true); itemOutput->setDisabled(true);
itemOutput->setIcon(COLUMN_CHECKBOX, SingleColorIcon(":/icons/lock_closed")); itemOutput->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed"));
} }
// set checkbox // set checkbox

View file

@ -16,6 +16,7 @@
#include <QString> #include <QString>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
class PlatformStyle;
class WalletModel; class WalletModel;
class CCoinControl; class CCoinControl;
@ -32,7 +33,7 @@ class CoinControlDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit CoinControlDialog(QWidget *parent = 0); explicit CoinControlDialog(const PlatformStyle *platformStyle, QWidget *parent = 0);
~CoinControlDialog(); ~CoinControlDialog();
void setModel(WalletModel *model); void setModel(WalletModel *model);
@ -57,6 +58,8 @@ private:
QAction *lockAction; QAction *lockAction;
QAction *unlockAction; QAction *unlockAction;
const PlatformStyle *platformStyle;
QString strPad(QString, int, QString); QString strPad(QString, int, QString);
void sortView(int, Qt::SortOrder); void sortView(int, Qt::SortOrder);
void updateView(); void updateView();

View file

@ -6,7 +6,6 @@
#include "ui_intro.h" #include "ui_intro.h"
#include "guiutil.h" #include "guiutil.h"
#include "scicon.h"
#include "util.h" #include "util.h"
@ -168,7 +167,7 @@ void Intro::pickDataDirectory()
/* If current default data directory does not exist, let the user choose one */ /* If current default data directory does not exist, let the user choose one */
Intro intro; Intro intro;
intro.setDataDirectory(dataDir); intro.setDataDirectory(dataDir);
intro.setWindowIcon(SingleColorIcon(":icons/bitcoin")); intro.setWindowIcon(QIcon(":icons/bitcoin"));
while(true) while(true)
{ {

View file

@ -5,7 +5,6 @@
#include "networkstyle.h" #include "networkstyle.h"
#include "guiconstants.h" #include "guiconstants.h"
#include "scicon.h"
#include <QApplication> #include <QApplication>

View file

@ -10,7 +10,7 @@
#include "guiconstants.h" #include "guiconstants.h"
#include "guiutil.h" #include "guiutil.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "scicon.h" #include "platformstyle.h"
#include "transactionfilterproxy.h" #include "transactionfilterproxy.h"
#include "transactiontablemodel.h" #include "transactiontablemodel.h"
#include "walletmodel.h" #include "walletmodel.h"
@ -25,7 +25,9 @@ class TxViewDelegate : public QAbstractItemDelegate
{ {
Q_OBJECT Q_OBJECT
public: 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; int halfheight = (mainRect.height() - 2*ypad)/2;
QRect amountRect(mainRect.left() + xspace, mainRect.top()+ypad, mainRect.width() - xspace, halfheight); 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); 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); icon.paint(painter, decorationRect);
QDateTime date = index.data(TransactionTableModel::DateRole).toDateTime(); QDateTime date = index.data(TransactionTableModel::DateRole).toDateTime();
@ -101,11 +103,12 @@ public:
} }
int unit; int unit;
const PlatformStyle *platformStyle;
}; };
#include "overviewpage.moc" #include "overviewpage.moc"
OverviewPage::OverviewPage(QWidget *parent) : OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::OverviewPage), ui(new Ui::OverviewPage),
clientModel(0), clientModel(0),
@ -116,13 +119,13 @@ OverviewPage::OverviewPage(QWidget *parent) :
currentWatchOnlyBalance(-1), currentWatchOnlyBalance(-1),
currentWatchUnconfBalance(-1), currentWatchUnconfBalance(-1),
currentWatchImmatureBalance(-1), currentWatchImmatureBalance(-1),
txdelegate(new TxViewDelegate()), txdelegate(new TxViewDelegate(platformStyle)),
filter(0) filter(0)
{ {
ui->setupUi(this); ui->setupUi(this);
// use a SingleColorIcon for the "out of sync warning" icon // 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) 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->labelTransactionsStatus->setIcon(icon);
ui->labelWalletStatus->setIcon(icon); ui->labelWalletStatus->setIcon(icon);

View file

@ -12,6 +12,7 @@
class ClientModel; class ClientModel;
class TransactionFilterProxy; class TransactionFilterProxy;
class TxViewDelegate; class TxViewDelegate;
class PlatformStyle;
class WalletModel; class WalletModel;
namespace Ui { namespace Ui {
@ -28,7 +29,7 @@ class OverviewPage : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit OverviewPage(QWidget *parent = 0); explicit OverviewPage(const PlatformStyle *platformStyle, QWidget *parent = 0);
~OverviewPage(); ~OverviewPage();
void setClientModel(ClientModel *clientModel); void setClientModel(ClientModel *clientModel);

147
src/qt/platformstyle.cpp Normal file
View file

@ -0,0 +1,147 @@
// Copyright (c) 2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "platformstyle.h"
#include "guiconstants.h"
#include <QApplication>
#include <QColor>
#include <QIcon>
#include <QImage>
#include <QPalette>
#include <QPixmap>
static const struct {
const char *platformId;
/** Show images on push buttons */
const bool imagesOnButtons;
/** Colorize single-color icons */
const bool colorizeIcons;
/** Extra padding/spacing in transactionview */
const bool useExtraSpacing;
} platform_styles[] = {
{"macosx", false, false, true},
{"windows", true, false, false},
/* Other: linux, unix, ... */
{"other", true, true, false}
};
static const unsigned platform_styles_count = sizeof(platform_styles)/sizeof(*platform_styles);
namespace {
/* Local functions for colorizing single-color images */
void MakeSingleColorImage(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;
QSize sz;
Q_FOREACH(sz, ico.availableSizes())
{
QImage img(ico.pixmap(sz).toImage());
MakeSingleColorImage(img, colorbase);
new_ico.addPixmap(QPixmap::fromImage(img));
}
return new_ico;
}
QImage ColorizeImage(const QString& filename, const QColor& colorbase)
{
QImage img(filename);
MakeSingleColorImage(img, colorbase);
return img;
}
QIcon ColorizeIcon(const QString& filename, const QColor& colorbase)
{
return QIcon(QPixmap::fromImage(ColorizeImage(filename, colorbase)));
}
}
PlatformStyle::PlatformStyle(const QString &name, bool imagesOnButtons, bool colorizeIcons, bool useExtraSpacing):
name(name),
imagesOnButtons(imagesOnButtons),
colorizeIcons(colorizeIcons),
useExtraSpacing(useExtraSpacing),
singleColor(0,0,0),
textColor(0,0,0)
{
// Determine icon highlighting color
if (colorizeIcons) {
const QColor colorHighlightBg(QApplication::palette().color(QPalette::Highlight));
const QColor colorHighlightFg(QApplication::palette().color(QPalette::HighlightedText));
const QColor colorText(QApplication::palette().color(QPalette::WindowText));
const int colorTextLightness = colorText.lightness();
QColor colorbase;
if (abs(colorHighlightBg.lightness() - colorTextLightness) < abs(colorHighlightFg.lightness() - colorTextLightness))
colorbase = colorHighlightBg;
else
colorbase = colorHighlightFg;
singleColor = colorbase;
}
// Determine text color
textColor = QColor(QApplication::palette().color(QPalette::WindowText));
}
QImage PlatformStyle::SingleColorImage(const QString& filename) const
{
if (!colorizeIcons)
return QImage(filename);
return ColorizeImage(filename, SingleColor());
}
QIcon PlatformStyle::SingleColorIcon(const QString& filename) const
{
if (!colorizeIcons)
return QIcon(filename);
return ColorizeIcon(filename, SingleColor());
}
QIcon PlatformStyle::SingleColorIcon(const QIcon& icon) const
{
if (!colorizeIcons)
return icon;
return ColorizeIcon(icon, SingleColor());
}
QIcon PlatformStyle::TextColorIcon(const QString& filename) const
{
return ColorizeIcon(filename, TextColor());
}
QIcon PlatformStyle::TextColorIcon(const QIcon& icon) const
{
return ColorizeIcon(icon, TextColor());
}
const PlatformStyle *PlatformStyle::instantiate(const QString &platformId)
{
for (unsigned x=0; x<platform_styles_count; ++x)
{
if (platformId == platform_styles[x].platformId)
{
return new PlatformStyle(
platform_styles[x].platformId,
platform_styles[x].imagesOnButtons,
platform_styles[x].colorizeIcons,
platform_styles[x].useExtraSpacing);
}
}
return 0;
}

55
src/qt/platformstyle.h Normal file
View file

@ -0,0 +1,55 @@
// Copyright (c) 2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_PLATFORMSTYLE_H
#define BITCOIN_QT_PLATFORMSTYLE_H
#include <QIcon>
#include <QPixmap>
#include <QString>
/* Coin network-specific GUI style information */
class PlatformStyle
{
public:
/** Get style associated with provided platform name, or 0 if not known */
static const PlatformStyle *instantiate(const QString &platformId);
const QString &getName() const { return name; }
bool getImagesOnButtons() const { return imagesOnButtons; }
bool getUseExtraSpacing() const { return useExtraSpacing; }
QColor TextColor() const { return textColor; }
QColor SingleColor() const { return singleColor; }
/** Colorize an image (given filename) with the icon color */
QImage SingleColorImage(const QString& filename) const;
/** Colorize an icon (given filename) with the icon color */
QIcon SingleColorIcon(const QString& filename) const;
/** Colorize an icon (given object) with the icon color */
QIcon SingleColorIcon(const QIcon& icon) const;
/** Colorize an icon (given filename) with the text color */
QIcon TextColorIcon(const QString& filename) const;
/** Colorize an icon (given object) with the text color */
QIcon TextColorIcon(const QIcon& icon) const;
private:
PlatformStyle(const QString &name, bool imagesOnButtons, bool colorizeIcons, bool useExtraSpacing);
QString name;
bool imagesOnButtons;
bool colorizeIcons;
bool useExtraSpacing;
QColor singleColor;
QColor textColor;
/* ... more to come later */
};
#endif // BITCOIN_QT_PLATFORMSTYLE_H

View file

@ -10,9 +10,9 @@
#include "bitcoinunits.h" #include "bitcoinunits.h"
#include "guiutil.h" #include "guiutil.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "platformstyle.h"
#include "receiverequestdialog.h" #include "receiverequestdialog.h"
#include "recentrequeststablemodel.h" #include "recentrequeststablemodel.h"
#include "scicon.h"
#include "walletmodel.h" #include "walletmodel.h"
#include <QAction> #include <QAction>
@ -22,24 +22,25 @@
#include <QScrollBar> #include <QScrollBar>
#include <QTextDocument> #include <QTextDocument>
ReceiveCoinsDialog::ReceiveCoinsDialog(QWidget *parent) : ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::ReceiveCoinsDialog), ui(new Ui::ReceiveCoinsDialog),
model(0) model(0),
platformStyle(platformStyle)
{ {
ui->setupUi(this); ui->setupUi(this);
#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac if (!platformStyle->getImagesOnButtons()) {
ui->clearButton->setIcon(QIcon()); ui->clearButton->setIcon(QIcon());
ui->receiveButton->setIcon(QIcon()); ui->receiveButton->setIcon(QIcon());
ui->showRequestButton->setIcon(QIcon()); ui->showRequestButton->setIcon(QIcon());
ui->removeRequestButton->setIcon(QIcon()); ui->removeRequestButton->setIcon(QIcon());
#else } else {
ui->clearButton->setIcon(SingleColorIcon(":/icons/remove")); ui->clearButton->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
ui->receiveButton->setIcon(SingleColorIcon(":/icons/receiving_addresses")); ui->receiveButton->setIcon(platformStyle->SingleColorIcon(":/icons/receiving_addresses"));
ui->showRequestButton->setIcon(SingleColorIcon(":/icons/edit")); ui->showRequestButton->setIcon(platformStyle->SingleColorIcon(":/icons/edit"));
ui->removeRequestButton->setIcon(SingleColorIcon(":/icons/remove")); ui->removeRequestButton->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
#endif }
// context menu actions // context menu actions
QAction *copyLabelAction = new QAction(tr("Copy label"), this); QAction *copyLabelAction = new QAction(tr("Copy label"), this);
@ -132,7 +133,7 @@ void ReceiveCoinsDialog::on_receiveButton_clicked()
if(ui->reuseAddress->isChecked()) if(ui->reuseAddress->isChecked())
{ {
/* Choose existing receiving address */ /* Choose existing receiving address */
AddressBookPage dlg(AddressBookPage::ForSelection, AddressBookPage::ReceivingTab, this); AddressBookPage dlg(platformStyle, AddressBookPage::ForSelection, AddressBookPage::ReceivingTab, this);
dlg.setModel(model->getAddressTableModel()); dlg.setModel(model->getAddressTableModel());
if(dlg.exec()) if(dlg.exec())
{ {

View file

@ -16,6 +16,7 @@
#include <QVariant> #include <QVariant>
class OptionsModel; class OptionsModel;
class PlatformStyle;
class WalletModel; class WalletModel;
namespace Ui { namespace Ui {
@ -39,7 +40,7 @@ public:
MINIMUM_COLUMN_WIDTH = 130 MINIMUM_COLUMN_WIDTH = 130
}; };
explicit ReceiveCoinsDialog(QWidget *parent = 0); explicit ReceiveCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent = 0);
~ReceiveCoinsDialog(); ~ReceiveCoinsDialog();
void setModel(WalletModel *model); void setModel(WalletModel *model);
@ -57,6 +58,8 @@ private:
GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer; GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer;
WalletModel *model; WalletModel *model;
QMenu *contextMenu; QMenu *contextMenu;
const PlatformStyle *platformStyle;
void copyColumnToClipboard(int column); void copyColumnToClipboard(int column);
virtual void resizeEvent(QResizeEvent *event); virtual void resizeEvent(QResizeEvent *event);

View file

@ -8,7 +8,7 @@
#include "clientmodel.h" #include "clientmodel.h"
#include "guiutil.h" #include "guiutil.h"
#include "peertablemodel.h" #include "peertablemodel.h"
#include "scicon.h" #include "platformstyle.h"
#include "chainparams.h" #include "chainparams.h"
#include "rpcserver.h" #include "rpcserver.h"
@ -200,21 +200,22 @@ void RPCExecutor::request(const QString &command)
} }
} }
RPCConsole::RPCConsole(QWidget *parent) : RPCConsole::RPCConsole(const PlatformStyle *platformStyle, QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::RPCConsole), ui(new Ui::RPCConsole),
clientModel(0), clientModel(0),
historyPtr(0), historyPtr(0),
cachedNodeid(-1), cachedNodeid(-1),
contextMenu(0) contextMenu(0),
platformStyle(platformStyle)
{ {
ui->setupUi(this); ui->setupUi(this);
GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this); GUIUtil::restoreWindowGeometry("nRPCConsoleWindow", this->size(), this);
#ifndef Q_OS_MAC if (platformStyle->getImagesOnButtons()) {
ui->openDebugLogfileButton->setIcon(SingleColorIcon(":/icons/export")); ui->openDebugLogfileButton->setIcon(platformStyle->SingleColorIcon(":/icons/export"));
#endif }
ui->clearButton->setIcon(SingleColorIcon(":/icons/remove")); ui->clearButton->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
// Install event filter for up and down arrow // Install event filter for up and down arrow
ui->lineEdit->installEventFilter(this); ui->lineEdit->installEventFilter(this);
@ -363,7 +364,7 @@ void RPCConsole::clear()
ui->messagesWidget->document()->addResource( ui->messagesWidget->document()->addResource(
QTextDocument::ImageResource, QTextDocument::ImageResource,
QUrl(ICON_MAPPING[i].url), QUrl(ICON_MAPPING[i].url),
SingleColorImage(ICON_MAPPING[i].source, SingleColor()).scaled(ICON_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); platformStyle->SingleColorImage(ICON_MAPPING[i].source).scaled(ICON_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
} }
// Set default style sheet // Set default style sheet

View file

@ -13,6 +13,7 @@
#include <QWidget> #include <QWidget>
class ClientModel; class ClientModel;
class PlatformStyle;
namespace Ui { namespace Ui {
class RPCConsole; class RPCConsole;
@ -29,7 +30,7 @@ class RPCConsole: public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit RPCConsole(QWidget *parent); explicit RPCConsole(const PlatformStyle *platformStyle, QWidget *parent);
~RPCConsole(); ~RPCConsole();
void setClientModel(ClientModel *model); void setClientModel(ClientModel *model);
@ -106,6 +107,7 @@ private:
int historyPtr; int historyPtr;
NodeId cachedNodeid; NodeId cachedNodeid;
QMenu *contextMenu; QMenu *contextMenu;
const PlatformStyle *platformStyle;
}; };
#endif // BITCOIN_QT_RPCCONSOLE_H #endif // BITCOIN_QT_RPCCONSOLE_H

View file

@ -1,98 +0,0 @@
// Copyright (c) 2014 The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "scicon.h"
#include <QApplication>
#include <QColor>
#include <QIcon>
#include <QImage>
#include <QPalette>
#include <QPixmap>
namespace {
void MakeSingleColorImage(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)));
}
}
}
}
QImage SingleColorImage(const QString& filename, const QColor& colorbase)
{
QImage img(filename);
#if !defined(WIN32) && !defined(MAC_OSX)
MakeSingleColorImage(img, colorbase);
#endif
return img;
}
QIcon SingleColorIcon(const QIcon& ico, const QColor& colorbase)
{
#if defined(WIN32) || defined(MAC_OSX)
return ico;
#else
QIcon new_ico;
QSize sz;
Q_FOREACH(sz, ico.availableSizes())
{
QImage img(ico.pixmap(sz).toImage());
MakeSingleColorImage(img, colorbase);
new_ico.addPixmap(QPixmap::fromImage(img));
}
return new_ico;
#endif
}
QIcon SingleColorIcon(const QString& filename, const QColor& colorbase)
{
return QIcon(QPixmap::fromImage(SingleColorImage(filename, colorbase)));
}
QColor SingleColor()
{
#if defined(WIN32) || defined(MAC_OSX)
return QColor(0,0,0);
#else
const QColor colorHighlightBg(QApplication::palette().color(QPalette::Highlight));
const QColor colorHighlightFg(QApplication::palette().color(QPalette::HighlightedText));
const QColor colorText(QApplication::palette().color(QPalette::WindowText));
const int colorTextLightness = colorText.lightness();
QColor colorbase;
if (abs(colorHighlightBg.lightness() - colorTextLightness) < abs(colorHighlightFg.lightness() - colorTextLightness))
colorbase = colorHighlightBg;
else
colorbase = colorHighlightFg;
return colorbase;
#endif
}
QIcon SingleColorIcon(const QString& filename)
{
return SingleColorIcon(filename, SingleColor());
}
static QColor TextColor()
{
return QColor(QApplication::palette().color(QPalette::WindowText));
}
QIcon TextColorIcon(const QString& filename)
{
return SingleColorIcon(filename, TextColor());
}
QIcon TextColorIcon(const QIcon& ico)
{
return SingleColorIcon(ico, TextColor());
}

View file

@ -1,24 +0,0 @@
// Copyright (c) 2014 The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_SCICON_H
#define BITCOIN_QT_SCICON_H
#include <QtCore>
QT_BEGIN_NAMESPACE
class QColor;
class QIcon;
class QString;
QT_END_NAMESPACE
QImage SingleColorImage(const QString& filename, const QColor&);
QIcon SingleColorIcon(const QIcon&, const QColor&);
QIcon SingleColorIcon(const QString& filename, const QColor&);
QColor SingleColor();
QIcon SingleColorIcon(const QString& filename);
QIcon TextColorIcon(const QIcon&);
QIcon TextColorIcon(const QString& filename);
#endif // BITCOIN_QT_SCICON_H

View file

@ -11,7 +11,7 @@
#include "coincontroldialog.h" #include "coincontroldialog.h"
#include "guiutil.h" #include "guiutil.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "scicon.h" #include "platformstyle.h"
#include "sendcoinsentry.h" #include "sendcoinsentry.h"
#include "walletmodel.h" #include "walletmodel.h"
@ -27,25 +27,26 @@
#include <QSettings> #include <QSettings>
#include <QTextDocument> #include <QTextDocument>
SendCoinsDialog::SendCoinsDialog(QWidget *parent) : SendCoinsDialog::SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::SendCoinsDialog), ui(new Ui::SendCoinsDialog),
clientModel(0), clientModel(0),
model(0), model(0),
fNewRecipientAllowed(true), fNewRecipientAllowed(true),
fFeeMinimized(true) fFeeMinimized(true),
platformStyle(platformStyle)
{ {
ui->setupUi(this); ui->setupUi(this);
#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac if (!platformStyle->getImagesOnButtons()) {
ui->addButton->setIcon(QIcon()); ui->addButton->setIcon(QIcon());
ui->clearButton->setIcon(QIcon()); ui->clearButton->setIcon(QIcon());
ui->sendButton->setIcon(QIcon()); ui->sendButton->setIcon(QIcon());
#else } else {
ui->addButton->setIcon(SingleColorIcon(":/icons/add")); ui->addButton->setIcon(platformStyle->SingleColorIcon(":/icons/add"));
ui->clearButton->setIcon(SingleColorIcon(":/icons/remove")); ui->clearButton->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
ui->sendButton->setIcon(SingleColorIcon(":/icons/send")); ui->sendButton->setIcon(platformStyle->SingleColorIcon(":/icons/send"));
#endif }
GUIUtil::setupAddressWidget(ui->lineEditCoinControlChange, this); GUIUtil::setupAddressWidget(ui->lineEditCoinControlChange, this);
@ -364,7 +365,7 @@ void SendCoinsDialog::accept()
SendCoinsEntry *SendCoinsDialog::addEntry() SendCoinsEntry *SendCoinsDialog::addEntry()
{ {
SendCoinsEntry *entry = new SendCoinsEntry(this); SendCoinsEntry *entry = new SendCoinsEntry(platformStyle, this);
entry->setModel(model); entry->setModel(model);
ui->entries->addWidget(entry); ui->entries->addWidget(entry);
connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*))); connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*)));
@ -711,7 +712,7 @@ void SendCoinsDialog::coinControlFeatureChanged(bool checked)
// Coin Control: button inputs -> show actual coin control dialog // Coin Control: button inputs -> show actual coin control dialog
void SendCoinsDialog::coinControlButtonClicked() void SendCoinsDialog::coinControlButtonClicked()
{ {
CoinControlDialog dlg; CoinControlDialog dlg(platformStyle);
dlg.setModel(model); dlg.setModel(model);
dlg.exec(); dlg.exec();
coinControlUpdateLabels(); coinControlUpdateLabels();

View file

@ -12,6 +12,7 @@
class ClientModel; class ClientModel;
class OptionsModel; class OptionsModel;
class PlatformStyle;
class SendCoinsEntry; class SendCoinsEntry;
class SendCoinsRecipient; class SendCoinsRecipient;
@ -31,7 +32,7 @@ class SendCoinsDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit SendCoinsDialog(QWidget *parent = 0); explicit SendCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent = 0);
~SendCoinsDialog(); ~SendCoinsDialog();
void setClientModel(ClientModel *clientModel); void setClientModel(ClientModel *clientModel);
@ -60,6 +61,7 @@ private:
WalletModel *model; WalletModel *model;
bool fNewRecipientAllowed; bool fNewRecipientAllowed;
bool fFeeMinimized; bool fFeeMinimized;
const PlatformStyle *platformStyle;
// Process WalletModel::SendCoinsReturn and generate a pair consisting // Process WalletModel::SendCoinsReturn and generate a pair consisting
// of a message and message flags for use in Q_EMIT message(). // of a message and message flags for use in Q_EMIT message().

View file

@ -9,30 +9,30 @@
#include "addresstablemodel.h" #include "addresstablemodel.h"
#include "guiutil.h" #include "guiutil.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "scicon.h" #include "platformstyle.h"
#include "walletmodel.h" #include "walletmodel.h"
#include <QApplication> #include <QApplication>
#include <QClipboard> #include <QClipboard>
SendCoinsEntry::SendCoinsEntry(QWidget *parent) : SendCoinsEntry::SendCoinsEntry(const PlatformStyle *platformStyle, QWidget *parent) :
QStackedWidget(parent), QStackedWidget(parent),
ui(new Ui::SendCoinsEntry), ui(new Ui::SendCoinsEntry),
model(0) model(0),
platformStyle(platformStyle)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->addressBookButton->setIcon(SingleColorIcon(":/icons/address-book")); ui->addressBookButton->setIcon(platformStyle->SingleColorIcon(":/icons/address-book"));
ui->pasteButton->setIcon(SingleColorIcon(":/icons/editpaste")); ui->pasteButton->setIcon(platformStyle->SingleColorIcon(":/icons/editpaste"));
ui->deleteButton->setIcon(SingleColorIcon(":/icons/remove")); ui->deleteButton->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
ui->deleteButton_is->setIcon(SingleColorIcon(":/icons/remove")); ui->deleteButton_is->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
ui->deleteButton_s->setIcon(SingleColorIcon(":/icons/remove")); ui->deleteButton_s->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
setCurrentWidget(ui->SendCoins); setCurrentWidget(ui->SendCoins);
#ifdef Q_OS_MAC if (platformStyle->getUseExtraSpacing())
ui->payToLayout->setSpacing(4); ui->payToLayout->setSpacing(4);
#endif
#if QT_VERSION >= 0x040700 #if QT_VERSION >= 0x040700
ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book")); ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book"));
#endif #endif
@ -65,7 +65,7 @@ void SendCoinsEntry::on_addressBookButton_clicked()
{ {
if(!model) if(!model)
return; return;
AddressBookPage dlg(AddressBookPage::ForSelection, AddressBookPage::SendingTab, this); AddressBookPage dlg(platformStyle, AddressBookPage::ForSelection, AddressBookPage::SendingTab, this);
dlg.setModel(model->getAddressTableModel()); dlg.setModel(model->getAddressTableModel());
if(dlg.exec()) if(dlg.exec())
{ {

View file

@ -10,6 +10,7 @@
#include <QStackedWidget> #include <QStackedWidget>
class WalletModel; class WalletModel;
class PlatformStyle;
namespace Ui { namespace Ui {
class SendCoinsEntry; class SendCoinsEntry;
@ -25,7 +26,7 @@ class SendCoinsEntry : public QStackedWidget
Q_OBJECT Q_OBJECT
public: public:
explicit SendCoinsEntry(QWidget *parent = 0); explicit SendCoinsEntry(const PlatformStyle *platformStyle, QWidget *parent = 0);
~SendCoinsEntry(); ~SendCoinsEntry();
void setModel(WalletModel *model); void setModel(WalletModel *model);
@ -64,6 +65,7 @@ private:
SendCoinsRecipient recipient; SendCoinsRecipient recipient;
Ui::SendCoinsEntry *ui; Ui::SendCoinsEntry *ui;
WalletModel *model; WalletModel *model;
const PlatformStyle *platformStyle;
bool updateLabel(const QString &address); bool updateLabel(const QString &address);
}; };

View file

@ -7,7 +7,7 @@
#include "addressbookpage.h" #include "addressbookpage.h"
#include "guiutil.h" #include "guiutil.h"
#include "scicon.h" #include "platformstyle.h"
#include "walletmodel.h" #include "walletmodel.h"
#include "base58.h" #include "base58.h"
@ -20,21 +20,22 @@
#include <QClipboard> #include <QClipboard>
SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget *parent) : SignVerifyMessageDialog::SignVerifyMessageDialog(const PlatformStyle *platformStyle, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::SignVerifyMessageDialog), ui(new Ui::SignVerifyMessageDialog),
model(0) model(0),
platformStyle(platformStyle)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->addressBookButton_SM->setIcon(SingleColorIcon(":/icons/address-book")); ui->addressBookButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/address-book"));
ui->pasteButton_SM->setIcon(SingleColorIcon(":/icons/editpaste")); ui->pasteButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/editpaste"));
ui->copySignatureButton_SM->setIcon(SingleColorIcon(":/icons/editcopy")); ui->copySignatureButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/editcopy"));
ui->signMessageButton_SM->setIcon(SingleColorIcon(":/icons/edit")); ui->signMessageButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/edit"));
ui->clearButton_SM->setIcon(SingleColorIcon(":/icons/remove")); ui->clearButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
ui->addressBookButton_VM->setIcon(SingleColorIcon(":/icons/address-book")); ui->addressBookButton_VM->setIcon(platformStyle->SingleColorIcon(":/icons/address-book"));
ui->verifyMessageButton_VM->setIcon(SingleColorIcon(":/icons/transaction_0")); ui->verifyMessageButton_VM->setIcon(platformStyle->SingleColorIcon(":/icons/transaction_0"));
ui->clearButton_VM->setIcon(SingleColorIcon(":/icons/remove")); ui->clearButton_VM->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
#if QT_VERSION >= 0x040700 #if QT_VERSION >= 0x040700
ui->signatureOut_SM->setPlaceholderText(tr("Click \"Sign Message\" to generate signature")); ui->signatureOut_SM->setPlaceholderText(tr("Click \"Sign Message\" to generate signature"));
@ -94,7 +95,7 @@ void SignVerifyMessageDialog::on_addressBookButton_SM_clicked()
{ {
if (model && model->getAddressTableModel()) if (model && model->getAddressTableModel())
{ {
AddressBookPage dlg(AddressBookPage::ForSelection, AddressBookPage::ReceivingTab, this); AddressBookPage dlg(platformStyle, AddressBookPage::ForSelection, AddressBookPage::ReceivingTab, this);
dlg.setModel(model->getAddressTableModel()); dlg.setModel(model->getAddressTableModel());
if (dlg.exec()) if (dlg.exec())
{ {
@ -185,7 +186,7 @@ void SignVerifyMessageDialog::on_addressBookButton_VM_clicked()
{ {
if (model && model->getAddressTableModel()) if (model && model->getAddressTableModel())
{ {
AddressBookPage dlg(AddressBookPage::ForSelection, AddressBookPage::SendingTab, this); AddressBookPage dlg(platformStyle, AddressBookPage::ForSelection, AddressBookPage::SendingTab, this);
dlg.setModel(model->getAddressTableModel()); dlg.setModel(model->getAddressTableModel());
if (dlg.exec()) if (dlg.exec())
{ {

View file

@ -7,6 +7,7 @@
#include <QDialog> #include <QDialog>
class PlatformStyle;
class WalletModel; class WalletModel;
namespace Ui { namespace Ui {
@ -18,7 +19,7 @@ class SignVerifyMessageDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit SignVerifyMessageDialog(QWidget *parent); explicit SignVerifyMessageDialog(const PlatformStyle *platformStyle, QWidget *parent);
~SignVerifyMessageDialog(); ~SignVerifyMessageDialog();
void setModel(WalletModel *model); void setModel(WalletModel *model);
@ -34,6 +35,7 @@ protected:
private: private:
Ui::SignVerifyMessageDialog *ui; Ui::SignVerifyMessageDialog *ui;
WalletModel *model; WalletModel *model;
const PlatformStyle *platformStyle;
private Q_SLOTS: private Q_SLOTS:
/* sign message */ /* sign message */

View file

@ -8,7 +8,7 @@
#include "guiconstants.h" #include "guiconstants.h"
#include "guiutil.h" #include "guiutil.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "scicon.h" #include "platformstyle.h"
#include "transactiondesc.h" #include "transactiondesc.h"
#include "transactionrecord.h" #include "transactionrecord.h"
#include "walletmodel.h" #include "walletmodel.h"
@ -222,12 +222,13 @@ public:
} }
}; };
TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel *parent): TransactionTableModel::TransactionTableModel(const PlatformStyle *platformStyle, CWallet* wallet, WalletModel *parent):
QAbstractTableModel(parent), QAbstractTableModel(parent),
wallet(wallet), wallet(wallet),
walletModel(parent), walletModel(parent),
priv(new TransactionTablePriv(wallet, this)), priv(new TransactionTablePriv(wallet, this)),
fProcessingQueuedTransactions(false) fProcessingQueuedTransactions(false),
platformStyle(platformStyle)
{ {
columns << QString() << QString() << tr("Date") << tr("Type") << tr("Label") << BitcoinUnits::getAmountColumnTitle(walletModel->getOptionsModel()->getDisplayUnit()); columns << QString() << QString() << tr("Date") << tr("Type") << tr("Label") << BitcoinUnits::getAmountColumnTitle(walletModel->getOptionsModel()->getDisplayUnit());
priv->refreshWallet(); priv->refreshWallet();
@ -521,7 +522,7 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
case Qt::DecorationRole: case Qt::DecorationRole:
{ {
QIcon icon = qvariant_cast<QIcon>(index.data(RawDecorationRole)); QIcon icon = qvariant_cast<QIcon>(index.data(RawDecorationRole));
return TextColorIcon(icon); return platformStyle->TextColorIcon(icon);
} }
case Qt::DisplayRole: case Qt::DisplayRole:
switch(index.column()) switch(index.column())

View file

@ -10,6 +10,7 @@
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <QStringList> #include <QStringList>
class PlatformStyle;
class TransactionRecord; class TransactionRecord;
class TransactionTablePriv; class TransactionTablePriv;
class WalletModel; class WalletModel;
@ -23,7 +24,7 @@ class TransactionTableModel : public QAbstractTableModel
Q_OBJECT Q_OBJECT
public: public:
explicit TransactionTableModel(CWallet* wallet, WalletModel *parent = 0); explicit TransactionTableModel(const PlatformStyle *platformStyle, CWallet* wallet, WalletModel *parent = 0);
~TransactionTableModel(); ~TransactionTableModel();
enum ColumnIndex { enum ColumnIndex {
@ -82,6 +83,7 @@ private:
QStringList columns; QStringList columns;
TransactionTablePriv *priv; TransactionTablePriv *priv;
bool fProcessingQueuedTransactions; bool fProcessingQueuedTransactions;
const PlatformStyle *platformStyle;
void subscribeToCoreSignals(); void subscribeToCoreSignals();
void unsubscribeFromCoreSignals(); void unsubscribeFromCoreSignals();

View file

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

View file

@ -10,6 +10,7 @@
#include <QWidget> #include <QWidget>
#include <QKeyEvent> #include <QKeyEvent>
class PlatformStyle;
class TransactionFilterProxy; class TransactionFilterProxy;
class WalletModel; class WalletModel;
@ -32,7 +33,7 @@ class TransactionView : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit TransactionView(QWidget *parent = 0); explicit TransactionView(const PlatformStyle *platformStyle, QWidget *parent = 0);
void setModel(WalletModel *model); void setModel(WalletModel *model);

View file

@ -12,9 +12,10 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLabel> #include <QLabel>
WalletFrame::WalletFrame(BitcoinGUI *_gui) : WalletFrame::WalletFrame(const PlatformStyle *platformStyle, BitcoinGUI *_gui) :
QFrame(_gui), QFrame(_gui),
gui(_gui) gui(_gui),
platformStyle(platformStyle)
{ {
// Leave HBox hook for adding a list view later // Leave HBox hook for adding a list view later
QHBoxLayout *walletFrameLayout = new QHBoxLayout(this); QHBoxLayout *walletFrameLayout = new QHBoxLayout(this);
@ -42,7 +43,7 @@ bool WalletFrame::addWallet(const QString& name, WalletModel *walletModel)
if (!gui || !clientModel || !walletModel || mapWalletViews.count(name) > 0) if (!gui || !clientModel || !walletModel || mapWalletViews.count(name) > 0)
return false; return false;
WalletView *walletView = new WalletView(this); WalletView *walletView = new WalletView(platformStyle, this);
walletView->setBitcoinGUI(gui); walletView->setBitcoinGUI(gui);
walletView->setClientModel(clientModel); walletView->setClientModel(clientModel);
walletView->setWalletModel(walletModel); walletView->setWalletModel(walletModel);

View file

@ -10,6 +10,7 @@
class BitcoinGUI; class BitcoinGUI;
class ClientModel; class ClientModel;
class PlatformStyle;
class SendCoinsRecipient; class SendCoinsRecipient;
class WalletModel; class WalletModel;
class WalletView; class WalletView;
@ -23,7 +24,7 @@ class WalletFrame : public QFrame
Q_OBJECT Q_OBJECT
public: public:
explicit WalletFrame(BitcoinGUI *_gui = 0); explicit WalletFrame(const PlatformStyle *platformStyle, BitcoinGUI *_gui = 0);
~WalletFrame(); ~WalletFrame();
void setClientModel(ClientModel *clientModel); void setClientModel(ClientModel *clientModel);
@ -45,6 +46,8 @@ private:
bool bOutOfSync; bool bOutOfSync;
const PlatformStyle *platformStyle;
WalletView *currentWalletView(); WalletView *currentWalletView();
public Q_SLOTS: public Q_SLOTS:

View file

@ -27,7 +27,7 @@
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent) : WalletModel::WalletModel(const PlatformStyle *platformStyle, CWallet *wallet, OptionsModel *optionsModel, QObject *parent) :
QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0), QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0),
transactionTableModel(0), transactionTableModel(0),
recentRequestsTableModel(0), recentRequestsTableModel(0),
@ -39,7 +39,7 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *p
fForceCheckBalanceChanged = false; fForceCheckBalanceChanged = false;
addressTableModel = new AddressTableModel(wallet, this); addressTableModel = new AddressTableModel(wallet, this);
transactionTableModel = new TransactionTableModel(wallet, this); transactionTableModel = new TransactionTableModel(platformStyle, wallet, this);
recentRequestsTableModel = new RecentRequestsTableModel(wallet, this); recentRequestsTableModel = new RecentRequestsTableModel(wallet, this);
// This timer will be fired repeatedly to update the balance // This timer will be fired repeatedly to update the balance

View file

@ -17,6 +17,7 @@
class AddressTableModel; class AddressTableModel;
class OptionsModel; class OptionsModel;
class PlatformStyle;
class RecentRequestsTableModel; class RecentRequestsTableModel;
class TransactionTableModel; class TransactionTableModel;
class WalletModelTransaction; class WalletModelTransaction;
@ -100,7 +101,7 @@ class WalletModel : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent = 0); explicit WalletModel(const PlatformStyle *platformStyle, CWallet *wallet, OptionsModel *optionsModel, QObject *parent = 0);
~WalletModel(); ~WalletModel();
enum StatusCode // Returned by sendCoins enum StatusCode // Returned by sendCoins

View file

@ -11,8 +11,8 @@
#include "guiutil.h" #include "guiutil.h"
#include "optionsmodel.h" #include "optionsmodel.h"
#include "overviewpage.h" #include "overviewpage.h"
#include "platformstyle.h"
#include "receivecoinsdialog.h" #include "receivecoinsdialog.h"
#include "scicon.h"
#include "sendcoinsdialog.h" #include "sendcoinsdialog.h"
#include "signverifymessagedialog.h" #include "signverifymessagedialog.h"
#include "transactiontablemodel.h" #include "transactiontablemodel.h"
@ -29,31 +29,32 @@
#include <QPushButton> #include <QPushButton>
#include <QVBoxLayout> #include <QVBoxLayout>
WalletView::WalletView(QWidget *parent): WalletView::WalletView(const PlatformStyle *platformStyle, QWidget *parent):
QStackedWidget(parent), QStackedWidget(parent),
clientModel(0), clientModel(0),
walletModel(0) walletModel(0),
platformStyle(platformStyle)
{ {
// Create tabs // Create tabs
overviewPage = new OverviewPage(); overviewPage = new OverviewPage(platformStyle);
transactionsPage = new QWidget(this); transactionsPage = new QWidget(this);
QVBoxLayout *vbox = new QVBoxLayout(); QVBoxLayout *vbox = new QVBoxLayout();
QHBoxLayout *hbox_buttons = new QHBoxLayout(); QHBoxLayout *hbox_buttons = new QHBoxLayout();
transactionView = new TransactionView(this); transactionView = new TransactionView(platformStyle, this);
vbox->addWidget(transactionView); vbox->addWidget(transactionView);
QPushButton *exportButton = new QPushButton(tr("&Export"), this); QPushButton *exportButton = new QPushButton(tr("&Export"), this);
exportButton->setToolTip(tr("Export the data in the current tab to a file")); exportButton->setToolTip(tr("Export the data in the current tab to a file"));
#ifndef Q_OS_MAC // Icons on push buttons are very uncommon on Mac if (platformStyle->getImagesOnButtons()) {
exportButton->setIcon(SingleColorIcon(":/icons/export")); exportButton->setIcon(platformStyle->SingleColorIcon(":/icons/export"));
#endif }
hbox_buttons->addStretch(); hbox_buttons->addStretch();
hbox_buttons->addWidget(exportButton); hbox_buttons->addWidget(exportButton);
vbox->addLayout(hbox_buttons); vbox->addLayout(hbox_buttons);
transactionsPage->setLayout(vbox); transactionsPage->setLayout(vbox);
receiveCoinsPage = new ReceiveCoinsDialog(); receiveCoinsPage = new ReceiveCoinsDialog(platformStyle);
sendCoinsPage = new SendCoinsDialog(); sendCoinsPage = new SendCoinsDialog(platformStyle);
addWidget(overviewPage); addWidget(overviewPage);
addWidget(transactionsPage); addWidget(transactionsPage);
@ -182,7 +183,7 @@ void WalletView::gotoSendCoinsPage(QString addr)
void WalletView::gotoSignMessageTab(QString addr) void WalletView::gotoSignMessageTab(QString addr)
{ {
// calls show() in showTab_SM() // calls show() in showTab_SM()
SignVerifyMessageDialog *signVerifyMessageDialog = new SignVerifyMessageDialog(this); SignVerifyMessageDialog *signVerifyMessageDialog = new SignVerifyMessageDialog(platformStyle, this);
signVerifyMessageDialog->setAttribute(Qt::WA_DeleteOnClose); signVerifyMessageDialog->setAttribute(Qt::WA_DeleteOnClose);
signVerifyMessageDialog->setModel(walletModel); signVerifyMessageDialog->setModel(walletModel);
signVerifyMessageDialog->showTab_SM(true); signVerifyMessageDialog->showTab_SM(true);
@ -194,7 +195,7 @@ void WalletView::gotoSignMessageTab(QString addr)
void WalletView::gotoVerifyMessageTab(QString addr) void WalletView::gotoVerifyMessageTab(QString addr)
{ {
// calls show() in showTab_VM() // calls show() in showTab_VM()
SignVerifyMessageDialog *signVerifyMessageDialog = new SignVerifyMessageDialog(this); SignVerifyMessageDialog *signVerifyMessageDialog = new SignVerifyMessageDialog(platformStyle, this);
signVerifyMessageDialog->setAttribute(Qt::WA_DeleteOnClose); signVerifyMessageDialog->setAttribute(Qt::WA_DeleteOnClose);
signVerifyMessageDialog->setModel(walletModel); signVerifyMessageDialog->setModel(walletModel);
signVerifyMessageDialog->showTab_VM(true); signVerifyMessageDialog->showTab_VM(true);
@ -272,7 +273,7 @@ void WalletView::usedSendingAddresses()
{ {
if(!walletModel) if(!walletModel)
return; return;
AddressBookPage *dlg = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab, this); AddressBookPage *dlg = new AddressBookPage(platformStyle, AddressBookPage::ForEditing, AddressBookPage::SendingTab, this);
dlg->setAttribute(Qt::WA_DeleteOnClose); dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->setModel(walletModel->getAddressTableModel()); dlg->setModel(walletModel->getAddressTableModel());
dlg->show(); dlg->show();
@ -282,7 +283,7 @@ void WalletView::usedReceivingAddresses()
{ {
if(!walletModel) if(!walletModel)
return; return;
AddressBookPage *dlg = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab, this); AddressBookPage *dlg = new AddressBookPage(platformStyle, AddressBookPage::ForEditing, AddressBookPage::ReceivingTab, this);
dlg->setAttribute(Qt::WA_DeleteOnClose); dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->setModel(walletModel->getAddressTableModel()); dlg->setModel(walletModel->getAddressTableModel());
dlg->show(); dlg->show();

View file

@ -12,6 +12,7 @@
class BitcoinGUI; class BitcoinGUI;
class ClientModel; class ClientModel;
class OverviewPage; class OverviewPage;
class PlatformStyle;
class ReceiveCoinsDialog; class ReceiveCoinsDialog;
class SendCoinsDialog; class SendCoinsDialog;
class SendCoinsRecipient; class SendCoinsRecipient;
@ -34,7 +35,7 @@ class WalletView : public QStackedWidget
Q_OBJECT Q_OBJECT
public: public:
explicit WalletView(QWidget *parent); explicit WalletView(const PlatformStyle *platformStyle, QWidget *parent);
~WalletView(); ~WalletView();
void setBitcoinGUI(BitcoinGUI *gui); void setBitcoinGUI(BitcoinGUI *gui);
@ -64,6 +65,7 @@ private:
TransactionView *transactionView; TransactionView *transactionView;
QProgressDialog *progressDialog; QProgressDialog *progressDialog;
const PlatformStyle *platformStyle;
public Q_SLOTS: public Q_SLOTS:
/** Switch to overview (home) page */ /** Switch to overview (home) page */