Add button to show and update current user profile on status bar
This commit is contained in:
@@ -441,6 +441,20 @@ void GMainWindow::WebBrowserOpenPage(std::string_view filename, std::string_view
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QString GetAccountUsername() {
|
||||||
|
Service::Account::ProfileManager manager;
|
||||||
|
const auto current_user = manager.GetUser(Settings::values.current_user);
|
||||||
|
ASSERT(current_user);
|
||||||
|
Service::Account::ProfileBase profile;
|
||||||
|
if (!manager.GetProfileBase(*current_user, profile)) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto text = Common::StringFromFixedZeroTerminatedBuffer(
|
||||||
|
reinterpret_cast<const char*>(profile.username.data()), profile.username.size());
|
||||||
|
return QString::fromStdString(text);
|
||||||
|
}
|
||||||
|
|
||||||
void GMainWindow::InitializeWidgets() {
|
void GMainWindow::InitializeWidgets() {
|
||||||
#ifdef YUZU_ENABLE_COMPATIBILITY_REPORTING
|
#ifdef YUZU_ENABLE_COMPATIBILITY_REPORTING
|
||||||
ui.action_Report_Compatibility->setVisible(true);
|
ui.action_Report_Compatibility->setVisible(true);
|
||||||
@@ -493,6 +507,48 @@ void GMainWindow::InitializeWidgets() {
|
|||||||
statusBar()->addPermanentWidget(label);
|
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
|
// Setup Dock button
|
||||||
dock_status_button = new QPushButton();
|
dock_status_button = new QPushButton();
|
||||||
dock_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton"));
|
dock_status_button->setObjectName(QStringLiteral("TogglableStatusBarButton"));
|
||||||
@@ -1902,6 +1958,8 @@ void GMainWindow::OnConfigure() {
|
|||||||
ui.centralwidget->setMouseTracking(false);
|
ui.centralwidget->setMouseTracking(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto username = GetAccountUsername();
|
||||||
|
profile_status_button->setText(username);
|
||||||
dock_status_button->setChecked(Settings::values.use_docked_mode);
|
dock_status_button->setChecked(Settings::values.use_docked_mode);
|
||||||
async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation);
|
async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation);
|
||||||
#ifdef HAS_VULKAN
|
#ifdef HAS_VULKAN
|
||||||
|
|||||||
@@ -233,6 +233,7 @@ private:
|
|||||||
QLabel* emu_speed_label = nullptr;
|
QLabel* emu_speed_label = nullptr;
|
||||||
QLabel* game_fps_label = nullptr;
|
QLabel* game_fps_label = nullptr;
|
||||||
QLabel* emu_frametime_label = nullptr;
|
QLabel* emu_frametime_label = nullptr;
|
||||||
|
QPushButton* profile_status_button = nullptr;
|
||||||
QPushButton* async_status_button = nullptr;
|
QPushButton* async_status_button = nullptr;
|
||||||
QPushButton* renderer_status_button = nullptr;
|
QPushButton* renderer_status_button = nullptr;
|
||||||
QPushButton* dock_status_button = nullptr;
|
QPushButton* dock_status_button = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user