From c87435f9713c768f75975ca80a9b83919172b5eb Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 29 Feb 2024 15:09:24 +0100 Subject: [PATCH] Core: Tweak cursor handling of mini splitter It is possible that the internal signals are missed which results in a stale cursor until it gets changed again. Explicitly handle the hover event and set the cursor there. This also makes the need to restart QC obsolete when toggling the respective option. Task-number: QTCREATORBUG-29980 Change-Id: I51dfa6fda018a325d43cddae99f395cd8c0accde Reviewed-by: Eike Ziller --- src/plugins/coreplugin/generalsettings.cpp | 4 ---- src/plugins/coreplugin/minisplitter.cpp | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp index 0689adea522..71cfacbb402 100644 --- a/src/plugins/coreplugin/generalsettings.cpp +++ b/src/plugins/coreplugin/generalsettings.cpp @@ -250,12 +250,8 @@ void GeneralSettingsWidget::fillLanguageBox() const void GeneralSettingsWidget::apply() { - bool showRestart = generalSettings().provideSplitterCursors.volatileValue() - != generalSettings().provideSplitterCursors.value(); generalSettings().apply(); generalSettings().writeSettings(); - if (showRestart) - ICore::askForRestart(Tr::tr("The cursors for resizing views will change after restart.")); int currentIndex = m_languageBox->currentIndex(); setLanguage(m_languageBox->itemData(currentIndex, Qt::UserRole).toString()); diff --git a/src/plugins/coreplugin/minisplitter.cpp b/src/plugins/coreplugin/minisplitter.cpp index 8fdec456b0b..dd2aa280e1f 100644 --- a/src/plugins/coreplugin/minisplitter.cpp +++ b/src/plugins/coreplugin/minisplitter.cpp @@ -90,10 +90,9 @@ public: { setMask(QRegion(contentsRect())); setAttribute(Qt::WA_MouseNoMask, true); - if (generalSettings().provideSplitterCursors()) - setCursor(orientation == Qt::Horizontal ? hsplitCursor() : vsplitCursor()); } protected: + bool event(QEvent *event) override; void resizeEvent(QResizeEvent *event) override; void paintEvent(QPaintEvent *event) override; @@ -107,6 +106,17 @@ private: using namespace Core; using namespace Core::Internal; +bool MiniSplitterHandle::event(QEvent *event) +{ + if (generalSettings().provideSplitterCursors()) { + if (event->type() == QEvent::HoverEnter) + setCursor(orientation() == Qt::Horizontal ? hsplitCursor() : vsplitCursor()); + else if (event->type() == QEvent::HoverLeave) + unsetCursor(); + } + return QSplitterHandle::event(event); +} + void MiniSplitterHandle::resizeEvent(QResizeEvent *event) { if (orientation() == Qt::Horizontal)