From dbdc2538f98147c7661cac00fe135df59aeb04e3 Mon Sep 17 00:00:00 2001 From: Tannin Date: Mon, 11 May 2015 21:39:56 +0200 Subject: bugfix: upon closing the profiles dialog, the profile was changed to the top-most profile and back --- src/mainwindow.cpp | 6 +++--- src/organizercore.cpp | 4 ++++ src/profilesdialog.cpp | 11 +++++++---- src/profilesdialog.h | 7 +++---- 4 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 10af1b27..b5347d4d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1011,11 +1011,11 @@ void MainWindow::on_profileBox_currentIndexChanged(int index) } if (ui->profileBox->currentIndex() == 0) { - ProfilesDialog(m_GamePath, this).exec(); + ui->profileBox->setCurrentIndex(previousIndex); + ProfilesDialog(ui->profileBox->currentText(), this).exec(); while (!refreshProfiles()) { - ProfilesDialog(m_GamePath, this).exec(); + ProfilesDialog(ui->profileBox->currentText(), this).exec(); } - ui->profileBox->setCurrentIndex(previousIndex); } else { activateSelectedProfile(); } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 8ddb6e39..bc22c91c 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -504,6 +504,10 @@ void OrganizerCore::createDefaultProfile() void OrganizerCore::setCurrentProfile(const QString &profileName) { + if ((m_CurrentProfile != nullptr) && + (profileName == m_CurrentProfile->name())) { + return; + } QString profileDir = qApp->property("dataPath").toString() + "/" + ToQString(AppConfig::profilesPath()) + "/" + profileName; Profile *newProfile = new Profile(QDir(profileDir), managedGame()); diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp index 44ee96e9..5443cec0 100644 --- a/src/profilesdialog.cpp +++ b/src/profilesdialog.cpp @@ -42,10 +42,9 @@ using namespace MOShared; Q_DECLARE_METATYPE(Profile::Ptr) -ProfilesDialog::ProfilesDialog(const QString &gamePath, QWidget *parent) +ProfilesDialog::ProfilesDialog(const QString &profileName, QWidget *parent) : TutorableDialog("Profiles", parent) , ui(new Ui::ProfilesDialog) - , m_GamePath(gamePath) , m_FailState(false) { ui->setupUi(this); @@ -58,7 +57,10 @@ ProfilesDialog::ProfilesDialog(const QString &gamePath, QWidget *parent) while (profileIter.hasNext()) { profileIter.next(); - addItem(profileIter.filePath()); + QListWidgetItem *item = addItem(profileIter.filePath()); + if (profileName == profileIter.fileName()) { + m_ProfilesList->setCurrentItem(item); + } } QCheckBox *invalidationBox = findChild("invalidationBox"); @@ -97,7 +99,7 @@ void ProfilesDialog::on_closeButton_clicked() } -void ProfilesDialog::addItem(const QString &name) +QListWidgetItem *ProfilesDialog::addItem(const QString &name) { QDir profileDir(name); QListWidgetItem *newItem = new QListWidgetItem(profileDir.dirName(), m_ProfilesList); @@ -107,6 +109,7 @@ void ProfilesDialog::addItem(const QString &name) } catch (const std::exception& e) { reportError(tr("failed to create profile: %1").arg(e.what())); } + return newItem; } void ProfilesDialog::createProfile(const QString &name, bool useDefaultSettings) diff --git a/src/profilesdialog.h b/src/profilesdialog.h index 5cb5a449..6dd0c1d4 100644 --- a/src/profilesdialog.h +++ b/src/profilesdialog.h @@ -46,11 +46,11 @@ public: /** * @brief constructor * - * @param gamePath the path to the game directory + * @param profileName currently enabled profile * @param parent parent widget * @todo the game path could be retrieved from GameInfo just as easily **/ - explicit ProfilesDialog(const QString &gamePath, QWidget *parent = 0); + explicit ProfilesDialog(const QString &profileName, QWidget *parent = 0); ~ProfilesDialog(); /** @@ -65,7 +65,7 @@ protected: private: - void addItem(const QString &name); + QListWidgetItem *addItem(const QString &name); void createProfile(const QString &name, bool useDefaultSettings); void createProfile(const QString &name, const Profile &reference); @@ -91,7 +91,6 @@ private slots: private: Ui::ProfilesDialog *ui; - QString m_GamePath; QListWidget *m_ProfilesList; bool m_FailState; -- cgit v1.3.1