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