general: Convert use_docked_mode to an enumeration

Allows some special interactions with it in the Qt frontend.
This commit is contained in:
lat9nq 2023-08-21 16:03:30 -04:00
parent 8a4cb3f902
commit 387ede76d2
17 changed files with 74 additions and 35 deletions

View file

@ -1158,9 +1158,9 @@ void GMainWindow::InitializeWidgets() {
[this](const QPoint& menu_location) {
QMenu context_menu;
for (auto const& docked_mode_pair : Config::use_docked_mode_texts_map) {
context_menu.addAction(docked_mode_pair.second, [this, docked_mode_pair] {
if (docked_mode_pair.first != Settings::values.use_docked_mode.GetValue()) {
for (auto const& [value, text] : Config::use_docked_mode_texts_map) {
context_menu.addAction(text, [this, value] {
if (value != Settings::values.use_docked_mode.GetValue()) {
OnToggleDockedMode();
}
});
@ -3636,7 +3636,8 @@ void GMainWindow::OnTasReset() {
}
void GMainWindow::OnToggleDockedMode() {
const bool is_docked = Settings::values.use_docked_mode.GetValue();
const bool is_docked =
Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked;
auto* player_1 = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
auto* handheld = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
@ -3650,7 +3651,8 @@ void GMainWindow::OnToggleDockedMode() {
controller_dialog->refreshConfiguration();
}
Settings::values.use_docked_mode.SetValue(!is_docked);
Settings::values.use_docked_mode.SetValue(is_docked ? Settings::ConsoleMode::Docked
: Settings::ConsoleMode::Handheld);
UpdateDockedButton();
OnDockedModeChanged(is_docked, !is_docked, *system);
}
@ -4080,8 +4082,8 @@ void GMainWindow::UpdateGPUAccuracyButton() {
}
void GMainWindow::UpdateDockedButton() {
const bool is_docked = Settings::values.use_docked_mode.GetValue();
dock_status_button->setChecked(is_docked);
const auto is_docked = Settings::values.use_docked_mode.GetValue();
dock_status_button->setChecked(is_docked == Settings::ConsoleMode::Docked);
dock_status_button->setText(
Config::use_docked_mode_texts_map.find(is_docked)->second.toUpper());
}