diff options
| author | 2019-06-05 15:30:51 -0400 | |
|---|---|---|
| committer | 2019-06-05 15:30:51 -0400 | |
| commit | 1eb979221f6664938456cefdbd5c79b7e59e2b8c (patch) | |
| tree | cffa349913d1abdd72a5fcc1e3735830f2fd45e2 /src | |
| parent | Merge pull request #2534 from ReinUsesLisp/shader-cleanup (diff) | |
| parent | yuzu/software_keyboard: Remove unnecessary GetStatus() member function (diff) | |
| download | yuzu-1eb979221f6664938456cefdbd5c79b7e59e2b8c.tar.gz yuzu-1eb979221f6664938456cefdbd5c79b7e59e2b8c.tar.xz yuzu-1eb979221f6664938456cefdbd5c79b7e59e2b8c.zip | |
Merge pull request #2527 from lioncash/index
yuzu/{profile_select, software_keyboard}: Tidy up interface
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/applets/profile_select.cpp | 8 | ||||
| -rw-r--r-- | src/yuzu/applets/profile_select.h | 8 | ||||
| -rw-r--r-- | src/yuzu/applets/software_keyboard.cpp | 6 | ||||
| -rw-r--r-- | src/yuzu/applets/software_keyboard.h | 2 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 26 |
5 files changed, 16 insertions, 34 deletions
diff --git a/src/yuzu/applets/profile_select.cpp b/src/yuzu/applets/profile_select.cpp index 42e26b978..6b5c7ba61 100644 --- a/src/yuzu/applets/profile_select.cpp +++ b/src/yuzu/applets/profile_select.cpp | |||
| @@ -122,21 +122,15 @@ QtProfileSelectionDialog::QtProfileSelectionDialog(QWidget* parent) | |||
| 122 | QtProfileSelectionDialog::~QtProfileSelectionDialog() = default; | 122 | QtProfileSelectionDialog::~QtProfileSelectionDialog() = default; |
| 123 | 123 | ||
| 124 | void QtProfileSelectionDialog::accept() { | 124 | void QtProfileSelectionDialog::accept() { |
| 125 | ok = true; | ||
| 126 | QDialog::accept(); | 125 | QDialog::accept(); |
| 127 | } | 126 | } |
| 128 | 127 | ||
| 129 | void QtProfileSelectionDialog::reject() { | 128 | void QtProfileSelectionDialog::reject() { |
| 130 | ok = false; | ||
| 131 | user_index = 0; | 129 | user_index = 0; |
| 132 | QDialog::reject(); | 130 | QDialog::reject(); |
| 133 | } | 131 | } |
| 134 | 132 | ||
| 135 | bool QtProfileSelectionDialog::GetStatus() const { | 133 | int QtProfileSelectionDialog::GetIndex() const { |
| 136 | return ok; | ||
| 137 | } | ||
| 138 | |||
| 139 | u32 QtProfileSelectionDialog::GetIndex() const { | ||
| 140 | return user_index; | 134 | return user_index; |
| 141 | } | 135 | } |
| 142 | 136 | ||
diff --git a/src/yuzu/applets/profile_select.h b/src/yuzu/applets/profile_select.h index c5b90a78e..cee886a77 100644 --- a/src/yuzu/applets/profile_select.h +++ b/src/yuzu/applets/profile_select.h | |||
| @@ -30,15 +30,13 @@ public: | |||
| 30 | void accept() override; | 30 | void accept() override; |
| 31 | void reject() override; | 31 | void reject() override; |
| 32 | 32 | ||
| 33 | bool GetStatus() const; | 33 | int GetIndex() const; |
| 34 | u32 GetIndex() const; | ||
| 35 | 34 | ||
| 36 | private: | 35 | private: |
| 37 | bool ok = false; | ||
| 38 | u32 user_index = 0; | ||
| 39 | |||
| 40 | void SelectUser(const QModelIndex& index); | 36 | void SelectUser(const QModelIndex& index); |
| 41 | 37 | ||
| 38 | int user_index = 0; | ||
| 39 | |||
| 42 | QVBoxLayout* layout; | 40 | QVBoxLayout* layout; |
| 43 | QTreeView* tree_view; | 41 | QTreeView* tree_view; |
| 44 | QStandardItemModel* item_model; | 42 | QStandardItemModel* item_model; |
diff --git a/src/yuzu/applets/software_keyboard.cpp b/src/yuzu/applets/software_keyboard.cpp index 5223ec977..af36f07c6 100644 --- a/src/yuzu/applets/software_keyboard.cpp +++ b/src/yuzu/applets/software_keyboard.cpp | |||
| @@ -104,13 +104,11 @@ QtSoftwareKeyboardDialog::QtSoftwareKeyboardDialog( | |||
| 104 | QtSoftwareKeyboardDialog::~QtSoftwareKeyboardDialog() = default; | 104 | QtSoftwareKeyboardDialog::~QtSoftwareKeyboardDialog() = default; |
| 105 | 105 | ||
| 106 | void QtSoftwareKeyboardDialog::accept() { | 106 | void QtSoftwareKeyboardDialog::accept() { |
| 107 | ok = true; | ||
| 108 | text = line_edit->text().toStdU16String(); | 107 | text = line_edit->text().toStdU16String(); |
| 109 | QDialog::accept(); | 108 | QDialog::accept(); |
| 110 | } | 109 | } |
| 111 | 110 | ||
| 112 | void QtSoftwareKeyboardDialog::reject() { | 111 | void QtSoftwareKeyboardDialog::reject() { |
| 113 | ok = false; | ||
| 114 | text.clear(); | 112 | text.clear(); |
| 115 | QDialog::reject(); | 113 | QDialog::reject(); |
| 116 | } | 114 | } |
| @@ -119,10 +117,6 @@ std::u16string QtSoftwareKeyboardDialog::GetText() const { | |||
| 119 | return text; | 117 | return text; |
| 120 | } | 118 | } |
| 121 | 119 | ||
| 122 | bool QtSoftwareKeyboardDialog::GetStatus() const { | ||
| 123 | return ok; | ||
| 124 | } | ||
| 125 | |||
| 126 | QtSoftwareKeyboard::QtSoftwareKeyboard(GMainWindow& main_window) { | 120 | QtSoftwareKeyboard::QtSoftwareKeyboard(GMainWindow& main_window) { |
| 127 | connect(this, &QtSoftwareKeyboard::MainWindowGetText, &main_window, | 121 | connect(this, &QtSoftwareKeyboard::MainWindowGetText, &main_window, |
| 128 | &GMainWindow::SoftwareKeyboardGetText, Qt::QueuedConnection); | 122 | &GMainWindow::SoftwareKeyboardGetText, Qt::QueuedConnection); |
diff --git a/src/yuzu/applets/software_keyboard.h b/src/yuzu/applets/software_keyboard.h index 78c5a042b..44bcece75 100644 --- a/src/yuzu/applets/software_keyboard.h +++ b/src/yuzu/applets/software_keyboard.h | |||
| @@ -36,10 +36,8 @@ public: | |||
| 36 | void reject() override; | 36 | void reject() override; |
| 37 | 37 | ||
| 38 | std::u16string GetText() const; | 38 | std::u16string GetText() const; |
| 39 | bool GetStatus() const; | ||
| 40 | 39 | ||
| 41 | private: | 40 | private: |
| 42 | bool ok = false; | ||
| 43 | std::u16string text; | 41 | std::u16string text; |
| 44 | 42 | ||
| 45 | QDialogButtonBox* buttons; | 43 | QDialogButtonBox* buttons; |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index f8a0daebd..c6526f855 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -238,15 +238,13 @@ void GMainWindow::ProfileSelectorSelectProfile() { | |||
| 238 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | | 238 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | |
| 239 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); | 239 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); |
| 240 | dialog.setWindowModality(Qt::WindowModal); | 240 | dialog.setWindowModality(Qt::WindowModal); |
| 241 | dialog.exec(); | 241 | if (dialog.exec() == QDialog::Rejected) { |
| 242 | |||
| 243 | if (!dialog.GetStatus()) { | ||
| 244 | emit ProfileSelectorFinishedSelection(std::nullopt); | 242 | emit ProfileSelectorFinishedSelection(std::nullopt); |
| 245 | return; | 243 | return; |
| 246 | } | 244 | } |
| 247 | 245 | ||
| 248 | Service::Account::ProfileManager manager; | 246 | Service::Account::ProfileManager manager; |
| 249 | const auto uuid = manager.GetUser(dialog.GetIndex()); | 247 | const auto uuid = manager.GetUser(static_cast<std::size_t>(dialog.GetIndex())); |
| 250 | if (!uuid.has_value()) { | 248 | if (!uuid.has_value()) { |
| 251 | emit ProfileSelectorFinishedSelection(std::nullopt); | 249 | emit ProfileSelectorFinishedSelection(std::nullopt); |
| 252 | return; | 250 | return; |
| @@ -261,9 +259,8 @@ void GMainWindow::SoftwareKeyboardGetText( | |||
| 261 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | | 259 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | |
| 262 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); | 260 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); |
| 263 | dialog.setWindowModality(Qt::WindowModal); | 261 | dialog.setWindowModality(Qt::WindowModal); |
| 264 | dialog.exec(); | ||
| 265 | 262 | ||
| 266 | if (!dialog.GetStatus()) { | 263 | if (dialog.exec() == QDialog::Rejected) { |
| 267 | emit SoftwareKeyboardFinishedText(std::nullopt); | 264 | emit SoftwareKeyboardFinishedText(std::nullopt); |
| 268 | return; | 265 | return; |
| 269 | } | 266 | } |
| @@ -901,11 +898,12 @@ void GMainWindow::SelectAndSetCurrentUser() { | |||
| 901 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | | 898 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | |
| 902 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); | 899 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); |
| 903 | dialog.setWindowModality(Qt::WindowModal); | 900 | dialog.setWindowModality(Qt::WindowModal); |
| 904 | dialog.exec(); | ||
| 905 | 901 | ||
| 906 | if (dialog.GetStatus()) { | 902 | if (dialog.exec() == QDialog::Rejected) { |
| 907 | Settings::values.current_user = static_cast<s32>(dialog.GetIndex()); | 903 | return; |
| 908 | } | 904 | } |
| 905 | |||
| 906 | Settings::values.current_user = dialog.GetIndex(); | ||
| 909 | } | 907 | } |
| 910 | 908 | ||
| 911 | void GMainWindow::BootGame(const QString& filename) { | 909 | void GMainWindow::BootGame(const QString& filename) { |
| @@ -1055,14 +1053,13 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
| 1055 | const std::string nand_dir = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); | 1053 | const std::string nand_dir = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); |
| 1056 | ASSERT(program_id != 0); | 1054 | ASSERT(program_id != 0); |
| 1057 | 1055 | ||
| 1058 | const auto select_profile = [this]() -> s32 { | 1056 | const auto select_profile = [this] { |
| 1059 | QtProfileSelectionDialog dialog(this); | 1057 | QtProfileSelectionDialog dialog(this); |
| 1060 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | | 1058 | dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | |
| 1061 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); | 1059 | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); |
| 1062 | dialog.setWindowModality(Qt::WindowModal); | 1060 | dialog.setWindowModality(Qt::WindowModal); |
| 1063 | dialog.exec(); | ||
| 1064 | 1061 | ||
| 1065 | if (!dialog.GetStatus()) { | 1062 | if (dialog.exec() == QDialog::Rejected) { |
| 1066 | return -1; | 1063 | return -1; |
| 1067 | } | 1064 | } |
| 1068 | 1065 | ||
| @@ -1070,11 +1067,12 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
| 1070 | }; | 1067 | }; |
| 1071 | 1068 | ||
| 1072 | const auto index = select_profile(); | 1069 | const auto index = select_profile(); |
| 1073 | if (index == -1) | 1070 | if (index == -1) { |
| 1074 | return; | 1071 | return; |
| 1072 | } | ||
| 1075 | 1073 | ||
| 1076 | Service::Account::ProfileManager manager; | 1074 | Service::Account::ProfileManager manager; |
| 1077 | const auto user_id = manager.GetUser(index); | 1075 | const auto user_id = manager.GetUser(static_cast<std::size_t>(index)); |
| 1078 | ASSERT(user_id); | 1076 | ASSERT(user_id); |
| 1079 | path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser, | 1077 | path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser, |
| 1080 | FileSys::SaveDataType::SaveData, | 1078 | FileSys::SaveDataType::SaveData, |