| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QAPPLICATION_H |
| 5 | #define QAPPLICATION_H |
| 6 | |
| 7 | #include <QtWidgets/qtwidgetsglobal.h> |
| 8 | #include <QtCore/qcoreapplication.h> |
| 9 | #include <QtGui/qwindowdefs.h> |
| 10 | #include <QtCore/qpoint.h> |
| 11 | #include <QtCore/qsize.h> |
| 12 | #include <QtGui/qcursor.h> |
| 13 | #include <QtGui/qguiapplication.h> |
| 14 | |
| 15 | QT_BEGIN_NAMESPACE |
| 16 | |
| 17 | |
| 18 | class QStyle; |
| 19 | class QEventLoop; |
| 20 | class QIcon; |
| 21 | class QLocale; |
| 22 | class QPlatformNativeInterface; |
| 23 | |
| 24 | class QApplication; |
| 25 | class QApplicationPrivate; |
| 26 | #if defined(qApp) |
| 27 | #undef qApp |
| 28 | #endif |
| 29 | #define qApp (static_cast<QApplication *>(QCoreApplication::instance())) |
| 30 | |
| 31 | class Q_WIDGETS_EXPORT QApplication : public QGuiApplication |
| 32 | { |
| 33 | Q_OBJECT |
| 34 | Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime) |
| 35 | Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval) |
| 36 | Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval) |
| 37 | #if QT_CONFIG(wheelevent) |
| 38 | Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines) |
| 39 | #endif |
| 40 | Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime) |
| 41 | Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance) |
| 42 | #ifndef QT_NO_STYLE_STYLESHEET |
| 43 | Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet) |
| 44 | #endif |
| 45 | Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled) |
| 46 | |
| 47 | public: |
| 48 | #ifdef Q_QDOC |
| 49 | QApplication(int &argc, char **argv); |
| 50 | #else |
| 51 | QApplication(int &argc, char **argv, int = ApplicationFlags); |
| 52 | #endif |
| 53 | virtual ~QApplication(); |
| 54 | |
| 55 | static QStyle *style(); |
| 56 | static void setStyle(QStyle*); |
| 57 | static QStyle *setStyle(const QString&); |
| 58 | |
| 59 | using QGuiApplication::palette; |
| 60 | static QPalette palette(const QWidget *); |
| 61 | static QPalette palette(const char *className); |
| 62 | static void setPalette(const QPalette &, const char* className = nullptr); |
| 63 | static QFont font(); |
| 64 | static QFont font(const QWidget*); |
| 65 | static QFont font(const char *className); |
| 66 | static void setFont(const QFont &, const char* className = nullptr); |
| 67 | |
| 68 | #if QT_DEPRECATED_SINCE(6,0) |
| 69 | QT_DEPRECATED_VERSION_X_6_0("Use the QFontMetricsF constructor instead." ) |
| 70 | static QFontMetrics fontMetrics(); |
| 71 | #endif |
| 72 | |
| 73 | static QWidgetList allWidgets(); |
| 74 | static QWidgetList topLevelWidgets(); |
| 75 | |
| 76 | static QWidget *(); |
| 77 | static QWidget *activeModalWidget(); |
| 78 | static QWidget *focusWidget(); |
| 79 | |
| 80 | static QWidget *activeWindow(); |
| 81 | |
| 82 | #if QT_DEPRECATED_SINCE(6, 5) |
| 83 | QT_DEPRECATED_VERSION_X_6_5("Use QWidget::activateWindow() instead." ) |
| 84 | static void setActiveWindow(QWidget* act); |
| 85 | #endif |
| 86 | |
| 87 | static QWidget *widgetAt(const QPoint &p); |
| 88 | static inline QWidget *widgetAt(int x, int y) { return widgetAt(p: QPoint(x, y)); } |
| 89 | static QWidget *topLevelAt(const QPoint &p); |
| 90 | static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(p: QPoint(x, y)); } |
| 91 | |
| 92 | static void beep(); |
| 93 | static void alert(QWidget *widget, int duration = 0); |
| 94 | |
| 95 | static void setCursorFlashTime(int); |
| 96 | static int cursorFlashTime(); |
| 97 | |
| 98 | static void setDoubleClickInterval(int); |
| 99 | static int doubleClickInterval(); |
| 100 | |
| 101 | static void setKeyboardInputInterval(int); |
| 102 | static int keyboardInputInterval(); |
| 103 | |
| 104 | #if QT_CONFIG(wheelevent) |
| 105 | static void setWheelScrollLines(int); |
| 106 | static int wheelScrollLines(); |
| 107 | #endif |
| 108 | |
| 109 | static void setStartDragTime(int ms); |
| 110 | static int startDragTime(); |
| 111 | static void setStartDragDistance(int l); |
| 112 | static int startDragDistance(); |
| 113 | |
| 114 | static bool isEffectEnabled(Qt::UIEffect); |
| 115 | static void setEffectEnabled(Qt::UIEffect, bool enable = true); |
| 116 | |
| 117 | static int exec(); |
| 118 | bool notify(QObject *, QEvent *) override; |
| 119 | |
| 120 | #ifdef QT_KEYPAD_NAVIGATION |
| 121 | static void setNavigationMode(Qt::NavigationMode mode); |
| 122 | static Qt::NavigationMode navigationMode(); |
| 123 | #endif |
| 124 | |
| 125 | QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QApplication) |
| 126 | |
| 127 | Q_SIGNALS: |
| 128 | void focusChanged(QWidget *old, QWidget *now); |
| 129 | |
| 130 | public: |
| 131 | QString styleSheet() const; |
| 132 | bool autoSipEnabled() const; |
| 133 | public Q_SLOTS: |
| 134 | #ifndef QT_NO_STYLE_STYLESHEET |
| 135 | void setStyleSheet(const QString& sheet); |
| 136 | #endif |
| 137 | void setAutoSipEnabled(const bool enabled); |
| 138 | static void closeAllWindows(); |
| 139 | static void aboutQt(); |
| 140 | |
| 141 | protected: |
| 142 | bool event(QEvent *) override; |
| 143 | bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override; |
| 144 | |
| 145 | private: |
| 146 | Q_DISABLE_COPY(QApplication) |
| 147 | Q_DECLARE_PRIVATE(QApplication) |
| 148 | |
| 149 | friend class QGraphicsWidget; |
| 150 | friend class QGraphicsItem; |
| 151 | friend class QGraphicsScene; |
| 152 | friend class QGraphicsScenePrivate; |
| 153 | friend class QWidget; |
| 154 | friend class QWidgetPrivate; |
| 155 | friend class QWidgetWindow; |
| 156 | friend class QTranslator; |
| 157 | friend class QWidgetAnimator; |
| 158 | #ifndef QT_NO_SHORTCUT |
| 159 | friend class QShortcut; |
| 160 | friend class QLineEdit; |
| 161 | friend class QWidgetTextControl; |
| 162 | #endif |
| 163 | friend class QAction; |
| 164 | |
| 165 | #ifndef QT_NO_GESTURES |
| 166 | friend class QGestureManager; |
| 167 | #endif |
| 168 | }; |
| 169 | |
| 170 | QT_END_NAMESPACE |
| 171 | |
| 172 | #endif // QAPPLICATION_H |
| 173 | |