From 144ee494b774fdc0fcdfdda53ebd8d4807a270dc Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Wed, 11 Apr 2018 14:20:34 +0100 Subject: dockwidgets: Resize the rubber-band when our drop target is resized Bug can be seen on the .gif attached to QTBUG-67611, the floating group window resizes, but the rubber band still has the old size. Change-Id: I7232a39574ea06fe036c75c21e7496c0f32f4632 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/widgets/qmainwindowlayout.cpp | 15 ++++++++++++++- src/widgets/widgets/qmainwindowlayout_p.h | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 34ad88913d..d4ce0ffa4c 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -317,6 +317,9 @@ bool QDockWidgetGroupWindow::event(QEvent *e) // We might need to show the widget again destroyOrHideIfEmpty(); break; + case QEvent::Resize: + updateCurrentGapRect(); + emit resized(); default: break; } @@ -548,12 +551,18 @@ bool QDockWidgetGroupWindow::hover(QLayoutItem *widgetItem, const QPoint &mouseP currentGapPos = newGapPos; newState.insertGap(currentGapPos, widgetItem); newState.fitItems(); - currentGapRect = newState.info(currentGapPos)->itemRect(currentGapPos.last(), true); *layoutInfo() = std::move(newState); + updateCurrentGapRect(); layoutInfo()->apply(opts & QMainWindow::AnimatedDocks); return true; } +void QDockWidgetGroupWindow::updateCurrentGapRect() +{ + if (!currentGapPos.isEmpty()) + currentGapRect = layoutInfo()->info(currentGapPos)->itemRect(currentGapPos.last(), true); +} + /* Remove the gap that was created by hover() */ @@ -1979,6 +1988,8 @@ void QMainWindowLayout::setCurrentHoveredFloat(QDockWidgetGroupWindow *w) if (currentHoveredFloat) { disconnect(currentHoveredFloat.data(), &QObject::destroyed, this, &QMainWindowLayout::updateGapIndicator); + disconnect(currentHoveredFloat.data(), &QDockWidgetGroupWindow::resized, + this, &QMainWindowLayout::updateGapIndicator); if (currentHoveredFloat) currentHoveredFloat->restore(); } else if (w) { @@ -1990,6 +2001,8 @@ void QMainWindowLayout::setCurrentHoveredFloat(QDockWidgetGroupWindow *w) if (w) { connect(w, &QObject::destroyed, this, &QMainWindowLayout::updateGapIndicator, Qt::UniqueConnection); + connect(w, &QDockWidgetGroupWindow::resized, + this, &QMainWindowLayout::updateGapIndicator, Qt::UniqueConnection); } updateGapIndicator(); diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 168d4444b9..53e045aaae 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -338,12 +338,16 @@ public: bool hasNativeDecos() const; bool hover(QLayoutItem *widgetItem, const QPoint &mousePos); + void updateCurrentGapRect(); void restore(); void apply(); QRect currentGapRect; QList currentGapPos; +signals: + void resized(); + protected: bool event(QEvent *) override; void paintEvent(QPaintEvent*) override; -- cgit v1.2.3