From df251dd514e00c82e84038c034926e72e38a3548 Mon Sep 17 00:00:00 2001 From: fcasal Date: Wed, 2 May 2018 07:02:24 +0100 Subject: [PATCH] Added new dark grey theme (#471) --- .../preferences/GeneralOptionsWidget.cpp | 4 +- .../preferences/GeneralOptionsWidget.ui | 5 ++ src/utils/Configuration.cpp | 47 +++++++++++++++---- src/utils/Configuration.h | 8 ++-- src/widgets/DisassemblerGraphView.cpp | 2 +- 5 files changed, 50 insertions(+), 16 deletions(-) diff --git a/src/dialogs/preferences/GeneralOptionsWidget.cpp b/src/dialogs/preferences/GeneralOptionsWidget.cpp index 91786307..a81bb9d5 100644 --- a/src/dialogs/preferences/GeneralOptionsWidget.cpp +++ b/src/dialogs/preferences/GeneralOptionsWidget.cpp @@ -35,7 +35,7 @@ void GeneralOptionsWidget::updateThemeFromConfig() // Disconnect currentIndexChanged because clearing the comboxBox and refiling it causes its index to change. disconnect(ui->colorComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(on_colorComboBox_currentIndexChanged(int))); - ui->themeComboBox->setCurrentIndex(Config()->getDarkTheme() ? 1 : 0); + ui->themeComboBox->setCurrentIndex(Config()->getDarkTheme()); QList themes = Core()->getColorThemes(); ui->colorComboBox->clear(); @@ -71,7 +71,7 @@ void GeneralOptionsWidget::on_fontSelectionButton_clicked() void GeneralOptionsWidget::on_themeComboBox_currentIndexChanged(int index) { //disconnect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateThemeFromConfig())); - Config()->setDarkTheme(index == 1); + Config()->setDarkTheme(index); //connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateThemeFromConfig())); } diff --git a/src/dialogs/preferences/GeneralOptionsWidget.ui b/src/dialogs/preferences/GeneralOptionsWidget.ui index af65c2e7..a167bec1 100644 --- a/src/dialogs/preferences/GeneralOptionsWidget.ui +++ b/src/dialogs/preferences/GeneralOptionsWidget.ui @@ -81,6 +81,11 @@ Dark + + + Dark Grey + + diff --git a/src/utils/Configuration.cpp b/src/utils/Configuration.cpp index d9902db2..1522bb3c 100644 --- a/src/utils/Configuration.cpp +++ b/src/utils/Configuration.cpp @@ -105,6 +105,7 @@ void Configuration::loadDefaultTheme() setColor("highlight", QColor(210, 210, 255)); // Windows background setColor("gui.background", QColor(255, 255, 255)); + setColor("gui.disass_selected", QColor(255, 255, 255)); // Disassembly nodes background setColor("gui.alt_background", QColor(245, 250, 255)); // Custom @@ -117,7 +118,7 @@ void Configuration::loadDefaultTheme() setColor("gui.navbar.empty", QColor(100, 100, 100)); } -void Configuration::loadDarkTheme() +void Configuration::loadBaseDark() { /* Load Qt Theme */ QFile f(":qdarkstyle/style.qss"); @@ -147,11 +148,6 @@ void Configuration::loadDarkTheme() setColor("gui.cflow", QColor(255, 255, 255)); setColor("gui.dataoffset", QColor(255, 255, 255)); setColor("gui.border", QColor(255, 255, 255)); - setColor("highlight", QColor(64, 115, 115)); - // Windows background - setColor("gui.background", QColor(36, 66, 79)); - // Disassembly nodes background - setColor("gui.alt_background", QColor(58, 100, 128)); // Custom setColor("gui.imports", QColor(50, 140, 255)); setColor("gui.main", QColor(0, 128, 0)); @@ -162,6 +158,32 @@ void Configuration::loadDarkTheme() setColor("gui.navbar.empty", QColor(100, 100, 100)); } +void Configuration::loadDarkTheme() +{ + loadBaseDark(); + // Windows background + setColor("gui.background", QColor(36, 66, 79)); + // Disassembly nodes background + setColor("gui.alt_background", QColor(58, 100, 128)); + // Disassembly nodes background when selected + setColor("gui.disass_selected", QColor(36, 66, 79)); + // Disassembly line selected + setColor("highlight", QColor(64, 115, 115)); +} + +void Configuration::loadDarkGreyTheme() +{ + loadBaseDark(); + // Windows background + setColor("gui.background", QColor(37, 40, 43)); + // Disassembly nodes background + setColor("gui.alt_background", QColor(28, 31, 36)); + // Disassembly nodes background when selected + setColor("gui.disass_selected", QColor(44, 53, 54)); + // Disassembly line selected + setColor("highlight", QColor(21, 29, 29)); +} + const QFont Configuration::getFont() const { QFont font = s.value("font", QFont("Inconsolata", 12)).value(); @@ -174,12 +196,17 @@ void Configuration::setFont(const QFont &font) emit fontsUpdated(); } -void Configuration::setDarkTheme(bool set) +void Configuration::setDarkTheme(int theme) { - s.setValue("dark", set); - if (set) { + s.setValue("dark", theme); + switch(theme){ + case 1: loadDarkTheme(); - } else { + break; + case 2: + loadDarkGreyTheme(); + break; + default: loadDefaultTheme(); } emit colorsUpdated(); diff --git a/src/utils/Configuration.h b/src/utils/Configuration.h index 74df8c87..95c32a7b 100644 --- a/src/utils/Configuration.h +++ b/src/utils/Configuration.h @@ -18,8 +18,10 @@ private: void loadInitial(); // Colors + void loadBaseDark(); void loadDefaultTheme(); void loadDarkTheme(); + void loadDarkGreyTheme(); void setColor(const QString &name, const QColor &color); // Images @@ -41,10 +43,10 @@ public: // Colors const QColor getColor(const QString &name) const; - void setDarkTheme(bool set); - bool getDarkTheme() + void setDarkTheme(int theme); + int getDarkTheme() { - return s.value("dark").toBool(); + return s.value("dark").toInt(); } QString getDirProjects(); diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index 99c8bcab..e554b0c2 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -448,7 +448,7 @@ DisassemblerGraphView::Instr *DisassemblerGraphView::getInstrForMouseEvent( void DisassemblerGraphView::colorsUpdatedSlot() { disassemblyBackgroundColor = ConfigColor("gui.alt_background"); - disassemblySelectedBackgroundColor = ConfigColor("gui.background"); + disassemblySelectedBackgroundColor = ConfigColor("gui.disass_selected"); mDisabledBreakpointColor = disassemblyBackgroundColor; graphNodeColor = ConfigColor("gui.border"); backgroundColor = ConfigColor("gui.background");