From e5668869b934a4ef9e6904ee45c2265dd0b7f8ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Wed, 13 Dec 2023 23:43:01 +0800 Subject: [PATCH] update --- src/FluFrameless.cpp | 23 ++++++++++++++----- .../imports/FluentUI/Controls/FluWindow.qml | 5 +++- .../imports/FluentUI/Controls/FluWindow.qml | 5 +++- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index 0c2d465e..dca0d462 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -62,23 +62,23 @@ void FluFrameless::classBegin(){ void FluFrameless::updateCursor(int edges){ switch (edges) { case 0: - qApp->restoreOverrideCursor(); + _window->setCursor(Qt::ArrowCursor); break; case Qt::LeftEdge: case Qt::RightEdge: - qApp->setOverrideCursor(QCursor(Qt::SizeHorCursor)); + _window->setCursor(Qt::SizeHorCursor); break; case Qt::TopEdge: case Qt::BottomEdge: - qApp->setOverrideCursor(QCursor(Qt::SizeVerCursor)); + _window->setCursor(Qt::SizeVerCursor); break; case Qt::LeftEdge | Qt::TopEdge: case Qt::RightEdge | Qt::BottomEdge: - qApp->setOverrideCursor(QCursor(Qt::SizeFDiagCursor)); + _window->setCursor(Qt::SizeFDiagCursor); break; case Qt::RightEdge | Qt::TopEdge: case Qt::LeftEdge | Qt::BottomEdge: - qApp->setOverrideCursor(QCursor(Qt::SizeBDiagCursor)); + _window->setCursor(Qt::SizeBDiagCursor); break; } } @@ -105,7 +105,6 @@ bool FluFrameless::eventFilter(QObject *obj, QEvent *ev){ if(_window->width() == _window->maximumWidth() && _window->width() == _window->minimumWidth() && _window->height() == _window->maximumHeight() && _window->height() == _window->minimumHeight()){ break; } - edges = 0; QMouseEvent *event = static_cast(ev); QPoint p = #if QT_VERSION < QT_VERSION_CHECK(6,0,0) @@ -113,6 +112,14 @@ bool FluFrameless::eventFilter(QObject *obj, QEvent *ev){ #else event->position().toPoint(); #endif + if(p.x() >= margin && p.x() <= (_window->width() - margin) && p.y() >= margin && p.y() <= (_window->height() - margin)){ + if(edges != 0){ + edges = 0; + updateCursor(edges); + } + break; + } + edges = 0; if ( p.x() < margin ) { edges |= Qt::LeftEdge; } @@ -145,8 +152,12 @@ void FluFrameless::componentComplete(){ _window->setFlag(Qt::FramelessWindowHint,true); _window->installEventFilter(this); #ifdef Q_OS_WIN + qDebug()<<"---------"; _nativeEvent =new FramelessEventFilter(_window); qApp->installNativeEventFilter(_nativeEvent); + HWND hWnd = reinterpret_cast(_window->winId()); + ULONG_PTR cNewStyle = GetClassLongPtr(hWnd, GCL_STYLE) | CS_DROPSHADOW; + SetClassLongPtr(hWnd, GCL_STYLE, cNewStyle); #endif } } diff --git a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml index d8290230..581bf25b 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluWindow.qml @@ -65,6 +65,9 @@ Window { } Component.onCompleted: { useSystemAppBar = FluApp.useSystemAppBar + if(!useSystemAppBar){ + loader_frameless.sourceComponent = com_frameless + } lifecycle.onCompleted(window) initArgument(argument) if(window.autoMaximize){ @@ -89,7 +92,7 @@ Window { } } FluLoader{ - sourceComponent: window.useSystemAppBar ? undefined : com_frameless + id:loader_frameless } QtObject{ id:d diff --git a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml index 4d90dc48..1500b7a5 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluWindow.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluWindow.qml @@ -64,6 +64,9 @@ Window { } Component.onCompleted: { useSystemAppBar = FluApp.useSystemAppBar + if(!useSystemAppBar){ + loader_frameless.sourceComponent = com_frameless + } lifecycle.onCompleted(window) initArgument(argument) if(window.autoMaximize){ @@ -88,7 +91,7 @@ Window { } } FluLoader{ - sourceComponent: window.useSystemAppBar ? undefined : com_frameless + id:loader_frameless } QtObject{ id:d