mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -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:
parent
7702541d81
commit
7f5737d03f
|
|
@ -157,6 +157,8 @@ target_sources(
|
|||
lib/utils/backup.hpp
|
||||
lib/utils/curl-helper.cpp
|
||||
lib/utils/curl-helper.hpp
|
||||
lib/utils/cursor-shape-changer.cpp
|
||||
lib/utils/cursor-shape-changer.hpp
|
||||
lib/utils/double-slider.cpp
|
||||
lib/utils/double-slider.hpp
|
||||
lib/utils/duration-control.cpp
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "advanced-scene-switcher.hpp"
|
||||
#include "action-queue.hpp"
|
||||
#include "cursor-shape-changer.hpp"
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "macro-condition-edit.hpp"
|
||||
#include "macro-export-import-dialog.hpp"
|
||||
|
|
@ -956,6 +957,22 @@ void AdvSceneSwitcher::SetupMacroTab()
|
|||
moveControlsToSplitter(ui->macroElseActionSplitter, 1,
|
||||
ui->macroActionsLayout->takeAt(1));
|
||||
|
||||
// Override splitter cursor icon when hovering over controls in splitter
|
||||
SetCursorOnWidgetHover(ui->conditionAdd, Qt::CursorShape::ArrowCursor);
|
||||
SetCursorOnWidgetHover(ui->conditionRemove,
|
||||
Qt::CursorShape::ArrowCursor);
|
||||
SetCursorOnWidgetHover(ui->conditionTop, Qt::CursorShape::ArrowCursor);
|
||||
SetCursorOnWidgetHover(ui->conditionUp, Qt::CursorShape::ArrowCursor);
|
||||
SetCursorOnWidgetHover(ui->conditionDown, Qt::CursorShape::ArrowCursor);
|
||||
SetCursorOnWidgetHover(ui->conditionBottom,
|
||||
Qt::CursorShape::ArrowCursor);
|
||||
SetCursorOnWidgetHover(ui->actionAdd, Qt::CursorShape::ArrowCursor);
|
||||
SetCursorOnWidgetHover(ui->actionRemove, Qt::CursorShape::ArrowCursor);
|
||||
SetCursorOnWidgetHover(ui->actionTop, Qt::CursorShape::ArrowCursor);
|
||||
SetCursorOnWidgetHover(ui->actionUp, Qt::CursorShape::ArrowCursor);
|
||||
SetCursorOnWidgetHover(ui->actionDown, Qt::CursorShape::ArrowCursor);
|
||||
SetCursorOnWidgetHover(ui->actionBottom, Qt::CursorShape::ArrowCursor);
|
||||
|
||||
// Reserve more space for macro edit area than for the macro list
|
||||
ui->macroListMacroEditSplitter->setStretchFactor(0, 1);
|
||||
ui->macroListMacroEditSplitter->setStretchFactor(1, 4);
|
||||
|
|
|
|||
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
|
||||
20
lib/utils/cursor-shape-changer.hpp
Normal file
20
lib/utils/cursor-shape-changer.hpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
#include <QWidget>
|
||||
|
||||
namespace advss {
|
||||
|
||||
class CursorShapeChanger : public QObject {
|
||||
public:
|
||||
CursorShapeChanger(QObject *, Qt::CursorShape shape);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *o, QEvent *e) override;
|
||||
|
||||
private:
|
||||
Qt::CursorShape _shape;
|
||||
std::atomic_bool _overrideActive = {false};
|
||||
};
|
||||
|
||||
void SetCursorOnWidgetHover(QWidget *widget, Qt::CursorShape shape);
|
||||
|
||||
} // namespace advss
|
||||
|
|
@ -37,7 +37,7 @@ void ListControls::AddActionHelper(const char *theme, const char *tooltip,
|
|||
auto button = new QToolButton(this);
|
||||
button->setToolTip(obs_module_text(tooltip));
|
||||
button->setProperty("themeID", QVariant(QString(theme)));
|
||||
auto action = addWidget(button);
|
||||
(void)addWidget(button);
|
||||
button->connect(button, &QToolButton::clicked, this, signal);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user