This commit is contained in:
zhuzichu 2024-01-02 18:27:59 +08:00
parent 1464e647d9
commit 0e0a385f2d
5 changed files with 20 additions and 12 deletions

View File

@ -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(){

View File

@ -240,3 +240,7 @@ bool FluTools::isWindows10OrGreater(){
return var.toBool();
}
}
int FluTools::getTaskBarHeight(QQuickWindow* window){
return window->screen()->geometry().height() - window->screen()->availableGeometry().height();
}

View File

@ -5,6 +5,7 @@
#include <QFile>
#include <QColor>
#include <QtQml/qqml.h>
#include <QQuickWindow>
#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

View File

@ -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){

View File

@ -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){