From e7543e8b84c5520e09d5703bc8b191a1a76195b7 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 5 Jun 2023 20:45:33 -0400 Subject: [PATCH] uisettings: Fix typings --- src/yuzu/multiplayer/direct_connect.cpp | 9 +-- src/yuzu/multiplayer/host_room.cpp | 16 +++-- src/yuzu/multiplayer/lobby.cpp | 7 ++- src/yuzu/uisettings.h | 84 ++++++++++++------------- 4 files changed, 61 insertions(+), 55 deletions(-) diff --git a/src/yuzu/multiplayer/direct_connect.cpp b/src/yuzu/multiplayer/direct_connect.cpp index d71cc23a72..a415a953f6 100644 --- a/src/yuzu/multiplayer/direct_connect.cpp +++ b/src/yuzu/multiplayer/direct_connect.cpp @@ -34,13 +34,14 @@ DirectConnectWindow::DirectConnectWindow(Core::System& system_, QWidget* parent) connect(watcher, &QFutureWatcher::finished, this, &DirectConnectWindow::OnConnection); ui->nickname->setValidator(validation.GetNickname()); - ui->nickname->setText(UISettings::values.multiplayer_nickname.GetValue()); + ui->nickname->setText( + QString::fromStdString(UISettings::values.multiplayer_nickname.GetValue())); if (ui->nickname->text().isEmpty() && !Settings::values.yuzu_username.GetValue().empty()) { // Use yuzu Web Service user name as nickname by default ui->nickname->setText(QString::fromStdString(Settings::values.yuzu_username.GetValue())); } ui->ip->setValidator(validation.GetIP()); - ui->ip->setText(UISettings::values.multiplayer_ip.GetValue()); + ui->ip->setText(QString::fromStdString(UISettings::values.multiplayer_ip.GetValue())); ui->port->setValidator(validation.GetPort()); ui->port->setText(QString::number(UISettings::values.multiplayer_port.GetValue())); @@ -91,8 +92,8 @@ void DirectConnectWindow::Connect() { } // Store settings - UISettings::values.multiplayer_nickname = ui->nickname->text(); - UISettings::values.multiplayer_ip = ui->ip->text(); + UISettings::values.multiplayer_nickname = ui->nickname->text().toStdString(); + UISettings::values.multiplayer_ip = ui->ip->text().toStdString(); if (ui->port->isModified() && !ui->port->text().isEmpty()) { UISettings::values.multiplayer_port = ui->port->text().toInt(); } else { diff --git a/src/yuzu/multiplayer/host_room.cpp b/src/yuzu/multiplayer/host_room.cpp index a8faa5b248..ef364ee43a 100644 --- a/src/yuzu/multiplayer/host_room.cpp +++ b/src/yuzu/multiplayer/host_room.cpp @@ -55,12 +55,14 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list, connect(ui->host, &QPushButton::clicked, this, &HostRoomWindow::Host); // Restore the settings: - ui->username->setText(UISettings::values.multiplayer_room_nickname.GetValue()); + ui->username->setText( + QString::fromStdString(UISettings::values.multiplayer_room_nickname.GetValue())); if (ui->username->text().isEmpty() && !Settings::values.yuzu_username.GetValue().empty()) { // Use yuzu Web Service user name as nickname by default ui->username->setText(QString::fromStdString(Settings::values.yuzu_username.GetValue())); } - ui->room_name->setText(UISettings::values.multiplayer_room_name.GetValue()); + ui->room_name->setText( + QString::fromStdString(UISettings::values.multiplayer_room_name.GetValue())); ui->port->setText(QString::number(UISettings::values.multiplayer_room_port.GetValue())); ui->max_player->setValue(UISettings::values.multiplayer_max_player.GetValue()); int index = UISettings::values.multiplayer_host_type.GetValue(); @@ -72,7 +74,8 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list, if (index != -1) { ui->game_list->setCurrentIndex(index); } - ui->room_description->setText(UISettings::values.multiplayer_room_description.GetValue()); + ui->room_description->setText( + QString::fromStdString(UISettings::values.multiplayer_room_description.GetValue())); } HostRoomWindow::~HostRoomWindow() = default; @@ -218,8 +221,8 @@ void HostRoomWindow::Host() { Network::NoPreferredIP, password, token); // Store settings - UISettings::values.multiplayer_room_nickname = ui->username->text(); - UISettings::values.multiplayer_room_name = ui->room_name->text(); + UISettings::values.multiplayer_room_nickname = ui->username->text().toStdString(); + UISettings::values.multiplayer_room_name = ui->room_name->text().toStdString(); UISettings::values.multiplayer_game_id = ui->game_list->currentData(GameListItemPath::ProgramIdRole).toLongLong(); UISettings::values.multiplayer_max_player = ui->max_player->value(); @@ -230,7 +233,8 @@ void HostRoomWindow::Host() { } else { UISettings::values.multiplayer_room_port = Network::DefaultRoomPort; } - UISettings::values.multiplayer_room_description = ui->room_description->toPlainText(); + UISettings::values.multiplayer_room_description = + ui->room_description->toPlainText().toStdString(); ui->host->setEnabled(true); emit SaveConfig(); close(); diff --git a/src/yuzu/multiplayer/lobby.cpp b/src/yuzu/multiplayer/lobby.cpp index 387f6f7c91..603e9ae3de 100644 --- a/src/yuzu/multiplayer/lobby.cpp +++ b/src/yuzu/multiplayer/lobby.cpp @@ -60,7 +60,8 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list, ui->room_list->setContextMenuPolicy(Qt::CustomContextMenu); ui->nickname->setValidator(validation.GetNickname()); - ui->nickname->setText(UISettings::values.multiplayer_nickname.GetValue()); + ui->nickname->setText( + QString::fromStdString(UISettings::values.multiplayer_nickname.GetValue())); // Try find the best nickname by default if (ui->nickname->text().isEmpty() || ui->nickname->text() == QStringLiteral("yuzu")) { @@ -202,9 +203,9 @@ void Lobby::OnJoinRoom(const QModelIndex& source) { // TODO(jroweboy): disable widgets and display a connecting while we wait // Save settings - UISettings::values.multiplayer_nickname = ui->nickname->text(); + UISettings::values.multiplayer_nickname = ui->nickname->text().toStdString(); UISettings::values.multiplayer_ip = - proxy->data(connection_index, LobbyItemHost::HostIPRole).toString(); + proxy->data(connection_index, LobbyItemHost::HostIPRole).value().toStdString(); UISettings::values.multiplayer_port = proxy->data(connection_index, LobbyItemHost::HostPortRole).toInt(); emit SaveConfig(); diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 20a517d34a..0be8ee3698 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h @@ -14,6 +14,8 @@ #include "common/common_types.h" #include "common/settings.h" +using Settings::Setting; + namespace UISettings { bool IsDarkTheme(); @@ -64,30 +66,33 @@ struct Values { QByteArray gamelist_header_state; QByteArray microprofile_geometry; - Settings::Setting microprofile_visible{false, "microProfileDialogVisible"}; + Setting microprofile_visible{false, "microProfileDialogVisible"}; - Settings::Setting single_window_mode{true, "singleWindowMode"}; - Settings::Setting fullscreen{false, "fullscreen"}; - Settings::Setting display_titlebar{true, "displayTitleBars"}; - Settings::Setting show_filter_bar{true, "showFilterBar"}; - Settings::Setting show_status_bar{true, "showStatusBar"}; - - Settings::Setting confirm_before_closing{true, "confirmClose"}; - Settings::Setting first_start{true, "firstStart"}; - Settings::Setting pause_when_in_background{false, "pauseWhenInBackground"}; - Settings::Setting mute_when_in_background{false, "muteWhenInBackground"}; - Settings::Setting hide_mouse{true, "hideInactiveMouse"}; - Settings::Setting controller_applet_disabled{false, "disableControllerApplet"}; + Setting single_window_mode{true, "singleWindowMode"}; + Setting fullscreen{false, "fullscreen"}; + Setting display_titlebar{true, "displayTitleBars"}; + Setting show_filter_bar{true, "showFilterBar"}; + Setting show_status_bar{true, "showStatusBar"}; + Setting confirm_before_closing{true, "confirmClose"}; + Setting first_start{true, "firstStart"}; + Setting pause_when_in_background{false, "pauseWhenInBackground"}; + Setting mute_when_in_background{false, "muteWhenInBackground"}; + Setting hide_mouse{true, "hideInactiveMouse"}; + Setting controller_applet_disabled{false, "disableControllerApplet"}; // Set when Vulkan is known to crash the application bool has_broken_vulkan = false; - Settings::Setting select_user_on_boot{false, "select_user_on_boot"}; + Setting select_user_on_boot{false, "select_user_on_boot"}; + Setting disable_web_applet{true, "disable_web_applet"}; // Discord RPC - Settings::Setting enable_discord_presence{true, "enable_discord_presence"}; + Setting enable_discord_presence{true, "enable_discord_presence"}; - Settings::Setting enable_screenshot_save_as{true, "enable_screenshot_save_as"}; + // logging + Setting show_console{false, "showConsole"}; + + Setting enable_screenshot_save_as{true, "enable_screenshot_save_as"}; QString roms_path; QString symbols_path; @@ -102,47 +107,42 @@ struct Values { // Shortcut name std::vector shortcuts; - Settings::Setting callout_flags{0, "calloutFlags"}; + Setting callout_flags{0, "calloutFlags"}; // multiplayer settings - Settings::Setting multiplayer_nickname{{}, "nickname"}; - Settings::Setting multiplayer_ip{{}, "ip"}; - Settings::SwitchableSetting multiplayer_port{24872, 0, UINT16_MAX, "port"}; - Settings::Setting multiplayer_room_nickname{{}, "room_nickname"}; - Settings::Setting multiplayer_room_name{{}, "room_name"}; - Settings::SwitchableSetting multiplayer_max_player{8, 0, 8, "max_player"}; - Settings::SwitchableSetting multiplayer_room_port{24872, 0, UINT16_MAX, - "room_port"}; - Settings::SwitchableSetting multiplayer_host_type{0, 0, 1, "host_type"}; - Settings::Setting multiplayer_game_id{{}, "game_id"}; - Settings::Setting multiplayer_room_description{{}, "room_description"}; + Setting multiplayer_nickname{{}, "nickname"}; + Setting multiplayer_ip{{}, "ip"}; + Setting multiplayer_port{24872, 0, UINT16_MAX, "port"}; + Setting multiplayer_room_nickname{{}, "room_nickname"}; + Setting multiplayer_room_name{{}, "room_name"}; + Setting multiplayer_max_player{8, 0, 8, "max_player"}; + Setting multiplayer_room_port{24872, 0, UINT16_MAX, "room_port"}; + Setting multiplayer_host_type{0, 0, 1, "host_type"}; + Setting multiplayer_game_id{{}, "game_id"}; + Setting multiplayer_room_description{{}, "room_description"}; std::pair, std::vector> multiplayer_ban_list; - // logging - Settings::Setting show_console{false, "showConsole"}; - // Game List - Settings::Setting show_add_ons{true, "show_add_ons"}; - Settings::Setting game_icon_size{64, "game_icon_size"}; - Settings::Setting folder_icon_size{48, "folder_icon_size"}; - Settings::Setting row_1_text_id{3, "row_1_text_id"}; - Settings::Setting row_2_text_id{2, "row_2_text_id"}; + Setting show_add_ons{true, "show_add_ons"}; + Setting game_icon_size{64, "game_icon_size"}; + Setting folder_icon_size{48, "folder_icon_size"}; + Setting row_1_text_id{3, "row_1_text_id"}; + Setting row_2_text_id{2, "row_2_text_id"}; std::atomic_bool is_game_list_reload_pending{false}; - Settings::Setting cache_game_list{true, "cache_game_list"}; - Settings::Setting favorites_expanded{true, "favorites_expanded"}; + Setting cache_game_list{true, "cache_game_list"}; + Setting favorites_expanded{true, "favorites_expanded"}; QVector favorited_ids; // Compatibility List - Settings::Setting show_compat{false, "show_compat"}; + Setting show_compat{false, "show_compat"}; // Size & File Types Column - Settings::Setting show_size{true, "show_size"}; - Settings::Setting show_types{true, "show_types"}; + Setting show_size{true, "show_size"}; + Setting show_types{true, "show_types"}; bool configuration_applied; bool reset_to_defaults; bool shortcut_already_warned{false}; - Settings::Setting disable_web_applet{true, "disable_web_applet"}; }; extern Values values;