mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-08 01:26:04 -05:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc17f0c708 |
@@ -173,8 +173,6 @@ target_sources(
|
||||
lib/macro/macro-signals.hpp
|
||||
lib/macro/macro-tab.cpp
|
||||
lib/macro/macro-tree.cpp
|
||||
lib/macro/macro-undo-redo.cpp
|
||||
lib/macro/macro-undo-redo.hpp
|
||||
lib/macro/macro-tree.hpp
|
||||
lib/macro/macro-websocket-trigger.cpp
|
||||
lib/macro/macro.cpp
|
||||
|
||||
@@ -198,20 +198,6 @@ AdvSceneSwitcher.macroTab.groupNameExists="The name \"%1\" is already used by a
|
||||
AdvSceneSwitcher.macroTab.removeSingleMacroPopup.text="Are you sure you want to remove \"%1\"?"
|
||||
AdvSceneSwitcher.macroTab.removeMultipleMacrosPopup.text="Are you sure you want to remove %1 macros/groups?"
|
||||
AdvSceneSwitcher.macroTab.removeGroupPopup.text="Are you sure you want to remove \"%1\" group and all its elements?"
|
||||
AdvSceneSwitcher.undo.renameMacro="Rename Macro '%1'"
|
||||
AdvSceneSwitcher.undo.modifyMacro="Modify Macro '%1'"
|
||||
AdvSceneSwitcher.undo.addMacro="Add Macro '%1'"
|
||||
AdvSceneSwitcher.undo.removeMacro="Remove Macro '%1'"
|
||||
AdvSceneSwitcher.undo.importMacros="Import Macros"
|
||||
AdvSceneSwitcher.undo.addSegment="Add %1 in '%2'"
|
||||
AdvSceneSwitcher.undo.removeSegment="Remove %1 in '%2'"
|
||||
AdvSceneSwitcher.undo.changeSegmentType="Change %1 Type in '%2'"
|
||||
AdvSceneSwitcher.undo.groupMacros="Group Macros '%1'"
|
||||
AdvSceneSwitcher.undo.ungroupMacros="Ungroup Macros '%1'"
|
||||
AdvSceneSwitcher.undo.removeMacroGroup="Remove Macro Group '%1'"
|
||||
AdvSceneSwitcher.undo.segment.action="Action"
|
||||
AdvSceneSwitcher.undo.segment.elseAction="Else Action"
|
||||
AdvSceneSwitcher.undo.segment.condition="Condition"
|
||||
AdvSceneSwitcher.macroTab.contextMenuAdd="Add"
|
||||
AdvSceneSwitcher.macroTab.copy="Duplicate Macro"
|
||||
AdvSceneSwitcher.macroTab.group="Group Selected Macros"
|
||||
@@ -356,9 +342,7 @@ AdvSceneSwitcher.condition.audio.type.volume="Configured volume level"
|
||||
AdvSceneSwitcher.condition.audio.type.syncOffset="Sync offset"
|
||||
AdvSceneSwitcher.condition.audio.type.monitor="Audio monitoring"
|
||||
AdvSceneSwitcher.condition.audio.type.balance="Audio balance"
|
||||
AdvSceneSwitcher.condition.audio.type.track="Audio track"
|
||||
AdvSceneSwitcher.condition.audio.entry="{{checkType}}of{{audioSources}}is{{condition}}{{volume}}{{volumeDB}}{{percentDBToggle}}{{syncOffset}}{{monitorTypes}}"
|
||||
AdvSceneSwitcher.condition.audio.layout.track="{{audioSources}}is enabled on{{checkType}}{{track}}"
|
||||
AdvSceneSwitcher.condition.cursor="Cursor"
|
||||
AdvSceneSwitcher.condition.cursor.type.region="is in region"
|
||||
AdvSceneSwitcher.condition.cursor.type.moving="is moving"
|
||||
@@ -2390,7 +2374,6 @@ AdvSceneSwitcher.tempVar.audio.muted="Source muted"
|
||||
AdvSceneSwitcher.tempVar.audio.sync_offset="Source audio sync offset"
|
||||
AdvSceneSwitcher.tempVar.audio.monitor="Source audio monitor type"
|
||||
AdvSceneSwitcher.tempVar.audio.balance="Source audio balance"
|
||||
AdvSceneSwitcher.tempVar.audio.trackEnabled="Audio track enabled"
|
||||
|
||||
AdvSceneSwitcher.tempVar.clipboard.mimeType.primary="Primary clipboard item MIME type"
|
||||
AdvSceneSwitcher.tempVar.clipboard.mimeType.primary.description="Highest priority MIME type of the current item stored in clipboard, if available."
|
||||
@@ -3140,3 +3123,6 @@ AdvSceneSwitcher.sceneGroupTab.defaultname="Scene Group %1"
|
||||
AdvSceneSwitcher.sceneGroupTab.exists="Scene Group or Scene name exists already"
|
||||
AdvSceneSwitcher.sceneGroupTab.help="Scene Groups can be selected as a target just like a regular scene.\n\nAs the name suggests a scene group is a collection of multiple scenes.\nThe scene group will advance through the list of its assigned scenes depending on the configured settings, which can be found on the right side.\n\nYou can configure the scene group to advance to the next scene in the list:\nAfter a number of times the scene group is selected as a target.\nAfter a certain amount of time has passed.\nOr randomly.\n\nFor example, a scene group containing the scenes ...\nScene 1\nScene 2\nScene 3 \n... will activate \"Scene 1\" the first time it is selected as a target.\nThe second time it will activate \"Scene 2\".\nThe remaining times \"Scene 3\" will be activated.\n\nClick the highlighted plus symbol below to add a new scene group."
|
||||
AdvSceneSwitcher.sceneGroupTab.scenes.help="Select the scene group you want to modify on the left.\n\nSelect a scene to add to this scene group by selecting the scene above and clicking the plus symbol below.\n\nA scene can be added multiple times to the same scene group."
|
||||
AdvSceneSwitcher.kwin.flatpakPermissionWarning="Window detection via KWin is unavailable.\nThe OBS Studio Flatpak sandbox is missing the 'org.kde.KWin' D-Bus permission this feature needs.\nRun the following, then restart OBS:"
|
||||
AdvSceneSwitcher.wayland.flatpakPermissionWarning="Window detection is unavailable.\nThe OBS Studio Flatpak has no X11 access on this Wayland session, and no compatible integration exists yet for this desktop.\nRunning OBS under an X11 session, or a non-Flatpak install, allows this feature to work."
|
||||
AdvSceneSwitcher.flatpakWindowDetectionWarning.doNotShowAgain="Don't show this warning again"
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
#include "platform-funcs.hpp"
|
||||
|
||||
#include "log-helper.hpp"
|
||||
#include "obs-module-helper.hpp"
|
||||
#include "plugin-state-helpers.hpp"
|
||||
#include "ui-helpers.hpp"
|
||||
|
||||
#include <obs-frontend-api.h>
|
||||
#include <QCheckBox>
|
||||
#include <QFontDatabase>
|
||||
#include <QGridLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
@@ -628,27 +639,108 @@ int ignoreXerror(Display *d, XErrorEvent *e)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool warnAboutWindowDetectionUnavailable = true;
|
||||
|
||||
static bool setupWindowDetectionWarningPersistence = []() {
|
||||
AddSaveStep([](obs_data_t *obj) {
|
||||
obs_data_set_bool(obj, "warnAboutFlatpakWindowDetection",
|
||||
warnAboutWindowDetectionUnavailable);
|
||||
});
|
||||
AddLoadStep([](obs_data_t *obj) {
|
||||
obs_data_set_default_bool(
|
||||
obj, "warnAboutFlatpakWindowDetection", true);
|
||||
warnAboutWindowDetectionUnavailable = obs_data_get_bool(
|
||||
obj, "warnAboutFlatpakWindowDetection");
|
||||
});
|
||||
return true;
|
||||
}();
|
||||
|
||||
static void showWindowDetectionWarning(const char *messageId,
|
||||
const char *command)
|
||||
{
|
||||
auto mainWindow =
|
||||
static_cast<QWidget *>(obs_frontend_get_main_window());
|
||||
QMessageBox msgBox(QMessageBox::Warning,
|
||||
obs_module_text("AdvSceneSwitcher.pluginName"),
|
||||
obs_module_text(messageId), QMessageBox::Ok,
|
||||
mainWindow);
|
||||
|
||||
if (command) {
|
||||
auto commandLineEdit = new QLineEdit(command, &msgBox);
|
||||
commandLineEdit->setReadOnly(true);
|
||||
commandLineEdit->setFont(
|
||||
QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||
commandLineEdit->setCursorPosition(0);
|
||||
auto layout = qobject_cast<QGridLayout *>(msgBox.layout());
|
||||
if (layout) {
|
||||
layout->addWidget(commandLineEdit, layout->rowCount(),
|
||||
0, 1, layout->columnCount());
|
||||
}
|
||||
}
|
||||
|
||||
auto checkbox = new QCheckBox(obs_module_text(
|
||||
"AdvSceneSwitcher.flatpakWindowDetectionWarning.doNotShowAgain"));
|
||||
msgBox.setCheckBox(checkbox);
|
||||
msgBox.exec();
|
||||
warnAboutWindowDetectionUnavailable = !checkbox->isChecked();
|
||||
}
|
||||
|
||||
static void handleWindowDetectionUnavailable(bool hasX11)
|
||||
{
|
||||
if (hasX11 || KWin) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!qEnvironmentVariableIsSet("FLATPAK_ID")) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool onKDE = qEnvironmentVariable("XDG_CURRENT_DESKTOP")
|
||||
.contains("KDE", Qt::CaseInsensitive);
|
||||
const char *messageId =
|
||||
onKDE ? "AdvSceneSwitcher.kwin.flatpakPermissionWarning"
|
||||
: "AdvSceneSwitcher.wayland.flatpakPermissionWarning";
|
||||
const char *command =
|
||||
onKDE ? "flatpak override --user --talk-name=org.kde.KWin com.obsproject.Studio"
|
||||
: nullptr;
|
||||
|
||||
blog(LOG_WARNING,
|
||||
"window detection unavailable: OBS Flatpak sandbox has no X11 "
|
||||
"access on this Wayland session and %s",
|
||||
onKDE ? "the KWin D-Bus compat call was blocked (missing "
|
||||
"'org.kde.KWin' talk-name permission)"
|
||||
: "no compatible native Wayland integration exists for "
|
||||
"this desktop");
|
||||
|
||||
AddFinishedLoadingStep([messageId, command]() {
|
||||
if (!warnAboutWindowDetectionUnavailable) {
|
||||
return;
|
||||
}
|
||||
showWindowDetectionWarning(messageId, command);
|
||||
});
|
||||
}
|
||||
|
||||
void PlatformInit()
|
||||
{
|
||||
const bool kwinAvailable = isKWinAvailable();
|
||||
KWin = kwinAvailable && registerKWinDBusListener(¬ifier) &&
|
||||
startKWinScript(KWinScriptObjectPath);
|
||||
if (KWin) {
|
||||
blog(LOG_INFO, "using KWin compat");
|
||||
} else {
|
||||
blog(LOG_INFO, "not using KWin compat");
|
||||
}
|
||||
|
||||
initProcps();
|
||||
initProc2();
|
||||
|
||||
auto display = disp();
|
||||
handleWindowDetectionUnavailable(display != nullptr);
|
||||
if (!display) {
|
||||
return;
|
||||
}
|
||||
|
||||
KWin = isKWinAvailable();
|
||||
if (!(KWin && startKWinScript(KWinScriptObjectPath) &&
|
||||
registerKWinDBusListener(¬ifier))) {
|
||||
// something bad happened while trying to initialize
|
||||
// the KWin script/dbus so disable it
|
||||
KWin = false;
|
||||
blog(LOG_INFO, "not using KWin compat");
|
||||
} else {
|
||||
blog(LOG_INFO, "using KWin compat");
|
||||
}
|
||||
|
||||
initXss();
|
||||
initProcps();
|
||||
initProc2();
|
||||
XSetErrorHandler(ignoreXerror);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileDevice>
|
||||
#include <QStandardPaths>
|
||||
#include <QTextStream>
|
||||
#include <QtDBus/QDBusConnectionInterface>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
@@ -96,12 +97,16 @@ bool isKWinAvailable()
|
||||
|
||||
bool startKWinScript(QString &scriptObjectPath)
|
||||
{
|
||||
// Not RuntimeLocation: under Flatpak, $XDG_RUNTIME_DIR is private to
|
||||
// the sandbox, so the unsandboxed KWin process can't read it back.
|
||||
const QString scriptPath =
|
||||
"/tmp/AdvancedSceneSwitcher/KWinFocusNotifier.js";
|
||||
QStandardPaths::writableLocation(
|
||||
QStandardPaths::CacheLocation) +
|
||||
"/AdvancedSceneSwitcher/KWinFocusNotifier.js";
|
||||
|
||||
const QString script =
|
||||
R"(var adss = "com.github.AdvancedSceneSwitcher";
|
||||
var adssPath = "/com/github/AdvancedSceneSwitcher";
|
||||
R"(var adss = "com.obsproject.Studio.Plugin.SceneSwitcher";
|
||||
var adssPath = "/com/obsproject/Studio/Plugin/SceneSwitcher";
|
||||
|
||||
function trackWindow(window) {
|
||||
var id = window.internalId.toString();
|
||||
@@ -129,7 +134,8 @@ workspace.windowActivated.connect(function(client) {
|
||||
}))";
|
||||
|
||||
if (const QDir dir; !dir.mkpath(QFileInfo(scriptPath).absolutePath())) {
|
||||
blog(LOG_ERROR, "error creating /tmp/AdvancedSceneSwitcher");
|
||||
blog(LOG_ERROR,
|
||||
"error creating KWinFocusNotifier script directory");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -198,8 +204,10 @@ bool stopKWinScript(const QString &scriptObjectPath)
|
||||
|
||||
bool registerKWinDBusListener(FocusNotifier *notifier)
|
||||
{
|
||||
static const QString serviceName = "com.github.AdvancedSceneSwitcher";
|
||||
static const QString objectPath = "/com/github/AdvancedSceneSwitcher";
|
||||
static const QString serviceName =
|
||||
"com.obsproject.Studio.Plugin.SceneSwitcher";
|
||||
static const QString objectPath =
|
||||
"/com/obsproject/Studio/Plugin/SceneSwitcher";
|
||||
auto bus = QDBusConnection::sessionBus();
|
||||
|
||||
if (bus.objectRegisteredAt(objectPath)) {
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace advss {
|
||||
|
||||
class FocusNotifier final : public QObject {
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "com.github.AdvancedSceneSwitcher")
|
||||
Q_CLASSINFO("D-Bus Interface",
|
||||
"com.obsproject.Studio.Plugin.SceneSwitcher")
|
||||
|
||||
static std::mutex _mutex;
|
||||
static int activePID;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "macro-undo-redo.hpp"
|
||||
#include "advanced-scene-switcher.hpp"
|
||||
#include "macro-helpers.hpp"
|
||||
#include "macro-settings.hpp"
|
||||
@@ -112,32 +111,9 @@ void MacroActionEdit::ActionSelectionChanged(const QString &text)
|
||||
return;
|
||||
}
|
||||
|
||||
Macro *const parentMacro =
|
||||
(*_entryData)->GetMacro()->GetNestedParentMacro();
|
||||
OBSDataAutoRelease parentBeforeData;
|
||||
if (parentMacro) {
|
||||
parentBeforeData = obs_data_create();
|
||||
parentMacro->Save(parentBeforeData);
|
||||
}
|
||||
|
||||
const std::string oldId = (*_entryData)->GetId();
|
||||
OBSDataAutoRelease oldData = obs_data_create();
|
||||
(*_entryData)->Save(oldData);
|
||||
|
||||
HeaderInfoChanged("");
|
||||
auto idx = _entryData->get()->GetIndex();
|
||||
auto macro = _entryData->get()->GetMacro();
|
||||
|
||||
// Determine whether this is an action or else-action before resetting.
|
||||
const auto *rawPtr = (*_entryData).get();
|
||||
const auto &elseActions = macro->ElseActions();
|
||||
const bool isElse = std::any_of(elseActions.begin(), elseActions.end(),
|
||||
[rawPtr](const auto &a) {
|
||||
return a.get() == rawPtr;
|
||||
});
|
||||
const auto segmentType = isElse ? MacroEdit::SegmentType::ELSE_ACTION
|
||||
: MacroEdit::SegmentType::ACTION;
|
||||
|
||||
{
|
||||
auto lock = LockContext();
|
||||
_entryData->reset();
|
||||
@@ -146,16 +122,6 @@ void MacroActionEdit::ActionSelectionChanged(const QString &text)
|
||||
(*_entryData)->PostLoad();
|
||||
RunAndClearPostLoadSteps();
|
||||
}
|
||||
|
||||
OBSDataAutoRelease newData = obs_data_create();
|
||||
(*_entryData)->Save(newData);
|
||||
if (parentMacro) {
|
||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
||||
} else {
|
||||
RegisterSegmentTypeChangeUndoRedo(macro, segmentType, idx,
|
||||
oldId, oldData, 0, id,
|
||||
newData, 0);
|
||||
}
|
||||
auto widget = MacroActionFactory::CreateWidget(id, this, *_entryData);
|
||||
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
|
||||
this, SLOT(HeaderInfoChanged(const QString &)));
|
||||
|
||||
@@ -83,7 +83,6 @@ bool MacroActionLoop::PostLoad()
|
||||
MacroAction::PostLoad();
|
||||
_loopMacro->PostLoad();
|
||||
_loopMacro->SetActionTriggerMode(Macro::ActionTriggerMode::ALWAYS);
|
||||
_loopMacro->SetNestedParentMacro(GetMacro());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -281,7 +281,6 @@ bool MacroActionMacro::PostLoad()
|
||||
MacroAction::PostLoad();
|
||||
_runOptions.macro.PostLoad();
|
||||
_nestedMacro->PostLoad();
|
||||
_nestedMacro->SetNestedParentMacro(GetMacro());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "macro-condition-edit.hpp"
|
||||
#include "macro-undo-redo.hpp"
|
||||
|
||||
#include "advanced-scene-switcher.hpp"
|
||||
#include "condition-logic.hpp"
|
||||
@@ -251,19 +250,6 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
|
||||
return;
|
||||
}
|
||||
|
||||
Macro *const parentMacro =
|
||||
(*_entryData)->GetMacro()->GetNestedParentMacro();
|
||||
OBSDataAutoRelease parentBeforeData;
|
||||
if (parentMacro) {
|
||||
parentBeforeData = obs_data_create();
|
||||
parentMacro->Save(parentBeforeData);
|
||||
}
|
||||
|
||||
const std::string oldId = (*_entryData)->GetId();
|
||||
const int oldLogic = (int)(*_entryData)->GetLogicType();
|
||||
OBSDataAutoRelease oldData = obs_data_create();
|
||||
(*_entryData)->Save(oldData);
|
||||
|
||||
auto temp = DurationModifier();
|
||||
_dur->SetValue(temp);
|
||||
HeaderInfoChanged("");
|
||||
@@ -281,17 +267,6 @@ void MacroConditionEdit::ConditionSelectionChanged(const QString &text)
|
||||
(*_entryData)->PostLoad();
|
||||
RunAndClearPostLoadSteps();
|
||||
}
|
||||
|
||||
OBSDataAutoRelease newData = obs_data_create();
|
||||
(*_entryData)->Save(newData);
|
||||
if (parentMacro) {
|
||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
||||
} else {
|
||||
RegisterSegmentTypeChangeUndoRedo(
|
||||
macro, MacroEdit::SegmentType::CONDITION, idx, oldId,
|
||||
oldData, oldLogic, id, newData,
|
||||
(int)(*_entryData)->GetLogicType());
|
||||
}
|
||||
auto widget =
|
||||
MacroConditionFactory::CreateWidget(id, this, *_entryData);
|
||||
QWidget::connect(widget, SIGNAL(HeaderInfoChanged(const QString &)),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "macro-edit.hpp"
|
||||
|
||||
#include "condition-logic.hpp"
|
||||
#include "macro-undo-redo.hpp"
|
||||
#include "cursor-shape-changer.hpp"
|
||||
#include "macro-action-edit.hpp"
|
||||
#include "macro-action-macro.hpp"
|
||||
@@ -258,92 +257,6 @@ std::shared_ptr<Macro> MacroEdit::GetMacro() const
|
||||
return _currentMacro;
|
||||
}
|
||||
|
||||
void MacroEdit::InsertSegmentWidget(SegmentType type, int idx)
|
||||
{
|
||||
auto macro = _currentMacro;
|
||||
if (!macro) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case SegmentType::ACTION: {
|
||||
if (idx < 0 || idx > (int)macro->Actions().size()) {
|
||||
break;
|
||||
}
|
||||
ui->actionsList->Insert(
|
||||
idx, new MacroActionEdit(this, ¯o->Actions()[idx]));
|
||||
SetActionData(*macro);
|
||||
ui->actionsList->SetHelpMsgVisible(false);
|
||||
break;
|
||||
}
|
||||
case SegmentType::ELSE_ACTION: {
|
||||
if (idx < 0 || idx > (int)macro->ElseActions().size()) {
|
||||
break;
|
||||
}
|
||||
ui->elseActionsList->Insert(
|
||||
idx,
|
||||
new MacroActionEdit(this, ¯o->ElseActions()[idx]));
|
||||
SetElseActionData(*macro);
|
||||
ui->elseActionsList->SetHelpMsgVisible(false);
|
||||
break;
|
||||
}
|
||||
case SegmentType::CONDITION: {
|
||||
if (idx < 0 || idx > (int)macro->Conditions().size()) {
|
||||
break;
|
||||
}
|
||||
ui->conditionsList->Insert(
|
||||
idx,
|
||||
new MacroConditionEdit(this, ¯o->Conditions()[idx],
|
||||
idx == 0));
|
||||
if (idx == 0 && macro->Conditions().size() > 1) {
|
||||
static_cast<MacroConditionEdit *>(
|
||||
ui->conditionsList->WidgetAt(1))
|
||||
->SetRootNode(false);
|
||||
}
|
||||
SetConditionData(*macro);
|
||||
ui->conditionsList->SetHelpMsgVisible(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MacroEdit::RemoveSegmentWidget(SegmentType type, int idx)
|
||||
{
|
||||
auto macro = _currentMacro;
|
||||
if (!macro) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case SegmentType::ACTION:
|
||||
if (idx >= 0 &&
|
||||
idx < ui->actionsList->ContentLayout()->count()) {
|
||||
ui->actionsList->Remove(idx);
|
||||
SetActionData(*macro);
|
||||
}
|
||||
break;
|
||||
case SegmentType::ELSE_ACTION:
|
||||
if (idx >= 0 &&
|
||||
idx < ui->elseActionsList->ContentLayout()->count()) {
|
||||
ui->elseActionsList->Remove(idx);
|
||||
SetElseActionData(*macro);
|
||||
}
|
||||
break;
|
||||
case SegmentType::CONDITION:
|
||||
if (idx >= 0 &&
|
||||
idx < ui->conditionsList->ContentLayout()->count()) {
|
||||
ui->conditionsList->Remove(idx);
|
||||
if (idx == 0 && !macro->Conditions().empty()) {
|
||||
static_cast<MacroConditionEdit *>(
|
||||
ui->conditionsList->WidgetAt(0))
|
||||
->SetRootNode(true);
|
||||
}
|
||||
SetConditionData(*macro);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MacroEdit::ClearSegmentWidgetCacheFor(Macro *macro) const
|
||||
{
|
||||
ui->conditionsList->ClearWidgetsFromCacheFor(macro);
|
||||
@@ -382,7 +295,7 @@ isValidMacroSegmentIdx(const std::deque<std::shared_ptr<MacroSegment>> &list,
|
||||
return (idx > 0 || (unsigned)idx < list.size());
|
||||
}
|
||||
|
||||
void MacroEdit::SetupMacroSegmentSelection(SegmentType type, int idx)
|
||||
void MacroEdit::SetupMacroSegmentSelection(MacroSection type, int idx)
|
||||
{
|
||||
auto macro = _currentMacro;
|
||||
if (!macro) {
|
||||
@@ -395,7 +308,7 @@ void MacroEdit::SetupMacroSegmentSelection(SegmentType type, int idx)
|
||||
std::deque<std::shared_ptr<MacroSegment>> segments;
|
||||
|
||||
switch (type) {
|
||||
case MacroEdit::SegmentType::CONDITION:
|
||||
case MacroEdit::MacroSection::CONDITIONS:
|
||||
setList = ui->conditionsList;
|
||||
setIdx = ¤tConditionIdx;
|
||||
segments = {macro->Conditions().begin(),
|
||||
@@ -406,7 +319,7 @@ void MacroEdit::SetupMacroSegmentSelection(SegmentType type, int idx)
|
||||
resetIdx1 = ¤tActionIdx;
|
||||
resetIdx2 = ¤tElseActionIdx;
|
||||
break;
|
||||
case MacroEdit::SegmentType::ACTION:
|
||||
case MacroEdit::MacroSection::ACTIONS:
|
||||
setList = ui->actionsList;
|
||||
setIdx = ¤tActionIdx;
|
||||
segments = {macro->Actions().begin(), macro->Actions().end()};
|
||||
@@ -416,7 +329,7 @@ void MacroEdit::SetupMacroSegmentSelection(SegmentType type, int idx)
|
||||
resetIdx1 = ¤tConditionIdx;
|
||||
resetIdx2 = ¤tElseActionIdx;
|
||||
break;
|
||||
case MacroEdit::SegmentType::ELSE_ACTION:
|
||||
case MacroEdit::MacroSection::ELSE_ACTIONS:
|
||||
setList = ui->elseActionsList;
|
||||
setIdx = ¤tElseActionIdx;
|
||||
segments = {macro->ElseActions().begin(),
|
||||
@@ -1052,7 +965,7 @@ void MacroEdit::UpMacroSegmentHotkey()
|
||||
int conditionSize = macro->Conditions().size();
|
||||
|
||||
if (currentActionIdx == -1 && currentConditionIdx == -1) {
|
||||
if (lastInteracted == SegmentType::CONDITION) {
|
||||
if (lastInteracted == MacroSection::CONDITIONS) {
|
||||
if (conditionSize == 0) {
|
||||
MacroActionSelectionChanged(0);
|
||||
} else {
|
||||
@@ -1108,7 +1021,7 @@ void MacroEdit::DownMacroSegmentHotkey()
|
||||
int conditionSize = macro->Conditions().size();
|
||||
|
||||
if (currentActionIdx == -1 && currentConditionIdx == -1) {
|
||||
if (lastInteracted == SegmentType::CONDITION) {
|
||||
if (lastInteracted == MacroSection::CONDITIONS) {
|
||||
if (conditionSize == 0) {
|
||||
MacroActionSelectionChanged(0);
|
||||
} else {
|
||||
@@ -1171,13 +1084,6 @@ void MacroEdit::AddMacroAction(Macro *macro, int idx, const std::string &id,
|
||||
return;
|
||||
}
|
||||
|
||||
Macro *const parentMacro = macro->GetNestedParentMacro();
|
||||
OBSDataAutoRelease parentBeforeData;
|
||||
if (parentMacro) {
|
||||
parentBeforeData = obs_data_create();
|
||||
parentMacro->Save(parentBeforeData);
|
||||
}
|
||||
|
||||
{
|
||||
auto lock = LockContext();
|
||||
macro->Actions().emplace(macro->Actions().begin() + idx,
|
||||
@@ -1192,11 +1098,6 @@ void MacroEdit::AddMacroAction(Macro *macro, int idx, const std::string &id,
|
||||
idx, new MacroActionEdit(this, ¯o->Actions()[idx]));
|
||||
SetActionData(*macro);
|
||||
}
|
||||
if (parentMacro) {
|
||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
||||
} else {
|
||||
RegisterSegmentAddUndoRedo(macro, SegmentType::ACTION, idx);
|
||||
}
|
||||
HighlightAction(idx);
|
||||
ui->actionsList->SetHelpMsgVisible(false);
|
||||
emit(MacroSegmentOrderChanged());
|
||||
@@ -1262,24 +1163,6 @@ void MacroEdit::RemoveMacroAction(int idx)
|
||||
return;
|
||||
}
|
||||
|
||||
Macro *const parentMacro = macro->GetNestedParentMacro();
|
||||
OBSDataAutoRelease parentBeforeData;
|
||||
if (parentMacro) {
|
||||
parentBeforeData = obs_data_create();
|
||||
parentMacro->Save(parentBeforeData);
|
||||
} else {
|
||||
OBSDataAutoRelease segData = obs_data_create();
|
||||
std::string segId;
|
||||
{
|
||||
auto lock = LockContext();
|
||||
macro->Actions().at(idx)->Save(segData);
|
||||
segId = macro->Actions().at(idx)->GetId();
|
||||
}
|
||||
RegisterSegmentRemoveUndoRedo(macro.get(), SegmentType::ACTION,
|
||||
idx, segId, segData,
|
||||
(int)Logic::Type::ROOT_NONE);
|
||||
}
|
||||
|
||||
{
|
||||
auto lock = LockContext();
|
||||
ui->actionsList->Remove(idx);
|
||||
@@ -1289,11 +1172,8 @@ void MacroEdit::RemoveMacroAction(int idx)
|
||||
macro->UpdateActionIndices();
|
||||
SetActionData(*macro);
|
||||
}
|
||||
if (parentMacro) {
|
||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
||||
}
|
||||
MacroActionSelectionChanged(-1);
|
||||
lastInteracted = SegmentType::ACTION;
|
||||
lastInteracted = MacroSection::ACTIONS;
|
||||
emit(MacroSegmentOrderChanged());
|
||||
}
|
||||
|
||||
@@ -1473,7 +1353,7 @@ void MacroEdit::MoveMacroActionDown(int idx)
|
||||
|
||||
void MacroEdit::MacroElseActionSelectionChanged(int idx)
|
||||
{
|
||||
SetupMacroSegmentSelection(SegmentType::ELSE_ACTION, idx);
|
||||
SetupMacroSegmentSelection(MacroSection::ELSE_ACTIONS, idx);
|
||||
}
|
||||
|
||||
void MacroEdit::MacroElseActionReorder(int to, int from)
|
||||
@@ -1510,13 +1390,6 @@ void MacroEdit::AddMacroElseAction(Macro *macro, int idx, const std::string &id,
|
||||
return;
|
||||
}
|
||||
|
||||
Macro *const parentMacro = macro->GetNestedParentMacro();
|
||||
OBSDataAutoRelease parentBeforeData;
|
||||
if (parentMacro) {
|
||||
parentBeforeData = obs_data_create();
|
||||
parentMacro->Save(parentBeforeData);
|
||||
}
|
||||
|
||||
{
|
||||
auto lock = LockContext();
|
||||
macro->ElseActions().emplace(macro->ElseActions().begin() + idx,
|
||||
@@ -1533,12 +1406,6 @@ void MacroEdit::AddMacroElseAction(Macro *macro, int idx, const std::string &id,
|
||||
new MacroActionEdit(this, ¯o->ElseActions()[idx]));
|
||||
SetElseActionData(*macro);
|
||||
}
|
||||
if (parentMacro) {
|
||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
||||
} else {
|
||||
RegisterSegmentAddUndoRedo(macro, SegmentType::ELSE_ACTION,
|
||||
idx);
|
||||
}
|
||||
HighlightElseAction(idx);
|
||||
ui->elseActionsList->SetHelpMsgVisible(false);
|
||||
emit(MacroSegmentOrderChanged());
|
||||
@@ -1588,25 +1455,6 @@ void MacroEdit::RemoveMacroElseAction(int idx)
|
||||
return;
|
||||
}
|
||||
|
||||
Macro *const parentMacro = macro->GetNestedParentMacro();
|
||||
OBSDataAutoRelease parentBeforeData;
|
||||
if (parentMacro) {
|
||||
parentBeforeData = obs_data_create();
|
||||
parentMacro->Save(parentBeforeData);
|
||||
} else {
|
||||
OBSDataAutoRelease segData = obs_data_create();
|
||||
std::string segId;
|
||||
{
|
||||
auto lock = LockContext();
|
||||
macro->ElseActions().at(idx)->Save(segData);
|
||||
segId = macro->ElseActions().at(idx)->GetId();
|
||||
}
|
||||
RegisterSegmentRemoveUndoRedo(macro.get(),
|
||||
SegmentType::ELSE_ACTION, idx,
|
||||
segId, segData,
|
||||
(int)Logic::Type::ROOT_NONE);
|
||||
}
|
||||
|
||||
{
|
||||
auto lock = LockContext();
|
||||
ui->elseActionsList->Remove(idx);
|
||||
@@ -1616,11 +1464,8 @@ void MacroEdit::RemoveMacroElseAction(int idx)
|
||||
macro->UpdateElseActionIndices();
|
||||
SetElseActionData(*macro);
|
||||
}
|
||||
if (parentMacro) {
|
||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
||||
}
|
||||
MacroElseActionSelectionChanged(-1);
|
||||
lastInteracted = SegmentType::ELSE_ACTION;
|
||||
lastInteracted = MacroSection::ELSE_ACTIONS;
|
||||
emit(MacroSegmentOrderChanged());
|
||||
}
|
||||
|
||||
@@ -1681,7 +1526,7 @@ void MacroEdit::MoveMacroElseActionDown(int idx)
|
||||
|
||||
void MacroEdit::MacroActionSelectionChanged(int idx)
|
||||
{
|
||||
SetupMacroSegmentSelection(SegmentType::ACTION, idx);
|
||||
SetupMacroSegmentSelection(MacroSection::ACTIONS, idx);
|
||||
}
|
||||
|
||||
void MacroEdit::MacroActionReorder(int to, int from)
|
||||
@@ -1754,13 +1599,6 @@ void MacroEdit::AddMacroCondition(Macro *macro, int idx, const std::string &id,
|
||||
return;
|
||||
}
|
||||
|
||||
Macro *const parentMacro = macro->GetNestedParentMacro();
|
||||
OBSDataAutoRelease parentBeforeData;
|
||||
if (parentMacro) {
|
||||
parentBeforeData = obs_data_create();
|
||||
parentMacro->Save(parentBeforeData);
|
||||
}
|
||||
|
||||
{
|
||||
auto lock = LockContext();
|
||||
auto cond = macro->Conditions().emplace(
|
||||
@@ -1779,11 +1617,6 @@ void MacroEdit::AddMacroCondition(Macro *macro, int idx, const std::string &id,
|
||||
idx == 0));
|
||||
SetConditionData(*macro);
|
||||
}
|
||||
if (parentMacro) {
|
||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
||||
} else {
|
||||
RegisterSegmentAddUndoRedo(macro, SegmentType::CONDITION, idx);
|
||||
}
|
||||
HighlightCondition(idx);
|
||||
ui->conditionsList->SetHelpMsgVisible(false);
|
||||
emit(MacroSegmentOrderChanged());
|
||||
@@ -1819,26 +1652,6 @@ void MacroEdit::RemoveMacroCondition(int idx)
|
||||
return;
|
||||
}
|
||||
|
||||
Macro *const parentMacro = macro->GetNestedParentMacro();
|
||||
OBSDataAutoRelease parentBeforeData;
|
||||
if (parentMacro) {
|
||||
parentBeforeData = obs_data_create();
|
||||
parentMacro->Save(parentBeforeData);
|
||||
} else {
|
||||
OBSDataAutoRelease segData = obs_data_create();
|
||||
std::string segId;
|
||||
int logic;
|
||||
{
|
||||
auto lock = LockContext();
|
||||
macro->Conditions().at(idx)->Save(segData);
|
||||
segId = macro->Conditions().at(idx)->GetId();
|
||||
logic = (int)macro->Conditions().at(idx)->GetLogicType();
|
||||
}
|
||||
RegisterSegmentRemoveUndoRedo(macro.get(),
|
||||
SegmentType::CONDITION, idx,
|
||||
segId, segData, logic);
|
||||
}
|
||||
|
||||
{
|
||||
auto lock = LockContext();
|
||||
ui->conditionsList->Remove(idx);
|
||||
@@ -1853,11 +1666,8 @@ void MacroEdit::RemoveMacroCondition(int idx)
|
||||
}
|
||||
SetConditionData(*macro);
|
||||
}
|
||||
if (parentMacro) {
|
||||
RegisterMacroModifyUndoRedo(parentMacro, parentBeforeData);
|
||||
}
|
||||
MacroConditionSelectionChanged(-1);
|
||||
lastInteracted = SegmentType::CONDITION;
|
||||
lastInteracted = MacroSection::CONDITIONS;
|
||||
emit(MacroSegmentOrderChanged());
|
||||
}
|
||||
|
||||
@@ -1982,7 +1792,7 @@ void MacroEdit::MoveMacroConditionDown(int idx)
|
||||
|
||||
void MacroEdit::MacroConditionSelectionChanged(int idx)
|
||||
{
|
||||
SetupMacroSegmentSelection(SegmentType::CONDITION, idx);
|
||||
SetupMacroSegmentSelection(MacroSection::CONDITIONS, idx);
|
||||
}
|
||||
|
||||
void MacroEdit::MacroConditionReorder(int to, int from)
|
||||
|
||||
@@ -12,15 +12,11 @@ class MacroEdit : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class SegmentType { CONDITION, ACTION, ELSE_ACTION };
|
||||
|
||||
MacroEdit(QWidget *parent, QStringList helpMsg = {});
|
||||
void SetMacro(const std::shared_ptr<Macro> &);
|
||||
std::shared_ptr<Macro> GetMacro() const;
|
||||
void ClearSegmentWidgetCacheFor(Macro *) const;
|
||||
void SetControlsDisabled(bool disable) const;
|
||||
void InsertSegmentWidget(SegmentType type, int idx);
|
||||
void RemoveSegmentWidget(SegmentType type, int idx);
|
||||
void HighlightAction(int idx, QColor color = QColor(Qt::green)) const;
|
||||
void HighlightElseAction(int idx,
|
||||
QColor color = QColor(Qt::green)) const;
|
||||
@@ -116,12 +112,14 @@ protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
|
||||
private:
|
||||
enum class MacroSection { CONDITIONS, ACTIONS, ELSE_ACTIONS };
|
||||
|
||||
void PopulateMacroActions(Macro &m, uint32_t afterIdx = 0);
|
||||
void PopulateMacroElseActions(Macro &m, uint32_t afterIdx = 0);
|
||||
void PopulateMacroConditions(Macro &m, uint32_t afterIdx = 0);
|
||||
void ScrollAndFocusNewSegment(MacroSegmentList *list, int newIdx,
|
||||
int *currentIdx);
|
||||
void SetupMacroSegmentSelection(SegmentType type, int idx);
|
||||
void SetupMacroSegmentSelection(MacroSection type, int idx);
|
||||
void
|
||||
SetupContextMenu(const QPoint &pos,
|
||||
const std::function<void(MacroEdit *, int)> &remove,
|
||||
@@ -133,7 +131,7 @@ private:
|
||||
void RunSegmentHighlightChecks();
|
||||
bool ElseSectionIsVisible() const;
|
||||
|
||||
SegmentType lastInteracted = SegmentType::CONDITION;
|
||||
MacroSection lastInteracted = MacroSection::CONDITIONS;
|
||||
int currentConditionIdx = -1;
|
||||
int currentActionIdx = -1;
|
||||
int currentElseActionIdx = -1;
|
||||
|
||||
@@ -201,8 +201,6 @@ bool MacroSegmentList::PopulateWidgetsFromCache(const Macro *macro)
|
||||
_contentLayout->addWidget(widget);
|
||||
widget->show();
|
||||
}
|
||||
// Widgets are now owned by the layout again, so the cache entry is stale.
|
||||
_widgetCache.erase(it);
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
@@ -465,17 +463,7 @@ void MacroSegmentList::SetupVisibleMacroSegmentWidgets()
|
||||
|
||||
const auto viewportRect = viewport()->rect();
|
||||
|
||||
for (int i = 0; i < _contentLayout->count(); ++i) {
|
||||
auto item = _contentLayout->itemAt(i);
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto segment = dynamic_cast<MacroSegmentEdit *>(item->widget());
|
||||
if (!segment) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto segment : widget()->findChildren<MacroSegmentEdit *>()) {
|
||||
const auto pos = segment->mapTo(viewport(), QPoint(0, 0));
|
||||
const QRect rect(pos, segment->size());
|
||||
if (!viewportRect.intersects(rect)) {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "macro-settings.hpp"
|
||||
#include "macro-signals.hpp"
|
||||
#include "macro-tree.hpp"
|
||||
#include "macro-undo-redo.hpp"
|
||||
#include "macro.hpp"
|
||||
#include "math-helpers.hpp"
|
||||
#include "name-dialog.hpp"
|
||||
@@ -123,7 +122,6 @@ void AdvSceneSwitcher::on_macroAdd_clicked()
|
||||
ui->macros->Add(newMacro);
|
||||
MacroSignalManager::Instance()->Add(
|
||||
QString::fromStdString(name));
|
||||
RegisterMacroAddUndoRedo(name);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,7 +131,6 @@ void AdvSceneSwitcher::on_macroAdd_clicked()
|
||||
ui->macros->AddToGroup(newMacro, selectedMacro);
|
||||
MacroSignalManager::Instance()->Add(
|
||||
QString::fromStdString(name));
|
||||
RegisterMacroAddUndoRedo(name);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -142,14 +139,12 @@ void AdvSceneSwitcher::on_macroAdd_clicked()
|
||||
ui->macros->Add(newMacro, selectedMacro);
|
||||
MacroSignalManager::Instance()->Add(
|
||||
QString::fromStdString(name));
|
||||
RegisterMacroAddUndoRedo(name);
|
||||
return;
|
||||
}
|
||||
|
||||
Macro::PrepareMoveToGroup(selectedMacroGroup, newMacro);
|
||||
ui->macros->Add(newMacro, selectedMacro);
|
||||
MacroSignalManager::Instance()->Add(QString::fromStdString(name));
|
||||
RegisterMacroAddUndoRedo(name);
|
||||
}
|
||||
|
||||
static void addGroupSubitems(std::vector<std::shared_ptr<Macro>> ¯os,
|
||||
@@ -190,12 +185,6 @@ void AdvSceneSwitcher::RemoveMacro(std::shared_ptr<Macro> ¯o)
|
||||
}
|
||||
}
|
||||
|
||||
if (macro->IsGroup()) {
|
||||
RegisterGroupDeleteUndoRedo(macro.get());
|
||||
} else {
|
||||
RegisterMacroRemoveUndoRedo(macro.get());
|
||||
}
|
||||
|
||||
if (macro->IsGroup()) {
|
||||
std::vector<std::shared_ptr<Macro>> macros = {macro};
|
||||
addGroupSubitems(macros, macro);
|
||||
@@ -252,16 +241,13 @@ void AdvSceneSwitcher::RemoveSelectedMacros()
|
||||
void AdvSceneSwitcher::RenameMacro(std::shared_ptr<Macro> ¯o,
|
||||
const QString &name)
|
||||
{
|
||||
const std::string oldName = macro->Name();
|
||||
const std::string newName = name.toStdString();
|
||||
auto oldName = QString::fromStdString(macro->Name());
|
||||
{
|
||||
auto lock = LockContext();
|
||||
macro->SetName(newName);
|
||||
macro->SetName(name.toStdString());
|
||||
}
|
||||
|
||||
RegisterMacroRenameUndoRedo(oldName, newName);
|
||||
MacroSignalManager::Instance()->Rename(QString::fromStdString(oldName),
|
||||
name);
|
||||
MacroSignalManager::Instance()->Rename(oldName, name);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_macroRemove_clicked()
|
||||
@@ -457,7 +443,6 @@ void AdvSceneSwitcher::ImportMacros()
|
||||
ui->macros->Reset(GetTopLevelMacros(),
|
||||
GetGlobalMacroSettings()._highlightExecuted);
|
||||
disableAddButtonHighlight();
|
||||
RegisterMacrosImportUndoRedo(importedMacros);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::on_macroName_editingFinished()
|
||||
@@ -829,7 +814,6 @@ void AdvSceneSwitcher::CopyMacro()
|
||||
ui->macros->Add(newMacro, macro);
|
||||
disableAddButtonHighlight();
|
||||
MacroSignalManager::Instance()->Add(QString::fromStdString(name));
|
||||
RegisterMacroAddUndoRedo(name);
|
||||
}
|
||||
|
||||
void AdvSceneSwitcher::PauseSelectedMacros()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "macro-tree.hpp"
|
||||
#include "macro-undo-redo.hpp"
|
||||
|
||||
#include "macro-helpers.hpp"
|
||||
#include "macro-search.hpp"
|
||||
@@ -825,8 +824,6 @@ void MacroTreeModel::GroupSelectedItems(QModelIndexList &indices)
|
||||
|
||||
Reset(_macros);
|
||||
assert(IsInValidState());
|
||||
|
||||
RegisterGroupCreateUndoRedo(name.toStdString());
|
||||
}
|
||||
|
||||
void MacroTreeModel::UngroupSelectedGroups(QModelIndexList &indices)
|
||||
@@ -840,7 +837,6 @@ void MacroTreeModel::UngroupSelectedGroups(QModelIndexList &indices)
|
||||
std::shared_ptr<Macro> item = _macros[ModelIndexToMacroIndex(
|
||||
indices[i].row(), _macros)];
|
||||
if (item->IsGroup()) {
|
||||
RegisterGroupRemoveUndoRedo(item->Name());
|
||||
Macro::RemoveGroup(item);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
#include "macro-edit.hpp"
|
||||
|
||||
#include <obs-data.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace advss {
|
||||
|
||||
class Macro;
|
||||
|
||||
void RegisterMacroAddUndoRedo(const std::string ¯oName);
|
||||
bool RegisterMacroRemoveUndoRedo(Macro *macro);
|
||||
void RegisterSegmentAddUndoRedo(Macro *macro, MacroEdit::SegmentType type,
|
||||
int index);
|
||||
void RegisterSegmentTypeChangeUndoRedo(Macro *macro,
|
||||
MacroEdit::SegmentType type, int index,
|
||||
const std::string &oldId,
|
||||
obs_data_t *oldData, int oldLogic,
|
||||
const std::string &newId,
|
||||
obs_data_t *newData, int newLogic);
|
||||
void RegisterSegmentRemoveUndoRedo(Macro *macro, MacroEdit::SegmentType type,
|
||||
int index, const std::string &segmentId,
|
||||
obs_data_t *segmentData, int logic);
|
||||
void RegisterMacroRenameUndoRedo(const std::string &oldName,
|
||||
const std::string &newName);
|
||||
void RegisterGroupCreateUndoRedo(const std::string &groupName);
|
||||
void RegisterGroupRemoveUndoRedo(const std::string &groupName);
|
||||
void RegisterGroupDeleteUndoRedo(Macro *macro);
|
||||
void RegisterMacroModifyUndoRedo(Macro *parentMacro, obs_data_t *beforeData);
|
||||
void RegisterMacrosImportUndoRedo(
|
||||
const std::vector<std::shared_ptr<Macro>> &importedMacros);
|
||||
|
||||
} // namespace advss
|
||||
@@ -130,13 +130,6 @@ public:
|
||||
void SetParent(std::shared_ptr<Macro> m) { _parent = m; }
|
||||
std::shared_ptr<Macro> Parent() const;
|
||||
|
||||
// For nested macros embedded in actions (e.g. loop, nested-macro action)
|
||||
void SetNestedParentMacro(Macro *parent)
|
||||
{
|
||||
_nestedParentMacro = parent;
|
||||
}
|
||||
Macro *GetNestedParentMacro() const { return _nestedParentMacro; }
|
||||
|
||||
// Saving and loading
|
||||
bool Save(obs_data_t *obj, bool saveForCopy = false) const;
|
||||
bool Load(obs_data_t *obj);
|
||||
@@ -194,7 +187,6 @@ private:
|
||||
std::deque<std::shared_ptr<MacroAction>> _elseActions;
|
||||
|
||||
std::weak_ptr<Macro> _parent;
|
||||
Macro *_nestedParentMacro = nullptr;
|
||||
uint32_t _groupSize = 0;
|
||||
bool _isGroup = false;
|
||||
bool _isCollapsed = false;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#include "macro-action-scene-collection.hpp"
|
||||
|
||||
#include "layout-helpers.hpp"
|
||||
#include "plugin-state-helpers.hpp"
|
||||
#include "selection-helpers.hpp"
|
||||
#include "ui-helpers.hpp"
|
||||
|
||||
#include <obs-frontend-api.h>
|
||||
|
||||
@@ -17,20 +15,6 @@ bool MacroActionSceneCollection::_registered = MacroActionFactory::Register(
|
||||
MacroActionSceneCollectionEdit::Create,
|
||||
"AdvSceneSwitcher.action.sceneCollection"});
|
||||
|
||||
template<typename F> void QueueUITaskLambda(F &&func)
|
||||
{
|
||||
using FnType = std::decay_t<F>;
|
||||
auto *heapFunc = new FnType(std::forward<F>(func));
|
||||
|
||||
QueueUITask(
|
||||
[](void *param) {
|
||||
std::unique_ptr<FnType> fn(
|
||||
static_cast<FnType *>(param));
|
||||
(*fn)();
|
||||
},
|
||||
heapFunc);
|
||||
}
|
||||
|
||||
bool MacroActionSceneCollection::PerformAction()
|
||||
{
|
||||
// Changing the scene collection will also reload the settings of the
|
||||
@@ -39,13 +23,7 @@ bool MacroActionSceneCollection::PerformAction()
|
||||
if (SettingsWindowIsOpened()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto collectionName = _sceneCollection;
|
||||
QueueUITaskLambda([collectionName]() {
|
||||
obs_frontend_set_current_scene_collection(
|
||||
collectionName.c_str());
|
||||
});
|
||||
|
||||
obs_frontend_set_current_scene_collection(_sceneCollection.c_str());
|
||||
// It does not make sense to continue as the current settings will be
|
||||
// invalid after switching scene collection.
|
||||
return false;
|
||||
|
||||
@@ -25,8 +25,6 @@ const static std::map<MacroConditionAudio::Type, std::string> checkTypes = {
|
||||
"AdvSceneSwitcher.condition.audio.type.monitor"},
|
||||
{MacroConditionAudio::Type::BALANCE,
|
||||
"AdvSceneSwitcher.condition.audio.type.balance"},
|
||||
{MacroConditionAudio::Type::TRACK,
|
||||
"AdvSceneSwitcher.condition.audio.type.track"},
|
||||
};
|
||||
|
||||
const static std::map<MacroConditionAudio::OutputCondition, std::string>
|
||||
@@ -247,20 +245,6 @@ bool MacroConditionAudio::CheckBalance()
|
||||
return ret && source;
|
||||
}
|
||||
|
||||
bool MacroConditionAudio::CheckTrack()
|
||||
{
|
||||
if (!_audioSource.GetSource()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OBSSourceAutoRelease source =
|
||||
obs_weak_source_get_source(_audioSource.GetSource());
|
||||
uint32_t mixers = obs_source_get_audio_mixers(source);
|
||||
bool enabled = (mixers >> (uint32_t)(_track - 1)) & 1u;
|
||||
SetTempVarValue("track_enabled", enabled ? "true" : "false");
|
||||
return enabled && source;
|
||||
}
|
||||
|
||||
bool MacroConditionAudio::CheckCondition()
|
||||
{
|
||||
bool ret = false;
|
||||
@@ -280,9 +264,6 @@ bool MacroConditionAudio::CheckCondition()
|
||||
case Type::BALANCE:
|
||||
ret = CheckBalance();
|
||||
break;
|
||||
case Type::TRACK:
|
||||
ret = CheckTrack();
|
||||
break;
|
||||
}
|
||||
|
||||
if (GetVariableValue().empty()) {
|
||||
@@ -300,7 +281,6 @@ bool MacroConditionAudio::Save(obs_data_t *obj) const
|
||||
_volumePercent.Save(obj, "volume");
|
||||
_syncOffset.Save(obj, "syncOffset");
|
||||
_balance.Save(obj, "balance");
|
||||
_track.Save(obj, "track");
|
||||
obs_data_set_int(obj, "checkType", static_cast<int>(_checkType));
|
||||
obs_data_set_int(obj, "outputCondition",
|
||||
static_cast<int>(_outputCondition));
|
||||
@@ -366,7 +346,6 @@ bool MacroConditionAudio::Load(obs_data_t *obj)
|
||||
_useDb = obs_data_get_bool(obj, "useDb");
|
||||
_volumeDB.Load(obj, "volumeDB");
|
||||
}
|
||||
_track.Load(obj, "track");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -442,12 +421,6 @@ void MacroConditionAudio::SetupTempVars()
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.audio.balance"));
|
||||
break;
|
||||
case Type::TRACK:
|
||||
AddTempvar(
|
||||
"track_enabled",
|
||||
obs_module_text(
|
||||
"AdvSceneSwitcher.tempVar.audio.trackEnabled"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -495,7 +468,6 @@ static QStringList getAudioSourcesList()
|
||||
MacroConditionAudioEdit::MacroConditionAudioEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroConditionAudio> entryData)
|
||||
: QWidget(parent),
|
||||
_layout(new QHBoxLayout),
|
||||
_checkTypes(new QComboBox()),
|
||||
_sources(new SourceSelectionWidget(this, getAudioSourcesList, true)),
|
||||
_condition(new QComboBox()),
|
||||
@@ -504,8 +476,7 @@ MacroConditionAudioEdit::MacroConditionAudioEdit(
|
||||
_percentDBToggle(new QPushButton),
|
||||
_syncOffset(new VariableSpinBox()),
|
||||
_monitorTypes(new QComboBox),
|
||||
_balance(new SliderSpinBox(0., 1., "")),
|
||||
_track(new VariableSpinBox())
|
||||
_balance(new SliderSpinBox(0., 1., ""))
|
||||
{
|
||||
_volumePercent->setSuffix("%");
|
||||
_volumePercent->setMaximum(100);
|
||||
@@ -520,9 +491,6 @@ MacroConditionAudioEdit::MacroConditionAudioEdit(
|
||||
_syncOffset->setMaximum(20000);
|
||||
_syncOffset->setSuffix("ms");
|
||||
|
||||
_track->setMinimum(1);
|
||||
_track->setMaximum(32);
|
||||
|
||||
QWidget::connect(_checkTypes, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(CheckTypeChanged(int)));
|
||||
QWidget::connect(
|
||||
@@ -551,16 +519,27 @@ MacroConditionAudioEdit::MacroConditionAudioEdit(
|
||||
this, SLOT(VolumeDBChanged(const NumberVariable<double> &)));
|
||||
QWidget::connect(_percentDBToggle, SIGNAL(clicked()), this,
|
||||
SLOT(PercentDBClicked()));
|
||||
QWidget::connect(
|
||||
_track,
|
||||
SIGNAL(NumberVariableChanged(const NumberVariable<int> &)),
|
||||
this, SLOT(TrackChanged(const NumberVariable<int> &)));
|
||||
|
||||
populateCheckTypes(_checkTypes);
|
||||
PopulateMonitorTypeSelection(_monitorTypes);
|
||||
|
||||
QHBoxLayout *switchLayout = new QHBoxLayout;
|
||||
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
||||
{"{{checkType}}", _checkTypes},
|
||||
{"{{audioSources}}", _sources},
|
||||
{"{{volume}}", _volumePercent},
|
||||
{"{{syncOffset}}", _syncOffset},
|
||||
{"{{monitorTypes}}", _monitorTypes},
|
||||
{"{{balance}}", _balance},
|
||||
{"{{condition}}", _condition},
|
||||
{"{{volumeDB}}", _volumeDB},
|
||||
{"{{percentDBToggle}}", _percentDBToggle},
|
||||
};
|
||||
PlaceWidgets(obs_module_text("AdvSceneSwitcher.condition.audio.entry"),
|
||||
switchLayout, widgetPlaceholders);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(_layout);
|
||||
mainLayout->addLayout(switchLayout);
|
||||
mainLayout->addWidget(_balance);
|
||||
setLayout(mainLayout);
|
||||
|
||||
@@ -629,12 +608,6 @@ void MacroConditionAudioEdit::BalanceChanged(const NumberVariable<double> &value
|
||||
_entryData->_balance = value;
|
||||
}
|
||||
|
||||
void MacroConditionAudioEdit::TrackChanged(const NumberVariable<int> &value)
|
||||
{
|
||||
GUARD_LOADING_AND_LOCK();
|
||||
_entryData->_track = value;
|
||||
}
|
||||
|
||||
void MacroConditionAudioEdit::VolumeDBChanged(
|
||||
const NumberVariable<double> &value)
|
||||
{
|
||||
@@ -719,8 +692,6 @@ void MacroConditionAudioEdit::CheckTypeChanged(int idx)
|
||||
} else if (_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::CONFIGURED_VOLUME) {
|
||||
populateVolumeConditionSelection(_condition);
|
||||
} else if (_entryData->GetType() == MacroConditionAudio::Type::TRACK) {
|
||||
_condition->clear();
|
||||
}
|
||||
SetWidgetVisibility();
|
||||
}
|
||||
@@ -737,7 +708,6 @@ void MacroConditionAudioEdit::UpdateEntryData()
|
||||
_syncOffset->SetValue(_entryData->_syncOffset);
|
||||
_monitorTypes->setCurrentIndex(_entryData->_monitorType);
|
||||
_balance->SetDoubleValue(_entryData->_balance);
|
||||
_track->SetValue(_entryData->_track);
|
||||
_checkTypes->setCurrentIndex(
|
||||
_checkTypes->findData(static_cast<int>(_entryData->GetType())));
|
||||
|
||||
@@ -778,63 +748,26 @@ void MacroConditionAudioEdit::SetWidgetVisibility()
|
||||
return;
|
||||
}
|
||||
|
||||
_layout->removeWidget(_checkTypes);
|
||||
_layout->removeWidget(_sources);
|
||||
_layout->removeWidget(_condition);
|
||||
_layout->removeWidget(_volumePercent);
|
||||
_layout->removeWidget(_volumeDB);
|
||||
_layout->removeWidget(_percentDBToggle);
|
||||
_layout->removeWidget(_syncOffset);
|
||||
_layout->removeWidget(_monitorTypes);
|
||||
_layout->removeWidget(_track);
|
||||
ClearLayout(_layout);
|
||||
|
||||
const std::unordered_map<std::string, QWidget *> placeholders = {
|
||||
{"{{checkType}}", _checkTypes},
|
||||
{"{{audioSources}}", _sources},
|
||||
{"{{condition}}", _condition},
|
||||
{"{{volume}}", _volumePercent},
|
||||
{"{{volumeDB}}", _volumeDB},
|
||||
{"{{percentDBToggle}}", _percentDBToggle},
|
||||
{"{{syncOffset}}", _syncOffset},
|
||||
{"{{monitorTypes}}", _monitorTypes},
|
||||
{"{{track}}", _track},
|
||||
};
|
||||
|
||||
const bool isTrack = _entryData->GetType() ==
|
||||
MacroConditionAudio::Type::TRACK;
|
||||
PlaceWidgets(
|
||||
obs_module_text(
|
||||
isTrack ? "AdvSceneSwitcher.condition.audio.layout.track"
|
||||
: "AdvSceneSwitcher.condition.audio.entry"),
|
||||
_layout, placeholders);
|
||||
|
||||
_condition->setVisible(
|
||||
!isTrack &&
|
||||
(_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::OUTPUT_VOLUME ||
|
||||
_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::CONFIGURED_VOLUME ||
|
||||
_entryData->GetType() == MacroConditionAudio::Type::BALANCE ||
|
||||
_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::SYNC_OFFSET));
|
||||
_syncOffset->setVisible(!isTrack &&
|
||||
_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::SYNC_OFFSET);
|
||||
_monitorTypes->setVisible(!isTrack &&
|
||||
_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::MONITOR);
|
||||
_track->setVisible(isTrack);
|
||||
_volumePercent->setVisible(!isTrack && HasVolumeControl() &&
|
||||
!_entryData->_useDb);
|
||||
_volumeDB->setVisible(!isTrack && HasVolumeControl() &&
|
||||
_entryData->_useDb);
|
||||
_percentDBToggle->setText(_entryData->_useDb ? "dB" : "%");
|
||||
_percentDBToggle->setVisible(!isTrack && HasVolumeControl());
|
||||
_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::OUTPUT_VOLUME ||
|
||||
_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::CONFIGURED_VOLUME ||
|
||||
_entryData->GetType() == MacroConditionAudio::Type::BALANCE ||
|
||||
_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::SYNC_OFFSET);
|
||||
_syncOffset->setVisible(_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::SYNC_OFFSET);
|
||||
_monitorTypes->setVisible(_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::MONITOR);
|
||||
_balance->setVisible(_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::BALANCE);
|
||||
_volMeter->setVisible(_entryData->GetType() ==
|
||||
MacroConditionAudio::Type::OUTPUT_VOLUME);
|
||||
_volumePercent->setVisible(HasVolumeControl() && !_entryData->_useDb);
|
||||
_volumeDB->setVisible(HasVolumeControl() && _entryData->_useDb);
|
||||
_percentDBToggle->setText(_entryData->_useDb ? "dB" : "%");
|
||||
_percentDBToggle->setVisible(HasVolumeControl());
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "source-selection.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <QHBoxLayout>
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
#include <chrono>
|
||||
@@ -37,7 +36,6 @@ public:
|
||||
SYNC_OFFSET,
|
||||
MONITOR,
|
||||
BALANCE,
|
||||
TRACK,
|
||||
};
|
||||
void SetType(const Type &);
|
||||
Type GetType() const { return _checkType; }
|
||||
@@ -62,7 +60,6 @@ public:
|
||||
IntVariable _syncOffset = 0;
|
||||
obs_monitoring_type _monitorType = OBS_MONITORING_TYPE_NONE;
|
||||
DoubleVariable _balance = 0.5;
|
||||
IntVariable _track = 1;
|
||||
OutputCondition _outputCondition = OutputCondition::ABOVE;
|
||||
VolumeCondition _volumeCondition = VolumeCondition::ABOVE;
|
||||
obs_volmeter_t *_volmeter = nullptr;
|
||||
@@ -73,7 +70,6 @@ private:
|
||||
bool CheckSyncOffset();
|
||||
bool CheckMonitor();
|
||||
bool CheckBalance();
|
||||
bool CheckTrack();
|
||||
void SetupTempVars();
|
||||
float GetVolumePeak();
|
||||
|
||||
@@ -115,7 +111,6 @@ private slots:
|
||||
void VolumeDBChanged(const NumberVariable<double> &value);
|
||||
void PercentDBClicked();
|
||||
void SyncSliderAndValueSelection(bool sliderMoved);
|
||||
void TrackChanged(const NumberVariable<int> &value);
|
||||
|
||||
signals:
|
||||
void HeaderInfoChanged(const QString &);
|
||||
@@ -124,7 +119,6 @@ private:
|
||||
void SetWidgetVisibility();
|
||||
bool HasVolumeControl() const;
|
||||
|
||||
QHBoxLayout *_layout;
|
||||
QComboBox *_checkTypes;
|
||||
SourceSelectionWidget *_sources;
|
||||
QComboBox *_condition;
|
||||
@@ -134,7 +128,6 @@ private:
|
||||
VariableSpinBox *_syncOffset;
|
||||
QComboBox *_monitorTypes;
|
||||
SliderSpinBox *_balance;
|
||||
VariableSpinBox *_track;
|
||||
VolControl *_volMeter = nullptr;
|
||||
|
||||
std::shared_ptr<MacroConditionAudio> _entryData;
|
||||
|
||||
@@ -110,9 +110,7 @@ void MacroEdit::HighlightControls() const {}
|
||||
void MacroEdit::PopulateMacroActions(Macro &, uint32_t) {}
|
||||
void MacroEdit::PopulateMacroElseActions(Macro &, uint32_t) {}
|
||||
void MacroEdit::PopulateMacroConditions(Macro &, uint32_t) {}
|
||||
void MacroEdit::InsertSegmentWidget(SegmentType, int) {}
|
||||
void MacroEdit::RemoveSegmentWidget(SegmentType, int) {}
|
||||
void MacroEdit::SetupMacroSegmentSelection(SegmentType, int) {}
|
||||
void MacroEdit::SetupMacroSegmentSelection(MacroSection, int) {}
|
||||
void MacroEdit::SetupContextMenu(const QPoint &,
|
||||
const std::function<void(MacroEdit *, int)> &,
|
||||
const std::function<void(MacroEdit *)> &,
|
||||
|
||||
Reference in New Issue
Block a user