Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globally implemented theme switching #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/qt/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
18 changes: 17 additions & 1 deletion src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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<QPushButton *> pushbuttons = this->findChildren<QPushButton *>();
// 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);
}
1 change: 1 addition & 0 deletions src/qt/addressbookpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/qt/addresstablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "wallet.h"
#include "base58.h"
#include <QFont>
#include "themecontrol.h"

const QString AddressTableModel::Send = "S";
const QString AddressTableModel::Receive = "R";
Expand Down
8 changes: 8 additions & 0 deletions src/qt/askpassphrasedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "guiconstants.h"
#include "walletmodel.h"
#include "themecontrol.h"

#include <QMessageBox>
#include <QPushButton>
Expand Down Expand Up @@ -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<QLineEdit *> lineedits = this->findChildren<QLineEdit *>();
foreach(QLineEdit *line, lineedits)
{
applyTheme(line, THEME_ASKPASSPHRASEDIALOG_BUTTON);
}
}

AskPassphraseDialog::~AskPassphraseDialog()
Expand Down
1 change: 1 addition & 0 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ QAxObject *globalcom = NULL;

int cputick = 0;


BitcoinGUI::BitcoinGUI(QWidget *parent) :
QMainWindow(parent),
clientModel(0),
Expand Down Expand Up @@ -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());
}

Expand Down
8 changes: 3 additions & 5 deletions src/qt/forms/askpassphrasedialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ color:lightgreen;
<item row="0" column="0">
<widget class="QLabel" name="passLabel1">
<property name="styleSheet">
<string notr="true">background-color:black;
<string notr="true">
</string>
</property>
<property name="text">
Expand All @@ -74,8 +74,7 @@ color:lightgreen;
<item row="1" column="0">
<widget class="QLabel" name="passLabel2">
<property name="styleSheet">
<string notr="true">background-color:black;
</string>
<string notr="true"/>
</property>
<property name="text">
<string>New passphrase</string>
Expand All @@ -98,8 +97,7 @@ color:lightgreen;
<item row="2" column="0">
<widget class="QLabel" name="passLabel3">
<property name="styleSheet">
<string notr="true">background-color:black;
</string>
<string notr="true"/>
</property>
<property name="text">
<string>Repeat new passphrase</string>
Expand Down
28 changes: 19 additions & 9 deletions src/qt/forms/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ color:green;
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabMain">
<attribute name="title">
Expand All @@ -554,6 +554,9 @@ color:green;
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="alt_text" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -601,6 +604,9 @@ color:green;
<property name="text">
<string>&amp;Start Gridcoin on system login</string>
</property>
<property name="alt_text" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -668,6 +674,9 @@ color:green;
<property name="toolTip">
<string>Connect to the Gridcoin network through a SOCKS proxy (e.g. when connecting through Tor).</string>
</property>
<property name="styleSheet">
<string notr="true">alternate-background-color: rgb(0, 85, 255);</string>
</property>
<property name="text">
<string>&amp;Connect through SOCKS proxy:</string>
</property>
Expand Down Expand Up @@ -788,14 +797,14 @@ color:green;
<string>Show only a tray icon after minimizing the window.</string>
</property>
<property name="styleSheet">
<string notr="true">
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;
</string>
<string notr="true"/>
</property>
<property name="text">
<string>&amp;Minimize to the tray instead of the taskbar</string>
</property>
<property name="alt_text" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand All @@ -804,14 +813,14 @@ color:lightgreen;
<string>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.</string>
</property>
<property name="styleSheet">
<string notr="true">
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;
</string>
<string notr="true"/>
</property>
<property name="text">
<string>M&amp;inimize on close</string>
</property>
<property name="alt_text" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -1022,6 +1031,7 @@ color:lightgreen;
<class>BitcoinAmountField</class>
<extends>QSpinBox</extends>
<header>bitcoinamountfield.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QValueComboBox</class>
Expand Down
6 changes: 6 additions & 0 deletions src/qt/forms/rpcconsole.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,9 @@ color:lightgreen;
<property name="text">
<string>Gridcoin Core:</string>
</property>
<property name="subtitle" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
Expand Down Expand Up @@ -1354,6 +1357,9 @@ color:lightgreen;
<property name="text">
<string>Network:</string>
</property>
<property name="subtitle" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="11" column="2">
Expand Down
14 changes: 6 additions & 8 deletions src/qt/forms/sendcoinsentry.ui
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,6 @@
</property>
<property name="styleSheet">
<string notr="true">
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;
</string>
</property>
</widget>
Expand Down Expand Up @@ -1930,17 +1928,17 @@ color:lightgreen;
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BitcoinAmountField</class>
<extends>QLineEdit</extends>
<header>bitcoinamountfield.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QValidatedLineEdit</class>
<extends>QLineEdit</extends>
<header>qvalidatedlineedit.h</header>
</customwidget>
<customwidget>
<class>BitcoinAmountField</class>
<extends>QSpinBox</extends>
<header>bitcoinamountfield.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../bitcoin.qrc"/>
Expand Down
7 changes: 4 additions & 3 deletions src/qt/forms/signverifymessagedialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,7 @@ color:green;
<item>
<widget class="QLabel" name="infoLabel_VM">
<property name="styleSheet">
<string notr="true">
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;
<string notr="true">color:lightgreen;
</string>
</property>
<property name="text">
Expand All @@ -263,6 +261,9 @@ color:lightgreen;
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="alt_text" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
Expand Down
2 changes: 2 additions & 0 deletions src/qt/miningdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "clientversion.h"
#include "uint256.h"
#include "base58.h"
#include "themecontrol.h"


// Copyright 10-3-2013
Expand All @@ -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(" &copy; 2009-%1 ").arg(COPYRIGHT_YEAR) + tr("The Bitcoin developers") + QString("<br>") + tr("Copyright") + QString(" &copy; "));
Expand Down
29 changes: 26 additions & 3 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
fProxyIpValid(true)
{
ui->setupUi(this);
setTheme(this, THEME_OPTIONSDIALOG);
triggerTheme();

/* Network elements init */
#ifndef USE_UPNP
Expand Down Expand Up @@ -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;
Expand All @@ -211,8 +214,8 @@ void OptionsDialog::on_okButton_clicked()
if (ui->applyButton->isEnabled())
{
mapper->submit();
setTheme();
emit optionsApplied();
setTheme(this, THEME_OPTIONSDIALOG);
}
accept();
}
Expand All @@ -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();
}

Expand Down Expand Up @@ -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<QPushButton *> pushbuttons = this->findChildren<QPushButton *>();
foreach(QPushButton *button, pushbuttons)
{ applyTheme(button, THEME_OPTIONSDIALOG_BUTTON); }

QList<QWidget *> children = ui->tabWidget->findChildren<QWidget *>();
foreach(QWidget *child, children)
{
if (child->property("alt_text")=="1")
{
applyTheme(child, THEME_ALT_TEXT);
}
}
}
1 change: 1 addition & 0 deletions src/qt/optionsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class OptionsDialog : public QDialog

void setModel(OptionsModel *model);
void setMapper();
void triggerTheme();

protected:
bool eventFilter(QObject *object, QEvent *event);
Expand Down
Loading