diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index 2bd2779d..7b6470c0 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -44,6 +44,8 @@ AdvSceneSwitcher.generalTab.generalBehavior.warnPluginLoadFailureMessage=" AdvSceneSwitcher.generalTab.generalBehavior.warnCorruptedInstallMessage="The plugin installation seems to be corrupted and might crash!\nPlease make sure the plugin was installed correctly!" AdvSceneSwitcher.generalTab.generalBehavior.hideLegacyTabs="Hide tabs which can be represented via macros" AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowMacroSearch="Always show macro search" +AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowFeatureTabs="Always show all feature tabs" +AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowFeatureTabs.tooltip="Show tabs that are normally hidden until first used in a macro (e.g. Action Queues, Variables, Twitch, Websockets)." AdvSceneSwitcher.generalTab.matchBehavior="Match behavior" AdvSceneSwitcher.generalTab.priority="Priority" AdvSceneSwitcher.generalTab.priority.description="Switching methods priority (Highest priority is at the top)" diff --git a/forms/advanced-scene-switcher.ui b/forms/advanced-scene-switcher.ui index 78e98a84..53e81146 100644 --- a/forms/advanced-scene-switcher.ui +++ b/forms/advanced-scene-switcher.ui @@ -68,7 +68,7 @@ 0 0 962 - 1132 + 1160 @@ -268,9 +268,19 @@ - + - AdvSceneSwitcher.generalTab.generalBehavior.disableUIHints + AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowMacroSearch + + + + + + + AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowFeatureTabs.tooltip + + + AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowFeatureTabs @@ -282,9 +292,9 @@ - + - AdvSceneSwitcher.generalTab.generalBehavior.alwaysShowMacroSearch + AdvSceneSwitcher.generalTab.generalBehavior.disableUIHints diff --git a/lib/general.cpp b/lib/general.cpp index 1d4ec7a6..f72c3674 100644 --- a/lib/general.cpp +++ b/lib/general.cpp @@ -1029,6 +1029,8 @@ void AdvSceneSwitcher::SetupGeneralTab() setTabOrder(ui->importSettings, ui->cooldownTime); setTabOrder(ui->cooldownTime, ui->noMatchDontSwitch); + SetupShowAllTabsCheckBox(ui->alwaysShowFeatureTabs, ui->tabWidget); + MinimizeSizeOfColumn(ui->statusLayout, 0); setWindowTitle(windowTitle() + " - " + g_GIT_TAG); } diff --git a/lib/utils/tab-helpers.cpp b/lib/utils/tab-helpers.cpp index bf72e413..c1bdc2c8 100644 --- a/lib/utils/tab-helpers.cpp +++ b/lib/utils/tab-helpers.cpp @@ -1,6 +1,7 @@ #include "tab-helpers.hpp" #include "log-helper.hpp" #include "obs-module-helper.hpp" +#include "plugin-state-helpers.hpp" #include #include @@ -33,6 +34,21 @@ struct TabCallbacks { static std::unordered_map createTabCallbacks; static int lastOpenedTab = -1; +static bool alwaysShowTabs = false; + +[[maybe_unused]] static bool _ = []() { + AddPluginInitStep([]() { + AddSaveStep([](obs_data_t *data) { + obs_data_set_bool(data, "alwaysShowTabs", + alwaysShowTabs); + }); + AddLoadStep([](obs_data_t *data) { + alwaysShowTabs = + obs_data_get_bool(data, "alwaysShowTabs"); + }); + }); + return true; +}(); void SetTabVisibleByName(QTabWidget *tabWidget, bool visible, const QString &name) @@ -197,7 +213,41 @@ void SetupOtherTabs(QTabWidget *tabWidget) .c_str()); tabWidget->insertTab(0, widget, tabText); callbacks.setupTab(tabWidget); + + if (alwaysShowTabs) { + tabWidget->setTabVisible(0, true); + } } } +void SetupShowAllTabsCheckBox(QCheckBox *checkBox, QTabWidget *tabWidget) +{ + const auto stateChanged = [tabWidget](int state) { + const bool newState = (state != 0); + if (newState == alwaysShowTabs) { + return; + } + + alwaysShowTabs = newState; + + // Only show currently hidden tabs, but don't hide tabs which + // are already visible + if (!alwaysShowTabs) { + return; + } + + for (const auto &[name, _] : createTabCallbacks) { + const auto localeKey = + std::string("AdvSceneSwitcher.") + name + + ".title"; + auto tabText = obs_module_text(localeKey.c_str()); + SetTabVisibleByName(tabWidget, true, tabText); + } + }; + + checkBox->setChecked(alwaysShowTabs); + QWidget::connect(checkBox, &QCheckBox::stateChanged, checkBox, + stateChanged); +} + } // namespace advss diff --git a/lib/utils/tab-helpers.hpp b/lib/utils/tab-helpers.hpp index b90060bf..f2bef70c 100644 --- a/lib/utils/tab-helpers.hpp +++ b/lib/utils/tab-helpers.hpp @@ -2,6 +2,8 @@ #include "export-symbol-helper.hpp" #include + +#include #include namespace advss { @@ -19,5 +21,6 @@ void SetupOtherTabs(QTabWidget *tabWidget); void SaveTabOrder(obs_data_t *obj); void LoadTabOrder(obs_data_t *obj); bool MacroTabIsInFocus(); +void SetupShowAllTabsCheckBox(QCheckBox *checkBox, QTabWidget *tabWidget); } // namespace advss