diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index a8cb6b37a..9cce58bee 100755 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -72,12 +72,16 @@ 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 - if (qFile.open(QFile::ReadOnly)) { - QString styleSheet = QLatin1String(qFile.readAll()); - this->setStyleSheet(styleSheet); + 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); diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp old mode 100644 new mode 100755 index 232758859..40f397ec3 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -38,12 +39,17 @@ 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 - if (qFile.open(QFile::ReadOnly)) { - QString styleSheet = QLatin1String(qFile.readAll()); - this->setStyleSheet(styleSheet); + QFile qFile(theme); // for development only + if (qFile.open(QFile::ReadOnly)) { + QString styleSheet = QLatin1String(qFile.readAll()); + this->setStyleSheet(styleSheet); + } } // context menu actions diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui old mode 100644 new mode 100755 index 92fa0a344..883468f70 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -482,6 +482,20 @@ &Display + + + + + + User Interface Theme: + + + + + + + + @@ -531,7 +545,7 @@ https://www.transifex.com/projects/p/darkcoin/ true - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + Qt::TextBrowserInteraction @@ -601,7 +615,7 @@ https://www.transifex.com/projects/p/darkcoin/ - + Qt::Vertical diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp old mode 100644 new mode 100755 index 5ee033921..6b649a507 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -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); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp old mode 100644 new mode 100755 index 96276d3b4..97c317723 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -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); diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h old mode 100644 new mode 100755 index 9d239f2df..f410c2c79 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -37,6 +37,7 @@ public: DisplayUnit, // BitcoinUnits::Unit DisplayAddresses, // bool ThirdPartyTxUrls, // QString + Theme, // QString Language, // QString CoinControlFeatures, // bool ThreadsScriptVerif, // int