Compare commits

...

6 Commits

Author SHA1 Message Date
GodKratos
60b184377e add UUID validation check
Co-authored-by: VolcaEM <63682805+VolcaEM@users.noreply.github.com>
2020-05-24 01:13:49 +12:00
Godkratos
7341257fc4 Validate uuid and fix returns 2020-05-18 11:10:12 +12:00
Godkratos
d011f89f15 Validate username before returning 2020-05-18 10:37:25 +12:00
Godkratos
de1ef273b3 Clang formatting 2020-05-18 01:01:40 +12:00
Godkratos
c2522f3e43 Move new method into anonymous namespace 2020-05-18 00:55:32 +12:00
Godkratos
d8b83aa8f5 Add button to show and update current user profile on status bar 2020-05-18 00:08:41 +12:00
2 changed files with 67 additions and 0 deletions

View File

@@ -135,6 +135,28 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif
namespace {
QString GetAccountUsername() {
const QString nouser = QString::fromStdString("No User");
Service::Account::ProfileManager manager;
const auto current_user = manager.GetUser(Settings::values.current_user);
if (!current_user.has_value() || (current_user == Common::UUID{})) {
return nouser;
}
Service::Account::ProfileBase profile;
if (!manager.GetProfileBase(*current_user, profile)) {
return nouser;
}
const auto text = Common::StringFromFixedZeroTerminatedBuffer(
reinterpret_cast<const char*>(profile.username.data()), profile.username.size());
return text.empty() ? nouser : QString::fromStdString(text);
}
} // Anonymous namespace
constexpr int default_mouse_timeout = 2500;
constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000;
@@ -493,6 +515,48 @@ void GMainWindow::InitializeWidgets() {
statusBar()->addPermanentWidget(label);
}
// Setup Profile button
profile_status_button = new QPushButton();
profile_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton"));
profile_status_button->setCheckable(true);
profile_status_button->setChecked(true);
profile_status_button->setFocusPolicy(Qt::NoFocus);
const auto username = GetAccountUsername();
profile_status_button->setText(username);
connect(profile_status_button, &QPushButton::clicked, [=] {
profile_status_button->setChecked(true);
if (emulation_running) {
return;
}
// User save data
const auto select_profile = [this] {
QtProfileSelectionDialog dialog(this);
dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint |
Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint);
dialog.setWindowModality(Qt::WindowModal);
if (dialog.exec() == QDialog::Rejected) {
return -1;
}
return dialog.GetIndex();
};
const auto index = select_profile();
if (index == -1) {
return;
}
Settings::values.current_user = index;
Settings::Apply();
const auto username = GetAccountUsername();
profile_status_button->setText(username);
});
statusBar()->insertPermanentWidget(0, profile_status_button);
// Setup Dock button
dock_status_button = new QPushButton();
dock_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton"));
@@ -1902,6 +1966,8 @@ void GMainWindow::OnConfigure() {
ui.centralwidget->setMouseTracking(false);
}
const auto username = GetAccountUsername();
profile_status_button->setText(username);
dock_status_button->setChecked(Settings::values.use_docked_mode);
async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation);
#ifdef HAS_VULKAN

View File

@@ -233,6 +233,7 @@ private:
QLabel* emu_speed_label = nullptr;
QLabel* game_fps_label = nullptr;
QLabel* emu_frametime_label = nullptr;
QPushButton* profile_status_button = nullptr;
QPushButton* async_status_button = nullptr;
QPushButton* renderer_status_button = nullptr;
QPushButton* dock_status_button = nullptr;