diff --git a/src/VivyApplication.cc b/src/VivyApplication.cc index efb10c01c29927a412fa85c03a65975524f00250..15be1249f7ccd6f9546a380641cf15ab7b94704a 100644 --- a/src/VivyApplication.cc +++ b/src/VivyApplication.cc @@ -1,5 +1,6 @@ #include "VivyApplication.hh" #include "UI/MainWindow.hh" +#include "UI/Theme/Theme.hh" using namespace Vivy; @@ -8,12 +9,22 @@ VivyApplication::VivyApplication(int &argc, char **argv) { } +VivyApplication::~VivyApplication() noexcept {} + void VivyApplication::setTheme(Theme theme) noexcept { if (theme == Theme::System) return; + else if (theme == Theme::QtCreator) { + qtCreatorThemePtr.reset(new Vivy::Theme("QtCreator")); + QSettings settings(QStringLiteral(":theme/design.creatortheme"), QSettings::IniFormat); + qtCreatorThemePtr->readSettings(&settings); + qtCreatorThemePtr->applyToApplication(); + return; + } + const QString sheet = theme == Theme::Dark ? QStringLiteral(":qdarkstyle/dark/style.qss") : QStringLiteral(":qdarkstyle/light/style.qss"); @@ -46,8 +57,8 @@ VivyApplication::exec() noexcept setAttribute(Qt::AA_DontShowIconsInMenus, false); setAttribute(Qt::AA_DontShowShortcutsInContextMenus, false); setFont(getApplicationFont(Font::Default)); - setTheme(Theme::Dark); // TODO: Set system theme for now (because we - // don't have a central theme provider). + setTheme(Theme::QtCreator); // TODO: Set system theme for now (because we + // don't have a central theme provider). // Cursor blinking setCursorFlashTime(0); diff --git a/src/VivyApplication.hh b/src/VivyApplication.hh index 0bfa830a8a20267695db7d08faf19f7ed076da55..f9e24ec6f6264873719f27ceb94ec351d2962645 100644 --- a/src/VivyApplication.hh +++ b/src/VivyApplication.hh @@ -36,6 +36,7 @@ namespace Vivy { class MainWindow; +class Theme; // Vivy application class class VivyApplication : public QApplication { @@ -54,7 +55,7 @@ public: DefaultBoldItalic }; - enum class Theme { System, Dark, Light }; + enum class Theme { System, Dark, Light, QtCreator }; private: int fontIdMonospace; @@ -64,11 +65,13 @@ private: int fontIdBold; int fontIdBoldItalic; + std::unique_ptr<Vivy::Theme> qtCreatorThemePtr{ nullptr }; std::unique_ptr<MainWindow> mainWindowPtr{ nullptr }; bool useFakeVim{ false }; public: VivyApplication(int &argc, char **argv); + ~VivyApplication() noexcept override; int exec() noexcept;