diff options
| author | 2019-01-02 21:05:02 -0500 | |
|---|---|---|
| committer | 2019-01-02 21:05:02 -0500 | |
| commit | 11f990975c4e7fc8d34480703bdba28d650e56cb (patch) | |
| tree | c8ab0a02ff074a70bfbdd139e44cf1fa5cbd0f55 /src | |
| parent | Merge pull request #1977 from lioncash/vi-log (diff) | |
| parent | qt: Use ProfileSelectionDialog when selecting user for save data (diff) | |
| download | yuzu-11f990975c4e7fc8d34480703bdba28d650e56cb.tar.gz yuzu-11f990975c4e7fc8d34480703bdba28d650e56cb.tar.xz yuzu-11f990975c4e7fc8d34480703bdba28d650e56cb.zip | |
Merge pull request #1941 from DarkLordZach/profile-select-save-data
qt: Use ProfileSelectionDialog when selecting user for save data
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/main.cpp | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 01a0f94ab..bd7b08007 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -827,31 +827,25 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
| 827 | const std::string nand_dir = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); | 827 | const std::string nand_dir = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); |
| 828 | ASSERT(program_id != 0); | 828 | ASSERT(program_id != 0); |
| 829 | 829 | ||
| 830 | Service::Account::ProfileManager manager{}; | 830 | const auto select_profile = [this]() -> s32 { |
| 831 | const auto user_ids = manager.GetAllUsers(); | 831 | QtProfileSelectionDialog dialog(this); |
| 832 | QStringList list; | 832 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | |
| 833 | for (const auto& user_id : user_ids) { | 833 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); |
| 834 | if (user_id == Service::Account::UUID{}) | 834 | dialog.setWindowModality(Qt::WindowModal); |
| 835 | continue; | 835 | dialog.exec(); |
| 836 | Service::Account::ProfileBase base; | 836 | |
| 837 | if (!manager.GetProfileBase(user_id, base)) | 837 | if (!dialog.GetStatus()) { |
| 838 | continue; | 838 | return -1; |
| 839 | 839 | } | |
| 840 | list.push_back(QString::fromStdString(Common::StringFromFixedZeroTerminatedBuffer( | ||
| 841 | reinterpret_cast<const char*>(base.username.data()), base.username.size()))); | ||
| 842 | } | ||
| 843 | 840 | ||
| 844 | bool ok = false; | 841 | return dialog.GetIndex(); |
| 845 | const auto index_string = | 842 | }; |
| 846 | QInputDialog::getItem(this, tr("Select User"), | ||
| 847 | tr("Please select the user's save data you would like to open."), | ||
| 848 | list, Settings::values.current_user, false, &ok); | ||
| 849 | if (!ok) | ||
| 850 | return; | ||
| 851 | 843 | ||
| 852 | const auto index = list.indexOf(index_string); | 844 | const auto index = select_profile(); |
| 853 | ASSERT(index != -1 && index < 8); | 845 | if (index == -1) |
| 846 | return; | ||
| 854 | 847 | ||
| 848 | Service::Account::ProfileManager manager; | ||
| 855 | const auto user_id = manager.GetUser(index); | 849 | const auto user_id = manager.GetUser(index); |
| 856 | ASSERT(user_id); | 850 | ASSERT(user_id); |
| 857 | path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser, | 851 | path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser, |