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 "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 =
......
......@@ -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;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter