Add command to automatically reload your theme (#4718)

This commit is contained in:
nerix
2023-07-23 14:13:21 +02:00
committed by GitHub
parent fca57696bb
commit 9f8a1d8823
7 changed files with 150 additions and 40 deletions
+12
View File
@@ -9,8 +9,10 @@
#include <QJsonObject>
#include <QPixmap>
#include <QString>
#include <QTimer>
#include <QVariant>
#include <memory>
#include <optional>
#include <vector>
@@ -39,6 +41,8 @@ public:
// The built in theme that will be used if some theme parsing fails
static const ThemeDescriptor fallbackTheme;
static const int AUTO_RELOAD_INTERVAL_MS = 500;
void initialize(Settings &settings, Paths &paths) final;
bool isLightTheme() const;
@@ -138,6 +142,9 @@ public:
void normalizeColor(QColor &color) const;
void update();
bool isAutoReloading() const;
void setAutoReload(bool autoReload);
/**
* Return a list of available themes
**/
@@ -152,6 +159,11 @@ private:
std::vector<ThemeDescriptor> availableThemes_;
QString currentThemePath_;
std::unique_ptr<QTimer> themeReloadTimer_;
// This will only be populated when auto-reloading themes
QJsonObject currentThemeJson_;
/**
* Figure out which themes are available in the Themes directory
*