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

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

parent 0d92bc3d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
#include "VivyApplication.hh" #include "VivyApplication.hh"
#include "UI/MainWindow.hh" #include "UI/MainWindow.hh"
#include "UI/Theme/Theme.hh"
using namespace Vivy; using namespace Vivy;
...@@ -8,12 +9,22 @@ VivyApplication::VivyApplication(int &argc, char **argv) ...@@ -8,12 +9,22 @@ VivyApplication::VivyApplication(int &argc, char **argv)
{ {
} }
VivyApplication::~VivyApplication() noexcept {}
void void
VivyApplication::setTheme(Theme theme) noexcept VivyApplication::setTheme(Theme theme) noexcept
{ {
if (theme == Theme::System) if (theme == Theme::System)
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");
...@@ -46,7 +57,7 @@ VivyApplication::exec() noexcept ...@@ -46,7 +57,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
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
namespace Vivy namespace Vivy
{ {
class MainWindow; class MainWindow;
class Theme;
// Vivy application class // Vivy application class
class VivyApplication : public QApplication { class VivyApplication : public QApplication {
...@@ -54,7 +55,7 @@ public: ...@@ -54,7 +55,7 @@ public:
DefaultBoldItalic DefaultBoldItalic
}; };
enum class Theme { System, Dark, Light }; enum class Theme { System, Dark, Light, QtCreator };
private: private:
int fontIdMonospace; int fontIdMonospace;
...@@ -64,11 +65,13 @@ private: ...@@ -64,11 +65,13 @@ private:
int fontIdBold; int fontIdBold;
int fontIdBoldItalic; int fontIdBoldItalic;
std::unique_ptr<Vivy::Theme> qtCreatorThemePtr{ nullptr };
std::unique_ptr<MainWindow> mainWindowPtr{ nullptr }; std::unique_ptr<MainWindow> mainWindowPtr{ nullptr };
bool useFakeVim{ false }; bool useFakeVim{ false };
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