mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Make sure setting to frameless/normal window keeps position and window size
This commit is contained in:
committed by
Mat Sutcliffe
parent
3c200034dc
commit
26ddf3a353
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user