mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-07-18 17:04:28 -05:00
Move vertical / horizontal control handling to macro segment
This commit is contained in:
parent
61d9031933
commit
48368f4bd6
|
|
@ -11,16 +11,11 @@ class MacroEntryControls : public QWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MacroEntryControls(const int animationDuration = 300,
|
||||
explicit MacroEntryControls(bool vertical = false,
|
||||
const int animationDuration = 300,
|
||||
QWidget *parent = 0);
|
||||
|
||||
void Show(bool visible = true);
|
||||
|
||||
QPushButton *GetUp() { return _up; }
|
||||
QPushButton *GetDown() { return _down; }
|
||||
QPushButton *GetAdd() { return _add; }
|
||||
QPushButton *GetRemove() { return _remove; }
|
||||
|
||||
signals:
|
||||
void Add();
|
||||
void Remove();
|
||||
|
|
@ -28,6 +23,7 @@ signals:
|
|||
void Down();
|
||||
|
||||
private:
|
||||
bool _vertical = false;
|
||||
bool _visible = false;
|
||||
QPushButton *_add;
|
||||
QPushButton *_remove;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ class MacroSegmentEdit : public QWidget {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MacroSegmentEdit(QWidget *parent = nullptr);
|
||||
MacroSegmentEdit(bool verticalControls = true,
|
||||
QWidget *parent = nullptr);
|
||||
// Use this function to avoid accidental edits when scrolling through
|
||||
// list of actions and conditions
|
||||
void SetFocusPolicyOfWidgets();
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ static inline void populateActionSelection(QComboBox *list)
|
|||
MacroActionEdit::MacroActionEdit(QWidget *parent,
|
||||
std::shared_ptr<MacroAction> *entryData,
|
||||
const std::string &id)
|
||||
: MacroSegmentEdit(parent), _entryData(entryData)
|
||||
: MacroSegmentEdit(switcher->useVerticalMacroControls, parent),
|
||||
_entryData(entryData)
|
||||
{
|
||||
_actionSelection = new QComboBox();
|
||||
|
||||
|
|
@ -77,23 +78,25 @@ MacroActionEdit::MacroActionEdit(QWidget *parent,
|
|||
_section->AddHeaderWidget(_actionSelection);
|
||||
_section->AddHeaderWidget(_headerInfo);
|
||||
|
||||
QVBoxLayout *verticalControlsLayout = new QVBoxLayout;
|
||||
if (switcher->useVerticalMacroControls) {
|
||||
verticalControlsLayout->addWidget(_controls->GetUp());
|
||||
verticalControlsLayout->addWidget(_controls->GetAdd());
|
||||
verticalControlsLayout->addWidget(_controls->GetRemove());
|
||||
verticalControlsLayout->addWidget(_controls->GetDown());
|
||||
verticalControlsLayout->setContentsMargins(0, 0, 0, 0);
|
||||
verticalControlsLayout->setSpacing(0);
|
||||
_controls->hide(); // Only useful in horizontal case
|
||||
}
|
||||
auto frame = new QFrame;
|
||||
frame->setObjectName("actionFrame");
|
||||
frame->setStyleSheet(
|
||||
"#actionFrame { border-radius: 4px; background-color: rgba(0,0,0,50); }");
|
||||
setStyleSheet("QCheckBox { background-color: rgba(0,0,0,0); }\
|
||||
QLabel { background-color: rgba(0,0,0,0); }");
|
||||
QVBoxLayout *frameLayout = new QVBoxLayout;
|
||||
frame->setLayout(frameLayout);
|
||||
frameLayout->addWidget(_section);
|
||||
|
||||
QVBoxLayout *actionLayout = new QVBoxLayout;
|
||||
actionLayout->addWidget(_section);
|
||||
actionLayout->addWidget(_controls);
|
||||
actionLayout->addWidget(frame);
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->addLayout(verticalControlsLayout);
|
||||
if (switcher->useVerticalMacroControls) {
|
||||
mainLayout->addWidget(_controls);
|
||||
} else {
|
||||
actionLayout->addWidget(_controls);
|
||||
}
|
||||
mainLayout->addLayout(actionLayout);
|
||||
setLayout(mainLayout);
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,9 @@ static inline void populateConditionSelection(QComboBox *list)
|
|||
MacroConditionEdit::MacroConditionEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroCondition> *entryData,
|
||||
const std::string &id, bool root)
|
||||
: MacroSegmentEdit(parent), _entryData(entryData), _isRoot(root)
|
||||
: MacroSegmentEdit(switcher->useVerticalMacroControls, parent),
|
||||
_entryData(entryData),
|
||||
_isRoot(root)
|
||||
{
|
||||
_logicSelection = new QComboBox();
|
||||
_conditionSelection = new QComboBox();
|
||||
|
|
@ -120,23 +122,15 @@ MacroConditionEdit::MacroConditionEdit(
|
|||
_section->AddHeaderWidget(_headerInfo);
|
||||
_section->AddHeaderWidget(_dur);
|
||||
|
||||
QVBoxLayout *verticalControlsLayout = new QVBoxLayout;
|
||||
if (switcher->useVerticalMacroControls) {
|
||||
verticalControlsLayout->addWidget(_controls->GetUp());
|
||||
verticalControlsLayout->addWidget(_controls->GetAdd());
|
||||
verticalControlsLayout->addWidget(_controls->GetRemove());
|
||||
verticalControlsLayout->addWidget(_controls->GetDown());
|
||||
verticalControlsLayout->setContentsMargins(0, 0, 0, 0);
|
||||
verticalControlsLayout->setSpacing(0);
|
||||
_controls->hide(); // Only useful in horizontal case
|
||||
}
|
||||
|
||||
QVBoxLayout *conditionLayout = new QVBoxLayout;
|
||||
conditionLayout->addWidget(_section);
|
||||
conditionLayout->addWidget(_controls);
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->addLayout(verticalControlsLayout);
|
||||
if (switcher->useVerticalMacroControls) {
|
||||
mainLayout->addWidget(_controls);
|
||||
} else {
|
||||
conditionLayout->addWidget(_controls);
|
||||
}
|
||||
mainLayout->addLayout(conditionLayout);
|
||||
setLayout(mainLayout);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#include "headers/macro-controls.hpp"
|
||||
|
||||
MacroEntryControls::MacroEntryControls(const int animationDuration,
|
||||
MacroEntryControls::MacroEntryControls(bool vertical,
|
||||
const int animationDuration,
|
||||
QWidget *parent)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent), _vertical(vertical)
|
||||
{
|
||||
_add = new QPushButton(this);
|
||||
_add->setMaximumSize(QSize(22, 22));
|
||||
|
|
@ -25,35 +26,48 @@ MacroEntryControls::MacroEntryControls(const int animationDuration,
|
|||
QVariant(QString::fromUtf8("downArrowIconSmall")));
|
||||
_down->setFlat(true);
|
||||
|
||||
auto line = new QFrame(this);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
|
||||
if (vertical) {
|
||||
auto mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->addWidget(_up);
|
||||
mainLayout->addWidget(_add);
|
||||
mainLayout->addWidget(_remove);
|
||||
mainLayout->addWidget(_down);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
mainLayout->setSpacing(0);
|
||||
setLayout(mainLayout);
|
||||
|
||||
auto mainLayout = new QHBoxLayout(this);
|
||||
} else {
|
||||
auto line = new QFrame(this);
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
line->setSizePolicy(QSizePolicy::Expanding,
|
||||
QSizePolicy::Maximum);
|
||||
|
||||
mainLayout->addWidget(_add);
|
||||
mainLayout->addWidget(_remove);
|
||||
auto mainLayout = new QHBoxLayout(this);
|
||||
|
||||
auto *separator = new QFrame(this);
|
||||
separator->setFrameShape(QFrame::VLine);
|
||||
separator->setFrameShadow(QFrame::Sunken);
|
||||
mainLayout->addWidget(separator);
|
||||
mainLayout->addWidget(_add);
|
||||
mainLayout->addWidget(_remove);
|
||||
|
||||
mainLayout->addWidget(_up);
|
||||
mainLayout->addWidget(_down);
|
||||
mainLayout->addWidget(line);
|
||||
auto *separator = new QFrame(this);
|
||||
separator->setFrameShape(QFrame::VLine);
|
||||
separator->setFrameShadow(QFrame::Sunken);
|
||||
mainLayout->addWidget(separator);
|
||||
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
mainLayout->addWidget(_up);
|
||||
mainLayout->addWidget(_down);
|
||||
mainLayout->addWidget(line);
|
||||
|
||||
_animation = new QPropertyAnimation(this, "maximumHeight");
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
_animation->setDuration(animationDuration);
|
||||
_animation->setStartValue(0);
|
||||
_animation->setEndValue(mainLayout->sizeHint().height());
|
||||
_animation = new QPropertyAnimation(this, "maximumHeight");
|
||||
|
||||
setMaximumHeight(0);
|
||||
setLayout(mainLayout);
|
||||
_animation->setDuration(animationDuration);
|
||||
_animation->setStartValue(0);
|
||||
_animation->setEndValue(mainLayout->sizeHint().height());
|
||||
|
||||
setMaximumHeight(0);
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
connect(_add, &QPushButton::clicked, this, &MacroEntryControls::Add);
|
||||
connect(_remove, &QPushButton::clicked, this,
|
||||
|
|
@ -64,7 +78,7 @@ MacroEntryControls::MacroEntryControls(const int animationDuration,
|
|||
|
||||
void MacroEntryControls::Show(bool visible)
|
||||
{
|
||||
if (_visible == visible) {
|
||||
if (_vertical || _visible == visible) {
|
||||
return;
|
||||
}
|
||||
_animation->setDirection(visible ? QAbstractAnimation::Forward
|
||||
|
|
|
|||
|
|
@ -40,11 +40,12 @@ bool MouseWheelWidgetAdjustmentGuard::eventFilter(QObject *o, QEvent *e)
|
|||
return QObject::eventFilter(o, e);
|
||||
}
|
||||
|
||||
MacroSegmentEdit::MacroSegmentEdit(QWidget *parent) : QWidget(parent)
|
||||
MacroSegmentEdit::MacroSegmentEdit(bool verticalControls, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
_section = new Section(300);
|
||||
_headerInfo = new QLabel();
|
||||
_controls = new MacroEntryControls();
|
||||
_controls = new MacroEntryControls(verticalControls);
|
||||
|
||||
_enterTimer.setSingleShot(true);
|
||||
_enterTimer.setInterval(1000);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user