From 28ad12bf308326d1ad8aaf7fc04a6e657338b215 Mon Sep 17 00:00:00 2001 From: spycrab Date: Wed, 31 Jan 2018 19:58:02 +0100 Subject: [PATCH] Qt/Settings: Update default gamelist path textbox when changed --- Source/Core/DolphinQt2/GameList/GameList.cpp | 2 +- Source/Core/DolphinQt2/Settings.cpp | 14 ++++++++++++++ Source/Core/DolphinQt2/Settings.h | 3 +++ Source/Core/DolphinQt2/Settings/PathPane.cpp | 6 ++++-- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinQt2/GameList/GameList.cpp b/Source/Core/DolphinQt2/GameList/GameList.cpp index c84e05d69d..e9ee5ddeaf 100644 --- a/Source/Core/DolphinQt2/GameList/GameList.cpp +++ b/Source/Core/DolphinQt2/GameList/GameList.cpp @@ -368,7 +368,7 @@ void GameList::UninstallWAD() void GameList::SetDefaultISO() { - SConfig::GetInstance().m_strDefaultISO = GetSelectedGame()->GetFilePath().toStdString(); + Settings::Instance().SetDefaultGame(GetSelectedGame()->GetFilePath()); } void GameList::OpenContainingFolder() diff --git a/Source/Core/DolphinQt2/Settings.cpp b/Source/Core/DolphinQt2/Settings.cpp index 433dd3ab95..d93a338f71 100644 --- a/Source/Core/DolphinQt2/Settings.cpp +++ b/Source/Core/DolphinQt2/Settings.cpp @@ -72,6 +72,20 @@ void Settings::RemovePath(const QString& qpath) emit PathRemoved(qpath); } +QString Settings::GetDefaultGame() const +{ + return QString::fromStdString(SConfig::GetInstance().m_strDefaultISO); +} + +void Settings::SetDefaultGame(QString path) +{ + if (GetDefaultGame() != path) + { + SConfig::GetInstance().m_strDefaultISO = path.toStdString(); + emit DefaultGameChanged(path); + } +} + bool Settings::GetPreferredView() const { return QSettings().value(QStringLiteral("PreferredView"), true).toBool(); diff --git a/Source/Core/DolphinQt2/Settings.h b/Source/Core/DolphinQt2/Settings.h index 7ae4340f7b..3cdc10959e 100644 --- a/Source/Core/DolphinQt2/Settings.h +++ b/Source/Core/DolphinQt2/Settings.h @@ -53,6 +53,8 @@ public: void RemovePath(const QString& path); bool GetPreferredView() const; void SetPreferredView(bool list); + QString GetDefaultGame() const; + void SetDefaultGame(QString path); // Emulation int GetStateSlot() const; @@ -96,6 +98,7 @@ signals: void ThemeChanged(); void PathAdded(const QString&); void PathRemoved(const QString&); + void DefaultGameChanged(const QString&); void HideCursorChanged(); void VolumeChanged(int volume); void NANDRefresh(); diff --git a/Source/Core/DolphinQt2/Settings/PathPane.cpp b/Source/Core/DolphinQt2/Settings/PathPane.cpp index 12faaa8af0..76ca08edfa 100644 --- a/Source/Core/DolphinQt2/Settings/PathPane.cpp +++ b/Source/Core/DolphinQt2/Settings/PathPane.cpp @@ -97,9 +97,11 @@ QGridLayout* PathPane::MakePathsLayout() QGridLayout* layout = new QGridLayout; layout->setColumnStretch(1, 1); - m_game_edit = new QLineEdit(QString::fromStdString(SConfig::GetInstance().m_strDefaultISO)); + m_game_edit = new QLineEdit(Settings::Instance().GetDefaultGame()); connect(m_game_edit, &QLineEdit::editingFinished, - [=] { SConfig::GetInstance().m_strDefaultISO = m_game_edit->text().toStdString(); }); + [this] { Settings::Instance().SetDefaultGame(m_game_edit->text()); }); + connect(&Settings::Instance(), &Settings::DefaultGameChanged, + [this](const QString& path) { m_game_edit->setText(path); }); QPushButton* game_open = new QPushButton; connect(game_open, &QPushButton::clicked, this, &PathPane::BrowseDefaultGame); layout->addWidget(new QLabel(tr("Default ISO:")), 0, 0);