From 680b6b2192480f908f967927f9c54b56cce6c6cc Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 28 May 2013 09:10:39 +0200 Subject: Android: Compile jar file on Windows Due to the way the DEX_CMD is formatted on Windows this would break every time. Since we actually bundle dx.bat in the repository, there's no need to check for its existence, so the easy fix is just to move the existence check into the code path where it's run from the SDK. Task-number: QTBUG-31405 Change-Id: If1aeb744d3abbd2488153b13aac401436965074e Reviewed-by: Oswald Buddenhagen Reviewed-by: Ray Donnelly --- mkspecs/features/java.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/java.prf b/mkspecs/features/java.prf index 7360103757..411a839ad8 100644 --- a/mkspecs/features/java.prf +++ b/mkspecs/features/java.prf @@ -62,8 +62,8 @@ android:!bundled_jar_file { } else { DEX_CMD = $$SDK_ROOT/platform-tools/dx !exists($$DEX_CMD): DEX_CMD = $$SDK_ROOT/build-tools/$$BUILD_TOOLS_REVISION/dx + !exists($$DEX_CMD): error("The path $$DEX_CMD does not exist. Please set the environment variable ANDROID_BUILD_TOOLS_REVISION to the revision of the build tools installed in your Android SDK.") } - !exists($$DEX_CMD): error("The path $$DEX_CMD does not exist. Please set the environment variable ANDROID_BUILD_TOOLS_REVISION to the revision of the build tools installed in your Android SDK.") QMAKE_LINK_SHLIB_CMD = $$DEX_CMD --dex --output $(TARGET) $$CLASS_DIR } else { QMAKE_LINK_SHLIB_CMD = jar cf $(TARGET) -C $$CLASS_DIR . -- cgit v1.2.3 From 85a6446164531ad400e1e2a62a42353c85571a2c Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 27 May 2013 19:56:12 +0200 Subject: Cocoa: Use actual modifiers when sending ShortcutOverride event Probably a typo since keyCode clearly has no modifiers encoded. Change-Id: I1c7908b06a759baf7b2c3462861a5d61f8c52b9f Reviewed-by: Frederik Gladhorn --- src/plugins/platforms/cocoa/qcocoamenu.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 18e17a340d..25ece7349c 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -177,7 +177,7 @@ static inline QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *getMenuLoader() } QKeyEvent accel_ev(QEvent::ShortcutOverride, (keyCode & (~Qt::KeyboardModifierMask)), - Qt::KeyboardModifiers(keyCode & Qt::KeyboardModifierMask)); + Qt::KeyboardModifiers(modifiers & Qt::KeyboardModifierMask)); accel_ev.ignore(); QCoreApplication::sendEvent(object, &accel_ev); if (accel_ev.isAccepted()) { -- cgit v1.2.3 From 81e981a704116ca7b1b619a2c1e8db837046d2cf Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 28 May 2013 10:17:32 +0200 Subject: Fix QPlatformWindow::initialGeometry() to not touch large windows. Do not touch windows whose geometry (including the unknown frame size) is likely to be larger than the screen. Remove fix-up in the Windows plugin. Task-number: QTBUG-30142 Task-number: QTBUG-31071 Change-Id: I13a8ffb9fb9d8c71d35de75094275388fa427f2c Reviewed-by: Shawn Rutledge Reviewed-by: Gabriel de Dietrich --- src/gui/kernel/qplatformwindow.cpp | 24 +++++++++++++++--------- src/plugins/platforms/windows/qwindowswindow.cpp | 9 --------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index d23cfde172..4c0d68e7c1 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -510,15 +510,21 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, } } if (w->isTopLevel() && qt_window_private(const_cast(w))->positionAutomatic) { - const QWindow *tp = w->transientParent(); - if (tp) { - // A transient window should be centered w.r.t. its transient parent. - rect.moveCenter(tp->geometry().center()); - } else { - // Center the window on the screen. (Only applicable on platforms - // which do not provide a better way.) - QPlatformScreen *scr = QPlatformScreen::platformScreenForWindow(w); - rect.moveCenter(scr->availableGeometry().center()); + if (const QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(w)) { + const QRect availableGeometry = platformScreen->availableGeometry(); + // Center unless the geometry ( + unknown window frame) is too large for the screen). + if (rect.height() < (availableGeometry.height() * 8) / 9 + && rect.width() < (availableGeometry.width() * 8) / 9) { + const QWindow *tp = w->transientParent(); + if (tp) { + // A transient window should be centered w.r.t. its transient parent. + rect.moveCenter(tp->geometry().center()); + } else { + // Center the window on the screen. (Only applicable on platforms + // which do not provide a better way.) + rect.moveCenter(availableGeometry.center()); + } + } } } return rect; diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 8ce6dcc9e7..9d817c2043 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -503,15 +503,6 @@ QWindowsWindow::WindowData const QWindowCreationContextPtr context(new QWindowCreationContext(w, rect, data.customMargins, style, exStyle)); QWindowsContext::instance()->setWindowCreationContext(context); - QRect screenGeometry; - if (QScreen *screen = w->screen()) - screenGeometry = screen->availableVirtualGeometry(); - - if (context->frameX < screenGeometry.left()) - context->frameX = screenGeometry.left(); - if (context->frameY < screenGeometry.top()) - context->frameY = screenGeometry.top(); - if (QWindowsContext::verboseWindows) qDebug().nospace() << "CreateWindowEx: " << w << *this -- cgit v1.2.3 From 72768c089a431eafcc816413c247c8b8d896fdce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 28 May 2013 15:43:05 +0200 Subject: Fixed crashes in QGLTextureDestroyer. QGLTextureDestroyer will try to make the context current on the GUI thread, regardless of whether it is owned by another thread. Use QOpenGLSharedResourceGuard instead which does the right thing and takes shared contexts into account. Task-number: QTBUG-31403 Change-Id: I1377f9284995a7ba5af32c85296eef152fc035c8 Reviewed-by: Gunnar Sletta --- src/opengl/qgl.cpp | 5 +---- src/opengl/qgl_p.h | 21 ++++++--------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 72c6e035d9..3f496a4ffc 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1579,10 +1579,7 @@ QGLContextPrivate::QGLContextPrivate(QGLContext *context) { group = new QGLContextGroup(context); - if (qApp) { - texture_destroyer = new QGLTextureDestroyer; - texture_destroyer->moveToThread(qApp->thread()); - } + texture_destroyer = new QGLTextureDestroyer; } QGLContextPrivate::~QGLContextPrivate() diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index ff9baf8971..484c3ea2d9 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -335,25 +335,16 @@ QT_END_NAMESPACE Q_DECLARE_METATYPE(GLuint) QT_BEGIN_NAMESPACE -class Q_OPENGL_EXPORT QGLTextureDestroyer : public QObject +class Q_OPENGL_EXPORT QGLTextureDestroyer { - Q_OBJECT public: - QGLTextureDestroyer() : QObject() { - connect(this, SIGNAL(freeTexture(QGLContext *, QPlatformPixmap *, quint32)), - this, SLOT(freeTexture_slot(QGLContext *, QPlatformPixmap *, quint32))); - } - void emitFreeTexture(QGLContext *context, QPlatformPixmap *boundPixmap, GLuint id) { - emit freeTexture(context, boundPixmap, id); + void emitFreeTexture(QGLContext *context, QPlatformPixmap *, GLuint id) { + if (context->contextHandle()) + (new QOpenGLSharedResourceGuard(context->contextHandle(), id, freeTextureFunc))->free(); } -Q_SIGNALS: - void freeTexture(QGLContext *context, QPlatformPixmap *boundPixmap, quint32 id); - -private slots: - void freeTexture_slot(QGLContext *context, QPlatformPixmap *boundPixmap, quint32 id) { - Q_UNUSED(boundPixmap); - QGLShareContextScope scope(context); +private: + static void freeTextureFunc(QOpenGLFunctions *, GLuint id) { glDeleteTextures(1, &id); } }; -- cgit v1.2.3 From 89f219da0c720c326c4c3aa696141e368832ee43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 28 May 2013 09:42:52 +0200 Subject: Disable "QBackingStore::flush() called with non-exposed window" warning This warning is pretty annoying and doesn't necessarily imply that an application is not working properly. Task-number: QTBUG-28613 Change-Id: Id0a2ebd91f9e4d59dce3e3e29637988d8e6175a9 Reviewed-by: Friedemann Kleint Reviewed-by: Gunnar Sletta --- src/gui/painting/qbackingstore.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index cd3f935c5b..edb5f66c5b 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -98,10 +98,12 @@ void QBackingStore::flush(const QRegion ®ion, QWindow *win, const QPoint &off if (!win) win = window(); +#ifdef QBACKINGSTORE_DEBUG if (win && win->isTopLevel() && !qt_window_private(win)->receivedExpose) { qWarning().nospace() << "QBackingStore::flush() called with non-exposed window " << win << ", behavior is undefined"; } +#endif d_ptr->platformBackingStore->flush(win, region, offset); } -- cgit v1.2.3 From 8230a0d38dd055387e5c5ed21dbff22cf93f853e Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Mon, 27 May 2013 15:00:20 +0200 Subject: qdoc: QML property lists were not shown For grouped properties, the property list in the summary section was not shown owing to a bug introduced when implementing the abstract base class concept for QML types. This has now been fixed. Task-number: QTBUG-31317 Change-Id: Idc2344539ecf3da53e1be6816f59e01922c5c6fc Reviewed-by: Jerome Pasion --- src/tools/qdoc/codemarker.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tools/qdoc/codemarker.cpp b/src/tools/qdoc/codemarker.cpp index e39ff203a5..c7d9c5b339 100644 --- a/src/tools/qdoc/codemarker.cpp +++ b/src/tools/qdoc/codemarker.cpp @@ -397,8 +397,11 @@ void CodeMarker::insert(FastSection &fastSection, bool irrelevant = false; bool inheritedMember = false; if (!node->relates()) { - if (node->parent() != fastSection.parent_) { // && !node->parent()->isAbstract()) { - if ((node->parent()->subType() != Node::QmlClass) || !node->parent()->isAbstract()) { + InnerNode* p = node->parent(); + if (p->subType() == Node::QmlPropertyGroup) + p = p->parent(); + if (p != fastSection.parent_) { // && !node->parent()->isAbstract()) { + if (p->subType() != Node::QmlClass || !p->isAbstract()) { //if (node->type() != Node::QmlProperty) { inheritedMember = true; } -- cgit v1.2.3 From a4fdd382e4a03e224a19c03c0a5b1d7e889842ff Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 28 May 2013 12:13:08 +0200 Subject: qdoc: "All Overview and HOWTOs" no longer lists internal pages This page is generated by a function in qdoc that was wwrriten especially for this page. It wasn't checking to see of the group member pages were marked with \internal. Now it does. Task-number: QTBUG-31197 Change-Id: If3f0e90f1a3748c47b3975373047b04d011d6748 Reviewed-by: Jerome Pasion --- src/tools/qdoc/ditaxmlgenerator.cpp | 4 ++-- src/tools/qdoc/htmlgenerator.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/qdoc/ditaxmlgenerator.cpp b/src/tools/qdoc/ditaxmlgenerator.cpp index eea1845e17..dd87e889bf 100644 --- a/src/tools/qdoc/ditaxmlgenerator.cpp +++ b/src/tools/qdoc/ditaxmlgenerator.cpp @@ -3138,7 +3138,7 @@ void DitaXmlGenerator::generateOverviewList(const Node* relative) // If we encounter a group definition page, we add all // the pages in that group to the list for that group. foreach (Node* member, docNode->members()) { - if (member->type() != Node::Document) + if (member->isInternal() || member->type() != Node::Document) continue; DocNode* page = static_cast(member); if (page) { @@ -3155,7 +3155,7 @@ void DitaXmlGenerator::generateOverviewList(const Node* relative) // If we encounter a page that belongs to a group then // we add that page to the list for that group. const DocNode* gn = qdb_->getGroup(group); - if (gn) + if (gn && !docNode->isInternal()) docNodeMap[gn].insert(sortKey, docNode); } } diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index 2dc4c1e6c6..7e1467f300 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -2644,7 +2644,7 @@ void HtmlGenerator::generateOverviewList(const Node *relative) // If we encounter a group definition page, we add all // the pages in that group to the list for that group. foreach (Node *member, docNode->members()) { - if (member->type() != Node::Document) + if (member->isInternal() || member->type() != Node::Document) continue; DocNode *page = static_cast(member); if (page) { @@ -2661,7 +2661,7 @@ void HtmlGenerator::generateOverviewList(const Node *relative) // If we encounter a page that belongs to a group then // we add that page to the list for that group. const DocNode* gn = qdb_->getGroup(group); - if (gn) + if (gn && !docNode->isInternal()) docNodeMap[gn].insert(sortKey, docNode); } } -- cgit v1.2.3 From 1faafdbe4a9ef79c9afec8d9a5e8c126a1384d9a Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 28 May 2013 16:09:59 +0200 Subject: Cocoa: Hide empty menus from the menubar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-31378 Change-Id: I33ab2979a26166fb07e836c85dfc8089af5e1fda Reviewed-by: Tor Arne Vestbø Reviewed-by: Shawn Rutledge --- src/plugins/platforms/cocoa/qcocoamenubar.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index b112e40549..e280cf4581 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -136,6 +136,17 @@ void QCocoaMenuBar::syncMenu(QPlatformMenu *menu) QCocoaMenu *cocoaMenu = static_cast(menu); Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items()) cocoaMenu->syncMenuItem(item); + + // If the NSMenu has no visble items, or only separators, we should hide it + // on the menubar. This can happen after syncing the menu items since they + // can be moved to other menus. + BOOL shouldHide = YES; + for (NSMenuItem *item in [cocoaMenu->nsMenu() itemArray]) + if (![item isSeparatorItem] && ![item isHidden]) { + shouldHide = NO; + break; + } + [cocoaMenu->nsMenuItem() setHidden:shouldHide]; } void QCocoaMenuBar::handleReparent(QWindow *newParentWindow) -- cgit v1.2.3 From a09a867de081b4e335ce36b7377ce33abcd3e142 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 28 May 2013 16:10:52 +0200 Subject: Cocoa: Allow delayed title setting in menu items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is what happens in uic generated code. Therefore, we should not mark an item as text-synced until it's got its text set. Task-number: QTBUG-31378 Change-Id: I7bb7db8abad922b50546c7669d285369ebf01394 Reviewed-by: Friedemann Kleint Reviewed-by: Tor Arne Vestbø Reviewed-by: Shawn Rutledge --- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 1255f75eb7..1e2b593a08 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -241,7 +241,8 @@ NSMenuItem *QCocoaMenuItem::sync() mergeItem = [loader quitMenuItem]; break; default: - m_textSynced = true; + if (!m_text.isEmpty()) + m_textSynced = true; break; } break; @@ -264,7 +265,7 @@ NSMenuItem *QCocoaMenuItem::sync() m_native = nil; // create item below m_merged = false; } - } else { + } else if (!m_text.isEmpty()) { m_textSynced = true; // NoRole, and that was set explicitly. So, nothing to do anymore. } -- cgit v1.2.3 From 75cdce283f03fb26a34750bc075f62e8bc35232a Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 28 May 2013 18:18:29 +0200 Subject: QMenu: Remove last references to QMacWindowFader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was never ported to Qt 5, and 10.7 has simple API for that. Task-number: QTBUG-31336 Change-Id: Ie00c4ed3af9cd098c9e63eba1c654f1801aa83aa Reviewed-by: Tor Arne Vestbø Reviewed-by: Shawn Rutledge --- src/plugins/platforms/cocoa/qcocoawindow.mm | 3 +++ src/plugins/platforms/cocoa/qt_mac_p.h | 15 -------------- src/widgets/widgets/qmenu.cpp | 31 +++-------------------------- src/widgets/widgets/qmenu_p.h | 2 +- 4 files changed, 7 insertions(+), 44 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 0dec048a9d..f8d0eafcb3 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -823,6 +823,9 @@ NSWindow * QCocoaWindow::createNSWindow() if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { // Make popup winows show on the same desktop as the parent full-screen window. [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary]; + + if ((type & Qt::Popup) == Qt::Popup) + [window setAnimationBehavior:NSWindowAnimationBehaviorUtilityWindow]; } #endif window->m_cocoaPlatformWindow = this; diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h index 0906431986..808ca9194b 100644 --- a/src/plugins/platforms/cocoa/qt_mac_p.h +++ b/src/plugins/platforms/cocoa/qt_mac_p.h @@ -111,21 +111,6 @@ public: } }; -// Class for chaining to gether a bunch of fades. It pretty much is only used for qmenu fading. -class QMacWindowFader -{ - QWidgetList m_windowsToFade; - float m_duration; - Q_DISABLE_COPY(QMacWindowFader) -public: - QMacWindowFader(); // PLEASE DON'T CALL THIS. - static QMacWindowFader *currentFader(); - void registerWindowToFade(QWidget *window); - void setFadeDuration(float durationInSecs) { m_duration = durationInSecs; } - float fadeDuration() const { return m_duration; } - void performFade(); -}; - class Q_WIDGETS_EXPORT QMacCocoaAutoReleasePool { private: diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 33d2e01ed7..7c72c5c456 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -420,25 +420,17 @@ void QMenuPrivate::hideUpToMenuBar() if (QMenu *m = qobject_cast(caused)) { caused = m->d_func()->causedPopup.widget; if (!m->d_func()->tornoff) - hideMenu(m, fadeMenus); + hideMenu(m); if (!fadeMenus) // Mac doesn't clear the action until after hidden. m->d_func()->setCurrentAction(0); } else { caused = 0; } } -#if defined(Q_WS_MAC) - if (fadeMenus) { - QEventLoop eventLoop; - QTimer::singleShot(int(MenuFadeTimeInSec * 1000), &eventLoop, SLOT(quit())); - QMacWindowFader::currentFader()->performFade(); - eventLoop.exec(); - } -#endif } setCurrentAction(0); } -void QMenuPrivate::hideMenu(QMenu *menu, bool justRegister) +void QMenuPrivate::hideMenu(QMenu *menu) { if (!menu) return; @@ -462,27 +454,10 @@ void QMenuPrivate::hideMenu(QMenu *menu, bool justRegister) eventLoop.exec(); } - // Fade out. - if (menu->style()->styleHint(QStyle::SH_Menu_FadeOutOnHide)) { - // ### Qt 4.4: - // Should be something like: q->transitionWindow(Qt::FadeOutTransition, MenuFadeTimeInSec); - // Hopefully we'll integrate qt/research/windowtransitions into main before 4.4. - // Talk to Richard, Trenton or Bjoern. -#if defined(Q_WS_MAC) - if (justRegister) { - QMacWindowFader::currentFader()->setFadeDuration(MenuFadeTimeInSec); - QMacWindowFader::currentFader()->registerWindowToFade(menu); - } else { - macWindowFade(qt_mac_window_for(menu), MenuFadeTimeInSec); - } - -#endif // Q_WS_MAC - } aboutToHide = false; menu->blockSignals(false); #endif // QT_NO_EFFECTS - if (!justRegister) - menu->close(); + menu->close(); } void QMenuPrivate::popupAction(QAction *action, int delay, bool activateFirst) diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index 15f3c92127..71a3fca237 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -189,7 +189,7 @@ public: virtual QList > calcCausedStack() const; QMenuCaused causedPopup; void hideUpToMenuBar(); - void hideMenu(QMenu *menu, bool justRegister = false); + void hideMenu(QMenu *menu); //index mappings inline QAction *actionAt(int i) const { return q_func()->actions().at(i); } -- cgit v1.2.3 From c3bec846ac89bb79fbdfa5e2bedb3495b0055b09 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 May 2013 21:40:01 +0200 Subject: remove bizarre perl detection magic the code makes no sense, and was added with the QNX port without comment. there is already a detection a few lines up. Change-Id: I18ec18604c37c7c42f2649a658dd22324d481dd3 Reviewed-by: Andreas Holzammer Reviewed-by: Harald Fernengel Reviewed-by: Rafael Roquetto --- configure | 6 ------ 1 file changed, 6 deletions(-) diff --git a/configure b/configure index d11a50554f..079f2e7415 100755 --- a/configure +++ b/configure @@ -2344,12 +2344,6 @@ for e in gawk nawk awk; do fi done -# find perl -PERL="/usr/bin/perl" -if "$WHICH" perl >/dev/null 2>&1 && ( perl /dev/null ) >/dev/null 2>&1; then - PERL=`$WHICH perl` -fi - ### skip this if the user just needs help... if [ "$OPT_HELP" != "yes" ]; then -- cgit v1.2.3 From 389b6f51613a2d34b132b3955e8595bc594a336a Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 28 May 2013 13:47:32 +0200 Subject: qdoc: Handle collision nodes when building index files Currently qdoc skips collision nodes (and their children) when reading index files. This means that cross-linking between modules does not work for nodes that are defined under a collision page node. Most notably, the QML global object 'Qt' cannot be linked to from outside Qml module as it collides with Qt namespace. This change fixes the issue by skipping collision nodes and only processing their children when writing index files. In addition, we need to adjust the function that searches for nodes to the possibility that there may be multiple nodes with the same name but different type. Task-number: QTBUG-31096 Change-Id: Ic71d714f85539d8537021c73d8f1a527006a6f23 Reviewed-by: Martin Smith --- src/tools/qdoc/node.cpp | 9 ++++++--- src/tools/qdoc/qdocindexfiles.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp index e627cf859e..2184e302ae 100644 --- a/src/tools/qdoc/node.cpp +++ b/src/tools/qdoc/node.cpp @@ -862,9 +862,12 @@ Node* InnerNode::findChildNodeByNameAndType(const QString& name, Type type) if (type == Function) return primaryFunctionMap.value(name); else { - Node *node = childMap.value(name); - if (node && node->type() == type) - return node; + QList nodes = childMap.values(name); + for (int i=0; itype() == type) + return node; + } } return 0; } diff --git a/src/tools/qdoc/qdocindexfiles.cpp b/src/tools/qdoc/qdocindexfiles.cpp index daba2cc78a..5f2ebdfd07 100644 --- a/src/tools/qdoc/qdocindexfiles.cpp +++ b/src/tools/qdoc/qdocindexfiles.cpp @@ -1183,8 +1183,13 @@ void QDocIndexFiles::generateIndexSections(QXmlStreamWriter& writer, It is just a place holder for a collection of QML property nodes. Recurse to its children, which are the QML property nodes. + + Do the same thing for collision nodes - we want children + of collision nodes in the index, but leaving out the + parent collision page will make searching for nodes easier. */ - if (child->subType() == Node::QmlPropertyGroup) { + if (child->subType() == Node::QmlPropertyGroup || + child->subType() == Node::Collision) { const InnerNode* pgn = static_cast(child); foreach (Node* c, pgn->childNodes()) { generateIndexSections(writer, c, generateInternalNodes); -- cgit v1.2.3 From aa1b4c0943187d82e0c313b93559e99226a9c75a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 2 May 2013 17:04:08 +0200 Subject: Disable precision timers when running MSVC2012 code on pre-Windows 8. Precision timers can cause the event loop to lock up when running MSVC2012 code on pre-Windows 8. Task-number: QTBUG-27266 Change-Id: Idd73731e82843d0d140859bab825bc1a54eccf1a Reviewed-by: Gunnar Sletta --- src/corelib/kernel/qeventdispatcher_win.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index ae291f13cd..d1bd8fbe95 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -52,6 +52,8 @@ #include "qelapsedtimer.h" #include "qcoreapplication_p.h" +#include "qsysinfo.h" + #include #include @@ -305,8 +307,14 @@ static void resolveTimerAPI() #endif triedResolve = true; #if !defined(Q_OS_WINCE) +# if defined(_MSC_VER) && _MSC_VER >= 1700 + if (QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS8) { // QTBUG-27266, Disable when running MSVC2012-built code on pre-Windows 8 +# else + { +# endif qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeSetEvent"); qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeKillEvent"); + } #else qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeSetEvent"); qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeKillEvent"); -- cgit v1.2.3 From 853a0b764e08d5f910072b6f3fd3ff3f9dc5c0c4 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 29 May 2013 12:54:15 +0200 Subject: fix PlatformToolSet tag location in vcxproj files The PlatformToolSet tag belongs into the PropertyGroup with the label "Configuration". The former location in an anonymous PropertyGroup tricked Visual Studio into displaying the right PlatformToolSet but using its default value. If VS 2010 and VS 2012 are freshly installed on the same machine, the default toolset for VS 2012 is VS 2010. Task-number: QTBUG-30822 Change-Id: If00a532e92b0812c552b1cac52ff77a1e7039146 Reviewed-by: Oswald Buddenhagen Reviewed-by: Joerg Bornemann --- qmake/generators/win32/msbuild_objectmodel.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 67446b2efe..44fbf20f81 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -182,6 +182,7 @@ const char _Optimization[] = "Optimization"; const char _OptimizeReferences[] = "OptimizeReferences"; const char _OutputDirectory[] = "OutputDirectory"; const char _OutputFile[] = "OutputFile"; +const char _PlatformToolSet[] = "PlatformToolSet"; const char _PrecompiledHeader[] = "PrecompiledHeader"; const char _PrecompiledHeaderFile[] = "PrecompiledHeaderFile"; const char _PrecompiledHeaderOutputFile[] = "PrecompiledHeaderOutputFile"; @@ -467,10 +468,6 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) << attrTag("Condition", condition) << valueTag(tool.Configuration.IntermediateDirectory); } - if (tool.Configuration.CompilerVersion >= NET2012) { - xml << tagValue("PlatformToolSet", - platformToolSetVersion(tool.Configuration.CompilerVersion)); - } if ( !tool.Configuration.PrimaryOutput.isEmpty() ) { xml<< tag("TargetName") << attrTag("Condition", condition) @@ -668,10 +665,6 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) << attrTag("Condition", condition) << valueTag(config.IntermediateDirectory); } - if (config.CompilerVersion >= NET2012) { - xml << tagValue("PlatformToolSet", - platformToolSetVersion(config.CompilerVersion)); - } if (!config.PrimaryOutput.isEmpty()) { xml << tag("TargetName") << attrTag("Condition", condition) @@ -1649,6 +1642,7 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCConfiguration &tool) xml << tag("PropertyGroup") << attrTag("Condition", generateCondition(tool)) << attrTag("Label", "Configuration") + << attrTagS(_PlatformToolSet, platformToolSetVersion(tool.CompilerVersion)) << attrTagS(_OutputDirectory, tool.OutputDirectory) << attrTagT(_ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage) << attrTagT(_BuildBrowserInformation, tool.BuildBrowserInformation) @@ -2057,7 +2051,6 @@ QString VCXProjectWriter::platformToolSetVersion(const DotNET version) case NET2012: return "v110"; } - Q_ASSERT(!"This MSVC version does not support the PlatformToolSet tag!"); return QString(); } -- cgit v1.2.3 From 1df7a6a50a794721edb1bc63d268378f4f0ed7c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Thu, 23 May 2013 12:44:20 +0200 Subject: Move QBasicDrag and QSimpleDrag to QtGui. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are useful as default implementations of QPlatformIntegration::drag(), instead of having it return 0 which will lead to crashes in Qt Quick 2 and widgets applications that use drag and drop. Task-number: QTBUG-31288 Change-Id: I70efa139306ced5d879def0f74e3a72d3bcd64f7 Reviewed-by: Jørgen Lind --- src/gui/kernel/kernel.pri | 4 + src/gui/kernel/qplatformintegration.cpp | 7 +- src/gui/kernel/qshapedpixmapdndwindow.cpp | 106 ++++++ src/gui/kernel/qshapedpixmapdndwindow_p.h | 75 +++++ src/gui/kernel/qsimpledrag.cpp | 366 +++++++++++++++++++++ src/gui/kernel/qsimpledrag_p.h | 122 +++++++ src/platformsupport/dnd/dnd.pri | 6 - src/platformsupport/dnd/qshapedpixmapdndwindow.cpp | 106 ------ src/platformsupport/dnd/qshapedpixmapdndwindow_p.h | 75 ----- src/platformsupport/dnd/qsimpledrag.cpp | 366 --------------------- src/platformsupport/dnd/qsimpledrag_p.h | 122 ------- src/platformsupport/platformsupport.pro | 1 - src/plugins/platforms/cocoa/qcocoadrag.h | 2 +- src/plugins/platforms/qnx/qqnxintegration.cpp | 2 +- src/plugins/platforms/xcb/qxcbdrag.cpp | 4 +- src/plugins/platforms/xcb/qxcbdrag.h | 2 +- 16 files changed, 684 insertions(+), 682 deletions(-) create mode 100644 src/gui/kernel/qshapedpixmapdndwindow.cpp create mode 100644 src/gui/kernel/qshapedpixmapdndwindow_p.h create mode 100644 src/gui/kernel/qsimpledrag.cpp create mode 100644 src/gui/kernel/qsimpledrag_p.h delete mode 100644 src/platformsupport/dnd/dnd.pri delete mode 100644 src/platformsupport/dnd/qshapedpixmapdndwindow.cpp delete mode 100644 src/platformsupport/dnd/qshapedpixmapdndwindow_p.h delete mode 100644 src/platformsupport/dnd/qsimpledrag.cpp delete mode 100644 src/platformsupport/dnd/qsimpledrag_p.h diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 91374fe2dd..3c019fc5b5 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -31,6 +31,8 @@ HEADERS += \ kernel/qplatformclipboard.h \ kernel/qplatformnativeinterface.h \ kernel/qplatformmenu.h \ + kernel/qshapedpixmapdndwindow_p.h \ + kernel/qsimpledrag_p.h \ kernel/qsurfaceformat.h \ kernel/qguiapplication.h \ kernel/qguiapplication_p.h \ @@ -89,6 +91,8 @@ SOURCES += \ kernel/qplatformclipboard.cpp \ kernel/qplatformnativeinterface.cpp \ kernel/qsessionmanager.cpp \ + kernel/qshapedpixmapdndwindow.cpp \ + kernel/qsimpledrag.cpp \ kernel/qsurfaceformat.cpp \ kernel/qguiapplication.cpp \ kernel/qwindow.cpp \ diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp index e82e30df80..e4f45ebb6e 100644 --- a/src/gui/kernel/qplatformintegration.cpp +++ b/src/gui/kernel/qplatformintegration.cpp @@ -49,6 +49,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -99,7 +100,11 @@ QPlatformClipboard *QPlatformIntegration::clipboard() const */ QPlatformDrag *QPlatformIntegration::drag() const { - return 0; + static QSimpleDrag *drag = 0; + if (!drag) { + drag = new QSimpleDrag; + } + return drag; } #endif diff --git a/src/gui/kernel/qshapedpixmapdndwindow.cpp b/src/gui/kernel/qshapedpixmapdndwindow.cpp new file mode 100644 index 0000000000..b3e64b01d0 --- /dev/null +++ b/src/gui/kernel/qshapedpixmapdndwindow.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qshapedpixmapdndwindow_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +QShapedPixmapWindow::QShapedPixmapWindow() + : QWindow(), + m_backingStore(0) +{ + QSurfaceFormat format; + format.setAlphaBufferSize(8); + setFormat(format); + setSurfaceType(RasterSurface); + setFlags(Qt::ToolTip | Qt::FramelessWindowHint | + Qt::X11BypassWindowManagerHint | Qt::WindowTransparentForInput); + create(); + m_backingStore = new QBackingStore(this); +} + +void QShapedPixmapWindow::render() +{ + QRect rect(QPoint(), geometry().size()); + + m_backingStore->beginPaint(rect); + + QPaintDevice *device = m_backingStore->paintDevice(); + + { + QPainter p(device); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.drawPixmap(0, 0, m_pixmap); + } + + m_backingStore->endPaint(); + m_backingStore->flush(rect); +} + +void QShapedPixmapWindow::setPixmap(const QPixmap &pixmap) +{ + m_pixmap = pixmap; +} + +void QShapedPixmapWindow::setHotspot(const QPoint &hotspot) +{ + m_hotSpot = hotspot; +} + +void QShapedPixmapWindow::updateGeometry() +{ + QRect rect(QCursor::pos() - m_hotSpot, m_pixmap.size()); + if (m_pixmap.isNull()) + m_backingStore->resize(QSize(1,1)); + else if (m_backingStore->size() != m_pixmap.size()) + m_backingStore->resize(m_pixmap.size()); + setGeometry(rect); +} + +void QShapedPixmapWindow::exposeEvent(QExposeEvent *) +{ + render(); +} + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qshapedpixmapdndwindow_p.h b/src/gui/kernel/qshapedpixmapdndwindow_p.h new file mode 100644 index 0000000000..20674b6b19 --- /dev/null +++ b/src/gui/kernel/qshapedpixmapdndwindow_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSHAPEDPIXMAPDNDWINDOW_H +#define QSHAPEDPIXMAPDNDWINDOW_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QShapedPixmapWindow : public QWindow +{ + Q_OBJECT +public: + QShapedPixmapWindow(); + + void render(); + + void setPixmap(const QPixmap &pixmap); + void setHotspot(const QPoint &hotspot); + + void updateGeometry(); + +protected: + void exposeEvent(QExposeEvent *); + +private: + QBackingStore *m_backingStore; + QPixmap m_pixmap; + QPoint m_hotSpot; +}; + +QT_END_NAMESPACE + +#endif // QSHAPEDPIXMAPDNDWINDOW_H diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp new file mode 100644 index 0000000000..f6912a2d57 --- /dev/null +++ b/src/gui/kernel/qsimpledrag.cpp @@ -0,0 +1,366 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qsimpledrag_p.h" + +#include "qbitmap.h" +#include "qdrag.h" +#include "qpixmap.h" +#include "qevent.h" +#include "qfile.h" +#include "qtextcodec.h" +#include "qguiapplication.h" +#include "qpoint.h" +#include "qbuffer.h" +#include "qimage.h" +#include "qregexp.h" +#include "qdir.h" +#include "qimagereader.h" +#include "qimagewriter.h" + +#include +#include + +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_DRAGANDDROP + +static QWindow* topLevelAt(const QPoint &pos) +{ + QWindowList list = QGuiApplication::topLevelWindows(); + for (int i = list.count()-1; i >= 0; --i) { + QWindow *w = list.at(i); + if (w->isVisible() && w->geometry().contains(pos) && !qobject_cast(w)) + return w; + } + return 0; +} + +/*! + \class QBasicDrag + \brief QBasicDrag is a base class for implementing platform drag and drop. + \since 5.0 + \internal + \ingroup qpa + + QBasicDrag implements QPlatformDrag::drag() by running a local event loop in which + it tracks mouse movements and moves the drag icon (QShapedPixmapWindow) accordingly. + It provides new virtuals allowing for querying whether the receiving window + (within the Qt application or outside) accepts the drag and sets the state accordingly. +*/ + +QBasicDrag::QBasicDrag() : + m_restoreCursor(false), m_eventLoop(0), + m_executed_drop_action(Qt::IgnoreAction), m_can_drop(false), + m_drag(0), m_drag_icon_window(0) +{ +} + +QBasicDrag::~QBasicDrag() +{ + delete m_drag_icon_window; +} + +void QBasicDrag::enableEventFilter() +{ + qApp->installEventFilter(this); +} + +void QBasicDrag::disableEventFilter() +{ + qApp->removeEventFilter(this); +} + +bool QBasicDrag::eventFilter(QObject *o, QEvent *e) +{ + if (!m_drag) { + if (e->type() == QEvent::KeyRelease && static_cast(e)->key() == Qt::Key_Escape) { + disableEventFilter(); + exitDndEventLoop(); + return true; // block the key release + } + return false; + } + + if (!qobject_cast(o)) + return false; + + switch (e->type()) { + case QEvent::ShortcutOverride: + // prevent accelerators from firing while dragging + e->accept(); + return true; + + case QEvent::KeyPress: + case QEvent::KeyRelease: + { + QKeyEvent *ke = static_cast(e); + if (ke->key() == Qt::Key_Escape && e->type() == QEvent::KeyPress) { + cancel(); + disableEventFilter(); + exitDndEventLoop(); + + } + return true; // Eat all key events + } + + case QEvent::MouseMove: + move(static_cast(e)); + return true; // Eat all mouse events + + case QEvent::MouseButtonRelease: + disableEventFilter(); + if (canDrop()) { + drop(static_cast(e)); + } else { + cancel(); + } + exitDndEventLoop(); + return true; // Eat all mouse events + + case QEvent::MouseButtonPress: + case QEvent::MouseButtonDblClick: + case QEvent::Wheel: + return true; + default: + break; + } + return false; +} + +Qt::DropAction QBasicDrag::drag(QDrag *o) +{ + m_drag = o; + m_executed_drop_action = Qt::IgnoreAction; + m_can_drop = false; + m_restoreCursor = true; +#ifndef QT_NO_CURSOR + qApp->setOverrideCursor(Qt::DragCopyCursor); + updateCursor(m_executed_drop_action); +#endif + startDrag(); + m_eventLoop = new QEventLoop; + m_eventLoop->exec(); + delete m_eventLoop; + m_eventLoop = 0; + m_drag = 0; + endDrag(); + return m_executed_drop_action; +} + +void QBasicDrag::restoreCursor() +{ + if (m_restoreCursor) { +#ifndef QT_NO_CURSOR + QGuiApplication::restoreOverrideCursor(); +#endif + m_restoreCursor = false; + } +} + +void QBasicDrag::startDrag() +{ + // ### TODO Check if its really necessary to have m_drag_icon_window + // when QDrag is used without a pixmap - QDrag::setPixmap() + if (!m_drag_icon_window) + m_drag_icon_window = new QShapedPixmapWindow(); + + m_drag_icon_window->setPixmap(m_drag->pixmap()); + m_drag_icon_window->setHotspot(m_drag->hotSpot()); + m_drag_icon_window->updateGeometry(); + m_drag_icon_window->setVisible(true); + + enableEventFilter(); +} + +void QBasicDrag::endDrag() +{ +} + +void QBasicDrag::cancel() +{ + disableEventFilter(); + restoreCursor(); + m_drag_icon_window->setVisible(false); +} + +void QBasicDrag::move(const QMouseEvent *) +{ + if (m_drag) + m_drag_icon_window->updateGeometry(); +} + +void QBasicDrag::drop(const QMouseEvent *) +{ + disableEventFilter(); + restoreCursor(); + m_drag_icon_window->setVisible(false); +} + +void QBasicDrag::exitDndEventLoop() +{ + if (m_eventLoop && m_eventLoop->isRunning()) + m_eventLoop->exit(); +} + +void QBasicDrag::updateCursor(Qt::DropAction action) +{ +#ifndef QT_NO_CURSOR + Qt::CursorShape cursorShape = Qt::ForbiddenCursor; + if (canDrop()) { + switch (action) { + case Qt::CopyAction: + cursorShape = Qt::DragCopyCursor; + break; + case Qt::LinkAction: + cursorShape = Qt::DragLinkCursor; + break; + default: + cursorShape = Qt::DragMoveCursor; + break; + } + } + + QCursor *cursor = qApp->overrideCursor(); + QPixmap pixmap = m_drag->dragCursor(action); + if (!cursor) { + qApp->changeOverrideCursor((pixmap.isNull()) ? QCursor(cursorShape) : QCursor(pixmap)); + } else { + if (!pixmap.isNull()) { + if ((cursor->pixmap().cacheKey() != pixmap.cacheKey())) { + qApp->changeOverrideCursor(QCursor(pixmap)); + } + } else { + if (cursorShape != cursor->shape()) { + qApp->changeOverrideCursor(QCursor(cursorShape)); + } + } + } +#endif + updateAction(action); +} + +/*! + \class QSimpleDrag + \brief QSimpleDrag implements QBasicDrag for Drag and Drop operations within the Qt Application itself. + \since 5.0 + \internal + \ingroup qpa + + The class checks whether the receiving window is a window of the Qt application + and sets the state accordingly. It does not take windows of other applications + into account. +*/ + +QSimpleDrag::QSimpleDrag() : m_current_window(0) +{ +} + +QMimeData *QSimpleDrag::platformDropData() +{ + if (drag()) + return drag()->mimeData(); + return 0; +} + +void QSimpleDrag::startDrag() +{ + QBasicDrag::startDrag(); + m_current_window = topLevelAt(QCursor::pos()); + if (m_current_window) { + QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_current_window, drag()->mimeData(), QCursor::pos(), drag()->supportedActions()); + setCanDrop(response.isAccepted()); + updateCursor(response.acceptedAction()); + } else { + setCanDrop(false); + updateCursor(Qt::IgnoreAction); + } + setExecutedDropAction(Qt::IgnoreAction); +} + +void QSimpleDrag::cancel() +{ + QBasicDrag::cancel(); + if (drag()) + QWindowSystemInterface::handleDrag(m_current_window, 0, QPoint(), Qt::IgnoreAction); + m_current_window = 0; +} + +void QSimpleDrag::move(const QMouseEvent *me) +{ + QBasicDrag::move(me); + QWindow *window = topLevelAt(me->globalPos()); + if (!window) + return; + + const QPoint pos = me->globalPos() - window->geometry().topLeft(); + const QPlatformDragQtResponse qt_response = + QWindowSystemInterface::handleDrag(window, drag()->mimeData(), pos, drag()->supportedActions()); + + updateCursor(qt_response.acceptedAction()); + setCanDrop(qt_response.isAccepted()); +} + +void QSimpleDrag::drop(const QMouseEvent *me) +{ + QBasicDrag::drop(me); + QWindow *window = topLevelAt(me->globalPos()); + if (!window) + return; + + const QPoint pos = me->globalPos() - window->geometry().topLeft(); + const QPlatformDropQtResponse response = + QWindowSystemInterface::handleDrop(window, drag()->mimeData(),pos, drag()->supportedActions()); + if (response.isAccepted()) { + setExecutedDropAction(response.acceptedAction()); + } else { + setExecutedDropAction(Qt::IgnoreAction); + } +} + +#endif // QT_NO_DRAGANDDROP + +QT_END_NAMESPACE diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h new file mode 100644 index 0000000000..36ea4c1ec5 --- /dev/null +++ b/src/gui/kernel/qsimpledrag_p.h @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSIMPLEDRAG_H +#define QSIMPLEDRAG_H + +#include + +#include + +QT_BEGIN_NAMESPACE + +#ifndef QT_NO_DRAGANDDROP + +class QMouseEvent; +class QWindow; +class QEventLoop; +class QDropData; +class QShapedPixmapWindow; + +class Q_GUI_EXPORT QBasicDrag : public QPlatformDrag, public QObject +{ +public: + virtual ~QBasicDrag(); + + virtual Qt::DropAction drag(QDrag *drag); + + virtual bool eventFilter(QObject *o, QEvent *e); + +protected: + QBasicDrag(); + + virtual void startDrag(); + virtual void cancel(); + virtual void move(const QMouseEvent *me); + virtual void drop(const QMouseEvent *me); + virtual void endDrag(); + + QShapedPixmapWindow *shapedPixmapWindow() const { return m_drag_icon_window; } + void updateCursor(Qt::DropAction action); + + bool canDrop() const { return m_can_drop; } + void setCanDrop(bool c) { m_can_drop = c; } + + Qt::DropAction executedDropAction() const { return m_executed_drop_action; } + void setExecutedDropAction(Qt::DropAction da) { m_executed_drop_action = da; } + + QDrag *drag() const { return m_drag; } + +private: + void enableEventFilter(); + void disableEventFilter(); + void restoreCursor(); + void exitDndEventLoop(); + + bool m_restoreCursor; + QEventLoop *m_eventLoop; + Qt::DropAction m_executed_drop_action; + bool m_can_drop; + QDrag *m_drag; + QShapedPixmapWindow *m_drag_icon_window; +}; + +class Q_GUI_EXPORT QSimpleDrag : public QBasicDrag +{ +public: + QSimpleDrag(); + virtual QMimeData *platformDropData(); + +protected: + virtual void startDrag(); + virtual void cancel(); + virtual void move(const QMouseEvent *me); + virtual void drop(const QMouseEvent *me); + +private: + QWindow *m_current_window; +}; + +#endif // QT_NO_DRAGANDDROP + +QT_END_NAMESPACE + +#endif diff --git a/src/platformsupport/dnd/dnd.pri b/src/platformsupport/dnd/dnd.pri deleted file mode 100644 index 47feb81ef2..0000000000 --- a/src/platformsupport/dnd/dnd.pri +++ /dev/null @@ -1,6 +0,0 @@ -HEADERS += \ - $$PWD/qsimpledrag_p.h \ - $$PWD/qshapedpixmapdndwindow_p.h -SOURCES += \ - $$PWD/qsimpledrag.cpp \ - $$PWD/qshapedpixmapdndwindow.cpp diff --git a/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp b/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp deleted file mode 100644 index b3e64b01d0..0000000000 --- a/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qshapedpixmapdndwindow_p.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -QShapedPixmapWindow::QShapedPixmapWindow() - : QWindow(), - m_backingStore(0) -{ - QSurfaceFormat format; - format.setAlphaBufferSize(8); - setFormat(format); - setSurfaceType(RasterSurface); - setFlags(Qt::ToolTip | Qt::FramelessWindowHint | - Qt::X11BypassWindowManagerHint | Qt::WindowTransparentForInput); - create(); - m_backingStore = new QBackingStore(this); -} - -void QShapedPixmapWindow::render() -{ - QRect rect(QPoint(), geometry().size()); - - m_backingStore->beginPaint(rect); - - QPaintDevice *device = m_backingStore->paintDevice(); - - { - QPainter p(device); - p.setCompositionMode(QPainter::CompositionMode_Source); - p.drawPixmap(0, 0, m_pixmap); - } - - m_backingStore->endPaint(); - m_backingStore->flush(rect); -} - -void QShapedPixmapWindow::setPixmap(const QPixmap &pixmap) -{ - m_pixmap = pixmap; -} - -void QShapedPixmapWindow::setHotspot(const QPoint &hotspot) -{ - m_hotSpot = hotspot; -} - -void QShapedPixmapWindow::updateGeometry() -{ - QRect rect(QCursor::pos() - m_hotSpot, m_pixmap.size()); - if (m_pixmap.isNull()) - m_backingStore->resize(QSize(1,1)); - else if (m_backingStore->size() != m_pixmap.size()) - m_backingStore->resize(m_pixmap.size()); - setGeometry(rect); -} - -void QShapedPixmapWindow::exposeEvent(QExposeEvent *) -{ - render(); -} - -QT_END_NAMESPACE diff --git a/src/platformsupport/dnd/qshapedpixmapdndwindow_p.h b/src/platformsupport/dnd/qshapedpixmapdndwindow_p.h deleted file mode 100644 index 20674b6b19..0000000000 --- a/src/platformsupport/dnd/qshapedpixmapdndwindow_p.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSHAPEDPIXMAPDNDWINDOW_H -#define QSHAPEDPIXMAPDNDWINDOW_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QShapedPixmapWindow : public QWindow -{ - Q_OBJECT -public: - QShapedPixmapWindow(); - - void render(); - - void setPixmap(const QPixmap &pixmap); - void setHotspot(const QPoint &hotspot); - - void updateGeometry(); - -protected: - void exposeEvent(QExposeEvent *); - -private: - QBackingStore *m_backingStore; - QPixmap m_pixmap; - QPoint m_hotSpot; -}; - -QT_END_NAMESPACE - -#endif // QSHAPEDPIXMAPDNDWINDOW_H diff --git a/src/platformsupport/dnd/qsimpledrag.cpp b/src/platformsupport/dnd/qsimpledrag.cpp deleted file mode 100644 index f2ff177055..0000000000 --- a/src/platformsupport/dnd/qsimpledrag.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsimpledrag_p.h" - -#include "qbitmap.h" -#include "qdrag.h" -#include "qpixmap.h" -#include "qevent.h" -#include "qfile.h" -#include "qtextcodec.h" -#include "qguiapplication.h" -#include "qpoint.h" -#include "qbuffer.h" -#include "qimage.h" -#include "qregexp.h" -#include "qdir.h" -#include "qimagereader.h" -#include "qimagewriter.h" - -#include -#include - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_DRAGANDDROP - -static QWindow* topLevelAt(const QPoint &pos) -{ - QWindowList list = QGuiApplication::topLevelWindows(); - for (int i = list.count()-1; i >= 0; --i) { - QWindow *w = list.at(i); - if (w->isVisible() && w->geometry().contains(pos) && !qobject_cast(w)) - return w; - } - return 0; -} - -/*! - \class QBasicDrag - \brief QBasicDrag is a base class for implementing platform drag and drop. - \since 5.0 - \internal - \ingroup qpa - - QBasicDrag implements QPlatformDrag::drag() by running a local event loop in which - it tracks mouse movements and moves the drag icon (QShapedPixmapWindow) accordingly. - It provides new virtuals allowing for querying whether the receiving window - (within the Qt application or outside) accepts the drag and sets the state accordingly. -*/ - -QBasicDrag::QBasicDrag() : - m_restoreCursor(false), m_eventLoop(0), - m_executed_drop_action(Qt::IgnoreAction), m_can_drop(false), - m_drag(0), m_drag_icon_window(0) -{ -} - -QBasicDrag::~QBasicDrag() -{ - delete m_drag_icon_window; -} - -void QBasicDrag::enableEventFilter() -{ - qApp->installEventFilter(this); -} - -void QBasicDrag::disableEventFilter() -{ - qApp->removeEventFilter(this); -} - -bool QBasicDrag::eventFilter(QObject *o, QEvent *e) -{ - if (!m_drag) { - if (e->type() == QEvent::KeyRelease && static_cast(e)->key() == Qt::Key_Escape) { - disableEventFilter(); - exitDndEventLoop(); - return true; // block the key release - } - return false; - } - - if (!qobject_cast(o)) - return false; - - switch (e->type()) { - case QEvent::ShortcutOverride: - // prevent accelerators from firing while dragging - e->accept(); - return true; - - case QEvent::KeyPress: - case QEvent::KeyRelease: - { - QKeyEvent *ke = static_cast(e); - if (ke->key() == Qt::Key_Escape && e->type() == QEvent::KeyPress) { - cancel(); - disableEventFilter(); - exitDndEventLoop(); - - } - return true; // Eat all key events - } - - case QEvent::MouseMove: - move(static_cast(e)); - return true; // Eat all mouse events - - case QEvent::MouseButtonRelease: - disableEventFilter(); - if (canDrop()) { - drop(static_cast(e)); - } else { - cancel(); - } - exitDndEventLoop(); - return true; // Eat all mouse events - - case QEvent::MouseButtonPress: - case QEvent::MouseButtonDblClick: - case QEvent::Wheel: - return true; - default: - break; - } - return false; -} - -Qt::DropAction QBasicDrag::drag(QDrag *o) -{ - m_drag = o; - m_executed_drop_action = Qt::IgnoreAction; - m_can_drop = false; - m_restoreCursor = true; -#ifndef QT_NO_CURSOR - qApp->setOverrideCursor(Qt::DragCopyCursor); - updateCursor(m_executed_drop_action); -#endif - startDrag(); - m_eventLoop = new QEventLoop; - m_eventLoop->exec(); - delete m_eventLoop; - m_eventLoop = 0; - m_drag = 0; - endDrag(); - return m_executed_drop_action; -} - -void QBasicDrag::restoreCursor() -{ - if (m_restoreCursor) { -#ifndef QT_NO_CURSOR - QGuiApplication::restoreOverrideCursor(); -#endif - m_restoreCursor = false; - } -} - -void QBasicDrag::startDrag() -{ - // ### TODO Check if its really necessary to have m_drag_icon_window - // when QDrag is used without a pixmap - QDrag::setPixmap() - if (!m_drag_icon_window) - m_drag_icon_window = new QShapedPixmapWindow(); - - m_drag_icon_window->setPixmap(m_drag->pixmap()); - m_drag_icon_window->setHotspot(m_drag->hotSpot()); - m_drag_icon_window->updateGeometry(); - m_drag_icon_window->setVisible(true); - - enableEventFilter(); -} - -void QBasicDrag::endDrag() -{ -} - -void QBasicDrag::cancel() -{ - disableEventFilter(); - restoreCursor(); - m_drag_icon_window->setVisible(false); -} - -void QBasicDrag::move(const QMouseEvent *) -{ - if (m_drag) - m_drag_icon_window->updateGeometry(); -} - -void QBasicDrag::drop(const QMouseEvent *) -{ - disableEventFilter(); - restoreCursor(); - m_drag_icon_window->setVisible(false); -} - -void QBasicDrag::exitDndEventLoop() -{ - if (m_eventLoop && m_eventLoop->isRunning()) - m_eventLoop->exit(); -} - -void QBasicDrag::updateCursor(Qt::DropAction action) -{ -#ifndef QT_NO_CURSOR - Qt::CursorShape cursorShape = Qt::ForbiddenCursor; - if (canDrop()) { - switch (action) { - case Qt::CopyAction: - cursorShape = Qt::DragCopyCursor; - break; - case Qt::LinkAction: - cursorShape = Qt::DragLinkCursor; - break; - default: - cursorShape = Qt::DragMoveCursor; - break; - } - } - - QCursor *cursor = qApp->overrideCursor(); - QPixmap pixmap = m_drag->dragCursor(action); - if (!cursor) { - qApp->changeOverrideCursor((pixmap.isNull()) ? QCursor(cursorShape) : QCursor(pixmap)); - } else { - if (!pixmap.isNull()) { - if ((cursor->pixmap().cacheKey() != pixmap.cacheKey())) { - qApp->changeOverrideCursor(QCursor(pixmap)); - } - } else { - if (cursorShape != cursor->shape()) { - qApp->changeOverrideCursor(QCursor(cursorShape)); - } - } - } -#endif - updateAction(action); -} - -/*! - \class QSimpleDrag - \brief QSimpleDrag implements QBasicDrag for Drag and Drop operations within the Qt Application itself. - \since 5.0 - \internal - \ingroup qpa - - The class checks whether the receiving window is a window of the Qt application - and sets the state accordingly. It does not take windows of other applications - into account. -*/ - -QSimpleDrag::QSimpleDrag() : m_current_window(0) -{ -} - -QMimeData *QSimpleDrag::platformDropData() -{ - if (drag()) - return drag()->mimeData(); - return 0; -} - -void QSimpleDrag::startDrag() -{ - QBasicDrag::startDrag(); - m_current_window = topLevelAt(QCursor::pos()); - if (m_current_window) { - QPlatformDragQtResponse response = QWindowSystemInterface::handleDrag(m_current_window, drag()->mimeData(), QCursor::pos(), drag()->supportedActions()); - setCanDrop(response.isAccepted()); - updateCursor(response.acceptedAction()); - } else { - setCanDrop(false); - updateCursor(Qt::IgnoreAction); - } - setExecutedDropAction(Qt::IgnoreAction); -} - -void QSimpleDrag::cancel() -{ - QBasicDrag::cancel(); - if (drag()) - QWindowSystemInterface::handleDrag(m_current_window, 0, QPoint(), Qt::IgnoreAction); - m_current_window = 0; -} - -void QSimpleDrag::move(const QMouseEvent *me) -{ - QBasicDrag::move(me); - QWindow *window = topLevelAt(me->globalPos()); - if (!window) - return; - - const QPoint pos = me->globalPos() - window->geometry().topLeft(); - const QPlatformDragQtResponse qt_response = - QWindowSystemInterface::handleDrag(window, drag()->mimeData(), pos, drag()->supportedActions()); - - updateCursor(qt_response.acceptedAction()); - setCanDrop(qt_response.isAccepted()); -} - -void QSimpleDrag::drop(const QMouseEvent *me) -{ - QBasicDrag::drop(me); - QWindow *window = topLevelAt(me->globalPos()); - if (!window) - return; - - const QPoint pos = me->globalPos() - window->geometry().topLeft(); - const QPlatformDropQtResponse response = - QWindowSystemInterface::handleDrop(window, drag()->mimeData(),pos, drag()->supportedActions()); - if (response.isAccepted()) { - setExecutedDropAction(response.acceptedAction()); - } else { - setExecutedDropAction(Qt::IgnoreAction); - } -} - -#endif // QT_NO_DRAGANDDROP - -QT_END_NAMESPACE diff --git a/src/platformsupport/dnd/qsimpledrag_p.h b/src/platformsupport/dnd/qsimpledrag_p.h deleted file mode 100644 index 10237b36d7..0000000000 --- a/src/platformsupport/dnd/qsimpledrag_p.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSIMPLEDRAG_H -#define QSIMPLEDRAG_H - -#include - -#include - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_DRAGANDDROP - -class QMouseEvent; -class QWindow; -class QEventLoop; -class QDropData; -class QShapedPixmapWindow; - -class QBasicDrag : public QPlatformDrag, public QObject -{ -public: - virtual ~QBasicDrag(); - - virtual Qt::DropAction drag(QDrag *drag); - - virtual bool eventFilter(QObject *o, QEvent *e); - -protected: - QBasicDrag(); - - virtual void startDrag(); - virtual void cancel(); - virtual void move(const QMouseEvent *me); - virtual void drop(const QMouseEvent *me); - virtual void endDrag(); - - QShapedPixmapWindow *shapedPixmapWindow() const { return m_drag_icon_window; } - void updateCursor(Qt::DropAction action); - - bool canDrop() const { return m_can_drop; } - void setCanDrop(bool c) { m_can_drop = c; } - - Qt::DropAction executedDropAction() const { return m_executed_drop_action; } - void setExecutedDropAction(Qt::DropAction da) { m_executed_drop_action = da; } - - QDrag *drag() const { return m_drag; } - -private: - void enableEventFilter(); - void disableEventFilter(); - void restoreCursor(); - void exitDndEventLoop(); - - bool m_restoreCursor; - QEventLoop *m_eventLoop; - Qt::DropAction m_executed_drop_action; - bool m_can_drop; - QDrag *m_drag; - QShapedPixmapWindow *m_drag_icon_window; -}; - -class QSimpleDrag : public QBasicDrag -{ -public: - QSimpleDrag(); - virtual QMimeData *platformDropData(); - -protected: - virtual void startDrag(); - virtual void cancel(); - virtual void move(const QMouseEvent *me); - virtual void drop(const QMouseEvent *me); - -private: - QWindow *m_current_window; -}; - -#endif // QT_NO_DRAGANDDROP - -QT_END_NAMESPACE - -#endif diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro index 4cb1f2c1bf..da87f395fd 100644 --- a/src/platformsupport/platformsupport.pro +++ b/src/platformsupport/platformsupport.pro @@ -9,7 +9,6 @@ PRECOMPILED_HEADER = ../corelib/global/qt_pch.h include(cfsocketnotifier/cfsocketnotifier.pri) include(cglconvenience/cglconvenience.pri) -include(dnd/dnd.pri) include(eglconvenience/eglconvenience.pri) include(eventdispatchers/eventdispatchers.pri) include(fbconvenience/fbconvenience.pri) diff --git a/src/plugins/platforms/cocoa/qcocoadrag.h b/src/plugins/platforms/cocoa/qcocoadrag.h index 6e29fd1a78..80259df600 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.h +++ b/src/plugins/platforms/cocoa/qcocoadrag.h @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index 072f60dff8..feb05e3093 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -89,7 +89,7 @@ #include #endif -#include +#include #include #include diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index db736cef4e..4961e0377c 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -57,8 +57,8 @@ #include -#include -#include +#include +#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index 5678c2d303..5648f70d9e 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -43,7 +43,7 @@ #define QXCBDRAG_H #include -#include +#include #include #include #include -- cgit v1.2.3 From de3d449dcff4ee00fea72b3697055f5459fb13ec Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 28 May 2013 14:23:57 +0200 Subject: Windows: Suppress mouse events synthesized by OS. Change the hint for QPlatformIntegration::SynthesizeMouseFromTouchEvents to false for Windows and suppress the events synthesized by OS. The synthesized events cause touch events to generate 2 clicks in Quick2. Leave code as is for Windows CE. Task-number: QTBUG-31386 Change-Id: Ia0987342dcdd55c8540810da5e4b90518a501ce6 Reviewed-by: Alan Alpert Reviewed-by: Shawn Rutledge --- src/plugins/platforms/windows/qwindowsintegration.cpp | 4 ++++ src/plugins/platforms/windows/qwindowsmousehandler.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 73df3ec032..814892b43a 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -552,11 +552,15 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co break; case QPlatformIntegration::UseRtlExtensions: return QVariant(d->m_context.useRTLExtensions()); +#ifdef Q_OS_WINCE case QPlatformIntegration::SynthesizeMouseFromTouchEvents: // We do not want Qt to synthesize mouse events as Windows also does that. // Alternatively, Windows-generated touch mouse events can be identified and // ignored by checking GetMessageExtraInfo() for MI_WP_SIGNATURE (0xFF515700). return false; +#endif // Q_OS_WINCE + default: + break; } return QPlatformIntegration::styleHint(hint); } diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index fd00a07d6c..5c096b7eca 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -157,9 +157,19 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, LRESULT *result) { + enum { signatureMask = 0xffffff00, miWpSignature = 0xff515700 }; + if (et == QtWindows::MouseWheelEvent) return translateMouseWheelEvent(window, hwnd, msg, result); +#ifndef Q_OS_WINCE + // Check for events synthesized from touch. Lower byte is touch index, 0 means pen. + const LPARAM extraInfo = GetMessageExtraInfo(); + const bool fromTouch = (extraInfo & signatureMask) == miWpSignature && (extraInfo & 0xff); + if (fromTouch) + return false; +#endif // !Q_OS_WINCE + const QPoint winEventPosition(GET_X_LPARAM(msg.lParam), GET_Y_LPARAM(msg.lParam)); if (et & QtWindows::NonClientEventFlag) { const QPoint globalPosition = winEventPosition; -- cgit v1.2.3 From 20d08a96c8240a9fda1a359d98be42f69ed9592e Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 17 Apr 2013 14:26:37 +0300 Subject: Fix tst_qtendian autotest build for WEC7. MSVC2008 compiler fo ARM targets fail to compile qToUnaligned when using sizeof(T) inside memcpy fynction. The compiler fails at least when the code is reached through the following macros and templates: -> tst_QtEndian::toLittleEndian -> qToLittleEndian(T src, uchar *dest) -> qToUnaligned(const T src, uchar *dest) The above sequence produces internal compiler error with MSVC2008/ARM builds when called from tst_endian. As a workaround sizeof(T) is called outside memcpy function. Change-Id: Ib4d382c2cebecb6e54bb99fc8fad72db93825fcd Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qendian.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index c9c4d23aab..9b939feea0 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -78,7 +78,10 @@ template inline void qbswap(const T src, uchar *dest) // If you want to avoid the memcopy, you must write specializations for this function template inline void qToUnaligned(const T src, uchar *dest) { - memcpy(dest, &src, sizeof(T)); + // Using sizeof(T) inside memcpy function produces internal compiler error with + // MSVC2008/ARM in tst_endian -> use extra indirection to resolve size of T. + const size_t size = sizeof(T); + memcpy(dest, &src, size); } /* T qFromLittleEndian(const uchar *src) -- cgit v1.2.3 From 12ae86119cf389dab368bbc8a9d49b29b0b155cd Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 29 May 2013 17:42:30 +0200 Subject: Mac style: Remove yet another reference to widgets Change-Id: I545cfe22c6307864cdb18093a37e09a8ad042347 Reviewed-by: J-P Nurmi Reviewed-by: Jens Bache-Wiig --- src/widgets/styles/qmacstyle_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index b7f39d45dd..a8fba4fb68 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -3366,7 +3366,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (const QStyleOptionToolButton *tb = qstyleoption_cast(opt)) { QStyleOptionToolButton myTb = *tb; myTb.state &= ~State_AutoRaise; - if (w && qobject_cast(w->parentWidget())) { + if (QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar)) { QRect cr = tb->rect; int shiftX = 0; int shiftY = 0; @@ -3405,7 +3405,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (tb->toolButtonStyle != Qt::ToolButtonIconOnly) { needText = true; if (tb->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { - QMainWindow *mw = qobject_cast(w->window()); + QMainWindow *mw = w ? qobject_cast(w->window()) : 0; if (mw && mw->unifiedTitleAndToolBarOnMac()) { pr.setHeight(pixmap.size().height() / pixmap.devicePixelRatio()); cr.adjust(0, pr.bottom() + 1, 0, 1); -- cgit v1.2.3 From 9e36747786b31c9494f99af5e1f7c977b51b7ce7 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 6 May 2013 14:07:10 +0200 Subject: Use [NSEvent characters] to retrieve the input character. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is how it was done in Qt 4. An issue with the current approach was that it did not consider modifiers when setting a Qt::Key_* value, which would assign the same Qt keycode for: a = a(65) Alt + a = ā(65) [here it should return a unicode value for 'ā'] This is inconsistent with the other platform plugins. Also in the combination with a dead keys it was returning nothing in the output. Task-number: QTBUG-29005 (cherry picked from commit 6730413fcac1d7eb39af3683b87f965c5823cb6c) Change-Id: Ic28eb55b3a9798ecb6012cc2e3fb18589b8b0392 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/cocoa/qnsview.mm | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index ee6a9616a6..5c5da830ac 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -897,7 +897,6 @@ static QTouchDevice *touchDevice = 0; ulong timestamp = [nsevent timestamp] * 1000; ulong nativeModifiers = [nsevent modifierFlags]; Qt::KeyboardModifiers modifiers = [QNSView convertKeyModifiers: nativeModifiers]; - NSString *charactersIgnoringModifiers = [nsevent charactersIgnoringModifiers]; NSString *characters = [nsevent characters]; // [from Qt 4 impl] There is no way to get the scan code from carbon. But we cannot @@ -909,19 +908,11 @@ static QTouchDevice *touchDevice = 0; EventRef eventRef = EventRef([nsevent eventRef]); GetEventParameter(eventRef, kEventParamKeyCode, typeUInt32, 0, sizeof(nativeVirtualKey), 0, &nativeVirtualKey); - QChar ch; - int keyCode; - if ([charactersIgnoringModifiers length] > 0) { // convert the first character into a key code - if ((modifiers & Qt::ControlModifier) && ([characters length] != 0)) { - ch = QChar([characters characterAtIndex:0]); - } else { - ch = QChar([charactersIgnoringModifiers characterAtIndex:0]); - } + QChar ch = QChar::ReplacementCharacter; + int keyCode = Qt::Key_unknown; + if ([characters length] != 0) { + ch = QChar([characters characterAtIndex:0]); keyCode = [self convertKeyCode:ch]; - } else { - // might be a dead key - ch = QChar::ReplacementCharacter; - keyCode = Qt::Key_unknown; } // we will send a key event unless the input method sets m_sendKeyEvent to false @@ -931,7 +922,7 @@ static QTouchDevice *touchDevice = 0; if (eventType == QEvent::KeyPress) { // ignore text for the U+F700-U+F8FF range. This is used by Cocoa when // delivering function keys (e.g. arrow keys, backspace, F1-F35, etc.) - if ([charactersIgnoringModifiers length] == 1 && (ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff)) + if (ch.unicode() < 0xf700 || ch.unicode() > 0xf8ff) text = QCFString::toQString(characters); if (m_composingText.isEmpty()) -- cgit v1.2.3