diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index 052a01c4..0e1f0acb 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -197,6 +197,8 @@ void FluFrameless::componentComplete(){ DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE); SetWindowLongPtr(hwnd,GWL_STYLE,style &~ WS_SYSMENU); SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE |SWP_FRAMECHANGED); + _stayTop = QQmlProperty(_window,"stayTop"); + _stayTop.connectNotifySignal(this,SLOT(_stayTopChange())); #else _window->setFlag(Qt::FramelessWindowHint,true); #endif @@ -204,6 +206,14 @@ void FluFrameless::componentComplete(){ } } +void FluFrameless::_stayTopChange(){ +#ifdef Q_OS_WIN + HWND hwnd = reinterpret_cast(_window->winId()); + DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE); + SetWindowLongPtr(hwnd,GWL_STYLE,style &~ WS_SYSMENU); +#endif +} + FluFrameless::~FluFrameless(){ if (!_window.isNull()) { _window->removeEventFilter(this); diff --git a/src/FluFrameless.h b/src/FluFrameless.h index 3f013190..99c7d854 100644 --- a/src/FluFrameless.h +++ b/src/FluFrameless.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "stdafx.h" #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) @@ -28,7 +29,6 @@ public: class FluFrameless : public QObject, public QQmlParserStatus { Q_OBJECT - Q_PROPERTY_AUTO(bool,stayTop) QML_NAMED_ELEMENT(FluFrameless) public: explicit FluFrameless(QObject *parent = nullptr); @@ -39,9 +39,11 @@ protected: bool eventFilter(QObject *obj, QEvent *event) override; private: void updateCursor(int edges); + Q_SLOT void _stayTopChange(); private: QPointer _window = nullptr; FramelessEventFilter* _nativeEvent = nullptr; + QQmlProperty _stayTop; }; #endif // FLUFRAMELESS_H diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index fd2f58f9..7d31803b 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -112,9 +112,7 @@ Window { } Component{ id:com_frameless - FluFrameless{ - stayTop: window.stayTop - } + FluFrameless{} } Component{ id:com_background diff --git a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml index e18ff8f4..61f66178 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml @@ -111,9 +111,7 @@ Window { } Component{ id:com_frameless - FluFrameless{ - stayTop: window.stayTop - } + FluFrameless{} } Component{ id:com_background