From 836fefa2d9f97a362df5b9141b58c61a6d754737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 17 Oct 2018 22:20:11 +0200 Subject: [PATCH] WIP saving of config for offline mode name modes --- application/MultiMC.cpp | 1 + application/pages/global/AccountListPage.cpp | 17 +++++++++++++++++ application/pages/global/AccountListPage.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index dc1d47f1..d8af1cd2 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -490,6 +490,7 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) // Offline mode stuff m_settings->registerSetting("OfflineModeNameMode", "UseAccountName"); + m_settings->registerSetting("OfflineModeName", "Player"); // Window state and geometry m_settings->registerSetting("MainWindowState", ""); diff --git a/application/pages/global/AccountListPage.cpp b/application/pages/global/AccountListPage.cpp index 895b04f9..958deaf8 100644 --- a/application/pages/global/AccountListPage.cpp +++ b/application/pages/global/AccountListPage.cpp @@ -68,6 +68,8 @@ AccountListPage::AccountListPage(QWidget *parent) ui->offlineButtonGroup->setId(ui->rememberNamesForInstancesBtn, int(OfflineModeNameMode::RememberPerInstance)); ui->offlineButtonGroup->setId(ui->useFixedNameBtn, int(OfflineModeNameMode::UseFixedName)); + connect(ui->offlineButtonGroup, SIGNAL(buttonToggled(int,bool)), this, SLOT(groupSelectionChanged(int,bool))); + updateButtonStates(); loadSettings(); } @@ -191,6 +193,7 @@ void AccountListPage::applySettings() s->set("OfflineModeNameMode", "UseFixedName"); break; } + s->set("OfflineModeName", ui->mainOfflineNameEdit->text()); } void AccountListPage::loadSettings() @@ -213,4 +216,18 @@ void AccountListPage::loadSettings() { ui->useFixedNameBtn->setChecked(true); } + ui->mainOfflineNameEdit->setText(s->get("OfflineModeName").toString()); +} + +void AccountListPage::groupSelectionChanged(int, bool) +{ + auto sortMode = (OfflineModeNameMode)ui->offlineButtonGroup->checkedId(); + if(sortMode == OfflineModeNameMode::UseFixedName) + { + ui->mainOfflineNameEdit->setEnabled(true); + } + else + { + ui->mainOfflineNameEdit->setEnabled(false); + } } diff --git a/application/pages/global/AccountListPage.h b/application/pages/global/AccountListPage.h index f31c6312..70ab7fa7 100644 --- a/application/pages/global/AccountListPage.h +++ b/application/pages/global/AccountListPage.h @@ -74,6 +74,8 @@ slots: void listChanged(); + void groupSelectionChanged(int, bool); + //! Updates the states of the dialog's buttons. void updateButtonStates();