From 0e0a385f2d8e16060b6df3494c43ce6c94330927 Mon Sep 17 00:00:00 2001 From: zhuzichu Date: Tue, 2 Jan 2024 18:27:59 +0800 Subject: [PATCH] update --- src/FluFramelessHelper.cpp | 4 ++-- src/FluTools.cpp | 4 ++++ src/FluTools.h | 2 ++ src/Qt5/imports/FluentUI/Controls/FluWindow.qml | 11 ++++++----- src/Qt6/imports/FluentUI/Controls/FluWindow.qml | 11 ++++++----- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/FluFramelessHelper.cpp b/src/FluFramelessHelper.cpp index 4c1ee824..bc9df2c1 100644 --- a/src/FluFramelessHelper.cpp +++ b/src/FluFramelessHelper.cpp @@ -307,7 +307,7 @@ void FluFramelessHelper::componentComplete(){ #endif int w = _realWidth.read().toInt(); int h = _realHeight.read().toInt()+_appBarHeight.read().toInt(); - if(_fixSize.read().toBool()){ + if(!resizeable()){ window->setMaximumSize(QSize(w,h)); window->setMinimumSize(QSize(w,h)); } @@ -414,7 +414,7 @@ void FluFramelessHelper::setOriginalPos(QVariant pos){ } bool FluFramelessHelper::resizeable(){ - return !(window->width() == window->maximumWidth() && window->width() == window->minimumWidth() && window->height() == window->maximumHeight() && window->height() == window->minimumHeight()); + return !_fixSize.read().toBool(); } bool FluFramelessHelper::_maximized(){ diff --git a/src/FluTools.cpp b/src/FluTools.cpp index f28ac368..8dd56b1c 100644 --- a/src/FluTools.cpp +++ b/src/FluTools.cpp @@ -240,3 +240,7 @@ bool FluTools::isWindows10OrGreater(){ return var.toBool(); } } + +int FluTools::getTaskBarHeight(QQuickWindow* window){ + return window->screen()->geometry().height() - window->screen()->availableGeometry().height(); +} diff --git a/src/FluTools.h b/src/FluTools.h index 04ecf631..c4f384c1 100644 --- a/src/FluTools.h +++ b/src/FluTools.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "singleton.h" /** @@ -54,6 +55,7 @@ public: Q_INVOKABLE int windowBuildNumber(); Q_INVOKABLE bool isWindows11OrGreater(); Q_INVOKABLE bool isWindows10OrGreater(); + Q_INVOKABLE int getTaskBarHeight(QQuickWindow* window); }; #endif // FLUTOOLS_H diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index 6f925706..9835af54 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -69,14 +69,14 @@ Window { Component.onCompleted: { _realHeight = height _realWidth = width + lifecycle.onCompleted(window) + initArgument(argument) moveWindowToDesktopCenter() fixWindowSize() useSystemAppBar = FluApp.useSystemAppBar if(!useSystemAppBar){ - loader_frameless_helper.sourceComponent = com_frameless + loader_frameless_helper.sourceComponent = com_frameless_helper } - lifecycle.onCompleted(window) - initArgument(argument) if(window.autoMaximize){ window.showMaximized() }else{ @@ -120,7 +120,7 @@ Window { function onClosing(event){closeListener(event)} } Component{ - id:com_frameless + id:com_frameless_helper FluFramelessHelper{ onLoadCompleted:{ window.moveWindowToDesktopCenter() @@ -305,7 +305,8 @@ Window { } function moveWindowToDesktopCenter(){ screen = Qt.application.screens[FluTools.cursorScreenIndex()] - window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height)/2+Screen.virtualY,window.width,window.height) + var taskBarHeight = FluTools.getTaskBarHeight(window) + window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height-taskBarHeight)/2+Screen.virtualY,window.width,window.height) } function fixWindowSize(){ if(fixSize){ diff --git a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml index 2d047743..9b9bfe88 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml @@ -68,14 +68,14 @@ Window { Component.onCompleted: { _realHeight = height _realWidth = width + lifecycle.onCompleted(window) + initArgument(argument) moveWindowToDesktopCenter() fixWindowSize() useSystemAppBar = FluApp.useSystemAppBar if(!useSystemAppBar){ - loader_frameless_helper.sourceComponent = com_frameless + loader_frameless_helper.sourceComponent = com_frameless_helper } - lifecycle.onCompleted(window) - initArgument(argument) if(window.autoMaximize){ window.showMaximized() }else{ @@ -119,7 +119,7 @@ Window { function onClosing(event){closeListener(event)} } Component{ - id:com_frameless + id:com_frameless_helper FluFramelessHelper{ onLoadCompleted:{ window.moveWindowToDesktopCenter() @@ -304,7 +304,8 @@ Window { } function moveWindowToDesktopCenter(){ screen = Qt.application.screens[FluTools.cursorScreenIndex()] - window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height)/2+Screen.virtualY,window.width,window.height) + var taskBarHeight = FluTools.getTaskBarHeight(window) + window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height-taskBarHeight)/2+Screen.virtualY,window.width,window.height) } function fixWindowSize(){ if(fixSize){