Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qapplication_p.h
Go to the documentation of this file.
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_P_H
5#define QAPPLICATION_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of qapplication_*.cpp, qwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp
13// and many other. This header file may change from version to version
14// without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtWidgets/private/qtwidgetsglobal_p.h>
20#include "QtWidgets/qapplication.h"
21#include "QtGui/qevent.h"
22#include "QtGui/qfont.h"
23#include "QtGui/qcursor.h"
24#include "QtGui/qregion.h"
25#include "QtGui/qwindow.h"
26#include "qwidget.h"
27#include <qpa/qplatformnativeinterface.h>
28#include "QtCore/qmutex.h"
29#include "QtCore/qtranslator.h"
30#include "QtCore/qbasictimer.h"
31#include "QtCore/qhash.h"
32#include "QtCore/qpointer.h"
33#include "private/qcoreapplication_p.h"
34#include "QtCore/qpoint.h"
35#include <QTime>
36#include <qpa/qwindowsysteminterface.h>
37#include <qpa/qwindowsysteminterface_p.h>
38#include <qpa/qplatformintegration.h>
39#include "private/qguiapplication_p.h"
40
42
43class QClipboard;
44class QGraphicsScene;
45class QObject;
46class QWidget;
47class QSocketNotifier;
48class QPointingDevice;
49#ifndef QT_NO_GESTURES
50class QGestureManager;
51#endif
52
53extern Q_GUI_EXPORT bool qt_is_tty_app;
54#ifndef QT_NO_CLIPBOARD
56#endif
57
59Q_WIDGETS_EXPORT FontHash *qt_app_fonts_hash();
60
61class Q_WIDGETS_EXPORT QApplicationPrivate : public QGuiApplicationPrivate
62{
63 Q_DECLARE_PUBLIC(QApplication)
64public:
65 QApplicationPrivate(int &argc, char **argv);
67
68 virtual void notifyLayoutDirectionChange() override;
69 virtual void notifyActiveWindowChange(QWindow *) override;
70
71 static bool autoSipEnabled;
72 static QString desktopStyleKey();
73
74 void createEventDispatcher() override;
75 static void dispatchEnterLeave(QWidget *enter, QWidget *leave, const QPointF &globalPosF);
76 static QWidget *desktop();
77 void notifyWindowIconChanged() override;
78
79#ifndef QT_NO_ACTION
80 QActionPrivate *createActionPrivate() const override;
81#endif
82#ifndef QT_NO_SHORTCUT
84#endif
85
86 //modality
87 Qt::WindowModality defaultModality() const override;
88 bool windowNeverBlocked(QWindow *window) const override;
89 static bool isBlockedByModal(QWidget *widget);
90 static bool modalState();
91 static bool tryModalHelper(QWidget *widget, QWidget **rettop = nullptr);
92
93#ifdef QT_KEYPAD_NAVIGATION
94 static bool keypadNavigationEnabled()
95 {
96 return navigationMode == Qt::NavigationModeKeypadTabOrder ||
98 }
99#endif
100
101 bool notify_helper(QObject *receiver, QEvent * e);
102
103 void init();
104 void initialize();
105 void process_cmdline();
106
107 static void setActiveWindow(QWidget* act);
108
109 static bool inPopupMode();
110 bool popupActive() override { return inPopupMode(); }
111 bool closeAllPopups() override;
112 void closePopup(QWidget *popup);
113 void openPopup(QWidget *popup);
114 static void setFocusWidget(QWidget *focus, Qt::FocusReason reason);
115 static QWidget *focusNextPrevChild_helper(QWidget *toplevel, bool next,
116 bool *wrappingOccurred = nullptr);
117
118#if QT_CONFIG(graphicsview)
119 // Maintain a list of all scenes to ensure font and palette propagation to
120 // all scenes.
121 QList<QGraphicsScene *> scene_list;
122#endif
123
125 QPoint toolTipPos, toolTipGlobalPos, hoverGlobalPos;
127
131
132protected:
133 void handleThemeChanged() override;
134
135 QPalette basePalette() const override;
136 void handlePaletteChanged(const char *className = nullptr) override;
137
138#if QT_CONFIG(draganddrop)
139 void notifyDragStarted(const QDrag *) override;
140#endif // QT_CONFIG(draganddrop)
141
142public:
149#if QT_CONFIG(wheelevent)
150 static int wheel_scroll_lines;
151 static QPointer<QWidget> wheel_widget;
152#endif
153
154 static int enabledAnimations; // Combination of QPlatformTheme::UiEffect
155 static bool widgetCount; // Coupled with -widgetcount switch
156
157 static void initializeWidgetPalettesFromTheme();
158 static void initializeWidgetFontHash();
159 static void setSystemFont(const QFont &font);
160
163
164 static QApplicationPrivate *instance() { return self; }
165
166#ifdef QT_KEYPAD_NAVIGATION
167 static QWidget *oldEditFocus;
168 static Qt::NavigationMode navigationMode;
169#endif
170
171#ifndef QT_NO_STYLE_STYLESHEET
173#endif
175 static QWidget *pickMouseReceiver(QWidget *candidate, const QPoint &windowPos, QPoint *pos,
176 QEvent::Type type, Qt::MouseButtons buttons,
177 QWidget *buttonDown, QWidget *alienWidget);
178 static bool sendMouseEvent(QWidget *receiver, QMouseEvent *event, QWidget *alienWidget,
179 QWidget *native, QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver,
180 bool spontaneous = true, bool onlyDispatchEnterLeave = false);
181 void sendSyntheticEnterLeave(QWidget *widget);
182
184 {
186 return window;
187 if (const QWidget *nativeParent = widget->nativeParentWidget())
188 return nativeParent->windowHandle();
189 return nullptr;
190 }
191
192#ifdef Q_OS_WIN
193 static HWND getHWNDForWidget(const QWidget *widget)
194 {
195 if (QWindow *window = windowForWidget(widget))
197 return static_cast<HWND> (QGuiApplication::platformNativeInterface()->
198 nativeResourceForWindow(QByteArrayLiteral("handle"), window));
199 return 0;
200 }
201#endif
202
203#ifndef QT_NO_GESTURES
206#endif
207
208 static bool updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent);
209 void initializeMultitouch();
210 void initializeMultitouch_sys();
211 void cleanupMultitouch();
212 void cleanupMultitouch_sys();
213 QWidget *findClosestTouchPointTarget(const QPointingDevice *device, const QEventPoint &touchPoint);
214 void appendTouchPoint(const QEventPoint &touchPoint);
215 void removeTouchPoint(int touchPointId);
217 void activateImplicitTouchGrab(QWidget *widget, QTouchEvent *touchBeginEvent,
218 ImplicitTouchGrabMode grabMode = GrabAcceptedPoints);
219 static bool translateRawTouchEvent(QWidget *widget, const QTouchEvent *touchEvent);
220 static void translateTouchCancel(const QPointingDevice *device, ulong timestamp);
221
223
224private:
225 static QApplicationPrivate *self;
226 static bool tryCloseAllWidgetWindows(QWindowList *processedWindows);
227
228 static void giveFocusAccordingToFocusPolicy(QWidget *w, QEvent *event, QPoint localPos);
229 static bool shouldSetFocus(QWidget *w, Qt::FocusPolicy policy);
230
231
232 static bool isAlien(QWidget *);
233};
234
235extern void qt_qpa_set_cursor(QWidget * w, bool force);
236
238
239#endif // QAPPLICATION_P_H
IOBluetoothDevice * device
static QApplicationPrivate * instance()
static QWidget * focus_widget
static QPointer< QWidget > leaveAfterRelease
QGestureManager * gestureManager
bool popupActive() override
QBasicTimer toolTipFallAsleep
static QWidget * hidden_focus_widget
QPointer< QWidget > toolTipWidget
static QWidget * active_window
static PaletteHash widgetPalettes
static int enabledAnimations
static QString styleSheet
static QWindow * windowForWidget(const QWidget *widget)
static QFont * sys_font
static QWidgetList * popupWidgets
static QStyle * app_style
static QWidget * main_widget
static bool autoSipEnabled
void appendTouchPoint(const QEventPoint &touchPoint)
static QFont * set_font
void removeTouchPoint(int touchPointId)
The QApplication class manages the GUI application's control flow and main settings.
\inmodule QtCore
Definition qbasictimer.h:18
The QClipboard class provides access to the window system clipboard.
Definition qclipboard.h:20
static bool notify_helper(QObject *, QEvent *)
\inmodule QtGui
Definition qdrag.h:22
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
\inmodule QtCore
Definition qcoreevent.h:45
Type
This enum type defines the valid event types in Qt.
Definition qcoreevent.h:51
\reentrant
Definition qfont.h:20
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
virtual QPalette basePalette() const
virtual QActionPrivate * createActionPrivate() const
Definition qaction.cpp:41
virtual bool windowNeverBlocked(QWindow *window) const
virtual QShortcutPrivate * createShortcutPrivate() const
virtual void handlePaletteChanged(const char *className=nullptr)
void createEventDispatcher() override
Called from QCoreApplication::init()
virtual void handleThemeChanged()
virtual QPixmap applyQIconStyleHelper(QIcon::Mode, const QPixmap &basePixmap) const
virtual void notifyActiveWindowChange(QWindow *previous)
virtual void notifyLayoutDirectionChange()
virtual Qt::WindowModality defaultModality() const
virtual void notifyWindowIconChanged()
static QPlatformNativeInterface * platformNativeInterface()
\inmodule QtCore
Definition qhash.h:818
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition qicon.h:22
Definition qlist.h:74
\inmodule QtGui
Definition qevent.h:195
\inmodule QtCore
Definition qobject.h:90
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qpoint.h:214
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore
Definition qpointer.h:18
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:916
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QWidget * nativeParentWidget() const
Definition qwidget.cpp:4340
QWindow * windowHandle() const
If this is a native widget, return the associated QWindow.
Definition qwidget.cpp:2490
\inmodule QtGui
Definition qwindow.h:63
QOpenGLWidget * widget
[1]
bool focus
[0]
double e
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
NavigationMode
@ NavigationModeKeypadDirectional
@ NavigationModeKeypadTabOrder
WindowModality
FocusPolicy
Definition qnamespace.h:105
FocusReason
Q_GUI_EXPORT bool qt_is_tty_app
void qt_qpa_set_cursor(QWidget *w, bool force)
Definition qwidget.cpp:5021
Q_WIDGETS_EXPORT FontHash * qt_app_fonts_hash()
QHash< QByteArray, QFont > FontHash
QClipboard * qt_clipboard
#define QByteArrayLiteral(str)
Definition qbytearray.h:52
static bool initialize()
Definition qctf.cpp:67
GLenum mode
GLfloat GLfloat GLfloat w
[0]
GLenum type
struct _cl_event * event
unsigned long ulong
Definition qtypes.h:30
#define leave(x)
const char className[16]
[1]
Definition qwizard.cpp:100
aWidget window() -> setWindowTitle("New Window Title")
[2]
QSizePolicy policy