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 "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,7 +57,7 @@ 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
setTheme(Theme::QtCreator); // TODO: Set system theme for now (because we
// don't have a central theme provider).
// Cursor blinking
......
......@@ -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;
......
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