mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Enable dragging macro segment by header
This commit is contained in:
parent
f8b2dea270
commit
46eaada0c4
|
|
@ -7,6 +7,7 @@
|
|||
#include <QMouseEvent>
|
||||
#include <QLabel>
|
||||
#include <QScrollBar>
|
||||
#include <QApplication>
|
||||
|
||||
MacroSegment::MacroSegment(Macro *m, bool supportsVariableValue)
|
||||
: _macro(m), _supportsVariableValue(supportsVariableValue)
|
||||
|
|
@ -182,11 +183,37 @@ MacroSegmentEdit::MacroSegmentEdit(bool highlight, QWidget *parent)
|
|||
SetSelected(false);
|
||||
ShowDropLine(DropLineState::NONE);
|
||||
|
||||
// Enable dragging while clicking on the header text
|
||||
_headerInfo->installEventFilter(this);
|
||||
|
||||
_timer.setInterval(1500);
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(Highlight()));
|
||||
_timer.start();
|
||||
}
|
||||
|
||||
bool MacroSegmentEdit::eventFilter(QObject *obj, QEvent *ev)
|
||||
{
|
||||
if (obj == _headerInfo && ev->type() == QEvent::MouseMove) {
|
||||
if (!parentWidget()) {
|
||||
return QWidget::eventFilter(obj, ev);
|
||||
}
|
||||
// Generate a mouse move event for the MacroSegmentList
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(ev);
|
||||
QMouseEvent *newEvent = new QMouseEvent(
|
||||
mouseEvent->type(),
|
||||
_headerInfo->mapTo(this, mouseEvent->pos()),
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
mouseEvent->globalPos(),
|
||||
#else
|
||||
mouseEvent->globalPosition(),
|
||||
#endif
|
||||
mouseEvent->button(), mouseEvent->buttons(),
|
||||
mouseEvent->modifiers());
|
||||
QApplication::sendEvent(parentWidget(), newEvent);
|
||||
}
|
||||
return QWidget::eventFilter(obj, ev);
|
||||
}
|
||||
|
||||
void MacroSegmentEdit::HeaderInfoChanged(const QString &text)
|
||||
{
|
||||
_headerInfo->setVisible(!text.isEmpty());
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ signals:
|
|||
void SceneGroupRenamed(const QString &oldName, const QString newName);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *ev) override;
|
||||
|
||||
Section *_section;
|
||||
QLabel *_headerInfo;
|
||||
QWidget *_frame;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user