From 872cfe036d9472739939ad401dbe9511193d62ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 21 Oct 2016 09:07:26 +0200 Subject: GH-903 simple theme switching and dark theme --- application/themes/DarkTheme.cpp | 37 +++++++++++++++++++++++++++++++++++++ application/themes/DarkTheme.h | 14 ++++++++++++++ application/themes/ITheme.h | 13 +++++++++++++ application/themes/SystemTheme.cpp | 28 ++++++++++++++++++++++++++++ application/themes/SystemTheme.h | 19 +++++++++++++++++++ 5 files changed, 111 insertions(+) create mode 100644 application/themes/DarkTheme.cpp create mode 100644 application/themes/DarkTheme.h create mode 100644 application/themes/ITheme.h create mode 100644 application/themes/SystemTheme.cpp create mode 100644 application/themes/SystemTheme.h (limited to 'application/themes') diff --git a/application/themes/DarkTheme.cpp b/application/themes/DarkTheme.cpp new file mode 100644 index 00000000..7445dedf --- /dev/null +++ b/application/themes/DarkTheme.cpp @@ -0,0 +1,37 @@ +#include "DarkTheme.h" + +QString DarkTheme::id() +{ + return "dark"; +} + +QString DarkTheme::name() +{ + return QObject::tr("Dark"); +} + +QPalette DarkTheme::colorScheme() +{ + QPalette darkPalette; + darkPalette.setColor(QPalette::Window, QColor(49,54,59)); + darkPalette.setColor(QPalette::WindowText, Qt::white); + darkPalette.setColor(QPalette::Base, QColor(35,38,41)); + darkPalette.setColor(QPalette::AlternateBase, QColor(49,54,59)); + darkPalette.setColor(QPalette::ToolTipBase, Qt::white); + darkPalette.setColor(QPalette::ToolTipText, Qt::white); + darkPalette.setColor(QPalette::Text, Qt::white); + darkPalette.setColor(QPalette::Button, QColor(49,54,59)); + darkPalette.setColor(QPalette::ButtonText, Qt::white); + darkPalette.setColor(QPalette::BrightText, Qt::red); + darkPalette.setColor(QPalette::Link, QColor(42, 130, 218)); + + darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218)); + darkPalette.setColor(QPalette::HighlightedText, Qt::black); + return darkPalette; +} + + +QString DarkTheme::appStyleSheet() +{ + return "QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }"; +} diff --git a/application/themes/DarkTheme.h b/application/themes/DarkTheme.h new file mode 100644 index 00000000..11e621a6 --- /dev/null +++ b/application/themes/DarkTheme.h @@ -0,0 +1,14 @@ +#pragma once + +#include "ITheme.h" + +class DarkTheme: public ITheme +{ +public: + virtual ~DarkTheme() {} + + QString id() override; + QString name() override; + QString appStyleSheet() override; + QPalette colorScheme() override; +}; diff --git a/application/themes/ITheme.h b/application/themes/ITheme.h new file mode 100644 index 00000000..8e0836eb --- /dev/null +++ b/application/themes/ITheme.h @@ -0,0 +1,13 @@ +#pragma once +#include +#include + +class ITheme +{ +public: + virtual ~ITheme() {} + virtual QString id() = 0; + virtual QString name() = 0; + virtual QString appStyleSheet() = 0; + virtual QPalette colorScheme() = 0; +}; diff --git a/application/themes/SystemTheme.cpp b/application/themes/SystemTheme.cpp new file mode 100644 index 00000000..6ced6843 --- /dev/null +++ b/application/themes/SystemTheme.cpp @@ -0,0 +1,28 @@ +#include "SystemTheme.h" +#include +#include + +SystemTheme::SystemTheme() +{ + systemPalette = QApplication::style()->standardPalette(); +} + +QString SystemTheme::id() +{ + return "system"; +} + +QString SystemTheme::name() +{ + return QObject::tr("System"); +} + +QPalette SystemTheme::colorScheme() +{ + return systemPalette; +} + +QString SystemTheme::appStyleSheet() +{ + return QString(); +} diff --git a/application/themes/SystemTheme.h b/application/themes/SystemTheme.h new file mode 100644 index 00000000..90fd8ed9 --- /dev/null +++ b/application/themes/SystemTheme.h @@ -0,0 +1,19 @@ +#pragma once + +#include "ITheme.h" + +class SystemTheme: public ITheme +{ +public: + SystemTheme(); + virtual ~SystemTheme() {} + + QString id() override; + QString name() override; + QString appStyleSheet() override; + QPalette colorScheme() override; +private: + QPalette systemPalette; + QString systemTheme; +}; + -- cgit v1.2.3