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),
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("drkblue.css"); // for development only
QFile qFile(theme); // for development only
if (qFile.open(QFile::ReadOnly)) {
QString styleSheet = QLatin1String(qFile.readAll());
this->setStyleSheet(styleSheet);
}
}
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 <QFlags>
#include <QIcon>
#include <QSettings>
#include <QString>
#include <QTreeWidget>
#include <QTreeWidgetItem>
@ -38,13 +39,18 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) :
model(0)
{
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("drkblue.css"); // for development only
QFile qFile(theme); // for development only
if (qFile.open(QFile::ReadOnly)) {
QString styleSheet = QLatin1String(qFile.readAll());
this->setStyleSheet(styleSheet);
}
}
// context menu actions
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>
</attribute>
<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>
<layout class="QHBoxLayout" name="horizontalLayout_1_Display">
<item>
@ -531,7 +545,7 @@ https://www.transifex.com/projects/p/darkcoin/</string>
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
@ -601,7 +615,7 @@ https://www.transifex.com/projects/p/darkcoin/</string>
</layout>
</item>
<item>
<spacer name="verticalSpacer_Display">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>

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

@ -69,6 +69,12 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
#endif
/* 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");
ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant(""));
foreach(const QString &langStr, translations.entryList())
@ -154,6 +160,7 @@ void OptionsDialog::setModel(OptionsModel *model)
/* Network */
connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning()));
/* Display */
connect(ui->theme, SIGNAL(valueChanged()), this, SLOT(showRestartWarning()));
connect(ui->lang, SIGNAL(valueChanged()), this, SLOT(showRestartWarning()));
connect(ui->thirdPartyTxUrls, SIGNAL(textChanged(const QString &)), this, SLOT(showRestartWarning()));
}
@ -185,6 +192,7 @@ void OptionsDialog::setMapper()
#endif
/* Display */
mapper->addMapping(ui->theme, OptionsModel::Theme);
mapper->addMapping(ui->lang, OptionsModel::Language);
mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);
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");
// Display
if (!settings.contains("theme"))
settings.setValue("theme", "");
if (!settings.contains("language"))
settings.setValue("language", "");
if (!SoftSetArg("-lang", settings.value("language").toString().toStdString()))
@ -224,6 +226,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return bDisplayAddresses;
case ThirdPartyTxUrls:
return strThirdPartyTxUrls;
case Theme:
return settings.value("theme");
case Language:
return settings.value("language");
case CoinControlFeatures:
@ -336,6 +340,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
setRestartRequired(true);
}
break;
case Theme:
if (settings.value("theme") != value) {
settings.setValue("theme", value);
setRestartRequired(true);
}
break;
case Language:
if (settings.value("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
DisplayAddresses, // bool
ThirdPartyTxUrls, // QString
Theme, // QString
Language, // QString
CoinControlFeatures, // bool
ThreadsScriptVerif, // int