1 /****************************************************************************
2 **
3 ** DQt - D bindings for the Qt Toolkit
4 **
5 ** GNU Lesser General Public License Usage
6 ** This file may be used under the terms of the GNU Lesser
7 ** General Public License version 3 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
9 ** packaging of this file. Please review the following information to
10 ** ensure the GNU Lesser General Public License version 3 requirements
11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
12 **
13 ****************************************************************************/
14 module qt.widgets.application;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.coreapplication;
19 import qt.core.coreevent;
20 import qt.core.namespace;
21 import qt.core.object;
22 import qt.core.point;
23 import qt.core.size;
24 import qt.core.string;
25 import qt.gui.font;
26 import qt.gui.fontmetrics;
27 import qt.gui.guiapplication;
28 import qt.gui.icon;
29 import qt.gui.palette;
30 import qt.helpers;
31 import qt.widgets.desktopwidget;
32 import qt.widgets.style;
33 import qt.widgets.widget;
34 
35 /+ #ifdef QT_INCLUDE_COMPAT
36 #endif
37 
38 
39 class QDesktopWidget;
40 class QStyle;
41 class QEventLoop;
42 class QIcon;
43 template <typename T> class QList;
44 class QLocale;
45 class QPlatformNativeInterface;
46 
47 class QApplication; +/
48 extern(C++, class) struct QApplicationPrivate;
49 /+ #if defined(qApp)
50 #undef qApp
51 #endif +/
52 /+ #define qApp (static_cast<QApplication *>(QCoreApplication::instance())) +/
53 enum qApp = q{(static_cast!(QApplication)(QCoreApplication.instance()))};
54 
55 class /+ Q_WIDGETS_EXPORT +/ QApplication : QGuiApplication
56 {
57     mixin(Q_OBJECT);
58     /+ Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
59     Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime)
60     Q_PROPERTY(int doubleClickInterval  READ doubleClickInterval WRITE setDoubleClickInterval)
61     Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
62 #if QT_CONFIG(wheelevent)
63     Q_PROPERTY(int wheelScrollLines  READ wheelScrollLines WRITE setWheelScrollLines)
64 #endif
65 #if QT_DEPRECATED_SINCE(5, 15)
66     Q_PROPERTY(QSize globalStrut READ globalStrut WRITE setGlobalStrut)
67 #endif
68     Q_PROPERTY(int startDragTime  READ startDragTime WRITE setStartDragTime)
69     Q_PROPERTY(int startDragDistance  READ startDragDistance WRITE setStartDragDistance)
70 #ifndef QT_NO_STYLE_STYLESHEET
71     Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
72 #endif
73     Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled) +/
74 
75 public:
76 /+ #ifdef Q_QDOC
77     QApplication(int &argc, char **argv);
78 #else +/
79     this(ref int argc, char** argv, int = ApplicationFlags);
80 /+ #endif +/
81     /+ virtual +/~this();
82 
83     static QStyle style();
84     static void setStyle(QStyle);
85     static QStyle setStyle(ref const(QString));
86     enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 }
87 /+ #if QT_DEPRECATED_SINCE(5, 8) +/
88     /+ QT_DEPRECATED +/ static int colorSpec();
89     /+ QT_DEPRECATED +/ static void setColorSpec(int);
90 /+ #endif // QT_DEPRECATED_SINCE(5, 8)
91 #if QT_DEPRECATED_SINCE(5, 0)
92     QT_DEPRECATED static inline void setGraphicsSystem(const QString &) {}
93 #endif +/
94 
95     /+ using QGuiApplication::palette; +/
96     static QPalette palette(const(QWidget) );
97     static QPalette palette(const(char)* className);
98     static void setPalette(ref const(QPalette) , const(char)* className = null);
99     static QFont font();
100     static QFont font(const(QWidget));
101     static QFont font(const(char)* className);
102     static void setFont(ref const(QFont) , const(char)* className = null);
103     static QFontMetrics fontMetrics();
104 
105 /+ #if QT_VERSION < 0x060000 +/ // remove these forwarders in Qt 6
106     static void setWindowIcon(ref const(QIcon) icon);
107     static QIcon windowIcon();
108 /+ #endif +/
109 
110     static QWidgetList allWidgets();
111     static QWidgetList topLevelWidgets();
112 
113     static QDesktopWidget desktop();
114 
115     static QWidget activePopupWidget();
116     static QWidget activeModalWidget();
117     static QWidget focusWidget();
118 
119     static QWidget activeWindow();
120     static void setActiveWindow(QWidget act);
121 
122     static QWidget widgetAt(ref const(QPoint) p);
123     pragma(inline, true) static QWidget widgetAt(int x, int y) { auto tmp = QPoint(x, y); return widgetAt(tmp); }
124     static QWidget topLevelAt(ref const(QPoint) p);
125     pragma(inline, true) static QWidget topLevelAt(int x, int y)  { auto tmp = QPoint(x, y); return topLevelAt(tmp); }
126 
127 /+ #if QT_DEPRECATED_SINCE(5, 0)
128     QT_DEPRECATED static inline void syncX() {}
129 #endif +/
130     static void beep();
131     static void alert(QWidget widget, int duration = 0);
132 
133     static void setCursorFlashTime(int);
134     static int cursorFlashTime();
135 
136     static void setDoubleClickInterval(int);
137     static int doubleClickInterval();
138 
139     static void setKeyboardInputInterval(int);
140     static int keyboardInputInterval();
141 
142 /+ #if QT_CONFIG(wheelevent) +/
143     static void setWheelScrollLines(int);
144     static int wheelScrollLines();
145 /+ #endif
146 #if QT_DEPRECATED_SINCE(5, 15) +/
147     static void setGlobalStrut(ref const(QSize) );
148     static QSize globalStrut();
149 /+ #endif +/
150 
151     static void setStartDragTime(int ms);
152     static int startDragTime();
153     static void setStartDragDistance(int l);
154     static int startDragDistance();
155 
156     static bool isEffectEnabled(/+ Qt:: +/qt.core.namespace.UIEffect);
157     static void setEffectEnabled(/+ Qt:: +/qt.core.namespace.UIEffect, bool enable = true);
158 
159 /+ #if QT_DEPRECATED_SINCE(5, 0)
160     QT_DEPRECATED static QLocale keyboardInputLocale()
161     { return qApp ? QGuiApplication::inputMethod()->locale() : QLocale::c(); }
162     QT_DEPRECATED static Qt::LayoutDirection keyboardInputDirection()
163     { return qApp ? QGuiApplication::inputMethod()->inputDirection() : Qt::LeftToRight; }
164 #endif +/
165 
166     static int exec();
167     override bool notify(QObject , QEvent );
168 
169 /+ #ifdef QT_KEYPAD_NAVIGATION
170 # if QT_DEPRECATED_SINCE(5, 13) +/
171     version(QT_KEYPAD_NAVIGATION)
172     {
173         /+ QT_DEPRECATED_X ("Use QApplication::setNavigationMode() instead") +/
174             static void setKeypadNavigationEnabled(bool);
175         /+ QT_DEPRECATED_X ("Use QApplication::navigationMode() instead") +/
176             static bool keypadNavigationEnabled();
177     /+ # endif +/
178         static void setNavigationMode(/+ Qt:: +/qt.core.namespace.NavigationMode mode);
179         static /+ Qt:: +/qt.core.namespace.NavigationMode navigationMode();
180     }
181 /+ #endif +/
182 
183 /+ Q_SIGNALS +/public:
184     @QSignal final void focusChanged(QWidget old, QWidget now);
185 
186 public:
187     final QString styleSheet() const;
188 public /+ Q_SLOTS +/:
189     version(QT_NO_STYLE_STYLESHEET){}else
190     {
191         @QSlot final void setStyleSheet(ref const(QString) sheet);
192     }
193     @QSlot final void setAutoSipEnabled(const(bool) enabled);
194     @QSlot final bool autoSipEnabled() const;
195     @QSlot static void closeAllWindows();
196     @QSlot static void aboutQt();
197 
198 protected:
199     override bool event(QEvent );
200     override bool compressEvent(QEvent , QObject receiver, QPostEventList* );
201 
202 private:
203     /+ Q_DISABLE_COPY(QApplication) +/
204     /+ Q_DECLARE_PRIVATE(QApplication) +/
205 
206     /+ friend class QGraphicsWidget; +/
207     /+ friend class QGraphicsItem; +/
208     /+ friend class QGraphicsScene; +/
209     /+ friend class QGraphicsScenePrivate; +/
210     /+ friend class QWidget; +/
211     /+ friend class QWidgetPrivate; +/
212     /+ friend class QWidgetWindow; +/
213     /+ friend class QTranslator; +/
214     /+ friend class QWidgetAnimator; +/
215     version(QT_NO_SHORTCUT){}else
216     {
217         /+ friend class QShortcut; +/
218         /+ friend class QLineEdit; +/
219         /+ friend class QWidgetTextControl; +/
220     }
221     /+ friend class QAction; +/
222 
223     version(QT_NO_GESTURES){}else
224     {
225         /+ friend class QGestureManager; +/
226     }
227 }
228