mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-07 09:05:57 -05:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cdacfc946c | ||
|
|
26e854f0a3 | ||
|
|
2bc89364b2 | ||
|
|
e080d2de9b | ||
|
|
ca1262aeb7 | ||
|
|
cbc95e2095 | ||
|
|
9c5051cbf8 | ||
|
|
e6ca3390a2 | ||
|
|
e74b531905 |
@@ -124,6 +124,7 @@ AdvSceneSwitcher.macroTab.rename="Rename"
|
|||||||
AdvSceneSwitcher.macroTab.remove="Remove"
|
AdvSceneSwitcher.macroTab.remove="Remove"
|
||||||
AdvSceneSwitcher.macroTab.export="Export"
|
AdvSceneSwitcher.macroTab.export="Export"
|
||||||
AdvSceneSwitcher.macroTab.export.info="Paste the string below into the import dialog to import the selected macros:"
|
AdvSceneSwitcher.macroTab.export.info="Paste the string below into the import dialog to import the selected macros:"
|
||||||
|
AdvSceneSwitcher.macroTab.export.usePlainText="Use plain text"
|
||||||
AdvSceneSwitcher.macroTab.import="Import"
|
AdvSceneSwitcher.macroTab.import="Import"
|
||||||
AdvSceneSwitcher.macroTab.import.info="Paste the export string into the below text box to import macros:"
|
AdvSceneSwitcher.macroTab.import.info="Paste the export string into the below text box to import macros:"
|
||||||
AdvSceneSwitcher.macroTab.import.invalid="Invalid import data provided!"
|
AdvSceneSwitcher.macroTab.import.invalid="Invalid import data provided!"
|
||||||
@@ -132,6 +133,9 @@ AdvSceneSwitcher.macroTab.expandAll="Expand all"
|
|||||||
AdvSceneSwitcher.macroTab.collapseAll="Collapse all"
|
AdvSceneSwitcher.macroTab.collapseAll="Collapse all"
|
||||||
AdvSceneSwitcher.macroTab.maximize="Maximize"
|
AdvSceneSwitcher.macroTab.maximize="Maximize"
|
||||||
AdvSceneSwitcher.macroTab.minimize="Minimize"
|
AdvSceneSwitcher.macroTab.minimize="Minimize"
|
||||||
|
AdvSceneSwitcher.macroTab.segment.useCustomLabel="Use custom label"
|
||||||
|
AdvSceneSwitcher.macroTab.segment.defaultCustomLabel="My label"
|
||||||
|
AdvSceneSwitcher.macroTab.segment.setCustomLabel="Set label ..."
|
||||||
AdvSceneSwitcher.macroTab.highlightSettings="Visual settings"
|
AdvSceneSwitcher.macroTab.highlightSettings="Visual settings"
|
||||||
AdvSceneSwitcher.macroTab.hotkeySettings="Hotkey settings"
|
AdvSceneSwitcher.macroTab.hotkeySettings="Hotkey settings"
|
||||||
AdvSceneSwitcher.macroTab.generalSettings="General settings"
|
AdvSceneSwitcher.macroTab.generalSettings="General settings"
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ void AdvSceneSwitcher::on_sceneGroupAdd_clicked()
|
|||||||
placeHolderText = format.arg(++i);
|
placeHolderText = format.arg(++i);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool accepted = AdvSSNameDialog::AskForName(
|
bool accepted = NameDialog::AskForName(
|
||||||
this, obs_module_text("AdvSceneSwitcher.sceneGroupTab.add"),
|
this, obs_module_text("AdvSceneSwitcher.sceneGroupTab.add"),
|
||||||
obs_module_text("AdvSceneSwitcher.sceneGroupTab.add"), name,
|
obs_module_text("AdvSceneSwitcher.sceneGroupTab.add"), name,
|
||||||
placeHolderText);
|
placeHolderText);
|
||||||
|
|||||||
@@ -8,9 +8,13 @@
|
|||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
|
static bool usePlainText = false;
|
||||||
|
|
||||||
MacroExportImportDialog::MacroExportImportDialog(Type type)
|
MacroExportImportDialog::MacroExportImportDialog(Type type)
|
||||||
: QDialog(nullptr),
|
: QDialog(nullptr),
|
||||||
_importExportString(new QPlainTextEdit(this))
|
_importExportString(new QPlainTextEdit(this)),
|
||||||
|
_usePlainText(new QCheckBox(obs_module_text(
|
||||||
|
"AdvSceneSwitcher.macroTab.export.usePlainText")))
|
||||||
{
|
{
|
||||||
_importExportString->setReadOnly(type == Type::EXPORT_MACRO);
|
_importExportString->setReadOnly(type == Type::EXPORT_MACRO);
|
||||||
auto label = new QLabel(obs_module_text(
|
auto label = new QLabel(obs_module_text(
|
||||||
@@ -30,9 +34,15 @@ MacroExportImportDialog::MacroExportImportDialog(Type type)
|
|||||||
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
buttons->setCenterButtons(true);
|
buttons->setCenterButtons(true);
|
||||||
|
|
||||||
|
_usePlainText->setChecked(usePlainText);
|
||||||
|
_usePlainText->setVisible(type == Type::EXPORT_MACRO);
|
||||||
|
connect(_usePlainText, &QCheckBox::stateChanged, this,
|
||||||
|
&MacroExportImportDialog::UsePlainTextChanged);
|
||||||
|
|
||||||
auto layout = new QVBoxLayout;
|
auto layout = new QVBoxLayout;
|
||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
layout->addWidget(_importExportString);
|
layout->addWidget(_importExportString);
|
||||||
|
layout->addWidget(_usePlainText);
|
||||||
layout->addWidget(buttons);
|
layout->addWidget(buttons);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
@@ -65,6 +75,21 @@ void MacroExportImportDialog::ExportMacros(const QString &json)
|
|||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MacroExportImportDialog::UsePlainTextChanged(int value)
|
||||||
|
{
|
||||||
|
if (usePlainText == (!!value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto current = _importExportString->toPlainText();
|
||||||
|
if (usePlainText) {
|
||||||
|
_importExportString->setPlainText(compressMacroString(current));
|
||||||
|
} else {
|
||||||
|
_importExportString->setPlainText(
|
||||||
|
decompressMacroString(current));
|
||||||
|
}
|
||||||
|
usePlainText = value;
|
||||||
|
}
|
||||||
|
|
||||||
static bool isValidData(const QString &json)
|
static bool isValidData(const QString &json)
|
||||||
{
|
{
|
||||||
OBSDataAutoRelease data =
|
OBSDataAutoRelease data =
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
|
||||||
@@ -13,8 +14,12 @@ public:
|
|||||||
static void ExportMacros(const QString &json);
|
static void ExportMacros(const QString &json);
|
||||||
static bool ImportMacros(QString &json);
|
static bool ImportMacros(QString &json);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void UsePlainTextChanged(int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPlainTextEdit *_importExportString;
|
QPlainTextEdit *_importExportString;
|
||||||
|
QCheckBox *_usePlainText;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -246,6 +246,11 @@ MacroSegmentEdit *MacroSegmentList::WidgetAt(int idx)
|
|||||||
return static_cast<MacroSegmentEdit *>(item->widget());
|
return static_cast<MacroSegmentEdit *>(item->widget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MacroSegmentEdit *MacroSegmentList::WidgetAt(const QPoint &pos)
|
||||||
|
{
|
||||||
|
return WidgetAt(GetSegmentIndexFromPos(mapToGlobal(pos)));
|
||||||
|
}
|
||||||
|
|
||||||
void MacroSegmentList::HideLastDropLine()
|
void MacroSegmentList::HideLastDropLine()
|
||||||
{
|
{
|
||||||
if (_dropLineIdx >= 0 && _dropLineIdx < _contentLayout->count()) {
|
if (_dropLineIdx >= 0 && _dropLineIdx < _contentLayout->count()) {
|
||||||
@@ -319,7 +324,7 @@ QRect MacroSegmentList::GetContentItemRectWithPadding(int idx)
|
|||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MacroSegmentList::GetWidgetIdx(const QPoint &pos)
|
int MacroSegmentList::GetSegmentIndexFromPos(const QPoint &pos)
|
||||||
{
|
{
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
for (int i = 0; i < _contentLayout->count(); ++i) {
|
for (int i = 0; i < _contentLayout->count(); ++i) {
|
||||||
@@ -359,7 +364,7 @@ void MacroSegmentList::CheckScroll()
|
|||||||
|
|
||||||
void MacroSegmentList::CheckDropLine(const QPoint &pos)
|
void MacroSegmentList::CheckDropLine(const QPoint &pos)
|
||||||
{
|
{
|
||||||
int idx = GetWidgetIdx(pos);
|
int idx = GetSegmentIndexFromPos(pos);
|
||||||
if (idx == _dragPosition) {
|
if (idx == _dragPosition) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -410,7 +415,7 @@ bool MacroSegmentList::IsInListArea(const QPoint &pos)
|
|||||||
|
|
||||||
int MacroSegmentList::GetDropIndex(const QPoint &pos)
|
int MacroSegmentList::GetDropIndex(const QPoint &pos)
|
||||||
{
|
{
|
||||||
int idx = GetWidgetIdx(pos);
|
int idx = GetSegmentIndexFromPos(pos);
|
||||||
if (idx == _dragPosition) {
|
if (idx == _dragPosition) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public:
|
|||||||
void SetHelpMsg(const QString &msg);
|
void SetHelpMsg(const QString &msg);
|
||||||
void SetHelpMsgVisible(bool visible);
|
void SetHelpMsgVisible(bool visible);
|
||||||
MacroSegmentEdit *WidgetAt(int idx);
|
MacroSegmentEdit *WidgetAt(int idx);
|
||||||
|
MacroSegmentEdit *WidgetAt(const QPoint &);
|
||||||
void Insert(int idx, MacroSegmentEdit *widget);
|
void Insert(int idx, MacroSegmentEdit *widget);
|
||||||
void Add(QWidget *widget);
|
void Add(QWidget *widget);
|
||||||
void Remove(int idx);
|
void Remove(int idx);
|
||||||
@@ -44,7 +45,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
int GetDragIndex(const QPoint &);
|
int GetDragIndex(const QPoint &);
|
||||||
int GetDropIndex(const QPoint &);
|
int GetDropIndex(const QPoint &);
|
||||||
int GetWidgetIdx(const QPoint &);
|
int GetSegmentIndexFromPos(const QPoint &);
|
||||||
void CheckScroll();
|
void CheckScroll();
|
||||||
void CheckDropLine(const QPoint &);
|
void CheckDropLine(const QPoint &);
|
||||||
bool IsInListArea(const QPoint &);
|
bool IsInListArea(const QPoint &);
|
||||||
|
|||||||
@@ -20,13 +20,30 @@ MacroSegment::MacroSegment(Macro *m, bool supportsVariableValue)
|
|||||||
|
|
||||||
bool MacroSegment::Save(obs_data_t *obj) const
|
bool MacroSegment::Save(obs_data_t *obj) const
|
||||||
{
|
{
|
||||||
obs_data_set_bool(obj, "collapsed", static_cast<int>(_collapsed));
|
OBSDataAutoRelease data = obs_data_create();
|
||||||
|
obs_data_set_bool(data, "collapsed", _collapsed);
|
||||||
|
obs_data_set_bool(data, "useCustomLabel", _useCustomLabel);
|
||||||
|
obs_data_set_string(data, "customLabel", _customLabel.c_str());
|
||||||
|
obs_data_set_obj(obj, "segmentSettings", data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MacroSegment::Load(obs_data_t *obj)
|
bool MacroSegment::Load(obs_data_t *obj)
|
||||||
{
|
{
|
||||||
_collapsed = obs_data_get_bool(obj, "collapsed");
|
// TODO: remove this fallback at some point
|
||||||
|
if (obs_data_has_user_value(obj, "segmentSettings")) {
|
||||||
|
OBSDataAutoRelease data =
|
||||||
|
obs_data_get_obj(obj, "segmentSettings");
|
||||||
|
_collapsed = obs_data_get_bool(data, "collapsed");
|
||||||
|
_useCustomLabel = obs_data_get_bool(data, "useCustomLabel");
|
||||||
|
_customLabel = obs_data_get_string(data, "customLabel");
|
||||||
|
} else {
|
||||||
|
_collapsed = obs_data_get_bool(obj, "collapsed");
|
||||||
|
_useCustomLabel = false;
|
||||||
|
_customLabel = obs_module_text(
|
||||||
|
"AdvSceneSwitcher.macroTab.segment.defaultCustomLabel");
|
||||||
|
}
|
||||||
|
|
||||||
ClearAvailableTempvars();
|
ClearAvailableTempvars();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -296,6 +313,12 @@ bool MacroSegmentEdit::eventFilter(QObject *obj, QEvent *ev)
|
|||||||
|
|
||||||
void MacroSegmentEdit::HeaderInfoChanged(const QString &text)
|
void MacroSegmentEdit::HeaderInfoChanged(const QString &text)
|
||||||
{
|
{
|
||||||
|
if (Data() && Data()->GetUseCustomLabel()) {
|
||||||
|
_headerInfo->show();
|
||||||
|
_headerInfo->setText(
|
||||||
|
QString::fromStdString(Data()->GetCustomLabel()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
_headerInfo->setVisible(!text.isEmpty());
|
_headerInfo->setVisible(!text.isEmpty());
|
||||||
_headerInfo->setText(text);
|
_headerInfo->setText(text);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ public:
|
|||||||
int GetIndex() const { return _idx; }
|
int GetIndex() const { return _idx; }
|
||||||
void SetCollapsed(bool collapsed) { _collapsed = collapsed; }
|
void SetCollapsed(bool collapsed) { _collapsed = collapsed; }
|
||||||
bool GetCollapsed() const { return _collapsed; }
|
bool GetCollapsed() const { return _collapsed; }
|
||||||
|
void SetUseCustomLabel(bool enable) { _useCustomLabel = enable; }
|
||||||
|
bool GetUseCustomLabel() const { return _useCustomLabel; }
|
||||||
|
void SetCustomLabel(const std::string &label) { _customLabel = label; }
|
||||||
|
std::string GetCustomLabel() const { return _customLabel; }
|
||||||
virtual bool Save(obs_data_t *obj) const = 0;
|
virtual bool Save(obs_data_t *obj) const = 0;
|
||||||
virtual bool Load(obs_data_t *obj) = 0;
|
virtual bool Load(obs_data_t *obj) = 0;
|
||||||
virtual bool PostLoad();
|
virtual bool PostLoad();
|
||||||
@@ -63,6 +67,11 @@ private:
|
|||||||
bool _highlight = false;
|
bool _highlight = false;
|
||||||
bool _collapsed = false;
|
bool _collapsed = false;
|
||||||
|
|
||||||
|
// Custom header labels
|
||||||
|
bool _useCustomLabel = false;
|
||||||
|
std::string _customLabel = obs_module_text(
|
||||||
|
"AdvSceneSwitcher.macroTab.segment.defaultCustomLabel");
|
||||||
|
|
||||||
// Variable helpers
|
// Variable helpers
|
||||||
const bool _supportsVariableValue = false;
|
const bool _supportsVariableValue = false;
|
||||||
int _variableRefs = 0;
|
int _variableRefs = 0;
|
||||||
@@ -86,8 +95,10 @@ public:
|
|||||||
void SetSelected(bool);
|
void SetSelected(bool);
|
||||||
virtual std::shared_ptr<MacroSegment> Data() const = 0;
|
virtual std::shared_ptr<MacroSegment> Data() const = 0;
|
||||||
|
|
||||||
protected slots:
|
public slots:
|
||||||
void HeaderInfoChanged(const QString &);
|
void HeaderInfoChanged(const QString &);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
void Collapsed(bool);
|
void Collapsed(bool);
|
||||||
void Highlight();
|
void Highlight();
|
||||||
void EnableHighlight(bool);
|
void EnableHighlight(bool);
|
||||||
|
|||||||
@@ -95,7 +95,9 @@ void MacroSelection::MacroRename(const QString &oldName, const QString &newName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MacroSelectionDialog::MacroSelectionDialog(QWidget *)
|
MacroSelectionDialog::MacroSelectionDialog(QWidget *parent)
|
||||||
|
: QDialog(parent),
|
||||||
|
_macroSelection(new MacroSelection(this))
|
||||||
{
|
{
|
||||||
setModal(true);
|
setModal(true);
|
||||||
setWindowModality(Qt::WindowModality::ApplicationModal);
|
setWindowModality(Qt::WindowModality::ApplicationModal);
|
||||||
@@ -103,21 +105,20 @@ MacroSelectionDialog::MacroSelectionDialog(QWidget *)
|
|||||||
setMinimumWidth(350);
|
setMinimumWidth(350);
|
||||||
setMinimumHeight(70);
|
setMinimumHeight(70);
|
||||||
|
|
||||||
QDialogButtonBox *buttonbox = new QDialogButtonBox(
|
auto buttonbox = new QDialogButtonBox(QDialogButtonBox::Ok |
|
||||||
QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
buttonbox->setCenterButtons(true);
|
buttonbox->setCenterButtons(true);
|
||||||
connect(buttonbox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
connect(buttonbox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
|
||||||
_macroSelection = new MacroSelection(window());
|
auto selectionLayout = new QHBoxLayout;
|
||||||
auto *selectionLayout = new QHBoxLayout;
|
|
||||||
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
||||||
{"{{macroSelection}}", _macroSelection},
|
{"{{macroSelection}}", _macroSelection},
|
||||||
};
|
};
|
||||||
PlaceWidgets(obs_module_text("AdvSceneSwitcher.askForMacro"),
|
PlaceWidgets(obs_module_text("AdvSceneSwitcher.askForMacro"),
|
||||||
selectionLayout, widgetPlaceholders);
|
selectionLayout, widgetPlaceholders);
|
||||||
auto *layout = new QVBoxLayout();
|
auto layout = new QVBoxLayout();
|
||||||
layout->addLayout(selectionLayout);
|
layout->addLayout(selectionLayout);
|
||||||
layout->addWidget(buttonbox);
|
layout->addWidget(buttonbox);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
@@ -125,7 +126,7 @@ MacroSelectionDialog::MacroSelectionDialog(QWidget *)
|
|||||||
|
|
||||||
bool MacroSelectionDialog::AskForMacro(QWidget *parent, std::string ¯oName)
|
bool MacroSelectionDialog::AskForMacro(QWidget *parent, std::string ¯oName)
|
||||||
{
|
{
|
||||||
MacroSelectionDialog dialog(parent);
|
MacroSelectionDialog dialog(GetSettingsWindow());
|
||||||
dialog.setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle"));
|
dialog.setWindowTitle(obs_module_text("AdvSceneSwitcher.windowTitle"));
|
||||||
|
|
||||||
if (dialog.exec() != DialogCode::Accepted) {
|
if (dialog.exec() != DialogCode::Accepted) {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ bool AdvSceneSwitcher::AddNewMacro(std::shared_ptr<Macro> &res,
|
|||||||
placeHolderText = fmt.arg(++i);
|
placeHolderText = fmt.arg(++i);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool accepted = AdvSSNameDialog::AskForName(
|
bool accepted = NameDialog::AskForName(
|
||||||
this, obs_module_text("AdvSceneSwitcher.macroTab.add"),
|
this, obs_module_text("AdvSceneSwitcher.macroTab.add"),
|
||||||
obs_module_text("AdvSceneSwitcher.macroTab.name"), name,
|
obs_module_text("AdvSceneSwitcher.macroTab.name"), name,
|
||||||
placeHolderText);
|
placeHolderText);
|
||||||
@@ -199,7 +199,7 @@ void AdvSceneSwitcher::RenameSelectedMacro()
|
|||||||
|
|
||||||
std::string oldName = macro->Name();
|
std::string oldName = macro->Name();
|
||||||
std::string name;
|
std::string name;
|
||||||
if (!AdvSSNameDialog::AskForName(
|
if (!NameDialog::AskForName(
|
||||||
this, obs_module_text("AdvSceneSwitcher.windowTitle"),
|
this, obs_module_text("AdvSceneSwitcher.windowTitle"),
|
||||||
obs_module_text("AdvSceneSwitcher.item.newName"), name,
|
obs_module_text("AdvSceneSwitcher.item.newName"), name,
|
||||||
QString::fromStdString(oldName))) {
|
QString::fromStdString(oldName))) {
|
||||||
@@ -370,7 +370,7 @@ bool AdvSceneSwitcher::ResolveMacroImportNameConflict(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string newName;
|
std::string newName;
|
||||||
bool accepted = AdvSSNameDialog::AskForName(
|
bool accepted = NameDialog::AskForName(
|
||||||
this,
|
this,
|
||||||
obs_module_text(macro->IsGroup()
|
obs_module_text(macro->IsGroup()
|
||||||
? "AdvSceneSwitcher.macroTab.addGroup"
|
? "AdvSceneSwitcher.macroTab.addGroup"
|
||||||
@@ -943,11 +943,39 @@ void AdvSceneSwitcher::ShowMacroContextMenu(const QPoint &pos)
|
|||||||
menu.exec(globalPos);
|
menu.exec(globalPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handleCustomLabelChange(MacroSegmentEdit *segmentEdit,
|
||||||
|
QAction *contextMenuOption)
|
||||||
|
{
|
||||||
|
bool enable = contextMenuOption->isChecked();
|
||||||
|
auto segment = segmentEdit->Data();
|
||||||
|
segment->SetUseCustomLabel(enable);
|
||||||
|
if (!enable) {
|
||||||
|
segmentEdit->HeaderInfoChanged(
|
||||||
|
QString::fromStdString(segment->GetShortDesc()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string label;
|
||||||
|
bool accepted = NameDialog::AskForName(
|
||||||
|
GetSettingsWindow(),
|
||||||
|
obs_module_text(
|
||||||
|
"AdvSceneSwitcher.macroTab.segment.setCustomLabel"),
|
||||||
|
"", label, QString::fromStdString(segment->GetCustomLabel()));
|
||||||
|
if (!accepted) {
|
||||||
|
segment->SetUseCustomLabel(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
segment->SetCustomLabel(label);
|
||||||
|
segmentEdit->HeaderInfoChanged("");
|
||||||
|
}
|
||||||
|
|
||||||
static void setupConextMenu(AdvSceneSwitcher *ss, const QPoint &pos,
|
static void setupConextMenu(AdvSceneSwitcher *ss, const QPoint &pos,
|
||||||
std::function<void(AdvSceneSwitcher *)> expand,
|
std::function<void(AdvSceneSwitcher *)> expand,
|
||||||
std::function<void(AdvSceneSwitcher *)> collapse,
|
std::function<void(AdvSceneSwitcher *)> collapse,
|
||||||
std::function<void(AdvSceneSwitcher *)> maximize,
|
std::function<void(AdvSceneSwitcher *)> maximize,
|
||||||
std::function<void(AdvSceneSwitcher *)> minimize)
|
std::function<void(AdvSceneSwitcher *)> minimize,
|
||||||
|
MacroSegmentList *list)
|
||||||
{
|
{
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
menu.addAction(obs_module_text("AdvSceneSwitcher.macroTab.expandAll"),
|
menu.addAction(obs_module_text("AdvSceneSwitcher.macroTab.expandAll"),
|
||||||
@@ -958,34 +986,46 @@ static void setupConextMenu(AdvSceneSwitcher *ss, const QPoint &pos,
|
|||||||
ss, [ss, maximize]() { maximize(ss); });
|
ss, [ss, maximize]() { maximize(ss); });
|
||||||
menu.addAction(obs_module_text("AdvSceneSwitcher.macroTab.minimize"),
|
menu.addAction(obs_module_text("AdvSceneSwitcher.macroTab.minimize"),
|
||||||
ss, [ss, minimize]() { minimize(ss); });
|
ss, [ss, minimize]() { minimize(ss); });
|
||||||
menu.exec(pos);
|
|
||||||
|
auto segmentEdit = list->WidgetAt(pos);
|
||||||
|
if (segmentEdit) {
|
||||||
|
auto customLabel = menu.addAction(obs_module_text(
|
||||||
|
"AdvSceneSwitcher.macroTab.segment.useCustomLabel"));
|
||||||
|
customLabel->setCheckable(true);
|
||||||
|
auto segment = segmentEdit ? segmentEdit->Data() : nullptr;
|
||||||
|
customLabel->setChecked(segment &&
|
||||||
|
segment->GetUseCustomLabel());
|
||||||
|
QWidget::connect(customLabel, &QAction::triggered,
|
||||||
|
std::bind(handleCustomLabelChange, segmentEdit,
|
||||||
|
customLabel));
|
||||||
|
}
|
||||||
|
menu.exec(list->mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::ShowMacroActionsContextMenu(const QPoint &pos)
|
void AdvSceneSwitcher::ShowMacroActionsContextMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
setupConextMenu(this, ui->actionsList->mapToGlobal(pos),
|
setupConextMenu(this, pos, &AdvSceneSwitcher::ExpandAllActions,
|
||||||
&AdvSceneSwitcher::ExpandAllActions,
|
|
||||||
&AdvSceneSwitcher::CollapseAllActions,
|
&AdvSceneSwitcher::CollapseAllActions,
|
||||||
&AdvSceneSwitcher::MaximizeActions,
|
&AdvSceneSwitcher::MaximizeActions,
|
||||||
&AdvSceneSwitcher::MinimizeActions);
|
&AdvSceneSwitcher::MinimizeActions, ui->actionsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::ShowMacroElseActionsContextMenu(const QPoint &pos)
|
void AdvSceneSwitcher::ShowMacroElseActionsContextMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
setupConextMenu(this, ui->elseActionsList->mapToGlobal(pos),
|
setupConextMenu(this, pos, &AdvSceneSwitcher::ExpandAllElseActions,
|
||||||
&AdvSceneSwitcher::ExpandAllElseActions,
|
|
||||||
&AdvSceneSwitcher::CollapseAllElseActions,
|
&AdvSceneSwitcher::CollapseAllElseActions,
|
||||||
&AdvSceneSwitcher::MaximizeElseActions,
|
&AdvSceneSwitcher::MaximizeElseActions,
|
||||||
&AdvSceneSwitcher::MinimizeElseActions);
|
&AdvSceneSwitcher::MinimizeElseActions,
|
||||||
|
ui->elseActionsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::ShowMacroConditionsContextMenu(const QPoint &pos)
|
void AdvSceneSwitcher::ShowMacroConditionsContextMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
setupConextMenu(this, ui->conditionsList->mapToGlobal(pos),
|
setupConextMenu(this, pos, &AdvSceneSwitcher::ExpandAllConditions,
|
||||||
&AdvSceneSwitcher::ExpandAllConditions,
|
|
||||||
&AdvSceneSwitcher::CollapseAllConditions,
|
&AdvSceneSwitcher::CollapseAllConditions,
|
||||||
&AdvSceneSwitcher::MaximizeConditions,
|
&AdvSceneSwitcher::MaximizeConditions,
|
||||||
&AdvSceneSwitcher::MinimizeConditions);
|
&AdvSceneSwitcher::MinimizeConditions,
|
||||||
|
ui->conditionsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvSceneSwitcher::CopyMacro()
|
void AdvSceneSwitcher::CopyMacro()
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ void ItemSelection::RenameItem()
|
|||||||
Item *item = variant.value<Item *>();
|
Item *item = variant.value<Item *>();
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
bool accepted = AdvSSNameDialog::AskForName(
|
bool accepted = NameDialog::AskForName(
|
||||||
this, obs_module_text("AdvSceneSwitcher.windowTitle"),
|
this, obs_module_text("AdvSceneSwitcher.windowTitle"),
|
||||||
obs_module_text("AdvSceneSwitcher.item.newName"), name,
|
obs_module_text("AdvSceneSwitcher.item.newName"), name,
|
||||||
QString::fromStdString(item->Name()));
|
QString::fromStdString(item->Name()));
|
||||||
|
|||||||
@@ -5,22 +5,22 @@
|
|||||||
|
|
||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
AdvSSNameDialog::AdvSSNameDialog(QWidget *parent) : QDialog(parent)
|
NameDialog::NameDialog(QWidget *parent)
|
||||||
|
: QDialog(parent),
|
||||||
|
_label(new QLabel(this)),
|
||||||
|
_userText(new QLineEdit(this))
|
||||||
|
|
||||||
{
|
{
|
||||||
setModal(true);
|
setModal(true);
|
||||||
setWindowModality(Qt::WindowModality::WindowModal);
|
setWindowModality(Qt::WindowModality::WindowModal);
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
setFixedWidth(555);
|
setFixedWidth(555);
|
||||||
setMinimumHeight(100);
|
setMinimumHeight(100);
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
auto layout = new QVBoxLayout;
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
label = new QLabel(this);
|
layout->addWidget(_label);
|
||||||
layout->addWidget(label);
|
layout->addWidget(_userText);
|
||||||
label->setText("Set Text");
|
|
||||||
|
|
||||||
userText = new QLineEdit(this);
|
|
||||||
layout->addWidget(userText);
|
|
||||||
|
|
||||||
QDialogButtonBox *buttonbox = new QDialogButtonBox(
|
QDialogButtonBox *buttonbox = new QDialogButtonBox(
|
||||||
QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
@@ -30,43 +30,44 @@ AdvSSNameDialog::AdvSSNameDialog(QWidget *parent) : QDialog(parent)
|
|||||||
connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsWhitespace(char ch)
|
static bool isWhitespace(char ch)
|
||||||
{
|
{
|
||||||
return ch == ' ' || ch == '\t';
|
return ch == ' ' || ch == '\t';
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CleanWhitespace(std::string &str)
|
static void cleanWhitespace(std::string &str)
|
||||||
{
|
{
|
||||||
while (str.size() && IsWhitespace(str.back()))
|
while (str.size() && isWhitespace(str.back())) {
|
||||||
str.erase(str.end() - 1);
|
str.erase(str.end() - 1);
|
||||||
while (str.size() && IsWhitespace(str.front()))
|
}
|
||||||
|
while (str.size() && isWhitespace(str.front())) {
|
||||||
str.erase(str.begin());
|
str.erase(str.begin());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AdvSSNameDialog::AskForName(QWidget *parent, const QString &title,
|
bool NameDialog::AskForName(QWidget *parent, const QString &title,
|
||||||
const QString &text,
|
const QString &prompt, std::string &userTextInput,
|
||||||
std::string &userTextInput,
|
const QString &placeHolder, int maxSize, bool clean)
|
||||||
const QString &placeHolder, int maxSize,
|
|
||||||
bool clean)
|
|
||||||
{
|
{
|
||||||
if (maxSize <= 0 || maxSize > 32767) {
|
if (maxSize <= 0 || maxSize > 32767) {
|
||||||
maxSize = 170;
|
maxSize = 170;
|
||||||
}
|
}
|
||||||
|
|
||||||
AdvSSNameDialog dialog(parent);
|
NameDialog dialog(parent);
|
||||||
dialog.setWindowTitle(title);
|
dialog.setWindowTitle(title);
|
||||||
|
|
||||||
dialog.label->setText(text);
|
dialog._label->setVisible(!prompt.isEmpty());
|
||||||
dialog.userText->setMaxLength(maxSize);
|
dialog._label->setText(prompt);
|
||||||
dialog.userText->setText(placeHolder);
|
dialog._userText->setMaxLength(maxSize);
|
||||||
dialog.userText->selectAll();
|
dialog._userText->setText(placeHolder);
|
||||||
|
dialog._userText->selectAll();
|
||||||
|
|
||||||
if (dialog.exec() != DialogCode::Accepted) {
|
if (dialog.exec() != DialogCode::Accepted) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
userTextInput = dialog.userText->text().toUtf8().constData();
|
userTextInput = dialog._userText->text().toUtf8().constData();
|
||||||
if (clean) {
|
if (clean) {
|
||||||
CleanWhitespace(userTextInput);
|
cleanWhitespace(userTextInput);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,23 +8,23 @@
|
|||||||
namespace advss {
|
namespace advss {
|
||||||
|
|
||||||
// Based on OBS's NameDialog
|
// Based on OBS's NameDialog
|
||||||
class AdvSSNameDialog : public QDialog {
|
class NameDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AdvSSNameDialog(QWidget *parent);
|
NameDialog(QWidget *parent);
|
||||||
|
|
||||||
// Returns true if user clicks OK, false otherwise
|
// Returns true if user clicks OK, false otherwise
|
||||||
// userTextInput returns string that user typed into dialog
|
// userTextInput returns string that user typed into dialog
|
||||||
EXPORT static bool AskForName(QWidget *parent, const QString &title,
|
EXPORT static bool AskForName(QWidget *parent, const QString &title,
|
||||||
const QString &text,
|
const QString &prompt,
|
||||||
std::string &userTextInput,
|
std::string &userTextInput,
|
||||||
const QString &placeHolder = QString(""),
|
const QString &placeHolder = QString(""),
|
||||||
int maxSize = 170, bool clean = true);
|
int maxSize = 170, bool clean = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel *label;
|
QLabel *_label;
|
||||||
QLineEdit *userText;
|
QLineEdit *_userText;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace advss
|
} // namespace advss
|
||||||
|
|||||||
@@ -250,6 +250,8 @@ TempVariableSelection::TempVariableSelection(QWidget *parent)
|
|||||||
_info->setPixmap(pixmap);
|
_info->setPixmap(pixmap);
|
||||||
_info->hide();
|
_info->hide();
|
||||||
|
|
||||||
|
_selection->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||||
|
_selection->setMaximumWidth(350);
|
||||||
_selection->setDuplicatesEnabled(true);
|
_selection->setDuplicatesEnabled(true);
|
||||||
PopulateSelection();
|
PopulateSelection();
|
||||||
|
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ void SceneItemSelection::Save(obs_data_t *obj, const char *name) const
|
|||||||
break;
|
break;
|
||||||
case SceneItemSelection::Type::INDEX_RANGE:
|
case SceneItemSelection::Type::INDEX_RANGE:
|
||||||
_index.Save(data, indexSaveName.data());
|
_index.Save(data, indexSaveName.data());
|
||||||
_index.Save(data, indexEndSaveName.data());
|
_indexEnd.Save(data, indexEndSaveName.data());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -648,8 +648,10 @@ SceneItemSelectionWidget::SceneItemSelectionWidget(QWidget *parent,
|
|||||||
"AdvSceneSwitcher.sceneItemSelection.configure"));
|
"AdvSceneSwitcher.sceneItemSelection.configure"));
|
||||||
|
|
||||||
_index->setMinimum(1);
|
_index->setMinimum(1);
|
||||||
|
_index->setMaximum(999);
|
||||||
_index->setSuffix(".");
|
_index->setSuffix(".");
|
||||||
_indexEnd->setMinimum(1);
|
_indexEnd->setMinimum(1);
|
||||||
|
_indexEnd->setMaximum(999);
|
||||||
_indexEnd->setSuffix(".");
|
_indexEnd->setSuffix(".");
|
||||||
|
|
||||||
populateSourceGroupSelection(_sourceGroups);
|
populateSourceGroupSelection(_sourceGroups);
|
||||||
|
|||||||
@@ -243,6 +243,9 @@ SourceSettingSelection::SourceSettingSelection(QWidget *parent)
|
|||||||
_tooltip->setPixmap(pixmap);
|
_tooltip->setPixmap(pixmap);
|
||||||
_tooltip->hide();
|
_tooltip->hide();
|
||||||
|
|
||||||
|
_settings->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||||
|
_settings->setMaximumWidth(350);
|
||||||
|
|
||||||
QWidget::connect(_settings, SIGNAL(currentIndexChanged(int)), this,
|
QWidget::connect(_settings, SIGNAL(currentIndexChanged(int)), this,
|
||||||
SLOT(SelectionIdxChanged(int)));
|
SLOT(SelectionIdxChanged(int)));
|
||||||
|
|
||||||
|
|||||||
@@ -137,9 +137,9 @@ void StringListEdit::showEvent(QShowEvent *e)
|
|||||||
void StringListEdit::Add()
|
void StringListEdit::Add()
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
bool accepted = AdvSSNameDialog::AskForName(this, _addString,
|
bool accepted = NameDialog::AskForName(this, _addString,
|
||||||
_addStringDescription, name,
|
_addStringDescription, name, "",
|
||||||
"", _maxStringSize, false);
|
_maxStringSize, false);
|
||||||
|
|
||||||
if (!accepted || (!_allowEmpty && name.empty())) {
|
if (!accepted || (!_allowEmpty && name.empty())) {
|
||||||
return;
|
return;
|
||||||
@@ -205,10 +205,10 @@ void StringListEdit::Down()
|
|||||||
void StringListEdit::Clicked(QListWidgetItem *item)
|
void StringListEdit::Clicked(QListWidgetItem *item)
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
bool accepted = AdvSSNameDialog::AskForName(this, _addString,
|
bool accepted = NameDialog::AskForName(this, _addString,
|
||||||
_addStringDescription, name,
|
_addStringDescription, name,
|
||||||
item->text(),
|
item->text(), _maxStringSize,
|
||||||
_maxStringSize, false);
|
false);
|
||||||
|
|
||||||
if (!accepted || (!_allowEmpty && name.empty())) {
|
if (!accepted || (!_allowEmpty && name.empty())) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ void TwitchCategorySearchButton::SetToken(
|
|||||||
void TwitchCategorySearchButton::StartManualCategorySearch()
|
void TwitchCategorySearchButton::StartManualCategorySearch()
|
||||||
{
|
{
|
||||||
std::string category;
|
std::string category;
|
||||||
bool accepted = AdvSSNameDialog::AskForName(
|
bool accepted = NameDialog::AskForName(
|
||||||
this,
|
this,
|
||||||
obs_module_text("AdvSceneSwitcher.twitchCategories.search"),
|
obs_module_text("AdvSceneSwitcher.twitchCategories.search"),
|
||||||
obs_module_text("AdvSceneSwitcher.twitchCategories.name"),
|
obs_module_text("AdvSceneSwitcher.twitchCategories.name"),
|
||||||
|
|||||||
Reference in New Issue
Block a user