DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dthememanager.h
1// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DTHEMEMANAGER_H
6#define DTHEMEMANAGER_H
7
8#include <dtkwidget_global.h>
9#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
10
11#include <QObject>
12#include <QString>
13#include <QGlobalStatic>
14#include <DObject>
15
16DWIDGET_BEGIN_NAMESPACE
17
18class DThemeManagerPrivate;
19class LIBDTKWIDGETSHARED_EXPORT D_DECL_DEPRECATED DThemeManager : public QObject, public DTK_CORE_NAMESPACE::DObject
20{
21 Q_OBJECT
22
23public:
24 static DThemeManager *instance();
25
26 QString theme() const;
27 QString theme(const QWidget *widget, QWidget **baseWidget = nullptr) const;
28 void setTheme(const QString theme);
29 void setTheme(QWidget *widget, const QString theme);
30
31 QString getQssForWidget(const QString className, const QString &theme = QString()) const;
32 QString getQssForWidget(const QWidget *widget) const;
33
34 static void registerWidget(QWidget *widget, QStringList properties = QStringList());
35 // TODO: use blow instead, the only thing should do is rebuilding
36 // static void registerWidget(QWidget *widget, const QStringList &properties = QStringList());
37 static void registerWidget(QWidget *widget, const QString &filename, const QStringList &properties = QStringList());
38
39public Q_SLOTS:
40 void updateQss();
41 void updateThemeOnParentChanged(QWidget *widget);
42
43Q_SIGNALS:
44 void themeChanged(QString theme);
45 void widgetThemeChanged(QWidget *widget, QString theme);
46
47protected:
48 DThemeManager();
49 bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
50
51private:
52 friend class DApplication;
53 D_DECLARE_PRIVATE(DThemeManager)
54};
55
56DWIDGET_END_NAMESPACE
57
58#endif // DTHEMEMANAGER_H
59
60#endif