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 <eike.ziller@qt.io>
This commit is contained in:
Christian Stenger
2024-02-29 15:09:24 +01:00
parent 9832af9701
commit c87435f971
2 changed files with 12 additions and 6 deletions

View File

@@ -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());

View File

@@ -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)