diff --git a/src/DockWidgetBase.cpp b/src/DockWidgetBase.cpp index b67ed811..fd770789 100644 --- a/src/DockWidgetBase.cpp +++ b/src/DockWidgetBase.cpp @@ -133,6 +133,7 @@ public: bool m_updatingToggleAction = false; bool m_updatingFloatAction = false; bool m_isForceClosing = false; + QSize m_lastOverlayedSize = QSize(0, 0); }; DockWidgetBase::DockWidgetBase(const QString &name, Options options) @@ -517,6 +518,11 @@ bool DockWidgetBase::hasPreviousDockedLocation() const return d->m_lastPositions.isValid(); } +QSize DockWidgetBase::lastOverlayedSize() const +{ + return d->m_lastOverlayedSize; +} + FloatingWindow *DockWidgetBase::morphIntoFloatingWindow() { qCDebug(creation) << "DockWidget::morphIntoFloatingWindow() this=" << this @@ -796,6 +802,19 @@ void DockWidgetBase::onHidden(bool spontaneous) } } +bool DockWidgetBase::onResize(QSize newSize) +{ + if (isOverlayed()) { + if (auto frame = this->frame()) { + d->m_lastOverlayedSize = frame->QWidgetAdapter::size(); + } else { + qWarning() << Q_FUNC_INFO << "Overlayed dock widget without frame shouldn't happen"; + } + } + + return QWidgetAdapter::onResize(newSize); +} + void DockWidgetBase::onCloseEvent(QCloseEvent *e) { e->accept(); // By default we accept, means DockWidget closes diff --git a/src/DockWidgetBase.h b/src/DockWidgetBase.h index f151134e..8bdaa33b 100644 --- a/src/DockWidgetBase.h +++ b/src/DockWidgetBase.h @@ -440,6 +440,10 @@ public: /// When you call dockWidget->setFloating(false) it will only dock if it knows where to. bool hasPreviousDockedLocation() const; + /// @brief returns the last size the widget has when overlayed + /// Empty otherwise + QSize lastOverlayedSize() const; + Q_SIGNALS: ///@brief signal emitted when the parent changed void parentChanged(); @@ -491,6 +495,8 @@ protected: void onParentChanged(); void onShown(bool spontaneous); void onHidden(bool spontaneous); + bool onResize(QSize newSize) override; + #ifndef PYTHON_BINDINGS //Pyside bug: https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-1327 void onCloseEvent(QCloseEvent *e) override; #endif