!241 chore: 优化 KDE 深色模式支持实现方式

* chore: 优化 KDE 深色模式支持实现方式
This commit is contained in:
2023-10-28 12:15:45 +00:00
committed by Pluto
parent 1a98dae4f8
commit 0db7fad640
4 changed files with 161 additions and 77 deletions

26
src/backend/ThemeChecker.h Normal file → Executable file
View File

@@ -2,25 +2,39 @@
#define THEMECHECKER_H
#include <QObject>
#include <QTimer>
#include <QDBusVariant>
#include <QDBusInterface>
#include <DPlatformTheme>
#include <DGuiApplicationHelper>
class ThemeChecker : public QObject
{
Q_OBJECT
public:
explicit ThemeChecker(QObject *parent = nullptr);
static ThemeChecker *instance();
bool useDarkTheme();
private:
void initThemeType();
void initConnections();
signals:
void themeChanged(bool isDark);
public slots:
void checkThemeChange();
private slots:
void slotSettingChanged(const QString &_namespace, const QString &key, const QDBusVariant &variant);
void slotThemeNameChanged(const QByteArray &theme);
void slotPaletteTypeChanged(Dtk::Gui::DGuiApplicationHelper::ColorType paletteType);
private:
int lastColorSchema;
QTimer *timer;
QDBusInterface *m_interface = nullptr;
Dtk::Gui::DGuiApplicationHelper::ColorType m_paletteType;
Dtk::Gui::DGuiApplicationHelper::ColorType m_themeType;
};
#endif // THEMECHECKER_H