Merge pull request #2527 from lioncash/index
yuzu/{profile_select, software_keyboard}: Tidy up interface
This commit is contained in:
commit
1eb979221f
|
@ -122,21 +122,15 @@ QtProfileSelectionDialog::QtProfileSelectionDialog(QWidget* parent)
|
||||||
QtProfileSelectionDialog::~QtProfileSelectionDialog() = default;
|
QtProfileSelectionDialog::~QtProfileSelectionDialog() = default;
|
||||||
|
|
||||||
void QtProfileSelectionDialog::accept() {
|
void QtProfileSelectionDialog::accept() {
|
||||||
ok = true;
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtProfileSelectionDialog::reject() {
|
void QtProfileSelectionDialog::reject() {
|
||||||
ok = false;
|
|
||||||
user_index = 0;
|
user_index = 0;
|
||||||
QDialog::reject();
|
QDialog::reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtProfileSelectionDialog::GetStatus() const {
|
int QtProfileSelectionDialog::GetIndex() const {
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 QtProfileSelectionDialog::GetIndex() const {
|
|
||||||
return user_index;
|
return user_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,15 +30,13 @@ public:
|
||||||
void accept() override;
|
void accept() override;
|
||||||
void reject() override;
|
void reject() override;
|
||||||
|
|
||||||
bool GetStatus() const;
|
int GetIndex() const;
|
||||||
u32 GetIndex() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool ok = false;
|
|
||||||
u32 user_index = 0;
|
|
||||||
|
|
||||||
void SelectUser(const QModelIndex& index);
|
void SelectUser(const QModelIndex& index);
|
||||||
|
|
||||||
|
int user_index = 0;
|
||||||
|
|
||||||
QVBoxLayout* layout;
|
QVBoxLayout* layout;
|
||||||
QTreeView* tree_view;
|
QTreeView* tree_view;
|
||||||
QStandardItemModel* item_model;
|
QStandardItemModel* item_model;
|
||||||
|
|
|
@ -104,13 +104,11 @@ QtSoftwareKeyboardDialog::QtSoftwareKeyboardDialog(
|
||||||
QtSoftwareKeyboardDialog::~QtSoftwareKeyboardDialog() = default;
|
QtSoftwareKeyboardDialog::~QtSoftwareKeyboardDialog() = default;
|
||||||
|
|
||||||
void QtSoftwareKeyboardDialog::accept() {
|
void QtSoftwareKeyboardDialog::accept() {
|
||||||
ok = true;
|
|
||||||
text = line_edit->text().toStdU16String();
|
text = line_edit->text().toStdU16String();
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtSoftwareKeyboardDialog::reject() {
|
void QtSoftwareKeyboardDialog::reject() {
|
||||||
ok = false;
|
|
||||||
text.clear();
|
text.clear();
|
||||||
QDialog::reject();
|
QDialog::reject();
|
||||||
}
|
}
|
||||||
|
@ -119,10 +117,6 @@ std::u16string QtSoftwareKeyboardDialog::GetText() const {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtSoftwareKeyboardDialog::GetStatus() const {
|
|
||||||
return ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
QtSoftwareKeyboard::QtSoftwareKeyboard(GMainWindow& main_window) {
|
QtSoftwareKeyboard::QtSoftwareKeyboard(GMainWindow& main_window) {
|
||||||
connect(this, &QtSoftwareKeyboard::MainWindowGetText, &main_window,
|
connect(this, &QtSoftwareKeyboard::MainWindowGetText, &main_window,
|
||||||
&GMainWindow::SoftwareKeyboardGetText, Qt::QueuedConnection);
|
&GMainWindow::SoftwareKeyboardGetText, Qt::QueuedConnection);
|
||||||
|
|
|
@ -36,10 +36,8 @@ public:
|
||||||
void reject() override;
|
void reject() override;
|
||||||
|
|
||||||
std::u16string GetText() const;
|
std::u16string GetText() const;
|
||||||
bool GetStatus() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool ok = false;
|
|
||||||
std::u16string text;
|
std::u16string text;
|
||||||
|
|
||||||
QDialogButtonBox* buttons;
|
QDialogButtonBox* buttons;
|
||||||
|
|
|
@ -238,15 +238,13 @@ void GMainWindow::ProfileSelectorSelectProfile() {
|
||||||
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
|
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
|
||||||
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
|
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
|
||||||
dialog.setWindowModality(Qt::WindowModal);
|
dialog.setWindowModality(Qt::WindowModal);
|
||||||
dialog.exec();
|
if (dialog.exec() == QDialog::Rejected) {
|
||||||
|
|
||||||
if (!dialog.GetStatus()) {
|
|
||||||
emit ProfileSelectorFinishedSelection(std::nullopt);
|
emit ProfileSelectorFinishedSelection(std::nullopt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Service::Account::ProfileManager manager;
|
Service::Account::ProfileManager manager;
|
||||||
const auto uuid = manager.GetUser(dialog.GetIndex());
|
const auto uuid = manager.GetUser(static_cast<std::size_t>(dialog.GetIndex()));
|
||||||
if (!uuid.has_value()) {
|
if (!uuid.has_value()) {
|
||||||
emit ProfileSelectorFinishedSelection(std::nullopt);
|
emit ProfileSelectorFinishedSelection(std::nullopt);
|
||||||
return;
|
return;
|
||||||
|
@ -261,9 +259,8 @@ void GMainWindow::SoftwareKeyboardGetText(
|
||||||
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
|
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
|
||||||
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
|
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
|
||||||
dialog.setWindowModality(Qt::WindowModal);
|
dialog.setWindowModality(Qt::WindowModal);
|
||||||
dialog.exec();
|
|
||||||
|
|
||||||
if (!dialog.GetStatus()) {
|
if (dialog.exec() == QDialog::Rejected) {
|
||||||
emit SoftwareKeyboardFinishedText(std::nullopt);
|
emit SoftwareKeyboardFinishedText(std::nullopt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -901,11 +898,12 @@ void GMainWindow::SelectAndSetCurrentUser() {
|
||||||
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
|
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
|
||||||
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
|
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
|
||||||
dialog.setWindowModality(Qt::WindowModal);
|
dialog.setWindowModality(Qt::WindowModal);
|
||||||
dialog.exec();
|
|
||||||
|
|
||||||
if (dialog.GetStatus()) {
|
if (dialog.exec() == QDialog::Rejected) {
|
||||||
Settings::values.current_user = static_cast<s32>(dialog.GetIndex());
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Settings::values.current_user = dialog.GetIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::BootGame(const QString& filename) {
|
void GMainWindow::BootGame(const QString& filename) {
|
||||||
|
@ -1055,14 +1053,13 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
|
||||||
const std::string nand_dir = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
|
const std::string nand_dir = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir);
|
||||||
ASSERT(program_id != 0);
|
ASSERT(program_id != 0);
|
||||||
|
|
||||||
const auto select_profile = [this]() -> s32 {
|
const auto select_profile = [this] {
|
||||||
QtProfileSelectionDialog dialog(this);
|
QtProfileSelectionDialog dialog(this);
|
||||||
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
|
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
|
||||||
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
|
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
|
||||||
dialog.setWindowModality(Qt::WindowModal);
|
dialog.setWindowModality(Qt::WindowModal);
|
||||||
dialog.exec();
|
|
||||||
|
|
||||||
if (!dialog.GetStatus()) {
|
if (dialog.exec() == QDialog::Rejected) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1070,11 +1067,12 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto index = select_profile();
|
const auto index = select_profile();
|
||||||
if (index == -1)
|
if (index == -1) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Service::Account::ProfileManager manager;
|
Service::Account::ProfileManager manager;
|
||||||
const auto user_id = manager.GetUser(index);
|
const auto user_id = manager.GetUser(static_cast<std::size_t>(index));
|
||||||
ASSERT(user_id);
|
ASSERT(user_id);
|
||||||
path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser,
|
path = nand_dir + FileSys::SaveDataFactory::GetFullPath(FileSys::SaveDataSpaceId::NandUser,
|
||||||
FileSys::SaveDataType::SaveData,
|
FileSys::SaveDataType::SaveData,
|
||||||
|
|
Reference in New Issue