diff options
author | Sergio Martins <sergio.martins@kdab.com> | 2017-01-10 17:03:17 +0000 |
---|---|---|
committer | Sérgio Martins <sergio.martins@kdab.com> | 2017-02-06 16:50:18 +0000 |
commit | 5484c5753cdb55cab7d90d9d5bde6989f8ac560a (patch) | |
tree | 379cc49c2400e07338f0839c4d24543e6b1e0645 /src/widgets | |
parent | 43b7722c6bce341af79049a1f76a90dd167f6ce9 (diff) |
Clear dock indicator when not over a floating dock group window
The rubberband is shown depending if there's a current hovered dock widget,
but there were a few places that were not calling updateGapIndicator().
Additionally, the rubberband will also disappear if the currentHoveredFloat
is destroyed externally (would leave a ghost rubber band behind).
Task-number: QTBUG-58049
Change-Id: Iafdf234aa04b0ee280e51f8fa2fd212c86610cd1
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
(cherry picked from commit dd2a871eaefe8925c88a835bf298180044d4b0e9)
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout.cpp | 29 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout_p.h | 3 |
2 files changed, 27 insertions, 5 deletions
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index f581fe4d88..7ba46ee6e8 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1876,6 +1876,27 @@ void QMainWindowLayout::invalidate() minSize = szHint = QSize(); } +#ifndef QT_NO_DOCKWIDGET +void QMainWindowLayout::setCurrentHoveredFloat(QWidget *w) +{ + if (currentHoveredFloat != w) { + if (currentHoveredFloat) { + disconnect(currentHoveredFloat.data(), &QObject::destroyed, + this, &QMainWindowLayout::updateGapIndicator); + } + + currentHoveredFloat = w; + + if (w) { + connect(w, &QObject::destroyed, + this, &QMainWindowLayout::updateGapIndicator, Qt::UniqueConnection); + } + + updateGapIndicator(); + } +} +#endif //QT_NO_DOCKWIDGET + /****************************************************************************** ** QMainWindowLayout - remaining stuff */ @@ -1962,7 +1983,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) dropTo->setParent(floatingTabs); dropTo->show(); dropTo->d_func()->plug(QRect()); - currentHoveredFloat = floatingTabs; + setCurrentHoveredFloat(floatingTabs); } QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(currentHoveredFloat); @@ -2106,7 +2127,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget) savedState.clear(); currentGapPos.clear(); pluggingWidget = 0; - currentHoveredFloat = Q_NULLPTR; + setCurrentHoveredFloat(Q_NULLPTR); //applying the state will make sure that the currentGap is updated correctly //and all the geometries (especially the one from the central widget) is correct layoutState.apply(false); @@ -2400,12 +2421,12 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) if (!w->geometry().contains(mousePos)) continue; - currentHoveredFloat = w; + setCurrentHoveredFloat(w); restore(true); return; } } - currentHoveredFloat = Q_NULLPTR; + setCurrentHoveredFloat(Q_NULLPTR); #endif //QT_NO_DOCKWIDGET QPoint pos = parentWidget()->mapFromGlobal(mousePos); diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 7475da8bdc..105af41327 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -306,13 +306,13 @@ public: #endif #ifndef QT_NO_DOCKWIDGET QPointer<QWidget> currentHoveredFloat; // set when dragging over a floating dock widget + void setCurrentHoveredFloat(QWidget *w); #endif void hover(QLayoutItem *widgetItem, const QPoint &mousePos); bool plug(QLayoutItem *widgetItem); QLayoutItem *unplug(QWidget *widget, bool group = false); void revert(QLayoutItem *widgetItem); - void updateGapIndicator(); void paintDropIndicator(QPainter *p, QWidget *widget, const QRegion &clip); void applyState(QMainWindowLayoutState &newState, bool animate = true); void restore(bool keepSavedState = false); @@ -320,6 +320,7 @@ public: void animationFinished(QWidget *widget); private Q_SLOTS: + void updateGapIndicator(); #ifndef QT_NO_DOCKWIDGET #ifndef QT_NO_TABBAR void tabChanged(); |