DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dapplication.h
1// SPDX-FileCopyrightText: 2015 - 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DAPPLICATION_H
6#define DAPPLICATION_H
7
8#include <dtkwidget_global.h>
9#include <DObject>
10#include <DPalette>
11#include <QApplication>
12
13DWIDGET_BEGIN_NAMESPACE
14
15DGUI_USE_NAMESPACE
16
17#define DAPPLICATION_XSTRING(s) DAPPLICATION_STRING(s)
18#define DAPPLICATION_STRING(s) #s
19
20class DApplication;
21class DApplicationPrivate;
22class DAboutDialog;
23class DFeatureDisplayDialog;
24class DLicenseDialog;
25class DAppHandler;
26
27#if defined(qApp)
28#undef qApp
29#endif
30#define qApp (static_cast<Dtk::Widget::DApplication *>(QCoreApplication::instance()))
31
32class LIBDTKWIDGETSHARED_EXPORT DApplication : public QApplication, public DTK_CORE_NAMESPACE::DObject
33{
34 Q_OBJECT
35 D_DECLARE_PRIVATE(DApplication)
36 Q_PROPERTY(bool visibleMenuShortcutText READ visibleMenuShortcutText WRITE setVisibleMenuShortcutText)
37 Q_PROPERTY(bool visibleMenuCheckboxWidget READ visibleMenuCheckboxWidget WRITE setVisibleMenuCheckboxWidget)
38 Q_PROPERTY(bool visibleMenuIcon READ visibleMenuIcon WRITE setVisibleMenuIcon)
39 Q_PROPERTY(bool autoActivateWindows READ autoActivateWindows WRITE setAutoActivateWindows)
40 Q_PROPERTY(QString applicationCreditsFile READ applicationCreditsFile WRITE setApplicationCreditsFile)
41 Q_PROPERTY(QByteArray applicationCreditsContent READ applicationCreditsContent WRITE setApplicationCreditsContent)
42 Q_PROPERTY(QString licensePath READ licensePath WRITE setLicensePath)
43
44public:
45 static DApplication *globalApplication(int &argc, char **argv);
46
47 DApplication(int &argc, char **argv);
48 ~DApplication();
49 enum SingleScope {
50 UserScope,
51 SystemScope
52 };
53#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
54 D_DECL_DEPRECATED QString theme() const;
55 D_DECL_DEPRECATED void setTheme(const QString &theme);
56#endif
57
58#ifdef Q_OS_UNIX
59 void setOOMScoreAdj(const int score);
60#endif
61
62 bool setSingleInstance(const QString &key);
63 bool setSingleInstance(const QString &key, SingleScope singleScope);
64
65 bool loadTranslator(QList<QLocale> localeFallback = QList<QLocale>() << QLocale::system());
66
67#if DTK_VERSION < DTK_VERSION_CHECK(6, 0, 0, 0)
69 D_DECL_DEPRECATED static bool loadDXcbPlugin();
70#endif
71 static bool isDXcbPlatform();
72
73 // return the libdtkwidget version of build application
74 static int buildDtkVersion();
75 // return the libdtkwidget version of runing application
76 static int runtimeDtkVersion();
77
78 // let startdde know that we've already started.
79 static void registerDDESession();
80
81 static void customQtThemeConfigPathByUserHome(const QString &home);
82 static void customQtThemeConfigPath(const QString &path);
83 static QString customizedQtThemeConfigPath();
84
85 // meta information that necessary to create a about dialog for the application.
86 QString productName() const;
87 void setProductName(const QString &productName);
88
89 const QIcon &productIcon() const;
90 void setProductIcon(const QIcon &productIcon);
91
92 QString applicationLicense() const;
93 void setApplicationLicense(const QString &license);
94
95 QString applicationDescription() const;
96 void setApplicationDescription(const QString &description);
97
98 QString applicationHomePage() const;
99 void setApplicationHomePage(const QString &link);
100
101 QString applicationAcknowledgementPage() const;
102 void setApplicationAcknowledgementPage(const QString &link);
103
104 bool applicationAcknowledgementVisible() const;
105 void setApplicationAcknowledgementVisible(bool visible);
106
107 DAboutDialog *aboutDialog();
108 void setAboutDialog(DAboutDialog *aboutDialog);
109
110 DFeatureDisplayDialog *featureDisplayDialog();
111 void setFeatureDisplayDialog(DFeatureDisplayDialog *featureDisplayDialog);
112
113 bool visibleMenuShortcutText() const;
114 void setVisibleMenuShortcutText(bool value);
115
116 bool visibleMenuCheckboxWidget() const;
117 void setVisibleMenuCheckboxWidget(bool value);
118
119 bool visibleMenuIcon() const;
120 void setVisibleMenuIcon(bool value);
121
122 bool autoActivateWindows() const;
123 void setAutoActivateWindows(bool autoActivateWindows);
124
125 // 使窗口内的输入框自动适应虚拟键盘
126 void acclimatizeVirtualKeyboard(QWidget *window);
127 void ignoreVirtualKeyboard(QWidget *window);
128 bool isAcclimatizedVirtualKeyboard(QWidget *window) const;
129
130 QString applicationCreditsFile() const;
131 void setApplicationCreditsFile(const QString &file);
132
133 QByteArray applicationCreditsContent() const;
134 void setApplicationCreditsContent(const QByteArray &content);
135
136 QString licensePath() const;
137 void setLicensePath(const QString &path);
138
139#ifdef VERSION
140 static inline QString buildVersion(const QString &fallbackVersion)
141 {
142 QString autoVersion = DAPPLICATION_XSTRING(VERSION);
143 if (autoVersion.isEmpty()) {
144 autoVersion = fallbackVersion;
145 }
146 return autoVersion;
147 }
148#else
149 static inline QString buildVersion(const QString &fallbackVersion)
150 {
151 return fallbackVersion;
152 }
153#endif
154
155Q_SIGNALS:
157
158 //###(zccrs): Depend the Qt platform theme plugin(from the package: dde-qt5integration)
160 //###(zccrs): Emit form the Qt platform theme plugin(from the package: dde-qt5integration)
161 void screenDevicePixelRatioChanged(QScreen *screen);
162
163public:
164 void setCustomHandler(DAppHandler *handler);
165 DAppHandler *customHandler();
166
167protected:
168 virtual void handleHelpAction();
169 virtual void handleAboutAction();
170 virtual void handleQuitAction();
171
172public:
173 bool notify(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
174
175private:
176 friend class DTitlebarPrivate;
177 friend class DMainWindowPrivate;
178
179 D_PRIVATE_SLOT(void _q_onNewInstanceStarted())
180 D_PRIVATE_SLOT(void _q_panWindowContentsForVirtualKeyboard())
181 D_PRIVATE_SLOT(void _q_resizeWindowContentsForVirtualKeyboard())
182 D_PRIVATE_SLOT(void _q_sizeModeChanged())
183};
184
185class LIBDTKWIDGETSHARED_EXPORT DAppHandler {
186public:
187 inline virtual ~DAppHandler() = default;
188
189 virtual void handleHelpAction() = 0;
190 virtual void handleAboutAction() = 0;
191 virtual void handleQuitAction() = 0;
192};
193
195public:
196 static int value;
197};
198
199#ifndef LIBDTKWIDGET_LIBRARY
200class Q_DECL_HIDDEN _DtkBuildVersion {
201public:
203 DtkBuildVersion::value = DTK_VERSION;
204 }
205};
206
207static _DtkBuildVersion _dtk_build_version;
208#endif
209
210DWIDGET_END_NAMESPACE
211
212#endif // DAPPLICATION_H
DAboutDialog 类提供了应用程序的关于对话框, 规范所有 deepin 应用关于窗口设计规范, 符合 deepin 风格
Definition daboutdialog.h:14
Definition dapplication.h:185
DApplication 是 DTK 中用于替换 QCoreApplication 相关功能实现的类.
Definition dapplication.h:33
void iconThemeChanged()
该信号在系统图标主题发生改变的时候被触发.
void newInstanceStarted()
该信号会在程序的一个新实例启动的时候被触发.
void screenDevicePixelRatioChanged(QScreen *screen)
该信号在对应屏幕 screen 的缩放比可能发现变化时触发.
特性介绍对话框,展示应用更新的新特性
Definition dfeaturedisplaydialog.h:37
Definition dmainwindow_p.h:108
Definition dtitlebar.cpp:59
Definition dapplication.h:194
Definition dapplication.h:200