mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-06-14 21:01:39 -05:00
Delay show and hide of macro controls
This commit is contained in:
parent
7a34c334bd
commit
487c735e13
|
|
@ -23,6 +23,7 @@ signals:
|
|||
void Down();
|
||||
|
||||
private:
|
||||
bool _visible = false;
|
||||
QPushButton *_add;
|
||||
QPushButton *_remove;
|
||||
QPushButton *_up;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <obs.hpp>
|
||||
|
||||
class Macro;
|
||||
|
|
@ -46,6 +47,8 @@ protected slots:
|
|||
void Up();
|
||||
void Down();
|
||||
void Collapsed(bool);
|
||||
void ShowControls();
|
||||
void HideControls();
|
||||
signals:
|
||||
void MacroAdded(const QString &name);
|
||||
void MacroRemoved(const QString &name);
|
||||
|
|
@ -67,6 +70,8 @@ protected:
|
|||
MacroEntryControls *_controls;
|
||||
|
||||
private:
|
||||
QTimer _enterTimer;
|
||||
QTimer _leaveTimer;
|
||||
virtual MacroSegment *Data() = 0;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,11 @@ MacroEntryControls::MacroEntryControls(const int animationDuration,
|
|||
|
||||
void MacroEntryControls::Show(bool visible)
|
||||
{
|
||||
if (_visible == visible) {
|
||||
return;
|
||||
}
|
||||
_animation->setDirection(visible ? QAbstractAnimation::Forward
|
||||
: QAbstractAnimation::Backward);
|
||||
_animation->start();
|
||||
_visible = visible;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@ MacroSegmentEdit::MacroSegmentEdit(QWidget *parent) : QWidget(parent)
|
|||
_headerInfo = new QLabel();
|
||||
_controls = new MacroEntryControls();
|
||||
|
||||
_enterTimer.setSingleShot(true);
|
||||
_enterTimer.setInterval(1000);
|
||||
_leaveTimer.setSingleShot(true);
|
||||
_leaveTimer.setInterval(1000);
|
||||
|
||||
QWidget::connect(_section, &Section::Collapsed, this,
|
||||
&MacroSegmentEdit::Collapsed);
|
||||
|
||||
|
|
@ -78,6 +83,10 @@ MacroSegmentEdit::MacroSegmentEdit(QWidget *parent) : QWidget(parent)
|
|||
&MacroSegmentEdit::Up);
|
||||
QWidget::connect(_controls, &MacroEntryControls::Down, this,
|
||||
&MacroSegmentEdit::Down);
|
||||
QWidget::connect(&_enterTimer, &QTimer::timeout, this,
|
||||
&MacroSegmentEdit::ShowControls);
|
||||
QWidget::connect(&_leaveTimer, &QTimer::timeout, this,
|
||||
&MacroSegmentEdit::HideControls);
|
||||
}
|
||||
|
||||
void MacroSegmentEdit::HeaderInfoChanged(const QString &text)
|
||||
|
|
@ -122,16 +131,28 @@ void MacroSegmentEdit::Collapsed(bool collapsed)
|
|||
}
|
||||
}
|
||||
|
||||
void MacroSegmentEdit::enterEvent(QEvent *)
|
||||
void MacroSegmentEdit::ShowControls()
|
||||
{
|
||||
_controls->Show(true);
|
||||
}
|
||||
|
||||
void MacroSegmentEdit::leaveEvent(QEvent *)
|
||||
void MacroSegmentEdit::HideControls()
|
||||
{
|
||||
_controls->Show(false);
|
||||
}
|
||||
|
||||
void MacroSegmentEdit::enterEvent(QEvent *)
|
||||
{
|
||||
_enterTimer.start();
|
||||
_leaveTimer.stop();
|
||||
}
|
||||
|
||||
void MacroSegmentEdit::leaveEvent(QEvent *)
|
||||
{
|
||||
_enterTimer.stop();
|
||||
_leaveTimer.start();
|
||||
}
|
||||
|
||||
void MacroSegmentEdit::SetFocusPolicyOfWidgets()
|
||||
{
|
||||
QList<QWidget *> widgets = this->findChildren<QWidget *>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user