summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmainwindowlayout.cpp
diff options
context:
space:
mode:
authorSergio Martins <sergio.martins@kdab.com>2017-01-10 17:03:17 +0000
committerSérgio Martins <sergio.martins@kdab.com>2017-02-01 10:15:07 +0000
commitdd2a871eaefe8925c88a835bf298180044d4b0e9 (patch)
treef6e4941d60e975a4a278ddce1484c32b33ee83c7 /src/widgets/widgets/qmainwindowlayout.cpp
parentfa8edcba0d4ebb5d9f66ff951e1870beb7b6a2db (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>
Diffstat (limited to 'src/widgets/widgets/qmainwindowlayout.cpp')
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 72e06e4efa..68ca571acf 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -1951,6 +1951,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
*/
@@ -2037,7 +2058,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
dropTo->setParent(floatingTabs);
dropTo->show();
dropTo->d_func()->plug(QRect());
- currentHoveredFloat = floatingTabs;
+ setCurrentHoveredFloat(floatingTabs);
}
#endif // QT_CONFIG(tabwidget)
#if QT_CONFIG(tabbar)
@@ -2190,7 +2211,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
currentGapPos.clear();
pluggingWidget = 0;
#if QT_CONFIG(dockwidget)
- currentHoveredFloat = nullptr;
+ setCurrentHoveredFloat(nullptr);
#endif
//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
@@ -2497,12 +2518,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(nullptr);
#endif //QT_NO_DOCKWIDGET
QPoint pos = parentWidget()->mapFromGlobal(mousePos);