This commit is contained in:
朱子楚\zhuzi 2024-01-01 20:01:46 +08:00
parent 475d293906
commit 4f66c546a8
4 changed files with 24 additions and 4 deletions

View File

@ -265,6 +265,9 @@ void FluFramelessHelper::componentComplete(){
_fixSize = QQmlProperty(window,"fixSize"); _fixSize = QQmlProperty(window,"fixSize");
_originalPos = QQmlProperty(window,"_originalPos"); _originalPos = QQmlProperty(window,"_originalPos");
_accentColor = QQmlProperty(window,"_accentColor"); _accentColor = QQmlProperty(window,"_accentColor");
_realHeight = QQmlProperty(window,"_realHeight");
_realWidth = QQmlProperty(window,"_realWidth");
_appBarHeight = QQmlProperty(window,"_appBarHeight");
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if(isCompositionEnabled()){ if(isCompositionEnabled()){
_accentColor.write(getAccentColor()); _accentColor.write(getAccentColor());
@ -278,16 +281,20 @@ void FluFramelessHelper::componentComplete(){
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION); 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); 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{ }else{
window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window); window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window);
} }
#else #else
window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window); window->setFlags((window->flags() & (~Qt::WindowMinMaxButtonsHint) & (~Qt::Dialog)) | Qt::FramelessWindowHint | Qt::Window);
#endif #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(); _onStayTopChange();
_stayTop.connectNotifySignal(this,SLOT(_onStayTopChange())); _stayTop.connectNotifySignal(this,SLOT(_onStayTopChange()));
_screen.connectNotifySignal(this,SLOT(_onScreenChanged())); _screen.connectNotifySignal(this,SLOT(_onScreenChanged()));

View File

@ -58,6 +58,9 @@ private:
QQmlProperty _originalPos; QQmlProperty _originalPos;
QQmlProperty _fixSize; QQmlProperty _fixSize;
QQmlProperty _accentColor; QQmlProperty _accentColor;
QQmlProperty _realHeight;
QQmlProperty _realWidth;
QQmlProperty _appBarHeight;
}; };
#endif // FLUFRAMELESSHELPER_H #endif // FLUFRAMELESSHELPER_H

View File

@ -61,9 +61,14 @@ Window {
property point _offsetXY : Qt.point(0,0) property point _offsetXY : Qt.point(0,0)
property var _originalPos property var _originalPos
property color _accentColor : FluTheme.dark ? "#333333" : "#6E6E6E" property color _accentColor : FluTheme.dark ? "#333333" : "#6E6E6E"
property int _realHeight
property int _realWidth
property int _appBarHeight: appBar.height
id:window id:window
color:"transparent" color:"transparent"
Component.onCompleted: { Component.onCompleted: {
_realHeight = height
_realWidth = width
moveWindowToDesktopCenter() moveWindowToDesktopCenter()
useSystemAppBar = FluApp.useSystemAppBar useSystemAppBar = FluApp.useSystemAppBar
if(!useSystemAppBar){ if(!useSystemAppBar){

View File

@ -60,9 +60,14 @@ Window {
property point _offsetXY : Qt.point(0,0) property point _offsetXY : Qt.point(0,0)
property var _originalPos property var _originalPos
property color _accentColor : FluTheme.dark ? "#333333" : "#6E6E6E" property color _accentColor : FluTheme.dark ? "#333333" : "#6E6E6E"
property int _realHeight
property int _realWidth
property int _appBarHeight: appBar.height
id:window id:window
color:"transparent" color:"transparent"
Component.onCompleted: { Component.onCompleted: {
_realHeight = height
_realWidth = width
moveWindowToDesktopCenter() moveWindowToDesktopCenter()
useSystemAppBar = FluApp.useSystemAppBar useSystemAppBar = FluApp.useSystemAppBar
if(!useSystemAppBar){ if(!useSystemAppBar){