From 649edbea0db336a213407772ece4f208a9495570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Sun, 23 Jun 2024 11:45:49 +0800 Subject: [PATCH] update --- example/example_en_US.ts | 50 ++++----- example/example_zh_CN.ts | 50 ++++----- example/qml/window/MainWindow.qml | 1 - src/FluFrameless.cpp | 31 +----- .../imports/FluentUI/Controls/FluWindow.qml | 104 ++++++++++-------- .../imports/FluentUI/Controls/FluWindow.qml | 101 +++++++++-------- 6 files changed, 168 insertions(+), 169 deletions(-) diff --git a/example/example_en_US.ts b/example/example_en_US.ts index 17a31341..af62a481 100644 --- a/example/example_en_US.ts +++ b/example/example_en_US.ts @@ -607,104 +607,104 @@ MainWindow - - + + Quit - + Are you sure you want to exit the program? - + Minimize - + Friendly Reminder - + FluentUI is hidden from the tray, click on the tray to activate the window again - - + + Cancel - + Open in Separate Window - + Click Time - + Search - + Finish - + Next - + Previous - + Dark Mode - + Here you can switch to night mode. - + Hide Easter eggs - + Try a few more clicks!! - + Upgrade Tips - + FluentUI is currently up to date - + -- The current app version - + Now go and download the new version? @@ -713,17 +713,17 @@ Updated content: - + OK - + The current version is already the latest - + The network is abnormal diff --git a/example/example_zh_CN.ts b/example/example_zh_CN.ts index d350e30c..865999ac 100644 --- a/example/example_zh_CN.ts +++ b/example/example_zh_CN.ts @@ -611,104 +611,104 @@ MainWindow - + Dark Mode 夜间模式 - - + + Quit 退出 - + Are you sure you want to exit the program? 您确定要退出程序吗 - + Minimize 最小化 - + Friendly Reminder 友情提示 - + FluentUI is hidden from the tray, click on the tray to activate the window again FluentUI 在托盘中处于隐藏状态,单击托盘以再次激活窗口 - - + + Cancel 取消 - + Open in Separate Window 在独立窗口中打开 - + Click Time 点击次数 - + Search 搜索 - + Finish 完成 - + Next 下一步 - + Previous 上一步 - + Here you can switch to night mode. 在这里,您可以切换到夜间模式。 - + Hide Easter eggs 隐藏彩蛋 - + Try a few more clicks!! 再试几下!! - + Upgrade Tips 升级提示 - + FluentUI is currently up to date FluentUI 目前最新版本 - + -- The current app version -- 当前应用版本 - + Now go and download the new version? @@ -721,17 +721,17 @@ Updated content: - + OK 确定 - + The current version is already the latest 当前版本已经是最新版本 - + The network is abnormal 网络异常 diff --git a/example/qml/window/MainWindow.qml b/example/qml/window/MainWindow.qml index 9e2fa681..9a4b2d64 100644 --- a/example/qml/window/MainWindow.qml +++ b/example/qml/window/MainWindow.qml @@ -20,7 +20,6 @@ FluWindow { launchMode: FluWindowType.SingleTask fitsAppBarWindows: true appBar: FluAppBar { - width: window.width height: 30 showDark: true darkClickListener:(button)=>handleDarkChanged(button) diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index b39f5b71..94ef70d3 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -108,14 +108,14 @@ void FluFrameless::componentComplete() { HWND hwnd = reinterpret_cast(window()->winId()); DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE); if (_fixSize) { - ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);; + ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);; for (int i = 0; i <= QGuiApplication::screens().count() - 1; ++i) { connect(QGuiApplication::screens().at(i), &QScreen::logicalDotsPerInchChanged, this, [=] { SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED); }); } } else { - ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME); + ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION); } SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); connect(window(), &QQuickWindow::screenChanged, this, [hwnd] { @@ -168,30 +168,11 @@ void FluFrameless::componentComplete() { } return false; } else if (uMsg == WM_NCCALCSIZE && wParam == TRUE) { - const auto clientRect = ((wParam == FALSE) ? reinterpret_cast(lParam) : &(reinterpret_cast(lParam))->rgrc[0]); - const LONG originalTop = clientRect->top; - const LONG originalLeft = clientRect->left; - const LONG originalRight = clientRect->right; - const LONG originalBottom = clientRect->bottom; - const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam); - if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) { - *result = hitTestResult; - return true; - } bool isMaximum = ::IsZoomed(hwnd); if (isMaximum) { - auto geometry = window()->screen()->geometry(); - auto offsetX = qAbs(geometry.left() - originalLeft); - auto offsetY = qAbs(geometry.top() - originalTop); - clientRect->top = originalTop + offsetY; - clientRect->bottom = originalBottom - offsetY; - clientRect->left = originalLeft + offsetX; - clientRect->right = originalRight - offsetX; - } else { - clientRect->top = originalTop; - clientRect->bottom = originalBottom; - clientRect->left = originalLeft; - clientRect->right = originalRight; + window()->setProperty("__margins",7); + }else{ + window()->setProperty("__margins",0); } _setMaximizeHovered(false); *result = WVR_REDRAW; @@ -251,7 +232,7 @@ void FluFrameless::componentComplete() { return true; } else if (uMsg == WM_NCPAINT) { *result = FALSE; - return true; + return false; } else if (uMsg == WM_NCACTIVATE) { *result = TRUE; return true; diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index d53813ae..90007cfd 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -16,7 +16,6 @@ Window { property Item appBar: FluAppBar { title: window.title height: 30 - width: window.width showDark: window.showDark showClose: window.showClose showMinimize: window.showMinimize @@ -41,6 +40,7 @@ Window { property bool autoCenter: true property bool autoDestroy: true property bool useSystemAppBar + property int __margins: 0 property color resizeBorderColor: { if(window.active){ return FluTheme.dark ? Qt.rgba(51/255,51/255,51/255,1) : Qt.rgba(110/255,110/255,110/255,1) @@ -174,6 +174,11 @@ Window { id:com_app_bar Item{ data: window.appBar + Component.onCompleted: { + window.appBar.width = Qt.binding(function(){ + return this.parent.width + }) + } } } Component{ @@ -246,53 +251,59 @@ Window { border.color: window.resizeBorderColor } } - FluLoader{ - anchors.fill: parent - sourceComponent: background - } - FluLoader{ - id:loader_app_bar - anchors { - top: parent.top - left: parent.left - right: parent.right - } - height: { - if(window.useSystemAppBar){ - return 0 - } - return window.fitsAppBarWindows ? 0 : window.appBar.height - } - sourceComponent: window.useSystemAppBar ? undefined : com_app_bar - } Item{ - id:layout_content - anchors{ - top: loader_app_bar.bottom - left: parent.left - right: parent.right - bottom: parent.bottom + id: layout_container + anchors.fill: parent + anchors.margins: window.__margins + FluLoader{ + anchors.fill: parent + sourceComponent: background } - clip: true - } - FluLoader{ - property string loadingText - property bool cancel: false - id:loader_loading - anchors.fill: parent - } - FluInfoBar{ - id:info_bar - root: window - } - FluLoader{ - id:loader_border - anchors.fill: parent - sourceComponent: { - if(window.useSystemAppBar || FluTools.isWin() || window.visibility === Window.Maximized || window.visibility === Window.FullScreen){ - return undefined + FluLoader{ + id:loader_app_bar + anchors { + top: parent.top + left: parent.left + right: parent.right + } + height: { + if(window.useSystemAppBar){ + return 0 + } + return window.fitsAppBarWindows ? 0 : window.appBar.height + } + sourceComponent: window.useSystemAppBar ? undefined : com_app_bar + } + Item{ + id:layout_content + anchors{ + top: loader_app_bar.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } + clip: true + } + FluLoader{ + property string loadingText + property bool cancel: false + id:loader_loading + anchors.fill: parent + } + FluInfoBar{ + id:info_bar + root: layout_container + } + + FluLoader{ + id:loader_border + anchors.fill: parent + sourceComponent: { + if(window.useSystemAppBar || FluTools.isWin() || window.visibility === Window.Maximized || window.visibility === Window.FullScreen){ + return undefined + } + return com_border } - return com_border } } function hideLoading(){ @@ -325,9 +336,6 @@ Window { window.minimumHeight = window.height } } - function registerForWindowResult(path){ - return FluApp.createWindowRegister(window,path) - } function setResult(data){ if(_windowRegister){ _windowRegister.setResult(data) diff --git a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml index 66008dfb..a25729ee 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml @@ -15,7 +15,6 @@ Window { property Item appBar: FluAppBar { title: window.title height: 30 - width: window.width showDark: window.showDark showClose: window.showClose showMinimize: window.showMinimize @@ -40,6 +39,7 @@ Window { property bool autoCenter: true property bool autoDestroy: true property bool useSystemAppBar + property int __margins: 0 property color resizeBorderColor: { if(window.active){ return FluTheme.dark ? Qt.rgba(51/255,51/255,51/255,1) : Qt.rgba(110/255,110/255,110/255,1) @@ -173,6 +173,11 @@ Window { id:com_app_bar Item{ data: window.appBar + Component.onCompleted: { + window.appBar.width = Qt.binding(function(){ + return this.parent.width + }) + } } } Component{ @@ -245,53 +250,59 @@ Window { border.color: window.resizeBorderColor } } - FluLoader{ - anchors.fill: parent - sourceComponent: background - } - FluLoader{ - id:loader_app_bar - anchors { - top: parent.top - left: parent.left - right: parent.right - } - height: { - if(window.useSystemAppBar){ - return 0 - } - return window.fitsAppBarWindows ? 0 : window.appBar.height - } - sourceComponent: window.useSystemAppBar ? undefined : com_app_bar - } Item{ - id:layout_content - anchors{ - top: loader_app_bar.bottom - left: parent.left - right: parent.right - bottom: parent.bottom + id: layout_container + anchors.fill: parent + anchors.margins: window.__margins + FluLoader{ + anchors.fill: parent + sourceComponent: background } - clip: true - } - FluLoader{ - property string loadingText - property bool cancel: false - id:loader_loading - anchors.fill: parent - } - FluInfoBar{ - id:info_bar - root: window - } - FluLoader{ - id:loader_border - anchors.fill: parent - sourceComponent: { - if(window.useSystemAppBar || FluTools.isWin() || window.visibility === Window.Maximized || window.visibility === Window.FullScreen){ - return undefined + FluLoader{ + id:loader_app_bar + anchors { + top: parent.top + left: parent.left + right: parent.right + } + height: { + if(window.useSystemAppBar){ + return 0 + } + return window.fitsAppBarWindows ? 0 : window.appBar.height + } + sourceComponent: window.useSystemAppBar ? undefined : com_app_bar + } + Item{ + id:layout_content + anchors{ + top: loader_app_bar.bottom + left: parent.left + right: parent.right + bottom: parent.bottom + } + clip: true + } + FluLoader{ + property string loadingText + property bool cancel: false + id:loader_loading + anchors.fill: parent + } + FluInfoBar{ + id:info_bar + root: layout_container + } + + FluLoader{ + id:loader_border + anchors.fill: parent + sourceComponent: { + if(window.useSystemAppBar || FluTools.isWin() || window.visibility === Window.Maximized || window.visibility === Window.FullScreen){ + return undefined + } + return com_border } - return com_border } } function hideLoading(){