mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-12 04:11:06 -05:00
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:
34
lib/utils/cursor-shape-changer.cpp
Normal file
34
lib/utils/cursor-shape-changer.cpp
Normal 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
|
||||
Reference in New Issue
Block a user