diff options
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qdrag.cpp | 19 | ||||
-rw-r--r-- | src/gui/kernel/qdrag.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 3 | ||||
-rw-r--r-- | src/gui/kernel/qevent.h | 9 | ||||
-rw-r--r-- | src/gui/kernel/qgenericplugin.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qgenericplugin.h | 5 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 68 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.h | 4 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 12 | ||||
-rw-r--r-- | src/gui/kernel/qinputdevicemanager_p.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qplatformdrag.cpp | 14 | ||||
-rw-r--r-- | src/gui/kernel/qplatformdrag.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qplatformintegration.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qplatformintegrationfactory.cpp | 14 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.cpp | 35 | ||||
-rw-r--r-- | src/gui/kernel/qplatformtheme.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qsimpledrag.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qsimpledrag_p.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qstylehints.cpp | 22 | ||||
-rw-r--r-- | src/gui/kernel/qstylehints.h | 4 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 74 |
21 files changed, 245 insertions, 68 deletions
diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index 2736fac8e0..36527966b7 100644 --- a/src/gui/kernel/qdrag.cpp +++ b/src/gui/kernel/qdrag.cpp @@ -33,6 +33,8 @@ #include <qdrag.h> #include "private/qguiapplication_p.h" +#include "qpa/qplatformintegration.h" +#include "qpa/qplatformdrag.h" #include <qpixmap.h> #include <qpoint.h> #include "qdnd_p.h" @@ -223,6 +225,8 @@ QObject *QDrag::target() const loop. Other events are still delivered to the application while the operation is performed. On Windows, the Qt event loop is blocked during the operation. + + \sa cancel() */ Qt::DropAction QDrag::exec(Qt::DropActions supportedActions) @@ -377,6 +381,21 @@ Qt::DropAction QDrag::defaultAction() const Q_D(const QDrag); return d->default_action; } + +/*! + Cancels a drag operation initiated by Qt. + + \note This is currently implemented on Windows and X11. + + \since 5.6 + \sa exec() +*/ +void QDrag::cancel() +{ + if (QPlatformDrag *platformDrag = QGuiApplicationPrivate::platformIntegration()->drag()) + platformDrag->cancelDrag(); +} + /*! \fn void QDrag::actionChanged(Qt::DropAction action) diff --git a/src/gui/kernel/qdrag.h b/src/gui/kernel/qdrag.h index 0672cb00f9..961d7c89d9 100644 --- a/src/gui/kernel/qdrag.h +++ b/src/gui/kernel/qdrag.h @@ -77,6 +77,8 @@ public: Qt::DropActions supportedActions() const; Qt::DropAction defaultAction() const; + static void cancel(); + Q_SIGNALS: void actionChanged(Qt::DropAction action); void targetChanged(QObject *newTarget); diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 2ca17692db..bd1b4d6393 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -37,6 +37,7 @@ #include "qpa/qplatformintegration.h" #include "qpa/qplatformdrag.h" #include "private/qevent_p.h" +#include "qfile.h" #include "qmetaobject.h" #include "qmimedata.h" #include "private/qdnd_p.h" @@ -3963,9 +3964,11 @@ QDebug operator<<(QDebug dbg, const QEvent *e) QtDebugUtils::formatQEnum(dbg, static_cast<const QApplicationStateChangeEvent *>(e)->applicationState()); dbg << ')'; break; +# ifndef QT_NO_CONTEXTMENU case QEvent::ContextMenu: dbg << "QContextMenuEvent(" << static_cast<const QContextMenuEvent *>(e)->pos() << ')'; break; +# endif // !QT_NO_CONTEXTMENU # ifndef QT_NO_TABLETEVENT case QEvent::TabletEnterProximity: case QEvent::TabletLeaveProximity: diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index b90fce97e0..66e650c42d 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -35,20 +35,19 @@ #define QEVENT_H #include <QtGui/qwindowdefs.h> -#include <QtCore/qobject.h> #include <QtGui/qregion.h> #include <QtCore/qnamespace.h> #include <QtCore/qstring.h> #include <QtGui/qkeysequence.h> #include <QtCore/qcoreevent.h> #include <QtCore/qvariant.h> -#include <QtCore/qmap.h> +#include <QtCore/qmap.h> // ### Qt 6: Remove #include <QtCore/qvector.h> -#include <QtCore/qset.h> +#include <QtCore/qset.h> // ### Qt 6: Remove #include <QtCore/qurl.h> -#include <QtCore/qfile.h> +#include <QtCore/qfile.h> // ### Qt 6: Replace by <qiodevice.h> and forward declare QFile #include <QtGui/qvector2d.h> -#include <QtGui/qtouchdevice.h> +#include <QtGui/qtouchdevice.h> // ### Qt 6: Replace by forward declaration QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qgenericplugin.cpp b/src/gui/kernel/qgenericplugin.cpp index 47f3ea5811..ae423b93e3 100644 --- a/src/gui/kernel/qgenericplugin.cpp +++ b/src/gui/kernel/qgenericplugin.cpp @@ -33,8 +33,6 @@ #include "qgenericplugin.h" -#ifndef QT_NO_LIBRARY - QT_BEGIN_NAMESPACE /*! @@ -90,5 +88,3 @@ QGenericPlugin::~QGenericPlugin() */ QT_END_NAMESPACE - -#endif // QT_NO_LIBRARY diff --git a/src/gui/kernel/qgenericplugin.h b/src/gui/kernel/qgenericplugin.h index 03c1df7fba..21ae97f045 100644 --- a/src/gui/kernel/qgenericplugin.h +++ b/src/gui/kernel/qgenericplugin.h @@ -39,9 +39,6 @@ QT_BEGIN_NAMESPACE - -#ifndef QT_NO_LIBRARY - #define QGenericPluginFactoryInterface_iid "org.qt-project.Qt.QGenericPluginFactoryInterface" class Q_GUI_EXPORT QGenericPlugin : public QObject @@ -54,8 +51,6 @@ public: virtual QObject* create(const QString& name, const QString &spec) = 0; }; -#endif // QT_NO_LIBRARY - QT_END_NAMESPACE #endif // QGENERICPLUGIN_H diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 00bad52432..248a7d0d1d 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -37,6 +37,7 @@ #include <qpa/qplatformintegrationfactory_p.h> #include "private/qevent_p.h" #include "qfont.h" +#include "qtouchdevice.h" #include <qpa/qplatformfontdatabase.h> #include <qpa/qplatformwindow.h> #include <qpa/qplatformnativeinterface.h> @@ -123,8 +124,6 @@ Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier; QPointF QGuiApplicationPrivate::lastCursorPosition(qInf(), qInf()); -Qt::MouseButtons QGuiApplicationPrivate::tabletState = Qt::NoButton; -QWindow *QGuiApplicationPrivate::tabletPressTarget = 0; QWindow *QGuiApplicationPrivate::currentMouseWindow = 0; QString QGuiApplicationPrivate::styleOverride; @@ -133,6 +132,8 @@ Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationI bool QGuiApplicationPrivate::highDpiScalingUpdated = false; +QVector<QGuiApplicationPrivate::TabletPointData> QGuiApplicationPrivate::tabletDevicePoints; + QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0; QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0; @@ -150,6 +151,7 @@ QIcon *QGuiApplicationPrivate::app_icon = 0; QString *QGuiApplicationPrivate::platform_name = 0; QString *QGuiApplicationPrivate::displayName = 0; +QString *QGuiApplicationPrivate::desktopFileName = 0; QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette @@ -610,6 +612,8 @@ QGuiApplication::~QGuiApplication() QGuiApplicationPrivate::platform_name = 0; delete QGuiApplicationPrivate::displayName; QGuiApplicationPrivate::displayName = 0; + delete QGuiApplicationPrivate::desktopFileName; + QGuiApplicationPrivate::desktopFileName = 0; } QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags) @@ -651,6 +655,34 @@ QString QGuiApplication::applicationDisplayName() } /*! + \property QGuiApplication::desktopFileName + \brief the base name of the desktop entry for this application + \since 5.7 + + This is the file name, without the full path, of the desktop entry + that represents this application according to the freedesktop desktop + entry specification. + + This property gives a precise indication of what desktop entry represents + the application and it is needed by the windowing system to retrieve + such information without resorting to imprecise heuristics. + + The latest version of the freedesktop desktop entry specification can be obtained + \l{http://standards.freedesktop.org/desktop-entry-spec/latest/}{here}. +*/ +void QGuiApplication::setDesktopFileName(const QString &name) +{ + if (!QGuiApplicationPrivate::desktopFileName) + QGuiApplicationPrivate::desktopFileName = new QString; + *QGuiApplicationPrivate::desktopFileName = name; +} + +QString QGuiApplication::desktopFileName() +{ + return QGuiApplicationPrivate::desktopFileName ? *QGuiApplicationPrivate::desktopFileName : QString(); +} + +/*! Returns the most recently shown modal window. If no modal windows are visible, this function returns zero. @@ -2166,12 +2198,26 @@ void QGuiApplicationPrivate::processFileOpenEvent(QWindowSystemInterfacePrivate: QGuiApplication::sendSpontaneousEvent(qApp, &event); } +QGuiApplicationPrivate::TabletPointData &QGuiApplicationPrivate::tabletDevicePoint(qint64 deviceId) +{ + for (int i = 0; i < tabletDevicePoints.size(); ++i) { + TabletPointData &pointData = tabletDevicePoints[i]; + if (pointData.deviceId == deviceId) + return pointData; + } + + tabletDevicePoints.append(TabletPointData(deviceId)); + return tabletDevicePoints.last(); +} + void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::TabletEvent *e) { #ifndef QT_NO_TABLETEVENT + TabletPointData &pointData = tabletDevicePoint(e->uid); + QEvent::Type type = QEvent::TabletMove; - if (e->buttons != tabletState) - type = (e->buttons > tabletState) ? QEvent::TabletPress : QEvent::TabletRelease; + if (e->buttons != pointData.state) + type = (e->buttons > pointData.state) ? QEvent::TabletPress : QEvent::TabletRelease; QWindow *window = e->window.data(); modifier_buttons = e->modifiers; @@ -2187,14 +2233,14 @@ void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::T } if (!window) return; - tabletPressTarget = window; + pointData.target = window; } else { if (e->nullWindow()) { - window = tabletPressTarget; + window = pointData.target; localValid = false; } if (type == QEvent::TabletRelease) - tabletPressTarget = 0; + pointData.target = Q_NULLPTR; if (!window) return; } @@ -2203,7 +2249,7 @@ void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::T QPointF delta = e->global - e->global.toPoint(); local = window->mapFromGlobal(e->global.toPoint()) + delta; } - Qt::MouseButtons stateChange = e->buttons ^ tabletState; + Qt::MouseButtons stateChange = e->buttons ^ pointData.state; Qt::MouseButton button = Qt::NoButton; for (int check = Qt::LeftButton; check <= int(Qt::MaxMouseButton); check = check << 1) { if (check & stateChange) { @@ -2217,7 +2263,7 @@ void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::T e->modifiers, e->uid, button, e->buttons); ev.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(window, &ev); - tabletState = e->buttons; + pointData.state = e->buttons; #else Q_UNUSED(e) #endif @@ -2229,7 +2275,7 @@ void QGuiApplicationPrivate::processTabletEnterProximityEvent(QWindowSystemInter QTabletEvent ev(QEvent::TabletEnterProximity, QPointF(), QPointF(), e->device, e->pointerType, 0, 0, 0, 0, 0, 0, - Qt::NoModifier, e->uid, Qt::NoButton, tabletState); + Qt::NoModifier, e->uid, Qt::NoButton, tabletDevicePoint(e->uid).state); ev.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(qGuiApp, &ev); #else @@ -2243,7 +2289,7 @@ void QGuiApplicationPrivate::processTabletLeaveProximityEvent(QWindowSystemInter QTabletEvent ev(QEvent::TabletLeaveProximity, QPointF(), QPointF(), e->device, e->pointerType, 0, 0, 0, 0, 0, 0, - Qt::NoModifier, e->uid, Qt::NoButton, tabletState); + Qt::NoModifier, e->uid, Qt::NoButton, tabletDevicePoint(e->uid).state); ev.setTimestamp(e->timestamp); QGuiApplication::sendSpontaneousEvent(qGuiApp, &ev); #else diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h index d995387d66..a773122d3e 100644 --- a/src/gui/kernel/qguiapplication.h +++ b/src/gui/kernel/qguiapplication.h @@ -67,6 +67,7 @@ class Q_GUI_EXPORT QGuiApplication : public QCoreApplication Q_OBJECT Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon) Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName WRITE setApplicationDisplayName) + Q_PROPERTY(QString desktopFileName READ desktopFileName WRITE setDesktopFileName) Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged) Q_PROPERTY(QString platformName READ platformName STORED false) Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed) @@ -83,6 +84,9 @@ public: static void setApplicationDisplayName(const QString &name); static QString applicationDisplayName(); + static void setDesktopFileName(const QString &name); + static QString desktopFileName(); + static QWindowList allWindows(); static QWindowList topLevelWindows(); static QWindow *topLevelAt(const QPoint &pos); diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 7c7da9790b..5ef8dee8b7 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -183,6 +183,7 @@ public: static QIcon *app_icon; static QString *platform_name; static QString *displayName; + static QString *desktopFileName; QWindowList modalWindowList; static void showModalWindow(QWindow *window); @@ -197,13 +198,20 @@ public: static int mousePressY; static int mouse_double_click_distance; static QPointF lastCursorPosition; - static Qt::MouseButtons tabletState; - static QWindow *tabletPressTarget; static QWindow *currentMouseWindow; static QWindow *currentMousePressWindow; static Qt::ApplicationState applicationState; static bool highDpiScalingUpdated; + struct TabletPointData { + TabletPointData(qint64 devId = 0) : deviceId(devId), state(Qt::NoButton), target(Q_NULLPTR) {} + qint64 deviceId; + Qt::MouseButtons state; + QWindow *target; + }; + static QVector<TabletPointData> tabletDevicePoints; + static TabletPointData &tabletDevicePoint(qint64 deviceId); + #ifndef QT_NO_CLIPBOARD static QClipboard *qt_clipboard; #endif diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h index d64793c23c..4c24b1bc93 100644 --- a/src/gui/kernel/qinputdevicemanager_p.h +++ b/src/gui/kernel/qinputdevicemanager_p.h @@ -61,7 +61,8 @@ public: DeviceTypeUnknown, DeviceTypePointer, DeviceTypeKeyboard, - DeviceTypeTouch + DeviceTypeTouch, + DeviceTypeTablet }; QInputDeviceManager(QObject *parent = 0); diff --git a/src/gui/kernel/qplatformdrag.cpp b/src/gui/kernel/qplatformdrag.cpp index d789c75d1d..11230194fc 100644 --- a/src/gui/kernel/qplatformdrag.cpp +++ b/src/gui/kernel/qplatformdrag.cpp @@ -155,6 +155,20 @@ Qt::DropAction QPlatformDrag::defaultAction(Qt::DropActions possibleActions, } /*! + \brief Cancels the currently active drag (only for drags of + the current application initiated by QPlatformDrag::drag()). + + The default implementation does nothing. + + \since 5.6 + */ + +void QPlatformDrag::cancelDrag() +{ + Q_UNIMPLEMENTED(); +} + +/*! \brief Called to notify QDrag about changes of the current action. */ diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h index 10ee88477f..72e28d2745 100644 --- a/src/gui/kernel/qplatformdrag.h +++ b/src/gui/kernel/qplatformdrag.h @@ -92,6 +92,7 @@ public: virtual QMimeData *platformDropData() = 0; virtual Qt::DropAction drag(QDrag *m_drag) = 0; + virtual void cancelDrag(); void updateAction(Qt::DropAction action); virtual Qt::DropAction defaultAction(Qt::DropActions possibleActions, Qt::KeyboardModifiers modifiers) const; diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index 14633d8b30..0968c9deed 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -149,13 +149,11 @@ QPlatformServices *QPlatformIntegration::services() const /*! \fn QPlatformWindow *QPlatformIntegration::createPlatformWindow(QWindow *window) const - Factory function for QPlatformWindow. The \a window parameter is a pointer to the top level - window which the QPlatformWindow is supposed to be created for. + Factory function for QPlatformWindow. The \a window parameter is a pointer to the window + which the QPlatformWindow is supposed to be created for. - All top level windows have to have a QPlatformWindow, and it will be created when the - QPlatformWindow is set to be visible for the first time. If the top level window's flags are - changed, or if the top level window's QPlatformWindowFormat is changed, then the top level - window's QPlatformWindow is deleted and a new one is created. + All windows have to have a QPlatformWindow, and it will be created on-demand when the + QWindow is made visible for the first time, or explicitly through calling QWindow::create(). In the constructor, of the QPlatformWindow, the window flags, state, title and geometry of the \a window should be applied to the underlying window. If the resulting flags or state diff --git a/src/gui/kernel/qplatformintegrationfactory.cpp b/src/gui/kernel/qplatformintegrationfactory.cpp index 5a1fb3ca83..d109ceb2f0 100644 --- a/src/gui/kernel/qplatformintegrationfactory.cpp +++ b/src/gui/kernel/qplatformintegrationfactory.cpp @@ -42,11 +42,13 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_LIBRARY Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive)) + +#ifndef QT_NO_LIBRARY Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader, (QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive)) +#endif // !QT_NO_LIBRARY static inline QPlatformIntegration *loadIntegration(QFactoryLoader *loader, const QString &key, const QStringList ¶meters, int &argc, char ** argv) { @@ -59,8 +61,6 @@ static inline QPlatformIntegration *loadIntegration(QFactoryLoader *loader, cons return 0; } -#endif // !QT_NO_LIBRARY - QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platform, const QStringList ¶mList, int &argc, char **argv, const QString &platformPluginPath) { #ifndef QT_NO_LIBRARY @@ -70,16 +70,10 @@ QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platfor if (QPlatformIntegration *ret = loadIntegration(directLoader(), platform, paramList, argc, argv)) return ret; } - if (QPlatformIntegration *ret = loadIntegration(loader(), platform, paramList, argc, argv)) - return ret; #else - Q_UNUSED(platform); - Q_UNUSED(paramList); - Q_UNUSED(argc); - Q_UNUSED(argv); Q_UNUSED(platformPluginPath); #endif - return 0; + return loadIntegration(loader(), platform, paramList, argc, argv); } /*! diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index ce8548f628..61dacfa076 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -682,6 +682,41 @@ QString QPlatformTheme::defaultStandardButtonText(int button) return QString(); } +QString QPlatformTheme::removeMnemonics(const QString &original) +{ + QString returnText(original.size(), 0); + int finalDest = 0; + int currPos = 0; + int l = original.length(); + while (l) { + if (original.at(currPos) == QLatin1Char('&') + && (l == 1 || original.at(currPos + 1) != QLatin1Char('&'))) { + ++currPos; + --l; + if (l == 0) + break; + } else if (original.at(currPos) == QLatin1Char('(') && l >= 4 && + original.at(currPos + 1) == QLatin1Char('&') && + original.at(currPos + 2) != QLatin1Char('&') && + original.at(currPos + 3) == QLatin1Char(')')) { + /* remove mnemonics its format is "\s*(&X)" */ + int n = 0; + while (finalDest > n && returnText.at(finalDest - n - 1).isSpace()) + ++n; + finalDest -= n; + currPos += 4; + l -= 4; + continue; + } + returnText[finalDest] = original.at(currPos); + ++currPos; + ++finalDest; + --l; + } + returnText.truncate(finalDest); + return returnText; +} + unsigned QPlatformThemePrivate::currentKeyPlatforms() { const uint keyboardScheme = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::KeyboardScheme).toInt(); diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h index 69cc2f90af..9355e83491 100644 --- a/src/gui/kernel/qplatformtheme.h +++ b/src/gui/kernel/qplatformtheme.h @@ -301,6 +301,7 @@ public: static QVariant defaultThemeHint(ThemeHint hint); static QString defaultStandardButtonText(int button); + static QString removeMnemonics(const QString &original); protected: explicit QPlatformTheme(QPlatformThemePrivate *priv); diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index 9f38c9b78a..706786385b 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -191,6 +191,14 @@ Qt::DropAction QBasicDrag::drag(QDrag *o) return m_executed_drop_action; } +void QBasicDrag::cancelDrag() +{ + if (m_eventLoop) { + cancel(); + m_eventLoop->quit(); + } +} + void QBasicDrag::restoreCursor() { if (m_restoreCursor) { diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h index 055136c436..d5dacd8fd2 100644 --- a/src/gui/kernel/qsimpledrag_p.h +++ b/src/gui/kernel/qsimpledrag_p.h @@ -66,6 +66,7 @@ public: virtual ~QBasicDrag(); virtual Qt::DropAction drag(QDrag *drag) Q_DECL_OVERRIDE; + void cancelDrag() Q_DECL_OVERRIDE; virtual bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index 7ff0f9f860..0ecd2e12e8 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -65,6 +65,7 @@ class QStyleHintsPrivate : public QObjectPrivate public: inline QStyleHintsPrivate() : m_mouseDoubleClickInterval(-1) + , m_mousePressAndHoldInterval(-1) , m_startDragDistance(-1) , m_startDragTime(-1) , m_keyboardInputInterval(-1) @@ -72,6 +73,7 @@ public: {} int m_mouseDoubleClickInterval; + int m_mousePressAndHoldInterval; int m_startDragDistance; int m_startDragTime; int m_keyboardInputInterval; @@ -129,6 +131,21 @@ int QStyleHints::mouseDoubleClickInterval() const } /*! + Sets the \a mousePressAndHoldInterval. + \internal + \sa mousePressAndHoldInterval() + \since 5.7 +*/ +void QStyleHints::setMousePressAndHoldInterval(int mousePressAndHoldInterval) +{ + Q_D(QStyleHints); + if (d->m_mousePressAndHoldInterval == mousePressAndHoldInterval) + return; + d->m_mousePressAndHoldInterval = mousePressAndHoldInterval; + emit mousePressAndHoldIntervalChanged(mousePressAndHoldInterval); +} + +/*! \property QStyleHints::mousePressAndHoldInterval \brief the time limit in milliseconds that activates a press and hold. @@ -137,7 +154,10 @@ int QStyleHints::mouseDoubleClickInterval() const */ int QStyleHints::mousePressAndHoldInterval() const { - return themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt(); + Q_D(const QStyleHints); + return d->m_mousePressAndHoldInterval >= 0 ? + d->m_mousePressAndHoldInterval : + themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt(); } /*! diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h index 82eb8a6f7d..5762482f35 100644 --- a/src/gui/kernel/qstylehints.h +++ b/src/gui/kernel/qstylehints.h @@ -51,7 +51,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject Q_PROPERTY(int keyboardAutoRepeatRate READ keyboardAutoRepeatRate STORED false CONSTANT FINAL) Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval NOTIFY keyboardInputIntervalChanged FINAL) Q_PROPERTY(int mouseDoubleClickInterval READ mouseDoubleClickInterval NOTIFY mouseDoubleClickIntervalChanged FINAL) - Q_PROPERTY(int mousePressAndHoldInterval READ mousePressAndHoldInterval STORED false CONSTANT FINAL) + Q_PROPERTY(int mousePressAndHoldInterval READ mousePressAndHoldInterval NOTIFY mousePressAndHoldIntervalChanged FINAL) Q_PROPERTY(QChar passwordMaskCharacter READ passwordMaskCharacter STORED false CONSTANT FINAL) Q_PROPERTY(int passwordMaskDelay READ passwordMaskDelay STORED false CONSTANT FINAL) Q_PROPERTY(bool setFocusOnTouchRelease READ setFocusOnTouchRelease STORED false CONSTANT FINAL) @@ -66,6 +66,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject public: void setMouseDoubleClickInterval(int mouseDoubleClickInterval); int mouseDoubleClickInterval() const; + void setMousePressAndHoldInterval(int mousePressAndHoldInterval); int mousePressAndHoldInterval() const; void setStartDragDistance(int startDragDistance); int startDragDistance() const; @@ -90,6 +91,7 @@ Q_SIGNALS: void cursorFlashTimeChanged(int cursorFlashTime); void keyboardInputIntervalChanged(int keyboardInputInterval); void mouseDoubleClickIntervalChanged(int mouseDoubleClickInterval); + void mousePressAndHoldIntervalChanged(int mousePressAndHoldInterval); void startDragDistanceChanged(int startDragDistance); void startDragTimeChanged(int startDragTime); diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index e262f3f8a4..2b9340c04d 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -392,6 +392,9 @@ void QWindowPrivate::create(bool recursive) if (platformWindow) return; + if (q->parent()) + q->parent()->create(); + platformWindow = QGuiApplicationPrivate::platformIntegration()->createPlatformWindow(q); Q_ASSERT(platformWindow); @@ -403,13 +406,21 @@ void QWindowPrivate::create(bool recursive) QObjectList childObjects = q->children(); for (int i = 0; i < childObjects.size(); i ++) { QObject *object = childObjects.at(i); - if (object->isWindowType()) { - QWindow *window = static_cast<QWindow *>(object); - if (recursive) - window->d_func()->create(true); - if (window->d_func()->platformWindow) - window->d_func()->platformWindow->setParent(platformWindow); - } + if (!object->isWindowType()) + continue; + + QWindow *childWindow = static_cast<QWindow *>(object); + if (recursive) + childWindow->d_func()->create(recursive); + + // The child may have had deferred creation due to this window not being created + // at the time setVisible was called, so we re-apply the visible state, which + // may result in creating the child, and emitting the appropriate signals. + if (childWindow->isVisible()) + childWindow->setVisible(true); + + if (QPlatformWindow *childPlatformWindow = childWindow->d_func()->platformWindow) + childPlatformWindow->setParent(this->platformWindow); } QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceCreated); @@ -474,14 +485,23 @@ void QWindow::setVisible(bool visible) { Q_D(QWindow); - if (d->visible == visible) + if (d->visible != visible) { + d->visible = visible; + emit visibleChanged(visible); + d->updateVisibility(); + } else if (d->platformWindow) { + // Visibility hasn't changed, and the platform window is in sync return; - d->visible = visible; - emit visibleChanged(visible); - d->updateVisibility(); + } - if (!d->platformWindow) - create(); + if (!d->platformWindow) { + // If we have a parent window, but the parent hasn't been created yet, we + // can defer creation until the parent is created or we're re-parented. + if (parent() && !parent()->handle()) + return; + else + create(); + } if (visible) { // remove posted quit events when showing a new window @@ -520,6 +540,7 @@ void QWindow::setVisible(bool visible) if (visible && (d->hasCursor || QGuiApplication::overrideCursor())) d->applyCursor(); #endif + d->platformWindow->setVisible(visible); if (!visible) { @@ -609,20 +630,25 @@ void QWindow::setParent(QWindow *parent) } QObject::setParent(parent); + d->parentWindow = parent; + if (parent) d->disconnectFromScreen(); else d->connectToScreen(newScreen); + // If we were set visible, but not created because we were a child, and we're now + // re-parented into a created parent, or to being a top level, we need re-apply the + // visibility state, which will also create. + if (isVisible() && (!parent || parent->handle())) + setVisible(true); + if (d->platformWindow) { - if (parent && parent->d_func()->platformWindow) { - d->platformWindow->setParent(parent->d_func()->platformWindow); - } else { - d->platformWindow->setParent(0); - } - } + if (parent) + parent->create(); - d->parentWindow = parent; + d->platformWindow->setParent(parent ? parent->d_func()->platformWindow : 0); + } QGuiApplicationPrivate::updateBlockedStatus(this); } @@ -1654,8 +1680,12 @@ void QWindow::destroy() QGuiApplicationPrivate::currentMouseWindow = parent(); if (QGuiApplicationPrivate::currentMousePressWindow == this) QGuiApplicationPrivate::currentMousePressWindow = parent(); - if (QGuiApplicationPrivate::tabletPressTarget == this) - QGuiApplicationPrivate::tabletPressTarget = parent(); + + for (int i = 0; i < QGuiApplicationPrivate::tabletDevicePoints.size(); ++i) { + QGuiApplicationPrivate::TabletPointData &pointData = QGuiApplicationPrivate::tabletDevicePoints[i]; + if (pointData.target == this) + pointData.target = parent(); + } bool wasVisible = isVisible(); d->visibilityOnDestroy = wasVisible && d->platformWindow; |