Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
58typedef QHash<QByteArray, QFont> FontHash;
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
83 QShortcutPrivate *createShortcutPrivate() const override;
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;
126 QPointer<QWidget> toolTipWidget;
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:
148#if QT_CONFIG(wheelevent)
149 static QPointer<QWidget> wheel_widget;
150#endif
151
152 static int enabledAnimations; // Combination of QPlatformTheme::UiEffect
153 static bool widgetCount; // Coupled with -widgetcount switch
154
155 static void initializeWidgetPalettesFromTheme();
156 static void initializeWidgetFontHash();
157 static void setSystemFont(const QFont &font);
158
159 using PaletteHash = QHash<QByteArray, QPalette>;
161
162 static QApplicationPrivate *instance() { return self; }
163
164#ifdef QT_KEYPAD_NAVIGATION
165 static QWidget *oldEditFocus;
166 static Qt::NavigationMode navigationMode;
167#endif
168
169#ifndef QT_NO_STYLE_STYLESHEET
171#endif
172 static QPointer<QWidget> leaveAfterRelease;
173 static QWidget *pickMouseReceiver(QWidget *candidate, const QPoint &windowPos, QPoint *pos,
174 QEvent::Type type, Qt::MouseButtons buttons,
175 QWidget *buttonDown, QWidget *alienWidget);
176 static bool sendMouseEvent(QWidget *receiver, QMouseEvent *event, QWidget *alienWidget,
177 QWidget *native, QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver,
178 bool spontaneous = true, bool onlyDispatchEnterLeave = false);
179 void sendSyntheticEnterLeave(QWidget *widget);
180
182 {
184 return window;
185 if (const QWidget *nativeParent = widget->nativeParentWidget())
186 return nativeParent->windowHandle();
187 return nullptr;
188 }
189
190#ifdef Q_OS_WIN
191 static HWND getHWNDForWidget(const QWidget *widget)
192 {
193 if (QWindow *window = windowForWidget(widget))
195 return static_cast<HWND> (QGuiApplication::platformNativeInterface()->
196 nativeResourceForWindow(QByteArrayLiteral("handle"), window));
197 return 0;
198 }
199#endif
200
201#ifndef QT_NO_GESTURES
204#endif
205
206 static bool updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent);
207 void initializeMultitouch();
208 void initializeMultitouch_sys();
209 void cleanupMultitouch();
210 void cleanupMultitouch_sys();
211 QWidget *findClosestTouchPointTarget(const QPointingDevice *device, const QEventPoint &touchPoint);
212 void appendTouchPoint(const QEventPoint &touchPoint);
213 void removeTouchPoint(int touchPointId);
215 void activateImplicitTouchGrab(QWidget *widget, QTouchEvent *touchBeginEvent,
216 ImplicitTouchGrabMode grabMode = GrabAcceptedPoints);
217 static bool translateRawTouchEvent(QWidget *widget, const QTouchEvent *touchEvent);
218 static void translateTouchCancel(const QPointingDevice *device, ulong timestamp);
219
220 QPixmap applyQIconStyleHelper(QIcon::Mode mode, const QPixmap& base) const override;
221
222private:
223 static QApplicationPrivate *self;
224 static bool tryCloseAllWidgetWindows(QWindowList *processedWindows);
225
226 static void giveFocusAccordingToFocusPolicy(QWidget *w, QEvent *event, QPoint localPos);
227 static bool shouldSetFocus(QWidget *w, Qt::FocusPolicy policy);
228
229 static QWidget *active_window;
230
231 static bool isAlien(QWidget *);
232};
233
234extern void qt_qpa_set_cursor(QWidget * w, bool force);
235
237
238#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 PaletteHash widgetPalettes
static int enabledAnimations
static QString styleSheet
static QWindow * windowForWidget(const QWidget *widget)
static QFont * sys_font
QHash< QByteArray, QPalette > PaletteHash
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
\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:22
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items.
static QPlatformNativeInterface * platformNativeInterface()
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition qicon.h:22
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
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:217
\inmodule QtCore\reentrant
Definition qpoint.h:25
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:129
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:917
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QWidget * nativeParentWidget() const
Definition qwidget.cpp:4333
QWindow * windowHandle() const
If this is a native widget, return the associated QWindow.
Definition qwidget.cpp:2483
\inmodule QtGui
Definition qwindow.h:63
QOpenGLWidget * widget
[1]
bool focus
[0]
short next
Definition keywords.cpp:445
Combined button and popup list for selecting options.
NavigationMode
@ NavigationModeKeypadDirectional
@ NavigationModeKeypadTabOrder
WindowModality
FocusPolicy
Definition qnamespace.h:106
FocusReason
Q_GUI_EXPORT bool qt_is_tty_app
void qt_qpa_set_cursor(QWidget *w, bool force)
Definition qwidget.cpp:5014
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:94
GLenum mode
GLfloat GLfloat GLfloat w
[0]
GLenum type
struct _cl_event * event
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
unsigned long ulong
Definition qtypes.h:35
static const uint base
Definition qurlidna.cpp:20
#define leave(x)
const char className[16]
[1]
Definition qwizard.cpp:100
aWidget window() -> setWindowTitle("New Window Title")
[2]
QSizePolicy policy