diff --git a/src/FluFramelessHelper.cpp b/src/FluFramelessHelper.cpp index 8ad340ac..e31ad179 100644 --- a/src/FluFramelessHelper.cpp +++ b/src/FluFramelessHelper.cpp @@ -265,6 +265,9 @@ void FluFramelessHelper::componentComplete(){ _fixSize = QQmlProperty(window,"fixSize"); _originalPos = QQmlProperty(window,"_originalPos"); _accentColor = QQmlProperty(window,"_accentColor"); + _realHeight = QQmlProperty(window,"_realHeight"); + _realWidth = QQmlProperty(window,"_realWidth"); + _appBarHeight = QQmlProperty(window,"_appBarHeight"); #ifdef Q_OS_WIN if(isCompositionEnabled()){ _accentColor.write(getAccentColor()); @@ -278,16 +281,20 @@ void FluFramelessHelper::componentComplete(){ SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION); } SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); - if(_fixSize.read().toBool()){ - window->setMaximumSize(window->size()); - window->setMinimumSize(window->size()); - } }else{ window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window); } #else window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window); #endif + int w = _realWidth.read().toInt(); + int h = _realHeight.read().toInt()+_appBarHeight.read().toInt(); + if(_fixSize.read().toBool()){ + window->setMaximumSize(QSize(w,h)); + window->setMinimumSize(QSize(w,h)); + } + window->setWidth(w); + window->setHeight(h); _onStayTopChange(); _stayTop.connectNotifySignal(this,SLOT(_onStayTopChange())); _screen.connectNotifySignal(this,SLOT(_onScreenChanged())); diff --git a/src/FluFramelessHelper.h b/src/FluFramelessHelper.h index 5a22f581..fccb8223 100644 --- a/src/FluFramelessHelper.h +++ b/src/FluFramelessHelper.h @@ -58,6 +58,9 @@ private: QQmlProperty _originalPos; QQmlProperty _fixSize; QQmlProperty _accentColor; + QQmlProperty _realHeight; + QQmlProperty _realWidth; + QQmlProperty _appBarHeight; }; #endif // FLUFRAMELESSHELPER_H diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index 2ff9aa5f..1f638728 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -61,9 +61,14 @@ Window { property point _offsetXY : Qt.point(0,0) property var _originalPos property color _accentColor : FluTheme.dark ? "#333333" : "#6E6E6E" + property int _realHeight + property int _realWidth + property int _appBarHeight: appBar.height id:window color:"transparent" Component.onCompleted: { + _realHeight = height + _realWidth = width moveWindowToDesktopCenter() useSystemAppBar = FluApp.useSystemAppBar if(!useSystemAppBar){ diff --git a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml index 8e3630a1..d155e186 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml @@ -60,9 +60,14 @@ Window { property point _offsetXY : Qt.point(0,0) property var _originalPos property color _accentColor : FluTheme.dark ? "#333333" : "#6E6E6E" + property int _realHeight + property int _realWidth + property int _appBarHeight: appBar.height id:window color:"transparent" Component.onCompleted: { + _realHeight = height + _realWidth = width moveWindowToDesktopCenter() useSystemAppBar = FluApp.useSystemAppBar if(!useSystemAppBar){