fix unwanted cursor change when leave edge region (#80)

This commit is contained in:
Altair Wei 2021-08-23 09:29:50 +08:00 committed by GitHub
parent 523e35fdb1
commit 01dd43c356
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>518</width> <width>518</width>
<height>362</height> <height>368</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -152,6 +152,13 @@
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents"> <widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;a href=&quot;https://www.google.com&quot;&gt;https://www.google.com&lt;/a&gt;</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QPushButton" name="pushButton"> <widget class="QPushButton" name="pushButton">
<property name="text"> <property name="text">

View File

@ -158,19 +158,27 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event)
} }
} else if (type == QEvent::MouseMove) { } else if (type == QEvent::MouseMove) {
// Display resize indicators // Display resize indicators
static bool cursorChanged = false;
if ((window->windowState() == Qt::WindowState::WindowNoState) && resizable) { if ((window->windowState() == Qt::WindowState::WindowNoState) && resizable) {
if (((edges & Qt::TopEdge) && (edges & Qt::LeftEdge)) if (((edges & Qt::TopEdge) && (edges & Qt::LeftEdge))
|| ((edges & Qt::BottomEdge) && (edges & Qt::RightEdge))) { || ((edges & Qt::BottomEdge) && (edges & Qt::RightEdge))) {
window->setCursor(Qt::SizeFDiagCursor); window->setCursor(Qt::SizeFDiagCursor);
cursorChanged = true;
} else if (((edges & Qt::TopEdge) && (edges & Qt::RightEdge)) } else if (((edges & Qt::TopEdge) && (edges & Qt::RightEdge))
|| ((edges & Qt::BottomEdge) && (edges & Qt::LeftEdge))) { || ((edges & Qt::BottomEdge) && (edges & Qt::LeftEdge))) {
window->setCursor(Qt::SizeBDiagCursor); window->setCursor(Qt::SizeBDiagCursor);
cursorChanged = true;
} else if ((edges & Qt::TopEdge) || (edges & Qt::BottomEdge)) { } else if ((edges & Qt::TopEdge) || (edges & Qt::BottomEdge)) {
window->setCursor(Qt::SizeVerCursor); window->setCursor(Qt::SizeVerCursor);
cursorChanged = true;
} else if ((edges & Qt::LeftEdge) || (edges & Qt::RightEdge)) { } else if ((edges & Qt::LeftEdge) || (edges & Qt::RightEdge)) {
window->setCursor(Qt::SizeHorCursor); window->setCursor(Qt::SizeHorCursor);
cursorChanged = true;
} else { } else {
if (cursorChanged) {
window->setCursor(Qt::ArrowCursor); window->setCursor(Qt::ArrowCursor);
cursorChanged = false;
}
} }
} }