Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 96fb877e rédigé par Kubat's avatar Kubat
Parcourir les fichiers

UI: Use the new theming system to set Vivy's theme

parent 0fe85263
Aucune branche associée trouvée
Aucune étiquette associée trouvée
2 requêtes de fusion!22Theme system,!21Add clean logs support + dependent MR
#include "VivyApplication.hh" #include "VivyApplication.hh"
#include "UI/MainWindow.hh" #include "UI/MainWindow.hh"
#include "UI/DockWidgetTitleBar.hh" #include "UI/DockWidgetTitleBar.hh"
#include "UI/Theme/Theme.hh"
#include "Lib/Document/VivyDocumentStore.hh" #include "Lib/Document/VivyDocumentStore.hh"
#include "Lib/Document/VivyDocument.hh" #include "Lib/Document/VivyDocument.hh"
#include "Lib/Script/ScriptStore.hh" #include "Lib/Script/ScriptStore.hh"
...@@ -40,6 +41,8 @@ VivyApplication::VivyApplication(int &argc, char **argv) ...@@ -40,6 +41,8 @@ VivyApplication::VivyApplication(int &argc, char **argv)
} }
} }
VivyApplication::~VivyApplication() noexcept {}
void void
VivyApplication::setTheme(Theme theme) noexcept VivyApplication::setTheme(Theme theme) noexcept
{ {
...@@ -48,6 +51,14 @@ VivyApplication::setTheme(Theme theme) noexcept ...@@ -48,6 +51,14 @@ VivyApplication::setTheme(Theme theme) noexcept
return; 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") const QString sheet = theme == Theme::Dark ? QStringLiteral(":qdarkstyle/dark/style.qss")
: QStringLiteral(":qdarkstyle/light/style.qss"); : QStringLiteral(":qdarkstyle/light/style.qss");
...@@ -82,7 +93,7 @@ VivyApplication::exec() noexcept ...@@ -82,7 +93,7 @@ VivyApplication::exec() noexcept
setAttribute(Qt::AA_DontShowIconsInMenus, false); setAttribute(Qt::AA_DontShowIconsInMenus, false);
setAttribute(Qt::AA_DontShowShortcutsInContextMenus, false); setAttribute(Qt::AA_DontShowShortcutsInContextMenus, false);
setFont(getApplicationFont(Font::Default)); setFont(getApplicationFont(Font::Default));
setTheme(Theme::Dark); // TODO: Set system theme for now (because we setTheme(Theme::QtCreator); // TODO: Set system theme for now (because we
// don't have a central theme provider). // don't have a central theme provider).
// Cursor blinking // Cursor blinking
...@@ -105,7 +116,7 @@ VivyApplication::exec() noexcept ...@@ -105,7 +116,7 @@ VivyApplication::exec() noexcept
case ApplicationType::GUI: { case ApplicationType::GUI: {
// Show the main window, also set up the log console // 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()); QDockWidget *logConsoleDock = new QDockWidget("Console", mainWindowPtr.get());
LogConsole *logConsole = new LogConsole(mainWindowPtr.get()); LogConsole *logConsole = new LogConsole(mainWindowPtr.get());
std::shared_ptr<ConsoleLogSinkDispatcher> consoleLogSinkDispatcher = std::shared_ptr<ConsoleLogSinkDispatcher> consoleLogSinkDispatcher =
......
...@@ -50,6 +50,7 @@ class VivyDocumentStore; ...@@ -50,6 +50,7 @@ class VivyDocumentStore;
class AbstractDocument; class AbstractDocument;
class ScriptDocument; class ScriptDocument;
class VivyDocument; class VivyDocument;
class Theme;
// Vivy application class // Vivy application class
class VivyApplication : public QApplication { class VivyApplication : public QApplication {
...@@ -73,7 +74,7 @@ public: ...@@ -73,7 +74,7 @@ public:
DefaultBoldItalic DefaultBoldItalic
}; };
enum class Theme { System, Dark, Light }; enum class Theme { System, Dark, Light, QtCreator };
private: private:
int fontIdMonospace; int fontIdMonospace;
...@@ -83,7 +84,8 @@ private: ...@@ -83,7 +84,8 @@ private:
int fontIdBold; int fontIdBold;
int fontIdBoldItalic; int fontIdBoldItalic;
std::shared_ptr<MainWindow> mainWindowPtr{ nullptr }; std::unique_ptr<Vivy::Theme> qtCreatorThemePtr{ nullptr };
std::unique_ptr<MainWindow> mainWindowPtr{ nullptr };
bool useFakeVim{ false }; bool useFakeVim{ false };
ApplicationType selectedType{ ApplicationType::GUI }; ApplicationType selectedType{ ApplicationType::GUI };
...@@ -93,6 +95,7 @@ private: ...@@ -93,6 +95,7 @@ private:
public: public:
VivyApplication(int &argc, char **argv); VivyApplication(int &argc, char **argv);
~VivyApplication() noexcept override;
int exec() noexcept; int exec() noexcept;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter