From d155d7b196d6c630767792150abc67a720cd324f Mon Sep 17 00:00:00 2001 From: Robert Hambrock Date: Fri, 25 Jul 2014 22:59:14 +0200 Subject: [PATCH] Globally implemented theme switching Not completely finished/satisfied with all of the widgets yet, but most of them switch themes fully. --- src/qt/aboutdialog.cpp | 3 +- src/qt/addressbookpage.cpp | 18 ++- src/qt/addressbookpage.h | 1 + src/qt/addresstablemodel.cpp | 1 + src/qt/askpassphrasedialog.cpp | 8 ++ src/qt/bitcoin.cpp | 1 + src/qt/bitcoingui.cpp | 8 +- src/qt/forms/askpassphrasedialog.ui | 8 +- src/qt/forms/optionsdialog.ui | 28 ++-- src/qt/forms/rpcconsole.ui | 6 + src/qt/forms/sendcoinsentry.ui | 14 +- src/qt/forms/signverifymessagedialog.ui | 7 +- src/qt/miningdialog.cpp | 2 + src/qt/optionsdialog.cpp | 29 +++- src/qt/optionsdialog.h | 1 + src/qt/rpcconsole.cpp | 24 ++++ src/qt/rpcconsole.h | 1 + src/qt/sendcoinsdialog.cpp | 25 ++++ src/qt/sendcoinsdialog.h | 2 + src/qt/sendcoinsentry.cpp | 16 +++ src/qt/sendcoinsentry.h | 2 + src/qt/signverifymessagedialog.cpp | 23 ++++ src/qt/signverifymessagedialog.h | 2 + src/qt/themecontrol.cpp | 172 +++++++++++++++++++++--- src/qt/themecontrol.h | 66 ++++++++- src/qt/transactiondescdialog.cpp | 2 + src/qt/transactionview.cpp | 16 +-- src/qt/transactionview.h | 2 + src/qt/walletview.cpp | 11 +- 29 files changed, 424 insertions(+), 75 deletions(-) diff --git a/src/qt/aboutdialog.cpp b/src/qt/aboutdialog.cpp index 73f6f83..9375686 100644 --- a/src/qt/aboutdialog.cpp +++ b/src/qt/aboutdialog.cpp @@ -39,8 +39,7 @@ AboutDialog::AboutDialog(QWidget *parent) : QString qsUtilization = QString::fromUtf8(sBoincUtilization.c_str()); QString qsRegVersion = QString::fromUtf8(sRegVer.c_str()); ui->copyrightLabel->setText("Boinc Magnitude: " + qsUtilization + " " + ", Registered Version: " + qsRegVersion + " " + cr); - setTheme(this, THEME_ABOUTDIALOG); - + applyTheme(this, THEME_ABOUTDIALOG); } diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index 00807df..cf5a335 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -27,7 +27,6 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) : tab(tab) { ui->setupUi(this); - setTheme(this, THEME_ADDRESSBOOKPAGE); #ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac ui->newAddress->setIcon(QIcon()); @@ -399,3 +398,20 @@ void AddressBookPage::selectNewAddress(const QModelIndex &parent, int begin, int newAddressToSelect.clear(); } } + +void AddressBookPage::triggerTheme(int main, int table, int button_a, int button_b) +{ + applyTheme(this, main); + applyTheme(ui->tableView, table); + applyTheme(ui->tableView->horizontalHeader(), main); + //PushButtons: + QList pushbuttons = this->findChildren(); + // if (pushbuttons.indexOf("newAddress") != -1) + // { + // pushbuttons.removeAll("newAddress"); + // applyTheme(ui->newAddress, THEME_RECEIVECOINSPAGE_BUTTON_B); + // } + foreach(QPushButton *button, pushbuttons) + { applyTheme(button, button_a); } + applyTheme(ui->newAddress, button_b); +} \ No newline at end of file diff --git a/src/qt/addressbookpage.h b/src/qt/addressbookpage.h index 34465aa..2f0281b 100644 --- a/src/qt/addressbookpage.h +++ b/src/qt/addressbookpage.h @@ -39,6 +39,7 @@ class AddressBookPage : public QDialog void setModel(AddressTableModel *model); void setOptionsModel(OptionsModel *optionsModel); + void triggerTheme(int main, int table, int button_a, int button_b); const QString &getReturnValue() const { return returnValue; } public slots: diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index e227487..c6152ad 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -4,6 +4,7 @@ #include "wallet.h" #include "base58.h" #include +#include "themecontrol.h" const QString AddressTableModel::Send = "S"; const QString AddressTableModel::Receive = "R"; diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp index 56eb1e0..d1cf1c6 100644 --- a/src/qt/askpassphrasedialog.cpp +++ b/src/qt/askpassphrasedialog.cpp @@ -3,6 +3,7 @@ #include "guiconstants.h" #include "walletmodel.h" +#include "themecontrol.h" #include #include @@ -59,6 +60,13 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) : connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); + + applyTheme(this, THEME_ASKPASSPHRASEDIALOG); + QList lineedits = this->findChildren(); + foreach(QLineEdit *line, lineedits) + { + applyTheme(line, THEME_ASKPASSPHRASEDIALOG_BUTTON); + } } AskPassphraseDialog::~AskPassphraseDialog() diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index cb90916..83f38d8 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -385,6 +385,7 @@ int main(int argc, char *argv[]) window.setClientModel(&clientModel); window.addWallet("~Default", &walletModel); window.setCurrentWallet("~Default"); + initStyle(); window.updateTheme(); // If -min option passed, start window minimized. diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index e81f61e..b5300b8 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -153,7 +153,7 @@ QAxObject *globalcom = NULL; int cputick = 0; - + BitcoinGUI::BitcoinGUI(QWidget *parent) : QMainWindow(parent), clientModel(0), @@ -1653,9 +1653,9 @@ void BitcoinGUI::detectShutdown() void BitcoinGUI::updateTheme() { - setTheme(this, THEME_BITCOINGUI); - setTheme(walletFrame, THEME_WALLETFRAME); - setTheme(rpcConsole, THEME_RPCCONSOLE); + applyTheme(this, THEME_BITCOINGUI); + applyTheme(walletFrame, THEME_WALLETFRAME); + rpcConsole->triggerTheme(); emit(pagesView()); } diff --git a/src/qt/forms/askpassphrasedialog.ui b/src/qt/forms/askpassphrasedialog.ui index 7e1310a..7c8091e 100644 --- a/src/qt/forms/askpassphrasedialog.ui +++ b/src/qt/forms/askpassphrasedialog.ui @@ -50,7 +50,7 @@ color:lightgreen; - background-color:black; + @@ -74,8 +74,7 @@ color:lightgreen; - background-color:black; - + New passphrase @@ -98,8 +97,7 @@ color:lightgreen; - background-color:black; - + Repeat new passphrase diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 4a65b4e..9f44c93 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -532,7 +532,7 @@ color:green; QTabWidget::North - 3 + 0 @@ -554,6 +554,9 @@ color:green; true + + true + @@ -601,6 +604,9 @@ color:green; &Start Gridcoin on system login + + true + @@ -668,6 +674,9 @@ color:green; Connect to the Gridcoin network through a SOCKS proxy (e.g. when connecting through Tor). + + alternate-background-color: rgb(0, 85, 255); + &Connect through SOCKS proxy: @@ -788,14 +797,14 @@ color:green; Show only a tray icon after minimizing the window. - -background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(127, 127, 127, 255)); -color:lightgreen; - + &Minimize to the tray instead of the taskbar + + true + @@ -804,14 +813,14 @@ color:lightgreen; Minimize instead of exit the application when the window is closed. When this option is enabled, the application will be closed only after selecting Quit in the menu. - -background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(127, 127, 127, 255)); -color:lightgreen; - + M&inimize on close + + true + @@ -1022,6 +1031,7 @@ color:lightgreen; BitcoinAmountField QSpinBox
bitcoinamountfield.h
+ 1 QValueComboBox diff --git a/src/qt/forms/rpcconsole.ui b/src/qt/forms/rpcconsole.ui index 9f9d82f..0b68b91 100644 --- a/src/qt/forms/rpcconsole.ui +++ b/src/qt/forms/rpcconsole.ui @@ -1180,6 +1180,9 @@ color:lightgreen; Gridcoin Core: + + true +
@@ -1354,6 +1357,9 @@ color:lightgreen; Network: + + true + diff --git a/src/qt/forms/sendcoinsentry.ui b/src/qt/forms/sendcoinsentry.ui index 2c76ba7..e2e0623 100644 --- a/src/qt/forms/sendcoinsentry.ui +++ b/src/qt/forms/sendcoinsentry.ui @@ -718,8 +718,6 @@ -background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(127, 127, 127, 255)); -color:lightgreen; @@ -1930,17 +1928,17 @@ color:lightgreen; - - BitcoinAmountField - QLineEdit -
bitcoinamountfield.h
- 1 -
QValidatedLineEdit QLineEdit
qvalidatedlineedit.h
+ + BitcoinAmountField + QSpinBox +
bitcoinamountfield.h
+ 1 +
diff --git a/src/qt/forms/signverifymessagedialog.ui b/src/qt/forms/signverifymessagedialog.ui index 8c930bb..9458a35 100644 --- a/src/qt/forms/signverifymessagedialog.ui +++ b/src/qt/forms/signverifymessagedialog.ui @@ -246,9 +246,7 @@ color:green; - -background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(127, 127, 127, 255)); -color:lightgreen; + color:lightgreen; @@ -263,6 +261,9 @@ color:lightgreen; true + + true + diff --git a/src/qt/miningdialog.cpp b/src/qt/miningdialog.cpp index 89bcba3..37b6ebf 100644 --- a/src/qt/miningdialog.cpp +++ b/src/qt/miningdialog.cpp @@ -19,6 +19,7 @@ #include "clientversion.h" #include "uint256.h" #include "base58.h" +#include "themecontrol.h" // Copyright 10-3-2013 @@ -31,6 +32,7 @@ MiningDialog::MiningDialog(QWidget *parent) : ui(new Ui::MiningDialog) { ui->setupUi(this); + applyTheme(this, THEME_MININGDIALOG); // Set current copyright year // ui->copyrightLabel->setText(tr("Copyright") + QString(" © 2009-%1 ").arg(COPYRIGHT_YEAR) + tr("The Bitcoin developers") + QString("
") + tr("Copyright") + QString(" © ")); diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index e6e0eed..75ce65d 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -22,7 +22,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) : fProxyIpValid(true) { ui->setupUi(this); - setTheme(this, THEME_OPTIONSDIALOG); + triggerTheme(); /* Network elements init */ #ifndef USE_UPNP @@ -200,6 +200,9 @@ void OptionsDialog::on_resetButton_clicked() model->Reset(); mapper->toFirst(); mapper->submit(); + setTheme(); + triggerTheme(); + emit optionsApplied(); /* re-enable restart warning messages display */ fRestartWarningDisplayed_Lang = fRestartWarningDisplayed_Proxy = false; @@ -211,8 +214,8 @@ void OptionsDialog::on_okButton_clicked() if (ui->applyButton->isEnabled()) { mapper->submit(); + setTheme(); emit optionsApplied(); - setTheme(this, THEME_OPTIONSDIALOG); } accept(); } @@ -225,8 +228,9 @@ void OptionsDialog::on_cancelButton_clicked() void OptionsDialog::on_applyButton_clicked() { mapper->submit(); + setTheme(); + triggerTheme(); emit optionsApplied(); - setTheme(this, THEME_OPTIONSDIALOG); disableApplyButton(); } @@ -289,3 +293,22 @@ bool OptionsDialog::eventFilter(QObject *object, QEvent *event) } return QDialog::eventFilter(object, event); } + +void OptionsDialog::triggerTheme() +{ + applyTheme(this, THEME_OPTIONSDIALOG); + applyTheme(ui->tabWidget, THEME_OPTIONSDIALOG_TAB); + + QList pushbuttons = this->findChildren(); + foreach(QPushButton *button, pushbuttons) + { applyTheme(button, THEME_OPTIONSDIALOG_BUTTON); } + + QList children = ui->tabWidget->findChildren(); + foreach(QWidget *child, children) + { + if (child->property("alt_text")=="1") + { + applyTheme(child, THEME_ALT_TEXT); + } + } +} diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index 2e3547e..e9cd649 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -21,6 +21,7 @@ class OptionsDialog : public QDialog void setModel(OptionsModel *model); void setMapper(); + void triggerTheme(); protected: bool eventFilter(QObject *object, QEvent *event); diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 7464e41..9f2c9af 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -4,6 +4,7 @@ #include "clientmodel.h" #include "bitcoinrpc.h" #include "guiutil.h" +#include "themecontrol.h" #include #include @@ -428,3 +429,26 @@ void RPCConsole::on_showCLOptionsButton_clicked() GUIUtil::HelpMessageBox help; help.exec(); } + +void RPCConsole::triggerTheme() +{ + applyTheme(this, THEME_RPCCONSOLE); + applyTheme(ui->tabWidget, THEME_RPCCONSOLE_TAB); + applyTheme(ui->messagesWidget, THEME_RPCCONSOLE_CONSOLE); + + QList pushbuttons = this->findChildren(); + foreach(QPushButton *button, pushbuttons) + { applyTheme(button, THEME_RPCCONSOLE_BUTTON); } + + QList children = ui->tabWidget->findChildren(); + foreach(QWidget *child, children) + { + if (child->property("subtitle")=="1") + { + applyTheme(child, THEME_RPCCONSOLE_SUBTITLE); + } + else {applyTheme(child, THEME_RPCCONSOLE_LABEL);} + } + + applyTheme(ui->lineEdit, THEME_RPCCONSOLE_BUTTON); +} diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 3c38b4b..1694407 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -18,6 +18,7 @@ class RPCConsole: public QDialog ~RPCConsole(); void setClientModel(ClientModel *model); + void triggerTheme(); enum MessageClass { MC_ERROR, diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 2c7bab2..c7c71a8 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -1,5 +1,6 @@ #include "sendcoinsdialog.h" #include "ui_sendcoinsdialog.h" +#include "themecontrol.h" #include "walletmodel.h" #include "bitcoinunits.h" @@ -177,6 +178,9 @@ void SendCoinsDialog::clear() delete ui->entries->takeAt(0)->widget(); } addEntry(); + SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(0)->widget()); + entry->triggerTheme(); + updateRemoveEnabled(); @@ -198,6 +202,7 @@ SendCoinsEntry *SendCoinsDialog::addEntry() SendCoinsEntry *entry = new SendCoinsEntry(this); entry->setModel(model); ui->entries->addWidget(entry); + connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*))); updateRemoveEnabled(); @@ -210,6 +215,10 @@ SendCoinsEntry *SendCoinsDialog::addEntry() QScrollBar* bar = ui->scrollArea->verticalScrollBar(); if(bar) bar->setSliderPosition(bar->maximum()); + if (ui->entries->count()>1) + { + entry->triggerTheme(); + } return entry; } @@ -327,3 +336,19 @@ void SendCoinsDialog::updateDisplayUnit() ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->getBalance())); } } + +void SendCoinsDialog::triggerTheme() +{ + applyTheme(this, THEME_SENDCOINSENTRY); + QList pushbuttons = this->findChildren(); + foreach(QPushButton *button, pushbuttons) + { applyTheme(button, THEME_SENDCOINSENTRY_BUTTON); } + for(int i = 0; i < ui->entries->count(); ++i) + { + SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + if(entry) + { + entry->triggerTheme(); + } + } +} diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index 043dfdc..95ef7a8 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -33,6 +33,8 @@ class SendCoinsDialog : public QDialog void pasteEntry(const SendCoinsRecipient &rv); bool handleURI(const QString &uri); + void triggerTheme(); + public slots: void clear(); void reject(); diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 6656dd7..144417a 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -7,6 +7,7 @@ #include "walletmodel.h" #include "optionsmodel.h" #include "addresstablemodel.h" +#include "themecontrol.h" #include #include @@ -177,3 +178,18 @@ void SendCoinsEntry::updateDisplayUnit() ui->payAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); } } + +void SendCoinsEntry::triggerTheme() +{ + applyTheme(this, THEME_SENDCOINSENTRY); + + QList toolbuttons = this->findChildren(); + foreach(QToolButton *button, toolbuttons) + { applyTheme(button, THEME_SENDCOINSENTRY_BUTTON); } + + applyTheme(ui->payAmount, THEME_SENDCOINSENTRY_BUTTON); + + QList lineedits = this->findChildren(); + foreach(QValidatedLineEdit *line, lineedits) + { applyTheme(line, THEME_SENDCOINSENTRY_LINE); } +} \ No newline at end of file diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h index ec5f341..3b7936f 100644 --- a/src/qt/sendcoinsentry.h +++ b/src/qt/sendcoinsentry.h @@ -34,6 +34,8 @@ class SendCoinsEntry : public QFrame void setFocus(); + void triggerTheme(); + public slots: void setRemoveEnabled(bool enabled); void clear(); diff --git a/src/qt/signverifymessagedialog.cpp b/src/qt/signverifymessagedialog.cpp index 0753223..1a48710 100644 --- a/src/qt/signverifymessagedialog.cpp +++ b/src/qt/signverifymessagedialog.cpp @@ -9,6 +9,7 @@ #include "optionsmodel.h" #include "walletmodel.h" #include "wallet.h" +#include "themecontrol.h" #include @@ -43,6 +44,7 @@ SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget *parent) : ui->signatureOut_SM->setFont(GUIUtil::bitcoinAddressFont()); ui->signatureIn_VM->setFont(GUIUtil::bitcoinAddressFont()); + } SignVerifyMessageDialog::~SignVerifyMessageDialog() @@ -73,6 +75,7 @@ void SignVerifyMessageDialog::showTab_SM(bool fShow) if (fShow) this->show(); + triggerTheme(); } void SignVerifyMessageDialog::showTab_VM(bool fShow) @@ -80,6 +83,7 @@ void SignVerifyMessageDialog::showTab_VM(bool fShow) ui->tabWidget->setCurrentIndex(1); if (fShow) this->show(); + triggerTheme(); } void SignVerifyMessageDialog::on_addressBookButton_SM_clicked() @@ -272,3 +276,22 @@ bool SignVerifyMessageDialog::eventFilter(QObject *object, QEvent *event) } return QDialog::eventFilter(object, event); } + +void SignVerifyMessageDialog::triggerTheme() +{ + applyTheme(this, THEME_SIGNVERIFYDIALOG); + applyTheme(ui->tabWidget, THEME_SIGNVERIFYDIALOG_TAB); + + QList pushbuttons = this->findChildren(); + foreach(QPushButton *button, pushbuttons) + { applyTheme(button, THEME_SIGNVERIFYDIALOG_BUTTON); } + + QList children = ui->tabWidget->findChildren(); + foreach(QWidget *child, children) + { + if (child->property("alt_text")=="1") + { + applyTheme(child, THEME_ALT_TEXT); + } + } +} \ No newline at end of file diff --git a/src/qt/signverifymessagedialog.h b/src/qt/signverifymessagedialog.h index 558f24e..36fd4b7 100644 --- a/src/qt/signverifymessagedialog.h +++ b/src/qt/signverifymessagedialog.h @@ -23,6 +23,8 @@ class SignVerifyMessageDialog : public QDialog void showTab_SM(bool fShow); void showTab_VM(bool fShow); + void triggerTheme(); + protected: bool eventFilter(QObject *object, QEvent *event); diff --git a/src/qt/themecontrol.cpp b/src/qt/themecontrol.cpp index ef619ed..d32478d 100644 --- a/src/qt/themecontrol.cpp +++ b/src/qt/themecontrol.cpp @@ -1,40 +1,168 @@ #include "themecontrol.h" #include "optionsmodel.h" +#include +#include +#include +#include -OptionsModel* model; +QStringList Style; + +void initStyle() +{ + for (int i = 0; i < ELEMENTS; i++) + {Style << ""; } + setTheme(); +} + +void alternateStyle() +{ + QString def_font= "font: 12pt;"; + QString def_background = "background-color:rgb(30,30,30);"; + QString def_color = "color:rgb(30,180,30);"; + QString def_color_light = "color:lightgreen;"; + QString def_gradient_moderate = "background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(30, 30, 30, 255), stop:1 rgba(127, 127, 127, 255)); "; + QString def_gradient_extreme = "background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(30, 30, 30, 255), stop:1 rgba(255, 255, 255, 255)); "; + + + Style.replace(THEME_ABOUTDIALOG, def_gradient_moderate+def_color_light); + + Style.replace(THEME_ADDRESSBOOKPAGE, def_background); + Style.replace(THEME_ADDRESSBOOKPAGE_TABLE, def_gradient_extreme); + Style.replace(THEME_ADDRESSBOOKPAGE_BUTTON_A, def_gradient_extreme); + Style.replace(THEME_ADDRESSBOOKPAGE_BUTTON_B, "background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(0, 240, 100, 255));"); -QStringList alternateStyle = QStringList() - << "background-color:white; color: black" // THEME_BITCOINGUI - << "background-color:rgb(200,200,200); color: black" // THEME_WALLETFRAME - << "background-color:yellow" // THEME_RPCCONSOLE - << "background-color:rgb(30,30,30); color: rgb(0,150,0)" // THEME_OVERVIEWPAGE - << "background-color:rgb(3,132,192); color: rgb(20,20,20)" // THEME_ADDRESSBOOKPAGE - << "background-color:yellow; color: rgb(20,20,20)" // THEME_ABOUTDIALOG - << "background-color:white; color: rgb(20,20,20)"; // THEME_OPTIONSDIALOG - - -QStringList defaultStyle = QStringList() - << "background-color:white; color: default" // THEME_BITCOINGUI - << "background-color:default; color: rgb(0,255,0)" // THEME_WALLETFRAME - << "background-color:default" // THEME_RPCCONSOLE - << "" // THEME_OVERVIEWPAGE - << "" // THEME_ADDRESSBOOKPAGE - << "" // THEME_ABOUTDIALOG - << ""; // THEME_OPTIONSDIALOG + Style.replace(THEME_ALT_TEXT, def_color_light); + + Style.replace(THEME_ASKPASSPHRASEDIALOG, def_background+"color: rgb(0,150,150)"); + Style.replace(THEME_ASKPASSPHRASEDIALOG_BUTTON, def_gradient_moderate); + + Style.replace(THEME_BITCOINGUI,"color: black"); + + Style.replace(THEME_EDITADDRESSDIALOG, ""); + + Style.replace(THEME_MININGDIALOG,def_background+def_color); + + Style.replace(THEME_OPTIONSDIALOG, def_background); + Style.replace(THEME_OPTIONSDIALOG_TAB, def_gradient_extreme+def_color); + Style.replace(THEME_OPTIONSDIALOG_BUTTON, def_gradient_extreme+def_color); + + Style.replace(THEME_OVERVIEWPAGE, ""); + + Style.replace(THEME_RECEIVECOINSPAGE, def_background); + Style.replace(THEME_RECEIVECOINSPAGE_TABLE, def_gradient_extreme); + Style.replace(THEME_RECEIVECOINSPAGE_BUTTON_A, def_gradient_extreme); + Style.replace(THEME_RECEIVECOINSPAGE_BUTTON_B, "background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(0, 240, 100, 255));"); + + Style.replace(THEME_RPCCONSOLE, def_gradient_moderate); + Style.replace(THEME_RPCCONSOLE_TAB, def_background+def_color_light); + Style.replace(THEME_RPCCONSOLE_CONSOLE, def_gradient_extreme+def_color); + Style.replace(THEME_RPCCONSOLE_SUBTITLE, "color:yellow"); + Style.replace(THEME_RPCCONSOLE_BUTTON, def_gradient_moderate+def_color); + Style.replace(THEME_RPCCONSOLE_LABEL, def_color); + + Style.replace(THEME_SENDCOINSPAGE, def_background); + Style.replace(THEME_SENDCOINSPAGE_BUTTON, def_gradient_moderate); + + Style.replace(THEME_SENDCOINSENTRY, def_background); + Style.replace(THEME_SENDCOINSENTRY_BUTTON, def_gradient_extreme); + Style.replace(THEME_SENDCOINSENTRY_LINE, def_gradient_moderate); + + Style.replace(THEME_SIGNVERIFYDIALOG, def_gradient_extreme); + Style.replace(THEME_SIGNVERIFYDIALOG_TAB, def_background+def_color); + Style.replace(THEME_SIGNVERIFYDIALOG_BUTTON, def_gradient_moderate); + + Style.replace(THEME_TRANSACTIONDESCDIALOG, def_gradient_moderate+"color:blue"); + + Style.replace(THEME_TRANSACTIONVIEW, def_background+"alternate-background-color: rgb(60,55,65);"+def_color); + Style.replace(THEME_TRANSACTIONVIEW_HEADER, "color: red;"); + + Style.replace(THEME_WALLETFRAME, def_font+def_background+def_color); +} + +void defaultStyle() +{ + QString def_font= "font:12pt;"; + QString def_background = "background-color:black;"; + QString def_color = "color:rgb(0,255,0);"; + QString def_color_light = "color:lightgreen;"; + QString def_gradient_moderate = "background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(127, 127, 127, 255)); "; + QString def_gradient_extreme = "background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(255, 255, 255, 255)); "; + + Style.replace(THEME_ABOUTDIALOG, def_background+def_color); + + Style.replace(THEME_ADDRESSBOOKPAGE, def_background); + Style.replace(THEME_ADDRESSBOOKPAGE_TABLE, def_gradient_extreme); + Style.replace(THEME_ADDRESSBOOKPAGE_BUTTON_A, def_gradient_extreme); + Style.replace(THEME_ADDRESSBOOKPAGE_BUTTON_B, "background-color:black;"); + + Style.replace(THEME_ALT_TEXT, def_color_light); + + Style.replace(THEME_ASKPASSPHRASEDIALOG, def_background); + Style.replace(THEME_ASKPASSPHRASEDIALOG_BUTTON, def_gradient_moderate); + + Style.replace(THEME_BITCOINGUI,"background-color:white"); + + Style.replace(THEME_EDITADDRESSDIALOG,""); + + Style.replace(THEME_MININGDIALOG,""); + + Style.replace(THEME_OPTIONSDIALOG, def_background); + Style.replace(THEME_OPTIONSDIALOG_TAB, def_gradient_extreme+def_color); + Style.replace(THEME_OPTIONSDIALOG_BUTTON, def_gradient_extreme+def_color); + + Style.replace(THEME_OVERVIEWPAGE, "background-color:default"+def_color); + + Style.replace(THEME_RECEIVECOINSPAGE, def_background); + Style.replace(THEME_RECEIVECOINSPAGE_TABLE, def_gradient_extreme); + Style.replace(THEME_RECEIVECOINSPAGE_BUTTON_A, def_gradient_extreme); + Style.replace(THEME_RECEIVECOINSPAGE_BUTTON_B, "background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 255), stop:1 rgba(0, 240, 000, 255));"); + + Style.replace(THEME_RPCCONSOLE, def_background); + Style.replace(THEME_RPCCONSOLE_TAB, "color:blue;"); + Style.replace(THEME_RPCCONSOLE_CONSOLE, def_background+def_color); + Style.replace(THEME_RPCCONSOLE_SUBTITLE, "color:lightblue;"); + Style.replace(THEME_RPCCONSOLE_BUTTON,def_gradient_moderate+def_color); + Style.replace(THEME_RPCCONSOLE_LABEL, def_color); + + Style.replace(THEME_SENDCOINSPAGE, def_background); + Style.replace(THEME_SENDCOINSPAGE_BUTTON, def_gradient_moderate); + + Style.replace(THEME_SENDCOINSENTRY, def_background); + Style.replace(THEME_SENDCOINSENTRY_BUTTON, def_gradient_moderate); + Style.replace(THEME_SENDCOINSENTRY_LINE, def_gradient_moderate); + + Style.replace(THEME_SIGNVERIFYDIALOG, def_gradient_extreme); + Style.replace(THEME_SIGNVERIFYDIALOG_TAB, def_background+def_color); + Style.replace(THEME_SIGNVERIFYDIALOG_BUTTON, def_gradient_moderate); + + Style.replace(THEME_TRANSACTIONDESCDIALOG, def_gradient_moderate+"color:yellow"); + + Style.replace(THEME_TRANSACTIONVIEW, "background-color:rgb(30,30,30);alternate-background-color: rgb(38, 25, 45);"+def_color); + Style.replace(THEME_TRANSACTIONVIEW_HEADER, def_color); + + Style.replace(THEME_WALLETFRAME, def_font+def_background+def_color); +} + +OptionsModel* model; void setOptionsModel(OptionsModel *optionsmodel) { model = optionsmodel; } -void setTheme(QWidget* target, int type) +void applyTheme(QWidget* target, int type) +{ + target->setStyleSheet(Style.at(type)); +} + +void setTheme() { if (model->getTogglePalette()) { - target->setStyleSheet(alternateStyle.at(type)); + alternateStyle(); } else { - target->setStyleSheet(defaultStyle.at(type)); + defaultStyle(); } } diff --git a/src/qt/themecontrol.h b/src/qt/themecontrol.h index db54673..f64899b 100644 --- a/src/qt/themecontrol.h +++ b/src/qt/themecontrol.h @@ -7,16 +7,72 @@ class OptionsModel; enum themes { + THEME_ALT_TEXT, + + // Autonomous Widgets + THEME_BITCOINGUI, - THEME_WALLETFRAME, + THEME_RPCCONSOLE, - THEME_OVERVIEWPAGE, - THEME_ADDRESSBOOKPAGE, + THEME_RPCCONSOLE_TAB, + THEME_RPCCONSOLE_CONSOLE, + THEME_RPCCONSOLE_BUTTON, + THEME_RPCCONSOLE_SUBTITLE, + THEME_RPCCONSOLE_LABEL, + + THEME_WALLETFRAME, + + // Dialogs THEME_ABOUTDIALOG, - THEME_OPTIONSDIALOG + + THEME_ASKPASSPHRASEDIALOG, + THEME_ASKPASSPHRASEDIALOG_BUTTON, + + THEME_EDITADDRESSDIALOG, + THEME_MININGDIALOG, + + THEME_OPTIONSDIALOG, + THEME_OPTIONSDIALOG_TAB, + THEME_OPTIONSDIALOG_BUTTON, + + THEME_SIGNVERIFYDIALOG, + THEME_SIGNVERIFYDIALOG_TAB, + THEME_SIGNVERIFYDIALOG_BUTTON, + + THEME_TRANSACTIONDESCDIALOG, + + // Pages + + THEME_ADDRESSBOOKPAGE, + THEME_ADDRESSBOOKPAGE_TABLE, + THEME_ADDRESSBOOKPAGE_BUTTON_A, + THEME_ADDRESSBOOKPAGE_BUTTON_B, + + THEME_OVERVIEWPAGE, + + THEME_RECEIVECOINSPAGE, + THEME_RECEIVECOINSPAGE_TABLE, + THEME_RECEIVECOINSPAGE_BUTTON_A, + THEME_RECEIVECOINSPAGE_BUTTON_B, + + THEME_SENDCOINSPAGE, + THEME_SENDCOINSPAGE_BUTTON, + + THEME_SENDCOINSENTRY, + THEME_SENDCOINSENTRY_BUTTON, + THEME_SENDCOINSENTRY_LINE, + + THEME_TRANSACTIONVIEW, + THEME_TRANSACTIONVIEW_HEADER, + + ELEMENTS }; -void setTheme(QWidget* target, int type); +void initStyle(); + +void setTheme(); + +void applyTheme(QWidget* target, int type); void setOptionsModel(OptionsModel *optionsmodel); diff --git a/src/qt/transactiondescdialog.cpp b/src/qt/transactiondescdialog.cpp index 3bd4808..a0557f1 100644 --- a/src/qt/transactiondescdialog.cpp +++ b/src/qt/transactiondescdialog.cpp @@ -1,5 +1,6 @@ #include "transactiondescdialog.h" #include "ui_transactiondescdialog.h" +#include "themecontrol.h" #include "transactiontablemodel.h" @@ -12,6 +13,7 @@ TransactionDescDialog::TransactionDescDialog(const QModelIndex &idx, QWidget *pa ui->setupUi(this); QString desc = idx.data(TransactionTableModel::LongDescriptionRole).toString(); ui->detailText->setHtml(desc); + applyTheme(this, THEME_TRANSACTIONDESCDIALOG); } TransactionDescDialog::~TransactionDescDialog() diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 4aeeccb..a378865 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -11,6 +11,7 @@ #include "editaddressdialog.h" #include "optionsmodel.h" #include "guiutil.h" +#include "themecontrol.h" #include #include @@ -176,14 +177,7 @@ void TransactionView::setModel(WalletModel *model) transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Status, 23); transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Date, 120); - transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Type, 120); - transactionView->horizontalHeader()->setStyleSheet("background-color: #121212;color:green"); - - //Add stylesheet to transaction view list: - transactionView->setStyleSheet("background-color: #161616;alternate-background-color: #363636;color:green;"); - - - + transactionView->horizontalHeader()->resizeSection(TransactionTableModel::Type, 120); @@ -444,3 +438,9 @@ void TransactionView::focusTransaction(const QModelIndex &idx) transactionView->setCurrentIndex(targetIdx); transactionView->setFocus(); } + +void TransactionView::triggerTheme() +{ + applyTheme(this, THEME_TRANSACTIONVIEW); + applyTheme(transactionView->horizontalHeader(), THEME_TRANSACTIONVIEW_HEADER); +} diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index bb41a83..19a5170 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -40,6 +40,8 @@ class TransactionView : public QWidget Range }; + void triggerTheme(); + private: WalletModel *model; TransactionFilterProxy *transactionProxyModel; diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 6ef49c8..0cad972 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -278,9 +278,10 @@ void WalletView::unlockWallet() void WalletView::themePages() { - setTheme(overviewPage, THEME_OVERVIEWPAGE); - setTheme(transactionsPage, THEME_OVERVIEWPAGE); - setTheme(addressBookPage, THEME_ADDRESSBOOKPAGE); - setTheme(receiveCoinsPage, THEME_OVERVIEWPAGE); - setTheme(sendCoinsPage, THEME_OVERVIEWPAGE); + applyTheme(overviewPage, THEME_OVERVIEWPAGE); + transactionView->triggerTheme(); + sendCoinsPage->triggerTheme(); + addressBookPage->triggerTheme(THEME_ADDRESSBOOKPAGE, THEME_ADDRESSBOOKPAGE_TABLE, THEME_ADDRESSBOOKPAGE_BUTTON_A, THEME_ADDRESSBOOKPAGE_BUTTON_B); + receiveCoinsPage->triggerTheme(THEME_RECEIVECOINSPAGE, THEME_RECEIVECOINSPAGE_TABLE, THEME_RECEIVECOINSPAGE_BUTTON_A, THEME_RECEIVECOINSPAGE_BUTTON_B); + signVerifyMessageDialog->triggerTheme(); } \ No newline at end of file