From 95f48b51bf32694555c59eec2efad1c338d1462d Mon Sep 17 00:00:00 2001 From: zhuzichu Date: Fri, 15 Dec 2023 16:04:00 +0800 Subject: [PATCH] update --- src/FluFrameless.cpp | 3 +++ src/Qt5/imports/FluentUI/Controls/FluWindow.qml | 13 +++++++++++++ src/Qt6/imports/FluentUI/Controls/FluWindow.qml | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index e04eb237..8240bc0e 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -46,11 +46,13 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void * } return false; }else if(uMsg == WM_NCCALCSIZE){ +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) NCCALCSIZE_PARAMS& sz = *reinterpret_cast(msg->lParam); if (sz.rgrc[0].top != 0) sz.rgrc[0].top -= 1; *result = WVR_REDRAW; return true; +#endif } return false; #endif @@ -163,6 +165,7 @@ void FluFrameless::componentComplete(){ HWND hWnd = reinterpret_cast(_window->winId()); ULONG_PTR cNewStyle = GetClassLongPtr(hWnd, GCL_STYLE) | CS_DROPSHADOW; SetClassLongPtr(hWnd, GCL_STYLE, cNewStyle); + SetWindowPos(hWnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE |SWP_FRAMECHANGED); #endif } } diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index 581bf25b..84f0c7e5 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -70,6 +70,7 @@ Window { } lifecycle.onCompleted(window) initArgument(argument) + moveWindowToDesktopCenter() if(window.autoMaximize){ window.showMaximized() }else{ @@ -248,6 +249,15 @@ Window { } return true } + Rectangle{ + color: parent.border.color + width: parent.width + height: 1 + anchors{ + top: parent.top + topMargin: 1 + } + } } function destoryOnClose(){ lifecycle.onDestoryOnClose() @@ -275,6 +285,9 @@ Window { function registerForWindowResult(path){ return lifecycle.createRegister(window,path) } + function moveWindowToDesktopCenter(){ + window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height)/2+Screen.virtualY,window.width,window.height) + } function onResult(data){ if(_pageRegister){ _pageRegister.onResult(data) diff --git a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml index 1500b7a5..57c20e8e 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml @@ -69,6 +69,7 @@ Window { } lifecycle.onCompleted(window) initArgument(argument) + moveWindowToDesktopCenter() if(window.autoMaximize){ window.showMaximized() }else{ @@ -274,6 +275,9 @@ Window { function registerForWindowResult(path){ return lifecycle.createRegister(window,path) } + function moveWindowToDesktopCenter(){ + window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height)/2+Screen.virtualY,window.width,window.height) + } function onResult(data){ if(_pageRegister){ _pageRegister.onResult(data)