1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtWidgets module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QAPPLICATION_H |
41 | #define QAPPLICATION_H |
42 | |
43 | #include <QtWidgets/qtwidgetsglobal.h> |
44 | #include <QtCore/qcoreapplication.h> |
45 | #include <QtGui/qwindowdefs.h> |
46 | #include <QtCore/qpoint.h> |
47 | #include <QtCore/qsize.h> |
48 | #include <QtGui/qcursor.h> |
49 | #include <QtGui/qguiapplication.h> |
50 | |
51 | QT_BEGIN_NAMESPACE |
52 | |
53 | |
54 | class QStyle; |
55 | class QEventLoop; |
56 | class QIcon; |
57 | class QLocale; |
58 | class QPlatformNativeInterface; |
59 | |
60 | class QApplication; |
61 | class QApplicationPrivate; |
62 | #if defined(qApp) |
63 | #undef qApp |
64 | #endif |
65 | #define qApp (static_cast<QApplication *>(QCoreApplication::instance())) |
66 | |
67 | class Q_WIDGETS_EXPORT QApplication : public QGuiApplication |
68 | { |
69 | Q_OBJECT |
70 | Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime) |
71 | Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval) |
72 | Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval) |
73 | #if QT_CONFIG(wheelevent) |
74 | Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines) |
75 | #endif |
76 | Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime) |
77 | Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance) |
78 | #ifndef QT_NO_STYLE_STYLESHEET |
79 | Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet) |
80 | #endif |
81 | Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled) |
82 | |
83 | public: |
84 | #ifdef Q_QDOC |
85 | QApplication(int &argc, char **argv); |
86 | #else |
87 | QApplication(int &argc, char **argv, int = ApplicationFlags); |
88 | #endif |
89 | virtual ~QApplication(); |
90 | |
91 | static QStyle *style(); |
92 | static void setStyle(QStyle*); |
93 | static QStyle *setStyle(const QString&); |
94 | |
95 | using QGuiApplication::palette; |
96 | static QPalette palette(const QWidget *); |
97 | static QPalette palette(const char *className); |
98 | static void setPalette(const QPalette &, const char* className = nullptr); |
99 | static QFont font(); |
100 | static QFont font(const QWidget*); |
101 | static QFont font(const char *className); |
102 | static void setFont(const QFont &, const char* className = nullptr); |
103 | |
104 | #if QT_DEPRECATED_SINCE(6,0) |
105 | QT_DEPRECATED_VERSION_X_6_0("Use the QFontMetricsF constructor instead." ) |
106 | static QFontMetrics fontMetrics(); |
107 | #endif |
108 | |
109 | static QWidgetList allWidgets(); |
110 | static QWidgetList topLevelWidgets(); |
111 | |
112 | static QWidget *(); |
113 | static QWidget *activeModalWidget(); |
114 | static QWidget *focusWidget(); |
115 | |
116 | static QWidget *activeWindow(); |
117 | static void setActiveWindow(QWidget* act); |
118 | |
119 | static QWidget *widgetAt(const QPoint &p); |
120 | static inline QWidget *widgetAt(int x, int y) { return widgetAt(QPoint(x, y)); } |
121 | static QWidget *topLevelAt(const QPoint &p); |
122 | static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); } |
123 | |
124 | static void beep(); |
125 | static void alert(QWidget *widget, int duration = 0); |
126 | |
127 | static void setCursorFlashTime(int); |
128 | static int cursorFlashTime(); |
129 | |
130 | static void setDoubleClickInterval(int); |
131 | static int doubleClickInterval(); |
132 | |
133 | static void setKeyboardInputInterval(int); |
134 | static int keyboardInputInterval(); |
135 | |
136 | #if QT_CONFIG(wheelevent) |
137 | static void setWheelScrollLines(int); |
138 | static int wheelScrollLines(); |
139 | #endif |
140 | |
141 | static void setStartDragTime(int ms); |
142 | static int startDragTime(); |
143 | static void setStartDragDistance(int l); |
144 | static int startDragDistance(); |
145 | |
146 | static bool isEffectEnabled(Qt::UIEffect); |
147 | static void setEffectEnabled(Qt::UIEffect, bool enable = true); |
148 | |
149 | static int exec(); |
150 | bool notify(QObject *, QEvent *) override; |
151 | |
152 | #ifdef QT_KEYPAD_NAVIGATION |
153 | static void setNavigationMode(Qt::NavigationMode mode); |
154 | static Qt::NavigationMode navigationMode(); |
155 | #endif |
156 | |
157 | Q_SIGNALS: |
158 | void focusChanged(QWidget *old, QWidget *now); |
159 | |
160 | public: |
161 | QString styleSheet() const; |
162 | public Q_SLOTS: |
163 | #ifndef QT_NO_STYLE_STYLESHEET |
164 | void setStyleSheet(const QString& sheet); |
165 | #endif |
166 | void setAutoSipEnabled(const bool enabled); |
167 | bool autoSipEnabled() const; |
168 | static void closeAllWindows(); |
169 | static void aboutQt(); |
170 | |
171 | protected: |
172 | bool event(QEvent *) override; |
173 | bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override; |
174 | |
175 | private: |
176 | Q_DISABLE_COPY(QApplication) |
177 | Q_DECLARE_PRIVATE(QApplication) |
178 | |
179 | friend class QGraphicsWidget; |
180 | friend class QGraphicsItem; |
181 | friend class QGraphicsScene; |
182 | friend class QGraphicsScenePrivate; |
183 | friend class QWidget; |
184 | friend class QWidgetPrivate; |
185 | friend class QWidgetWindow; |
186 | friend class QTranslator; |
187 | friend class QWidgetAnimator; |
188 | #ifndef QT_NO_SHORTCUT |
189 | friend class QShortcut; |
190 | friend class QLineEdit; |
191 | friend class QWidgetTextControl; |
192 | #endif |
193 | friend class QAction; |
194 | |
195 | #ifndef QT_NO_GESTURES |
196 | friend class QGestureManager; |
197 | #endif |
198 | }; |
199 | |
200 | QT_END_NAMESPACE |
201 | |
202 | #endif // QAPPLICATION_H |
203 | |