Theme selector added to options-page

This commit is contained in:
crowning2 2015-03-03 21:49:40 +01:00
parent 25ccc86acd
commit 6d58449987
6 changed files with 55 additions and 12 deletions

View File

@ -72,13 +72,17 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
prevBlocks(0), prevBlocks(0),
spinnerFrame(0) spinnerFrame(0)
{ {
/* Open default CSS */ /* Open CSS when configured */
QSettings settings;
QString theme = settings.value("theme", "").toString();
if(!theme.isEmpty()){
// QFile qFile(":/css/drkblue"); // QFile qFile(":/css/drkblue");
QFile qFile("drkblue.css"); // for development only QFile qFile(theme); // for development only
if (qFile.open(QFile::ReadOnly)) { if (qFile.open(QFile::ReadOnly)) {
QString styleSheet = QLatin1String(qFile.readAll()); QString styleSheet = QLatin1String(qFile.readAll());
this->setStyleSheet(styleSheet); this->setStyleSheet(styleSheet);
} }
}
GUIUtil::restoreWindowGeometry("nWindow", QSize(850, 550), this); GUIUtil::restoreWindowGeometry("nWindow", QSize(850, 550), this);

10
src/qt/coincontroldialog.cpp Normal file → Executable file
View File

@ -24,6 +24,7 @@
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QFlags> #include <QFlags>
#include <QIcon> #include <QIcon>
#include <QSettings>
#include <QString> #include <QString>
#include <QTreeWidget> #include <QTreeWidget>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
@ -38,13 +39,18 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) :
model(0) model(0)
{ {
ui->setupUi(this); ui->setupUi(this);
/* Open default CSS */
/* Open CSS when configured */
QSettings settings;
QString theme = settings.value("theme", "").toString();
if(!theme.isEmpty()){
// QFile qFile(":/css/drkblue"); // QFile qFile(":/css/drkblue");
QFile qFile("drkblue.css"); // for development only QFile qFile(theme); // for development only
if (qFile.open(QFile::ReadOnly)) { if (qFile.open(QFile::ReadOnly)) {
QString styleSheet = QLatin1String(qFile.readAll()); QString styleSheet = QLatin1String(qFile.readAll());
this->setStyleSheet(styleSheet); this->setStyleSheet(styleSheet);
} }
}
// context menu actions // context menu actions
QAction *copyAddressAction = new QAction(tr("Copy address"), this); QAction *copyAddressAction = new QAction(tr("Copy address"), this);

18
src/qt/forms/optionsdialog.ui Normal file → Executable file
View File

@ -482,6 +482,20 @@
<string>&amp;Display</string> <string>&amp;Display</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_Display"> <layout class="QVBoxLayout" name="verticalLayout_Display">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4_Display" stretch="0,0">
<item>
<widget class="QLabel" name="themeLabel">
<property name="text">
<string>User Interface Theme:</string>
</property>
</widget>
</item>
<item>
<widget class="QValueComboBox" name="theme"/>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_1_Display"> <layout class="QHBoxLayout" name="horizontalLayout_1_Display">
<item> <item>
@ -531,7 +545,7 @@ https://www.transifex.com/projects/p/darkcoin/</string>
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> <set>Qt::TextBrowserInteraction</set>
</property> </property>
</widget> </widget>
</item> </item>
@ -601,7 +615,7 @@ https://www.transifex.com/projects/p/darkcoin/</string>
</layout> </layout>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_Display"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>

8
src/qt/optionsdialog.cpp Normal file → Executable file
View File

@ -69,6 +69,12 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
#endif #endif
/* Display elements init */ /* Display elements init */
/* Theme selector */
ui->theme->addItem(QString("(") + tr("default") + QString(")"), QVariant(""));
ui->theme->addItem(QString("DRK-blue"), QVariant("drkblue.css")); // ToDo: remove .css when we finally use resources
/* Language selector */
QDir translations(":translations"); QDir translations(":translations");
ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant("")); ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant(""));
foreach(const QString &langStr, translations.entryList()) foreach(const QString &langStr, translations.entryList())
@ -154,6 +160,7 @@ void OptionsDialog::setModel(OptionsModel *model)
/* Network */ /* Network */
connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning())); connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning()));
/* Display */ /* Display */
connect(ui->theme, SIGNAL(valueChanged()), this, SLOT(showRestartWarning()));
connect(ui->lang, SIGNAL(valueChanged()), this, SLOT(showRestartWarning())); connect(ui->lang, SIGNAL(valueChanged()), this, SLOT(showRestartWarning()));
connect(ui->thirdPartyTxUrls, SIGNAL(textChanged(const QString &)), this, SLOT(showRestartWarning())); connect(ui->thirdPartyTxUrls, SIGNAL(textChanged(const QString &)), this, SLOT(showRestartWarning()));
} }
@ -185,6 +192,7 @@ void OptionsDialog::setMapper()
#endif #endif
/* Display */ /* Display */
mapper->addMapping(ui->theme, OptionsModel::Theme);
mapper->addMapping(ui->lang, OptionsModel::Language); mapper->addMapping(ui->lang, OptionsModel::Language);
mapper->addMapping(ui->unit, OptionsModel::DisplayUnit); mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);
mapper->addMapping(ui->displayAddresses, OptionsModel::DisplayAddresses); mapper->addMapping(ui->displayAddresses, OptionsModel::DisplayAddresses);

10
src/qt/optionsmodel.cpp Normal file → Executable file
View File

@ -138,6 +138,8 @@ void OptionsModel::Init()
addOverriddenOption("-socks"); addOverriddenOption("-socks");
// Display // Display
if (!settings.contains("theme"))
settings.setValue("theme", "");
if (!settings.contains("language")) if (!settings.contains("language"))
settings.setValue("language", ""); settings.setValue("language", "");
if (!SoftSetArg("-lang", settings.value("language").toString().toStdString())) if (!SoftSetArg("-lang", settings.value("language").toString().toStdString()))
@ -224,6 +226,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return bDisplayAddresses; return bDisplayAddresses;
case ThirdPartyTxUrls: case ThirdPartyTxUrls:
return strThirdPartyTxUrls; return strThirdPartyTxUrls;
case Theme:
return settings.value("theme");
case Language: case Language:
return settings.value("language"); return settings.value("language");
case CoinControlFeatures: case CoinControlFeatures:
@ -336,6 +340,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
setRestartRequired(true); setRestartRequired(true);
} }
break; break;
case Theme:
if (settings.value("theme") != value) {
settings.setValue("theme", value);
setRestartRequired(true);
}
break;
case Language: case Language:
if (settings.value("language") != value) { if (settings.value("language") != value) {
settings.setValue("language", value); settings.setValue("language", value);

1
src/qt/optionsmodel.h Normal file → Executable file
View File

@ -37,6 +37,7 @@ public:
DisplayUnit, // BitcoinUnits::Unit DisplayUnit, // BitcoinUnits::Unit
DisplayAddresses, // bool DisplayAddresses, // bool
ThirdPartyTxUrls, // QString ThirdPartyTxUrls, // QString
Theme, // QString
Language, // QString Language, // QString
CoinControlFeatures, // bool CoinControlFeatures, // bool
ThreadsScriptVerif, // int ThreadsScriptVerif, // int