From 6fc04db134dd0c05993f6602a0421689cca4a03a Mon Sep 17 00:00:00 2001 From: redstrate Date: Tue, 9 Nov 2021 12:36:09 -0500 Subject: [PATCH] Make profile select on launcher functional --- src/xivlauncher.cpp | 14 ++++++++++++++ src/xivlauncher.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/xivlauncher.cpp b/src/xivlauncher.cpp index df46a7b..e5b4a3a 100755 --- a/src/xivlauncher.cpp +++ b/src/xivlauncher.cpp @@ -258,6 +258,9 @@ LauncherWindow::LauncherWindow(QWidget* parent) : auto layout = new QFormLayout(); profileSelect = new QComboBox(); + connect(profileSelect, &QComboBox::currentIndexChanged, [=](int index) { + reloadControls(); + }); layout->addRow("Profile", profileSelect); @@ -389,12 +392,21 @@ void LauncherWindow::saveSettings() { } void LauncherWindow::reloadControls() { + if(currentlyReloadingControls) + return; + + currentlyReloadingControls = true; + + const int oldIndex = profileSelect->currentIndex(); + profileSelect->clear(); for(const auto& profile : profileList()) { profileSelect->addItem(profile); } + profileSelect->setCurrentIndex(oldIndex); + if(profileSelect->currentIndex() == -1) { profileSelect->setCurrentIndex(defaultProfileIndex); } @@ -423,4 +435,6 @@ void LauncherWindow::reloadControls() { registerButton->setEnabled(currentProfile().isSapphire); otpEdit->setEnabled(!currentProfile().isSapphire); + + currentlyReloadingControls = false; } \ No newline at end of file diff --git a/src/xivlauncher.h b/src/xivlauncher.h index 31521a5..4ec488f 100755 --- a/src/xivlauncher.h +++ b/src/xivlauncher.h @@ -76,6 +76,8 @@ signals: void settingsChanged(); private: + bool currentlyReloadingControls = false; + SapphireLauncher* sapphireLauncher; SquareBoot* squareBoot; SquareLauncher* squareLauncher;