diff --git a/src/blackgui/enableforframelesswindow.cpp b/src/blackgui/enableforframelesswindow.cpp index 2a850a123..b4cfd8501 100644 --- a/src/blackgui/enableforframelesswindow.cpp +++ b/src/blackgui/enableforframelesswindow.cpp @@ -60,9 +60,37 @@ namespace BlackGui void CEnableForFramelessWindow::setFrameless(bool frameless) { + const bool isFrameless = this->isFrameless(); + if (isFrameless == frameless) { return; } + + QWidget *w = this->getWidget(); + if (!w) { return; } + const QRect oldFrameGeometry = w->frameGeometry(); + const QRect oldGeometry = w->geometry(); + WindowMode nonFrameLessMode = m_originalWindowMode; // Tool/Normal Window if (nonFrameLessMode == WindowFrameless) { nonFrameLessMode = WindowNormal; } this->setMode(frameless ? WindowFrameless : nonFrameLessMode); + + if (frameless) + { + // from framed to frameless + w->setGeometry(oldFrameGeometry); + m_windowFrameSizeW = oldFrameGeometry.width() - oldGeometry.width(); + m_windowFrameSizeH = oldFrameGeometry.height() - oldGeometry.height(); + } + else + { + if (m_windowFrameSizeW >= 0 && m_windowFrameSizeH >= 0) + { + QRect newGeometry = oldGeometry; + // newGeometry.setWidth(oldGeometry.width() - m_windowFrameSizeW); + // newGeometry.setHeight(oldGeometry.height() - m_windowFrameSizeH); + newGeometry.setX(oldGeometry.x() + m_windowFrameSizeW); + newGeometry.setY(oldGeometry.y() + m_windowFrameSizeH); + w->setGeometry(newGeometry); + } + } } void CEnableForFramelessWindow::alwaysOnTop(bool onTop) diff --git a/src/blackgui/enableforframelesswindow.h b/src/blackgui/enableforframelesswindow.h index a4e7f9b5d..639ecf6b5 100644 --- a/src/blackgui/enableforframelesswindow.h +++ b/src/blackgui/enableforframelesswindow.h @@ -95,6 +95,8 @@ namespace BlackGui QWidget *m_widget = nullptr; //!< corresponding window or dock widget QSizeGrip *m_framelessSizeGrip = nullptr; //!< size grip object QByteArray m_framelessPropertyName; //!< property name for frameless widgets + int m_windowFrameSizeW = -1; //!< window frame width + int m_windowFrameSizeH = -1; //!< window frame height //! Can be used as notification if window mode changes virtual void windowFlagsChanged();