diff --git a/src/VivyApplication.cc b/src/VivyApplication.cc index d474fca4c21e01152380f3f4b5ff196d013d1cfa..08f2b2aca14c97e496073a570893b7198b7e64dc 100644 --- a/src/VivyApplication.cc +++ b/src/VivyApplication.cc @@ -1,6 +1,7 @@ #include "VivyApplication.hh" #include "UI/MainWindow.hh" #include "UI/DockWidgetTitleBar.hh" +#include "UI/Theme/Theme.hh" #include "Lib/Document/VivyDocumentStore.hh" #include "Lib/Document/VivyDocument.hh" #include "Lib/Script/ScriptStore.hh" @@ -40,6 +41,8 @@ VivyApplication::VivyApplication(int &argc, char **argv) } } +VivyApplication::~VivyApplication() noexcept {} + void VivyApplication::setTheme(Theme theme) noexcept { @@ -48,6 +51,14 @@ VivyApplication::setTheme(Theme theme) noexcept 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"); @@ -82,8 +93,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); @@ -105,7 +116,7 @@ VivyApplication::exec() noexcept case ApplicationType::GUI: { // Show the main window, also set up the log console - mainWindowPtr = std::make_shared<MainWindow>(); + mainWindowPtr = std::make_unique<MainWindow>(); QDockWidget *logConsoleDock = new QDockWidget("Console", mainWindowPtr.get()); LogConsole *logConsole = new LogConsole(mainWindowPtr.get()); std::shared_ptr<ConsoleLogSinkDispatcher> consoleLogSinkDispatcher = diff --git a/src/VivyApplication.hh b/src/VivyApplication.hh index 654989b1805c41220045f297bfeca642a51f3632..1d4164412b0cb8cd01a9a92e28c884d445644689 100644 --- a/src/VivyApplication.hh +++ b/src/VivyApplication.hh @@ -50,6 +50,7 @@ class VivyDocumentStore; class AbstractDocument; class ScriptDocument; class VivyDocument; +class Theme; // Vivy application class class VivyApplication : public QApplication { @@ -73,7 +74,7 @@ public: DefaultBoldItalic }; - enum class Theme { System, Dark, Light }; + enum class Theme { System, Dark, Light, QtCreator }; private: int fontIdMonospace; @@ -83,7 +84,8 @@ private: int fontIdBold; int fontIdBoldItalic; - std::shared_ptr<MainWindow> mainWindowPtr{ nullptr }; + std::unique_ptr<Vivy::Theme> qtCreatorThemePtr{ nullptr }; + std::unique_ptr<MainWindow> mainWindowPtr{ nullptr }; bool useFakeVim{ false }; ApplicationType selectedType{ ApplicationType::GUI }; @@ -93,6 +95,7 @@ private: public: VivyApplication(int &argc, char **argv); + ~VivyApplication() noexcept override; int exec() noexcept;