Reopen last opened tab in current session

Will reset to General tab on startup / scene collection change
This commit is contained in:
WarmUpTill
2022-02-04 22:13:36 +01:00
committed by WarmUpTill
parent 0effbd8ace
commit 1328896801
4 changed files with 14 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ AdvSceneSwitcher::~AdvSceneSwitcher()
{
if (switcher) {
switcher->settingsWindowOpened = false;
switcher->lastOpenedTab = ui->tabWidget->currentIndex();
}
}
@@ -86,6 +87,7 @@ void AdvSceneSwitcher::loadUI()
setupMacroTab();
setTabOrder();
setCurrentTab();
restoreWindowGeo();
checkFirstTimeSetup();

View File

@@ -460,6 +460,13 @@ void AdvSceneSwitcher::setTabOrder()
connect(bar, &QTabBar::tabMoved, this, &AdvSceneSwitcher::on_tabMoved);
}
void AdvSceneSwitcher::setCurrentTab()
{
if (switcher->lastOpenedTab >= 0) {
ui->tabWidget->setCurrentIndex(switcher->lastOpenedTab);
}
}
void AdvSceneSwitcher::restoreWindowGeo()
{
if (switcher->saveWindowGeo && windowPosValid(switcher->windowPos)) {
@@ -517,6 +524,9 @@ void SwitcherData::loadSettings(obs_data_t *obj)
loadSceneTriggers(obj);
loadGeneralSettings(obj);
loadHotkeys(obj);
// Reset on startup and scene collection change
switcher->lastOpenedTab = -1;
}
void SwitcherData::saveSettings(obs_data_t *obj)

View File

@@ -78,6 +78,7 @@ public:
void setupNetworkTab();
void setupMacroTab();
void setTabOrder();
void setCurrentTab();
void restoreWindowGeo();
void checkFirstTimeSetup();

View File

@@ -77,6 +77,7 @@ struct SwitcherData {
SwitcherThread *th = nullptr;
bool settingsWindowOpened = false;
int lastOpenedTab = -1;
bool firstBoot = true;
std::condition_variable cv;