profile_select: Return int instead of u32 for GetIndex()
Qt uses a signed value to represent indices. We should follow this convention where applicable to avoid unnecessary sign-conversion warnings, as well as making it easier to interoperate with other aspects of Qt. While we're at it, we can also make a sign-conversion explicit.
This commit is contained in:
parent
90c9d703ba
commit
139301c5a1
3 changed files with 9 additions and 8 deletions
|
@ -136,7 +136,7 @@ bool QtProfileSelectionDialog::GetStatus() const {
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 QtProfileSelectionDialog::GetIndex() const {
|
int QtProfileSelectionDialog::GetIndex() const {
|
||||||
return user_index;
|
return user_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ public:
|
||||||
void reject() override;
|
void reject() override;
|
||||||
|
|
||||||
bool GetStatus() const;
|
bool GetStatus() const;
|
||||||
u32 GetIndex() const;
|
int GetIndex() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
u32 user_index = 0;
|
int user_index = 0;
|
||||||
|
|
||||||
void SelectUser(const QModelIndex& index);
|
void SelectUser(const QModelIndex& index);
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,7 @@ void GMainWindow::ProfileSelectorSelectProfile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -904,7 +904,7 @@ void GMainWindow::SelectAndSetCurrentUser() {
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
|
|
||||||
if (dialog.GetStatus()) {
|
if (dialog.GetStatus()) {
|
||||||
Settings::values.current_user = static_cast<s32>(dialog.GetIndex());
|
Settings::values.current_user = dialog.GetIndex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1055,7 +1055,7 @@ 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);
|
||||||
|
@ -1070,11 +1070,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,
|
||||||
|
|
Loading…
Reference in a new issue