mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-19 00:27:23 -05:00
Rework to use MacroList widget
This commit is contained in:
parent
700e75a2b5
commit
a268f98b73
|
|
@ -16,7 +16,7 @@ std::vector<MacroRef> getNextMacro(std::vector<MacroRef> ¯os,
|
|||
{
|
||||
std::vector<MacroRef> res;
|
||||
if (macros.size() == 1) {
|
||||
if (macros[0]->Paused()) {
|
||||
if (!macros[0].get() || macros[0]->Paused()) {
|
||||
return res;
|
||||
} else {
|
||||
return macros;
|
||||
|
|
@ -42,7 +42,7 @@ bool MacroActionRandom::PerformAction()
|
|||
if (macros.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
if (macros.size() == 1) {
|
||||
if (macros.size() == 1 && macros[0].get()) {
|
||||
lastRandomMacro = macros[0];
|
||||
return macros[0]->PerformActions();
|
||||
}
|
||||
|
|
@ -73,42 +73,24 @@ bool MacroActionRandom::Load(obs_data_t *obj)
|
|||
|
||||
MacroActionRandomEdit::MacroActionRandomEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroActionRandom> entryData)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent), _list(new MacroList(this, false, false))
|
||||
{
|
||||
_macroList = new QListWidget();
|
||||
_macroList->setSortingEnabled(true);
|
||||
_add = new QPushButton();
|
||||
_add->setMaximumSize(QSize(22, 22));
|
||||
_add->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("addIconSmall")));
|
||||
_add->setFlat(true);
|
||||
_remove = new QPushButton();
|
||||
_remove->setMaximumSize(QSize(22, 22));
|
||||
_remove->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("removeIconSmall")));
|
||||
_remove->setFlat(true);
|
||||
|
||||
QWidget::connect(_add, SIGNAL(clicked()), this, SLOT(AddMacro()));
|
||||
QWidget::connect(_remove, SIGNAL(clicked()), this, SLOT(RemoveMacro()));
|
||||
QWidget::connect(window(),
|
||||
SIGNAL(MacroRenamed(const QString &, const QString &)),
|
||||
this,
|
||||
SLOT(MacroRename(const QString &, const QString &)));
|
||||
QWidget::connect(_list, SIGNAL(Added(const std::string &)), this,
|
||||
SLOT(Add(const std::string &)));
|
||||
QWidget::connect(_list, SIGNAL(Removed(int)), this, SLOT(Remove(int)));
|
||||
QWidget::connect(_list, SIGNAL(Replaced(int, const std::string &)),
|
||||
this, SLOT(Replace(int, const std::string &)));
|
||||
QWidget::connect(window(), SIGNAL(MacroRemoved(const QString &)), this,
|
||||
SLOT(MacroRemove(const QString &)));
|
||||
|
||||
auto *entryLayout = new QHBoxLayout;
|
||||
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {};
|
||||
placeWidgets(obs_module_text("AdvSceneSwitcher.action.random.entry"),
|
||||
entryLayout, widgetPlaceholders);
|
||||
|
||||
auto *argButtonLayout = new QHBoxLayout;
|
||||
argButtonLayout->addWidget(_add);
|
||||
argButtonLayout->addWidget(_remove);
|
||||
argButtonLayout->addStretch();
|
||||
|
||||
auto *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(entryLayout);
|
||||
mainLayout->addWidget(_macroList);
|
||||
mainLayout->addLayout(argButtonLayout);
|
||||
mainLayout->addWidget(_list);
|
||||
setLayout(mainLayout);
|
||||
|
||||
_entryData = entryData;
|
||||
|
|
@ -122,122 +104,59 @@ void MacroActionRandomEdit::UpdateEntryData()
|
|||
return;
|
||||
}
|
||||
|
||||
for (auto &m : _entryData->_macros) {
|
||||
if (!m.get()) {
|
||||
continue;
|
||||
}
|
||||
auto name = QString::fromStdString(m->Name());
|
||||
QListWidgetItem *item = new QListWidgetItem(name, _macroList);
|
||||
item->setData(Qt::UserRole, name);
|
||||
}
|
||||
SetMacroListSize();
|
||||
}
|
||||
|
||||
void MacroActionRandomEdit::MacroRemove(const QString &name)
|
||||
{
|
||||
if (_entryData) {
|
||||
auto it = _entryData->_macros.begin();
|
||||
while (it != _entryData->_macros.end()) {
|
||||
if (it->get()->Name() == name.toStdString()) {
|
||||
it = _entryData->_macros.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MacroActionRandomEdit::MacroRename(const QString &oldName,
|
||||
const QString &newName)
|
||||
{
|
||||
auto count = _macroList->count();
|
||||
for (int idx = 0; idx < count; ++idx) {
|
||||
QListWidgetItem *item = _macroList->item(idx);
|
||||
QString itemString = item->data(Qt::UserRole).toString();
|
||||
if (oldName == itemString) {
|
||||
item->setData(Qt::UserRole, newName);
|
||||
item->setText(newName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MacroActionRandomEdit::AddMacro()
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string macroName;
|
||||
bool accepted = MacroSelectionDialog::AskForMacro(this, macroName);
|
||||
|
||||
if (!accepted || macroName.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MacroRef macro(macroName);
|
||||
|
||||
if (!macro.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (FindEntry(macro->Name()) != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
QVariant v = QVariant::fromValue(QString::fromStdString(macroName));
|
||||
QListWidgetItem *item = new QListWidgetItem(
|
||||
QString::fromStdString(macroName), _macroList);
|
||||
item->setData(Qt::UserRole, QString::fromStdString(macroName));
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_macros.push_back(macro);
|
||||
SetMacroListSize();
|
||||
}
|
||||
|
||||
void MacroActionRandomEdit::RemoveMacro()
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto item = _macroList->currentItem();
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
std::string name = item->data(Qt::UserRole).toString().toStdString();
|
||||
for (auto it = _entryData->_macros.begin();
|
||||
it != _entryData->_macros.end(); ++it) {
|
||||
auto m = *it;
|
||||
if (m.get() && m->Name() == name) {
|
||||
_entryData->_macros.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete item;
|
||||
SetMacroListSize();
|
||||
}
|
||||
|
||||
int MacroActionRandomEdit::FindEntry(const std::string ¯o)
|
||||
{
|
||||
int count = _macroList->count();
|
||||
int idx = -1;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
QListWidgetItem *item = _macroList->item(i);
|
||||
QString itemString = item->data(Qt::UserRole).toString();
|
||||
if (QString::fromStdString(macro) == itemString) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
void MacroActionRandomEdit::SetMacroListSize()
|
||||
{
|
||||
setHeightToContentHeight(_macroList);
|
||||
_list->SetContent(_entryData->_macros);
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void MacroActionRandomEdit::MacroRemove(const QString &)
|
||||
{
|
||||
if (!_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = _entryData->_macros.begin();
|
||||
while (it != _entryData->_macros.end()) {
|
||||
it->UpdateRef();
|
||||
if (it->get() == nullptr) {
|
||||
it = _entryData->_macros.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void MacroActionRandomEdit::Add(const std::string &name)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
MacroRef macro(name);
|
||||
_entryData->_macros.push_back(macro);
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void MacroActionRandomEdit::Remove(int idx)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_macros.erase(std::next(_entryData->_macros.begin(), idx));
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void MacroActionRandomEdit::Replace(int idx, const std::string &name)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
MacroRef macro(name);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_macros[idx] = macro;
|
||||
adjustSize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "macro-selection.hpp"
|
||||
#include "macro-list.hpp"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QListWidget>
|
||||
|
|
@ -46,19 +46,14 @@ public:
|
|||
|
||||
private slots:
|
||||
void MacroRemove(const QString &name);
|
||||
void MacroRename(const QString &oldName, const QString &newName);
|
||||
void AddMacro();
|
||||
void RemoveMacro();
|
||||
void Add(const std::string &);
|
||||
void Remove(int);
|
||||
void Replace(int, const std::string &);
|
||||
|
||||
protected:
|
||||
std::shared_ptr<MacroActionRandom> _entryData;
|
||||
|
||||
private:
|
||||
int FindEntry(const std::string ¯o);
|
||||
void SetMacroListSize();
|
||||
|
||||
QListWidget *_macroList;
|
||||
QPushButton *_add;
|
||||
QPushButton *_remove;
|
||||
MacroList *_list;
|
||||
bool _loading = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -89,78 +89,42 @@ bool MacroActionSequence::Load(obs_data_t *obj)
|
|||
|
||||
MacroActionSequenceEdit::MacroActionSequenceEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroActionSequence> entryData)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent),
|
||||
_list(new MacroList(this, true, true)),
|
||||
_continueFrom(new QPushButton(obs_module_text(
|
||||
"AdvSceneSwitcher.action.sequence.continueFrom"))),
|
||||
_restart(new QCheckBox(
|
||||
obs_module_text("AdvSceneSwitcher.action.sequence.restart"))),
|
||||
_statusLine(new QLabel())
|
||||
{
|
||||
_macroList = new QListWidget();
|
||||
_add = new QPushButton();
|
||||
_add->setMaximumSize(QSize(22, 22));
|
||||
_add->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("addIconSmall")));
|
||||
_add->setFlat(true);
|
||||
_remove = new QPushButton();
|
||||
_remove->setMaximumSize(QSize(22, 22));
|
||||
_remove->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("removeIconSmall")));
|
||||
_remove->setFlat(true);
|
||||
_up = new QPushButton();
|
||||
_up->setMaximumSize(QSize(22, 22));
|
||||
_up->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("upArrowIconSmall")));
|
||||
_up->setFlat(true);
|
||||
_down = new QPushButton();
|
||||
_down->setMaximumSize(QSize(22, 22));
|
||||
_down->setProperty("themeID",
|
||||
QVariant(QString::fromUtf8("downArrowIconSmall")));
|
||||
_down->setFlat(true);
|
||||
_continueFrom = new QPushButton(obs_module_text(
|
||||
"AdvSceneSwitcher.action.sequence.continueFrom"));
|
||||
_restart = new QCheckBox(
|
||||
obs_module_text("AdvSceneSwitcher.action.sequence.restart"));
|
||||
_statusLine = new QLabel();
|
||||
QFrame *line = new QFrame();
|
||||
line->setFrameShape(QFrame::VLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
_list->AddControl(line);
|
||||
_list->AddControl(_continueFrom);
|
||||
|
||||
QWidget::connect(_add, SIGNAL(clicked()), this, SLOT(Add()));
|
||||
QWidget::connect(_remove, SIGNAL(clicked()), this, SLOT(Remove()));
|
||||
QWidget::connect(_up, SIGNAL(clicked()), this, SLOT(Up()));
|
||||
QWidget::connect(_down, SIGNAL(clicked()), this, SLOT(Down()));
|
||||
QWidget::connect(_list, SIGNAL(Added(const std::string &)), this,
|
||||
SLOT(Add(const std::string &)));
|
||||
QWidget::connect(_list, SIGNAL(Removed(int)), this, SLOT(Remove(int)));
|
||||
QWidget::connect(_list, SIGNAL(MovedUp(int)), this, SLOT(Up(int)));
|
||||
QWidget::connect(_list, SIGNAL(MovedDown(int)), this, SLOT(Down(int)));
|
||||
QWidget::connect(_list, SIGNAL(Replaced(int, const std::string &)),
|
||||
this, SLOT(Replace(int, const std::string &)));
|
||||
QWidget::connect(_continueFrom, SIGNAL(clicked()), this,
|
||||
SLOT(ContinueFromClicked()));
|
||||
QWidget::connect(_macroList,
|
||||
SIGNAL(itemDoubleClicked(QListWidgetItem *)), this,
|
||||
SLOT(MacroItemClicked(QListWidgetItem *)));
|
||||
|
||||
QWidget::connect(window(),
|
||||
SIGNAL(MacroRenamed(const QString &, const QString &)),
|
||||
this,
|
||||
SLOT(MacroRename(const QString &, const QString &)));
|
||||
QWidget::connect(_restart, SIGNAL(stateChanged(int)), this,
|
||||
SLOT(RestartChanged(int)));
|
||||
QWidget::connect(window(), SIGNAL(MacroRemoved(const QString &)), this,
|
||||
SLOT(MacroRemove(const QString &)));
|
||||
|
||||
auto *entryLayout = new QHBoxLayout;
|
||||
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {};
|
||||
placeWidgets(obs_module_text("AdvSceneSwitcher.action.sequence.entry"),
|
||||
entryLayout, widgetPlaceholders);
|
||||
|
||||
auto *argButtonLayout = new QHBoxLayout;
|
||||
argButtonLayout->addWidget(_add);
|
||||
argButtonLayout->addWidget(_remove);
|
||||
QFrame *line = new QFrame();
|
||||
line->setFrameShape(QFrame::VLine);
|
||||
line->setFrameShadow(QFrame::Sunken);
|
||||
argButtonLayout->addWidget(line);
|
||||
argButtonLayout->addWidget(_up);
|
||||
argButtonLayout->addWidget(_down);
|
||||
QFrame *line2 = new QFrame();
|
||||
line2->setFrameShape(QFrame::VLine);
|
||||
line2->setFrameShadow(QFrame::Sunken);
|
||||
argButtonLayout->addWidget(line2);
|
||||
argButtonLayout->addWidget(_continueFrom);
|
||||
argButtonLayout->addStretch();
|
||||
|
||||
auto *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(entryLayout);
|
||||
mainLayout->addWidget(_macroList);
|
||||
mainLayout->addLayout(argButtonLayout);
|
||||
mainLayout->addLayout(argButtonLayout);
|
||||
mainLayout->addWidget(_list);
|
||||
mainLayout->addWidget(_restart);
|
||||
mainLayout->addWidget(_statusLine);
|
||||
setLayout(mainLayout);
|
||||
|
|
@ -181,146 +145,78 @@ void MacroActionSequenceEdit::UpdateEntryData()
|
|||
return;
|
||||
}
|
||||
|
||||
for (auto &m : _entryData->_macros) {
|
||||
if (!m.get()) {
|
||||
continue;
|
||||
}
|
||||
auto name = QString::fromStdString(m->Name());
|
||||
QListWidgetItem *item = new QListWidgetItem(name, _macroList);
|
||||
item->setData(Qt::UserRole, name);
|
||||
}
|
||||
SetMacroListSize();
|
||||
_list->SetContent(_entryData->_macros);
|
||||
_restart->setChecked(_entryData->_restart);
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void MacroActionSequenceEdit::MacroRemove(const QString &name)
|
||||
void MacroActionSequenceEdit::MacroRemove(const QString &)
|
||||
{
|
||||
if (_entryData) {
|
||||
auto it = _entryData->_macros.begin();
|
||||
while (it != _entryData->_macros.end()) {
|
||||
if (it->get()->Name() == name.toStdString()) {
|
||||
it = _entryData->_macros.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
if (!_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = _entryData->_macros.begin();
|
||||
while (it != _entryData->_macros.end()) {
|
||||
it->UpdateRef();
|
||||
if (it->get() == nullptr) {
|
||||
it = _entryData->_macros.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void MacroActionSequenceEdit::MacroRename(const QString &oldName,
|
||||
const QString &newName)
|
||||
{
|
||||
auto count = _macroList->count();
|
||||
for (int idx = 0; idx < count; ++idx) {
|
||||
QListWidgetItem *item = _macroList->item(idx);
|
||||
QString itemString = item->data(Qt::UserRole).toString();
|
||||
if (oldName == itemString) {
|
||||
item->setData(Qt::UserRole, newName);
|
||||
item->setText(newName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MacroActionSequenceEdit::Add()
|
||||
void MacroActionSequenceEdit::Add(const std::string &name)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string macroName;
|
||||
bool accepted = MacroSelectionDialog::AskForMacro(this, macroName);
|
||||
|
||||
if (!accepted || macroName.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MacroRef macro(macroName);
|
||||
|
||||
if (!macro.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QVariant v = QVariant::fromValue(QString::fromStdString(macroName));
|
||||
new QListWidgetItem(QString::fromStdString(macroName), _macroList);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
MacroRef macro(name);
|
||||
_entryData->_macros.push_back(macro);
|
||||
SetMacroListSize();
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void MacroActionSequenceEdit::Remove()
|
||||
void MacroActionSequenceEdit::Remove(int idx)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto item = _macroList->currentItem();
|
||||
int idx = _macroList->currentRow();
|
||||
if (!item || idx == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
_entryData->_macros.erase(std::next(_entryData->_macros.begin(), idx));
|
||||
|
||||
delete item;
|
||||
SetMacroListSize();
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void MacroActionSequenceEdit::Up()
|
||||
void MacroActionSequenceEdit::Up(int idx)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
int idx = _macroList->currentRow();
|
||||
if (idx != -1 && idx != 0) {
|
||||
_macroList->insertItem(idx - 1, _macroList->takeItem(idx));
|
||||
_macroList->setCurrentRow(idx - 1);
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
std::swap(_entryData->_macros[idx],
|
||||
_entryData->_macros[idx - 1]);
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
std::swap(_entryData->_macros[idx], _entryData->_macros[idx - 1]);
|
||||
}
|
||||
|
||||
void MacroActionSequenceEdit::Down()
|
||||
void MacroActionSequenceEdit::Down(int idx)
|
||||
{
|
||||
int idx = _macroList->currentRow();
|
||||
if (idx != -1 && idx != _macroList->count() - 1) {
|
||||
_macroList->insertItem(idx + 1, _macroList->takeItem(idx));
|
||||
_macroList->setCurrentRow(idx + 1);
|
||||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
std::swap(_entryData->_macros[idx],
|
||||
_entryData->_macros[idx + 1]);
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
std::swap(_entryData->_macros[idx], _entryData->_macros[idx + 1]);
|
||||
}
|
||||
|
||||
void MacroActionSequenceEdit::MacroItemClicked(QListWidgetItem *item)
|
||||
void MacroActionSequenceEdit::Replace(int idx, const std::string &name)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string macroName;
|
||||
bool accepted = MacroSelectionDialog::AskForMacro(this, macroName);
|
||||
|
||||
if (!accepted || macroName.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MacroRef macro(macroName);
|
||||
|
||||
if (!macro.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
item->setText(QString::fromStdString(macroName));
|
||||
int idx = _macroList->currentRow();
|
||||
MacroRef macro(name);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_macros[idx] = macro;
|
||||
SetMacroListSize();
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void MacroActionSequenceEdit::ContinueFromClicked()
|
||||
|
|
@ -329,7 +225,7 @@ void MacroActionSequenceEdit::ContinueFromClicked()
|
|||
return;
|
||||
}
|
||||
|
||||
int idx = _macroList->currentRow();
|
||||
int idx = _list->CurrentRow();
|
||||
if (idx == -1) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -368,26 +264,3 @@ void MacroActionSequenceEdit::UpdateStatusLine()
|
|||
obs_module_text("AdvSceneSwitcher.action.sequence.status")};
|
||||
_statusLine->setText(format.arg(lastMacroName, nextMacroName));
|
||||
}
|
||||
|
||||
int MacroActionSequenceEdit::FindEntry(const std::string ¯o)
|
||||
{
|
||||
int count = _macroList->count();
|
||||
int idx = -1;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
QListWidgetItem *item = _macroList->item(i);
|
||||
QString itemString = item->data(Qt::UserRole).toString();
|
||||
if (QString::fromStdString(macro) == itemString) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
void MacroActionSequenceEdit::SetMacroListSize()
|
||||
{
|
||||
setHeightToContentHeight(_macroList);
|
||||
adjustSize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "macro-selection.hpp"
|
||||
#include "macro-list.hpp"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QListWidget>
|
||||
|
|
@ -50,12 +50,11 @@ public:
|
|||
|
||||
private slots:
|
||||
void MacroRemove(const QString &name);
|
||||
void MacroRename(const QString &oldName, const QString &newName);
|
||||
void Add();
|
||||
void Remove();
|
||||
void Up();
|
||||
void Down();
|
||||
void MacroItemClicked(QListWidgetItem *);
|
||||
void Add(const std::string &);
|
||||
void Remove(int);
|
||||
void Up(int);
|
||||
void Down(int);
|
||||
void Replace(int, const std::string &);
|
||||
void ContinueFromClicked();
|
||||
void RestartChanged(int state);
|
||||
void UpdateStatusLine();
|
||||
|
|
@ -64,14 +63,7 @@ protected:
|
|||
std::shared_ptr<MacroActionSequence> _entryData;
|
||||
|
||||
private:
|
||||
int FindEntry(const std::string ¯o);
|
||||
void SetMacroListSize();
|
||||
|
||||
QListWidget *_macroList;
|
||||
QPushButton *_add;
|
||||
QPushButton *_remove;
|
||||
QPushButton *_up;
|
||||
QPushButton *_down;
|
||||
MacroList *_list;
|
||||
QPushButton *_continueFrom;
|
||||
QCheckBox *_restart;
|
||||
QLabel *_statusLine;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user