This commit is contained in:
zhuzichu 2024-01-02 14:53:53 +08:00
parent 0cad207359
commit 0241ecd07f
5 changed files with 19 additions and 19 deletions

View File

@ -67,6 +67,7 @@ FluScrollablePage{
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
onClicked: { onClicked: {
FluApp.useSystemAppBar = !FluApp.useSystemAppBar FluApp.useSystemAppBar = !FluApp.useSystemAppBar
dialog_restart.open()
} }
} }
} }

View File

@ -70,6 +70,7 @@ FluScrollablePage{
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
onClicked: { onClicked: {
FluApp.useSystemAppBar = !FluApp.useSystemAppBar FluApp.useSystemAppBar = !FluApp.useSystemAppBar
dialog_restart.open()
} }
} }
} }

View File

@ -154,6 +154,11 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
} }
return false; return false;
}else if(uMsg == WM_NCPAINT){ }else if(uMsg == WM_NCPAINT){
*result = 0;
return true;
}
else if(uMsg == WM_NCACTIVATE){
*result = DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
return true; return true;
} }
return false; return false;
@ -273,7 +278,7 @@ void FluFramelessHelper::componentComplete(){
_appBarHeight = QQmlProperty(window,"_appBarHeight"); _appBarHeight = QQmlProperty(window,"_appBarHeight");
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if(isCompositionEnabled()){ if(isCompositionEnabled()){
window->setFlag(Qt::CustomizeWindowHint,true); window->setFlags(Qt::Window|Qt::CustomizeWindowHint);
_nativeEvent =new FramelessEventFilter(this); _nativeEvent =new FramelessEventFilter(this);
qApp->installNativeEventFilter(_nativeEvent); qApp->installNativeEventFilter(_nativeEvent);
HWND hwnd = reinterpret_cast<HWND>(window->winId()); HWND hwnd = reinterpret_cast<HWND>(window->winId());
@ -284,6 +289,7 @@ void FluFramelessHelper::componentComplete(){
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME); SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME);
} }
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);
}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);
} }
@ -361,16 +367,6 @@ FluFramelessHelper::~FluFramelessHelper(){
if(isCompositionEnabled()){ if(isCompositionEnabled()){
qApp->removeNativeEventFilter(_nativeEvent); qApp->removeNativeEventFilter(_nativeEvent);
delete _nativeEvent; delete _nativeEvent;
HWND hwnd = reinterpret_cast<HWND>(window->winId());
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
int w = window->width();
int h = window->height();
if(_fixSize.read().toBool()){
window->setMaximumSize(QSize(w,h));
window->setMinimumSize(QSize(w,h));
}
window->setWidth(w);
window->setHeight(h);
} }
#endif #endif
window->removeEventFilter(this); window->removeEventFilter(this);

View File

@ -39,7 +39,7 @@ Window {
property bool showMaximize: true property bool showMaximize: true
property bool showStayTop: true property bool showStayTop: true
property bool autoMaximize: false property bool autoMaximize: false
property bool useSystemAppBar: FluApp.useSystemAppBar property bool useSystemAppBar
property color resizeBorderColor: { property color resizeBorderColor: {
if(window.active){ if(window.active){
return _accentColor return _accentColor
@ -70,9 +70,10 @@ Window {
_realHeight = height _realHeight = height
_realWidth = width _realWidth = width
moveWindowToDesktopCenter() moveWindowToDesktopCenter()
loader_frameless_helper.sourceComponent = Qt.binding(function(){ useSystemAppBar = FluApp.useSystemAppBar
return window.useSystemAppBar ? undefined : com_frameless if(!useSystemAppBar){
}) loader_frameless_helper.sourceComponent = com_frameless
}
lifecycle.onCompleted(window) lifecycle.onCompleted(window)
initArgument(argument) initArgument(argument)
if(window.autoMaximize){ if(window.autoMaximize){

View File

@ -38,7 +38,7 @@ Window {
property bool showMaximize: true property bool showMaximize: true
property bool showStayTop: true property bool showStayTop: true
property bool autoMaximize: false property bool autoMaximize: false
property bool useSystemAppBar: FluApp.useSystemAppBar property bool useSystemAppBar
property color resizeBorderColor: { property color resizeBorderColor: {
if(window.active){ if(window.active){
return _accentColor return _accentColor
@ -69,9 +69,10 @@ Window {
_realHeight = height _realHeight = height
_realWidth = width _realWidth = width
moveWindowToDesktopCenter() moveWindowToDesktopCenter()
loader_frameless_helper.sourceComponent = Qt.binding(function(){ useSystemAppBar = FluApp.useSystemAppBar
return window.useSystemAppBar ? undefined : com_frameless if(!useSystemAppBar){
}) loader_frameless_helper.sourceComponent = com_frameless
}
lifecycle.onCompleted(window) lifecycle.onCompleted(window)
initArgument(argument) initArgument(argument)
if(window.autoMaximize){ if(window.autoMaximize){