qapplication.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. #ifndef QAPPLICATION_H
  40. #define QAPPLICATION_H
  41. #include <QtCore/qcoreapplication.h>
  42. #include <QtGui/qwindowdefs.h>
  43. #include <QtCore/qpoint.h>
  44. #include <QtCore/qsize.h>
  45. #include <QtGui/qcursor.h>
  46. #ifdef QT_INCLUDE_COMPAT
  47. # include <QtWidgets/qdesktopwidget.h>
  48. #endif
  49. #include <QtGui/qguiapplication.h>
  50. QT_BEGIN_NAMESPACE
  51. class QDesktopWidget;
  52. class QStyle;
  53. class QEventLoop;
  54. class QIcon;
  55. template <typename T> class QList;
  56. class QLocale;
  57. class QPlatformNativeInterface;
  58. class QApplication;
  59. class QApplicationPrivate;
  60. #if defined(qApp)
  61. #undef qApp
  62. #endif
  63. #define qApp (static_cast<QApplication *>(QCoreApplication::instance()))
  64. class Q_WIDGETS_EXPORT QApplication : public QGuiApplication
  65. {
  66. Q_OBJECT
  67. Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
  68. Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime)
  69. Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval)
  70. Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
  71. #ifndef QT_NO_WHEELEVENT
  72. Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines)
  73. #endif
  74. Q_PROPERTY(QSize globalStrut READ globalStrut WRITE setGlobalStrut)
  75. Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime)
  76. Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance)
  77. #ifndef QT_NO_STYLE_STYLESHEET
  78. Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
  79. #endif
  80. #ifdef Q_OS_WINCE
  81. Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold)
  82. #endif
  83. Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
  84. public:
  85. #ifdef Q_QDOC
  86. QApplication(int &argc, char **argv);
  87. #else
  88. QApplication(int &argc, char **argv, int = ApplicationFlags);
  89. #endif
  90. virtual ~QApplication();
  91. static QStyle *style();
  92. static void setStyle(QStyle*);
  93. static QStyle *setStyle(const QString&);
  94. enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 };
  95. static int colorSpec();
  96. static void setColorSpec(int);
  97. #if QT_DEPRECATED_SINCE(5, 0)
  98. QT_DEPRECATED static inline void setGraphicsSystem(const QString &) {}
  99. #endif
  100. using QGuiApplication::palette;
  101. static QPalette palette(const QWidget *);
  102. static QPalette palette(const char *className);
  103. static void setPalette(const QPalette &, const char* className = Q_NULLPTR);
  104. static QFont font();
  105. static QFont font(const QWidget*);
  106. static QFont font(const char *className);
  107. static void setFont(const QFont &, const char* className = Q_NULLPTR);
  108. static QFontMetrics fontMetrics();
  109. #if QT_VERSION < 0x060000 // remove these forwarders in Qt 6
  110. static void setWindowIcon(const QIcon &icon);
  111. static QIcon windowIcon();
  112. #endif
  113. static QWidgetList allWidgets();
  114. static QWidgetList topLevelWidgets();
  115. static QDesktopWidget *desktop();
  116. static QWidget *activePopupWidget();
  117. static QWidget *activeModalWidget();
  118. static QWidget *focusWidget();
  119. static QWidget *activeWindow();
  120. static void setActiveWindow(QWidget* act);
  121. static QWidget *widgetAt(const QPoint &p);
  122. static inline QWidget *widgetAt(int x, int y) { return widgetAt(QPoint(x, y)); }
  123. static QWidget *topLevelAt(const QPoint &p);
  124. static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); }
  125. #if QT_DEPRECATED_SINCE(5, 0)
  126. QT_DEPRECATED static inline void syncX() {}
  127. #endif
  128. static void beep();
  129. static void alert(QWidget *widget, int duration = 0);
  130. static void setCursorFlashTime(int);
  131. static int cursorFlashTime();
  132. static void setDoubleClickInterval(int);
  133. static int doubleClickInterval();
  134. static void setKeyboardInputInterval(int);
  135. static int keyboardInputInterval();
  136. #ifndef QT_NO_WHEELEVENT
  137. static void setWheelScrollLines(int);
  138. static int wheelScrollLines();
  139. #endif
  140. static void setGlobalStrut(const QSize &);
  141. static QSize globalStrut();
  142. static void setStartDragTime(int ms);
  143. static int startDragTime();
  144. static void setStartDragDistance(int l);
  145. static int startDragDistance();
  146. static bool isEffectEnabled(Qt::UIEffect);
  147. static void setEffectEnabled(Qt::UIEffect, bool enable = true);
  148. #if QT_DEPRECATED_SINCE(5, 0)
  149. QT_DEPRECATED static QLocale keyboardInputLocale()
  150. { return qApp ? QGuiApplication::inputMethod()->locale() : QLocale::c(); }
  151. QT_DEPRECATED static Qt::LayoutDirection keyboardInputDirection()
  152. { return qApp ? QGuiApplication::inputMethod()->inputDirection() : Qt::LeftToRight; }
  153. #endif
  154. static int exec();
  155. bool notify(QObject *, QEvent *) Q_DECL_OVERRIDE;
  156. #ifdef QT_KEYPAD_NAVIGATION
  157. static Q_DECL_DEPRECATED void setKeypadNavigationEnabled(bool);
  158. static bool keypadNavigationEnabled();
  159. static void setNavigationMode(Qt::NavigationMode mode);
  160. static Qt::NavigationMode navigationMode();
  161. #endif
  162. Q_SIGNALS:
  163. void focusChanged(QWidget *old, QWidget *now);
  164. public:
  165. QString styleSheet() const;
  166. public Q_SLOTS:
  167. #ifndef QT_NO_STYLE_STYLESHEET
  168. void setStyleSheet(const QString& sheet);
  169. #endif
  170. #ifdef Q_OS_WINCE
  171. void setAutoMaximizeThreshold(const int threshold);
  172. int autoMaximizeThreshold() const;
  173. #endif
  174. void setAutoSipEnabled(const bool enabled);
  175. bool autoSipEnabled() const;
  176. static void closeAllWindows();
  177. static void aboutQt();
  178. protected:
  179. bool event(QEvent *) Q_DECL_OVERRIDE;
  180. bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) Q_DECL_OVERRIDE;
  181. private:
  182. Q_DISABLE_COPY(QApplication)
  183. Q_DECLARE_PRIVATE(QApplication)
  184. friend class QGraphicsWidget;
  185. friend class QGraphicsItem;
  186. friend class QGraphicsScene;
  187. friend class QGraphicsScenePrivate;
  188. friend class QWidget;
  189. friend class QWidgetPrivate;
  190. friend class QWidgetWindow;
  191. friend class QTranslator;
  192. friend class QWidgetAnimator;
  193. #ifndef QT_NO_SHORTCUT
  194. friend class QShortcut;
  195. friend class QLineEdit;
  196. friend class QWidgetTextControl;
  197. #endif
  198. friend class QAction;
  199. #ifndef QT_NO_GESTURES
  200. friend class QGestureManager;
  201. #endif
  202. };
  203. QT_END_NAMESPACE
  204. #endif // QAPPLICATION_H