From 4f66c546a89669dfde02163ab8c6120f76121e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Mon, 1 Jan 2024 20:01:46 +0800 Subject: [PATCH] update --- src/FluFramelessHelper.cpp | 15 +++++++++++---- src/FluFramelessHelper.h | 3 +++ src/Qt5/imports/FluentUI/Controls/FluWindow.qml | 5 +++++ src/Qt6/imports/FluentUI/Controls/FluWindow.qml | 5 +++++ 4 files changed, 24 insertions(+), 4 deletions(-) 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){