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 | 32 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.h | 4 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 1 | ||||
-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/qplatformintegrationfactory.cpp | 14 | ||||
-rw-r--r-- | src/gui/kernel/qsimpledrag.cpp | 8 | ||||
-rw-r--r-- | src/gui/kernel/qsimpledrag_p.h | 1 |
15 files changed, 95 insertions, 25 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 0bb21752bc..233b9ef3f7 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" @@ -3948,9 +3949,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 2e0595152b..35e880fc5b 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> @@ -146,6 +147,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 @@ -606,6 +608,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) @@ -647,6 +651,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. 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 0559442049..6dc8735f86 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); 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/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/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; |