mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-21 17:47:28 -05:00
Add macro control widget
This commit is contained in:
parent
5c2adacca1
commit
d541356fd3
|
|
@ -203,6 +203,7 @@ set(advanced-scene-switcher_HEADERS
|
|||
src/headers/macro-condition-virtual-cam.hpp
|
||||
src/headers/macro-condition-window.hpp
|
||||
src/headers/macro.hpp
|
||||
src/headers/macro-entry-controls.hpp
|
||||
src/headers/macro-selection.hpp
|
||||
src/headers/curl-helper.hpp
|
||||
src/headers/hotkey.hpp
|
||||
|
|
@ -283,6 +284,7 @@ set(advanced-scene-switcher_SOURCES
|
|||
src/macro-condition-virtual-cam.cpp
|
||||
src/macro-condition-window.cpp
|
||||
src/macro.cpp
|
||||
src/macro-entry-controls.cpp
|
||||
src/macro-selection.cpp
|
||||
src/macro-tab.cpp
|
||||
src/curl-helper.cpp
|
||||
|
|
|
|||
31
src/headers/macro-entry-controls.hpp
Normal file
31
src/headers/macro-entry-controls.hpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QScrollArea>
|
||||
#include <QPushButton>
|
||||
#include <QLayout>
|
||||
#include <QWidget>
|
||||
|
||||
class MacroEntryControls : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MacroEntryControls(const int animationDuration = 300,
|
||||
QWidget *parent = 0);
|
||||
|
||||
void Show(bool visible = true);
|
||||
|
||||
signals:
|
||||
void Add();
|
||||
void Remove();
|
||||
void Up();
|
||||
void Down();
|
||||
|
||||
private:
|
||||
QPushButton *_add;
|
||||
QPushButton *_remove;
|
||||
QPushButton *_up;
|
||||
QPushButton *_down;
|
||||
QPropertyAnimation *_animation = nullptr;
|
||||
};
|
||||
70
src/macro-entry-controls.cpp
Normal file
70
src/macro-entry-controls.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#include "headers/macro-entry-controls.hpp"
|
||||
|
||||
MacroEntryControls::MacroEntryControls(const int animationDuration,
|
||||
QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
_add = new QPushButton(this);
|
||||
_add->setMaximumSize(QSize(22, 22));
|
||||
_add->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("addIconSmall")));
|
||||
_add->setFlat(true);
|
||||
_remove = new QPushButton(this);
|
||||
_remove->setMaximumSize(QSize(22, 22));
|
||||
_remove->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("removeIconSmall")));
|
||||
_remove->setFlat(true);
|
||||
_up = new QPushButton(this);
|
||||
_up->setMaximumSize(QSize(22, 22));
|
||||
_up->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("upArrowIconSmall")));
|
||||
_up->setFlat(true);
|
||||
_down = new QPushButton(this);
|
||||
_down->setMaximumSize(QSize(22, 22));
|
||||
_down->setProperty("themeID",
|
||||
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);
|
||||
|
||||
auto mainLayout = new QHBoxLayout(this);
|
||||
|
||||
mainLayout->addWidget(_add);
|
||||
mainLayout->addWidget(_remove);
|
||||
|
||||
auto *separator = new QFrame(this);
|
||||
separator->setFrameShape(QFrame::VLine);
|
||||
separator->setFrameShadow(QFrame::Sunken);
|
||||
mainLayout->addWidget(separator);
|
||||
|
||||
mainLayout->addWidget(_up);
|
||||
mainLayout->addWidget(_down);
|
||||
mainLayout->addWidget(line);
|
||||
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
_animation = new QPropertyAnimation(this, "maximumHeight");
|
||||
|
||||
_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,
|
||||
&MacroEntryControls::Remove);
|
||||
connect(_up, &QPushButton::clicked, this, &MacroEntryControls::Up);
|
||||
connect(_down, &QPushButton::clicked, this, &MacroEntryControls::Down);
|
||||
}
|
||||
|
||||
void MacroEntryControls::Show(bool visible)
|
||||
{
|
||||
_animation->setDirection(visible ? QAbstractAnimation::Forward
|
||||
: QAbstractAnimation::Backward);
|
||||
_animation->start();
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user