Use default cursor icon on macro segment control hover

Previously the cursor icon would be set to Qt::SplitVCursor as those
widgets were moved into the splitter handle layout
This commit is contained in:
WarmUpTill
2024-06-18 20:43:59 +02:00
committed by WarmUpTill
parent 7702541d81
commit 7f5737d03f
5 changed files with 74 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
#include "cursor-shape-changer.hpp"
#include <QCursor>
#include <QEvent>
#include <QGuiApplication>
namespace advss {
CursorShapeChanger::CursorShapeChanger(QObject *parent, Qt::CursorShape shape)
: QObject(parent),
_shape(shape)
{
}
bool CursorShapeChanger::eventFilter(QObject *o, QEvent *e)
{
if ((e->type() == QEvent::HoverEnter || e->type() == QEvent::Enter) &&
!_overrideActive) {
_overrideActive = true;
QGuiApplication::setOverrideCursor(QCursor(_shape));
} else if (_overrideActive && e->type() == QEvent::Leave) {
_overrideActive = false;
QGuiApplication::restoreOverrideCursor();
}
return QObject::eventFilter(o, e);
}
void SetCursorOnWidgetHover(QWidget *widget, Qt::CursorShape shape)
{
widget->installEventFilter(new CursorShapeChanger(widget, shape));
}
} // namespace advss