| 1 | // Copyright 2017 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "DolphinQt/Settings/WiiPane.h" |
| 5 | |
| 6 | #include <array> |
| 7 | #include <future> |
| 8 | #include <optional> |
| 9 | #include <utility> |
| 10 | |
| 11 | #include <QDir> |
| 12 | #include <QGridLayout> |
| 13 | #include <QGroupBox> |
| 14 | #include <QHBoxLayout> |
| 15 | #include <QLabel> |
| 16 | #include <QListWidget> |
| 17 | #include <QPushButton> |
| 18 | #include <QSpacerItem> |
| 19 | |
| 20 | #include "Common/Config/Config.h" |
| 21 | #include "Common/FatFsUtil.h" |
| 22 | #include "Common/FileUtil.h" |
| 23 | |
| 24 | #include "Core/Config/MainSettings.h" |
| 25 | #include "Core/Config/SYSCONFSettings.h" |
| 26 | #include "Core/ConfigManager.h" |
| 27 | #include "Core/Core.h" |
| 28 | #include "Core/System.h" |
| 29 | #include "Core/USBUtils.h" |
| 30 | |
| 31 | #include "DolphinQt/Config/ConfigControls/ConfigBool.h" |
| 32 | #include "DolphinQt/Config/ConfigControls/ConfigChoice.h" |
| 33 | #include "DolphinQt/Config/ConfigControls/ConfigSlider.h" |
| 34 | #include "DolphinQt/Config/ConfigControls/ConfigUserPath.h" |
| 35 | #include "DolphinQt/QtUtils/DolphinFileDialog.h" |
| 36 | #include "DolphinQt/QtUtils/ModalMessageBox.h" |
| 37 | #include "DolphinQt/QtUtils/NonDefaultQPushButton.h" |
| 38 | #include "DolphinQt/QtUtils/ParallelProgressDialog.h" |
| 39 | #include "DolphinQt/QtUtils/QtUtils.h" |
| 40 | #include "DolphinQt/Settings.h" |
| 41 | #include "DolphinQt/Settings/USBDevicePicker.h" |
| 42 | |
| 43 | namespace |
| 44 | { |
| 45 | struct SDSizeComboEntry |
| 46 | { |
| 47 | u64 size; |
| 48 | const char* name; |
| 49 | }; |
| 50 | static constexpr u64 MebibytesToBytes(u64 mebibytes) |
| 51 | { |
| 52 | return mebibytes * 1024u * 1024u; |
| 53 | } |
| 54 | static constexpr u64 GibibytesToBytes(u64 gibibytes) |
| 55 | { |
| 56 | return MebibytesToBytes(gibibytes * 1024u); |
| 57 | } |
| 58 | constexpr std::array sd_size_combo_entries{ |
| 59 | SDSizeComboEntry{0, _trans("Auto")}, |
| 60 | SDSizeComboEntry{MebibytesToBytes(64), _trans("64 MiB")}, |
| 61 | SDSizeComboEntry{MebibytesToBytes(128), _trans("128 MiB")}, |
| 62 | SDSizeComboEntry{MebibytesToBytes(256), _trans("256 MiB")}, |
| 63 | SDSizeComboEntry{MebibytesToBytes(512), _trans("512 MiB")}, |
| 64 | SDSizeComboEntry{GibibytesToBytes(1), _trans("1 GiB")}, |
| 65 | SDSizeComboEntry{GibibytesToBytes(2), _trans("2 GiB")}, |
| 66 | SDSizeComboEntry{GibibytesToBytes(4), _trans("4 GiB (SDHC)")}, |
| 67 | SDSizeComboEntry{GibibytesToBytes(8), _trans("8 GiB (SDHC)")}, |
| 68 | SDSizeComboEntry{GibibytesToBytes(16), _trans("16 GiB (SDHC)")}, |
| 69 | SDSizeComboEntry{GibibytesToBytes(32), _trans("32 GiB (SDHC)")}, |
| 70 | }; |
| 71 | } // namespace |
| 72 | |
| 73 | WiiPane::WiiPane(QWidget* parent) : QWidget(parent) |
| 74 | { |
| 75 | CreateLayout(); |
| 76 | PopulateUSBPassthroughListWidget(); |
| 77 | ConnectLayout(); |
| 78 | ValidateSelectionState(); |
| 79 | OnEmulationStateChanged(!Core::IsUninitialized(Core::System::GetInstance())); |
| 80 | } |
| 81 | |
| 82 | void WiiPane::CreateLayout() |
| 83 | { |
| 84 | m_main_layout = new QVBoxLayout{this}; |
| 85 | CreateMisc(); |
| 86 | CreateSDCard(); |
| 87 | CreateWhitelistedUSBPassthroughDevices(); |
| 88 | CreateWiiRemoteSettings(); |
| 89 | } |
| 90 | |
| 91 | void WiiPane::ConnectLayout() |
| 92 | { |
| 93 | // Whitelisted USB Passthrough Devices |
| 94 | connect(&Settings::Instance(), &Settings::ConfigChanged, this, |
| 95 | &WiiPane::PopulateUSBPassthroughListWidget); |
| 96 | connect(m_whitelist_usb_list, &QListWidget::itemClicked, this, &WiiPane::ValidateSelectionState); |
| 97 | connect(m_whitelist_usb_add_button, &QPushButton::clicked, this, |
| 98 | &WiiPane::OnUSBWhitelistAddButton); |
| 99 | connect(m_whitelist_usb_remove_button, &QPushButton::clicked, this, |
| 100 | &WiiPane::OnUSBWhitelistRemoveButton); |
| 101 | |
| 102 | // Emulation State |
| 103 | connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) { |
| 104 | OnEmulationStateChanged(state != Core::State::Uninitialized); |
| 105 | }); |
| 106 | } |
| 107 | |
| 108 | void WiiPane::CreateMisc() |
| 109 | { |
| 110 | auto* misc_settings_group = new QGroupBox(tr("Misc Settings")); |
| 111 | auto* misc_settings_group_layout = new QGridLayout(); |
| 112 | misc_settings_group->setLayout(misc_settings_group_layout); |
| 113 | m_main_layout->addWidget(misc_settings_group); |
| 114 | m_pal60_mode_checkbox = new ConfigBool(tr("Use PAL60 Mode (EuRGB60)"), Config::SYSCONF_PAL60); |
| 115 | m_screensaver_checkbox = new ConfigBool(tr("Enable Screen Saver"), Config::SYSCONF_SCREENSAVER); |
| 116 | m_wiilink_checkbox = |
| 117 | new ConfigBool(tr("Enable WiiConnect24 via WiiLink"), Config::MAIN_WII_WIILINK_ENABLE); |
| 118 | m_connect_keyboard_checkbox = |
| 119 | new ConfigBool(tr("Connect USB Keyboard"), Config::MAIN_WII_KEYBOARD); |
| 120 | |
| 121 | m_aspect_ratio_choice_label = new QLabel(tr("Aspect Ratio:")); |
| 122 | m_aspect_ratio_choice = new ConfigChoiceMap<bool>({{tr("4:3"), false}, {tr("16:9"), true}}, |
| 123 | Config::SYSCONF_WIDESCREEN); |
| 124 | |
| 125 | m_system_language_choice_label = new QLabel(tr("System Language:")); |
| 126 | m_system_language_choice = new ConfigChoiceU32( |
| 127 | {tr("Japanese"), tr("English"), tr("German"), tr("French"), tr("Spanish"), tr("Italian"), |
| 128 | tr("Dutch"), tr("Simplified Chinese"), tr("Traditional Chinese"), tr("Korean")}, |
| 129 | Config::SYSCONF_LANGUAGE); |
| 130 | |
| 131 | m_sound_mode_choice_label = new QLabel(tr("Sound:")); |
| 132 | m_sound_mode_choice = new ConfigChoiceU32( |
| 133 | {// i18n: Mono audio |
| 134 | tr("Mono"), |
| 135 | // i18n: Stereo audio |
| 136 | tr("Stereo"), |
| 137 | // i18n: Surround audio (Dolby Pro Logic II) |
| 138 | tr("Surround")}, |
| 139 | Config::SYSCONF_SOUND_MODE); |
| 140 | |
| 141 | m_pal60_mode_checkbox->SetDescription( |
| 142 | tr("Sets the Wii display mode to 60Hz (480i) instead of 50Hz " |
| 143 | "(576i) for PAL games.\nMay not work for all games.")); |
| 144 | m_screensaver_checkbox->SetDescription(tr("Dims the screen after five minutes of inactivity.")); |
| 145 | m_wiilink_checkbox->SetDescription(tr( |
| 146 | "Enables the WiiLink service for WiiConnect24 channels.\nWiiLink is an alternate provider " |
| 147 | "for the discontinued WiiConnect24 Channels such as the Forecast and Nintendo Channels\nRead " |
| 148 | "the Terms of Service at: https://www.wiilink24.com/tos")); |
| 149 | m_system_language_choice->SetDescription(tr("Sets the Wii system language.")); |
| 150 | m_connect_keyboard_checkbox->SetDescription( |
| 151 | tr("May cause slow down in Wii Menu and some games.")); |
| 152 | |
| 153 | misc_settings_group_layout->addWidget(m_pal60_mode_checkbox, 0, 0, 1, 1); |
| 154 | misc_settings_group_layout->addWidget(m_connect_keyboard_checkbox, 0, 1, 1, 1); |
| 155 | misc_settings_group_layout->addWidget(m_screensaver_checkbox, 1, 0, 1, 1); |
| 156 | misc_settings_group_layout->addWidget(m_wiilink_checkbox, 1, 1, 1, 1); |
| 157 | misc_settings_group_layout->addWidget(m_aspect_ratio_choice_label, 2, 0, 1, 1); |
| 158 | misc_settings_group_layout->addWidget(m_aspect_ratio_choice, 2, 1, 1, 1); |
| 159 | misc_settings_group_layout->addWidget(m_system_language_choice_label, 3, 0, 1, 1); |
| 160 | misc_settings_group_layout->addWidget(m_system_language_choice, 3, 1, 1, 1); |
| 161 | misc_settings_group_layout->addWidget(m_sound_mode_choice_label, 4, 0, 1, 1); |
| 162 | misc_settings_group_layout->addWidget(m_sound_mode_choice, 4, 1, 1, 1); |
| 163 | } |
| 164 | |
| 165 | void WiiPane::CreateSDCard() |
| 166 | { |
| 167 | auto* sd_settings_group = new QGroupBox(tr("SD Card Settings")); |
| 168 | auto* sd_settings_group_layout = new QGridLayout(); |
| 169 | sd_settings_group->setLayout(sd_settings_group_layout); |
| 170 | m_main_layout->addWidget(sd_settings_group); |
| 171 | |
| 172 | int row = 0; |
| 173 | m_sd_card_checkbox = new ConfigBool(tr("Insert SD Card"), Config::MAIN_WII_SD_CARD); |
| 174 | m_sd_card_checkbox->SetDescription(tr("Supports SD and SDHC. Default size is 128 MB.")); |
| 175 | m_allow_sd_writes_checkbox = |
| 176 | new ConfigBool(tr("Allow Writes to SD Card"), Config::MAIN_ALLOW_SD_WRITES); |
| 177 | sd_settings_group_layout->addWidget(m_sd_card_checkbox, row, 0, 1, 1); |
| 178 | sd_settings_group_layout->addWidget(m_allow_sd_writes_checkbox, row, 1, 1, 1); |
| 179 | ++row; |
| 180 | |
| 181 | { |
| 182 | QHBoxLayout* hlayout = new QHBoxLayout; |
| 183 | m_sd_raw_edit = new ConfigUserPath(F_WIISDCARDIMAGE_IDX, Config::MAIN_WII_SD_CARD_IMAGE_PATH); |
| 184 | QPushButton* sdcard_open = new NonDefaultQPushButton(QStringLiteral("...")); |
| 185 | connect(sdcard_open, &QPushButton::clicked, this, &WiiPane::BrowseSDRaw); |
| 186 | hlayout->addWidget(new QLabel(tr("SD Card Path:"))); |
| 187 | hlayout->addWidget(m_sd_raw_edit); |
| 188 | hlayout->addWidget(sdcard_open); |
| 189 | |
| 190 | sd_settings_group_layout->addLayout(hlayout, row, 0, 1, 2); |
| 191 | ++row; |
| 192 | } |
| 193 | |
| 194 | m_sync_sd_folder_checkbox = new ConfigBool(tr("Automatically Sync with Folder"), |
| 195 | Config::MAIN_WII_SD_CARD_ENABLE_FOLDER_SYNC); |
| 196 | m_sync_sd_folder_checkbox->SetDescription( |
| 197 | tr("Synchronizes the SD Card with the SD Sync Folder when starting and ending emulation.")); |
| 198 | sd_settings_group_layout->addWidget(m_sync_sd_folder_checkbox, row, 0, 1, 2); |
| 199 | ++row; |
| 200 | |
| 201 | { |
| 202 | QHBoxLayout* hlayout = new QHBoxLayout; |
| 203 | m_sd_sync_folder_edit = |
| 204 | new ConfigUserPath(D_WIISDCARDSYNCFOLDER_IDX, Config::MAIN_WII_SD_CARD_SYNC_FOLDER_PATH); |
| 205 | QPushButton* sdcard_open = new NonDefaultQPushButton(QStringLiteral("...")); |
| 206 | connect(sdcard_open, &QPushButton::clicked, this, &WiiPane::BrowseSDSyncFolder); |
| 207 | hlayout->addWidget(new QLabel(tr("SD Sync Folder:"))); |
| 208 | hlayout->addWidget(m_sd_sync_folder_edit); |
| 209 | hlayout->addWidget(sdcard_open); |
| 210 | |
| 211 | sd_settings_group_layout->addLayout(hlayout, row, 0, 1, 2); |
| 212 | ++row; |
| 213 | } |
| 214 | |
| 215 | std::vector<std::pair<QString, u64>> sd_size_choices; |
| 216 | for (const auto& entry : sd_size_combo_entries) |
| 217 | sd_size_choices.emplace_back(tr(entry.name), entry.size); |
| 218 | |
| 219 | m_sd_card_size_combo = new ConfigChoiceMap(sd_size_choices, Config::MAIN_WII_SD_CARD_FILESIZE); |
| 220 | sd_settings_group_layout->addWidget(new QLabel(tr("SD Card File Size:")), row, 0); |
| 221 | sd_settings_group_layout->addWidget(m_sd_card_size_combo, row, 1); |
| 222 | ++row; |
| 223 | |
| 224 | m_sd_pack_button = new NonDefaultQPushButton(tr(Common::SD_PACK_TEXT)); |
| 225 | m_sd_unpack_button = new NonDefaultQPushButton(tr(Common::SD_UNPACK_TEXT)); |
| 226 | connect(m_sd_pack_button, &QPushButton::clicked, [this] { |
| 227 | auto result = ModalMessageBox::warning( |
| 228 | this, tr(Common::SD_PACK_TEXT), |
| 229 | tr("You are about to pack the content of the folder at %1 into the file at %2. All " |
| 230 | "current content of the file will be deleted. Are you sure you want to continue?") |
| 231 | .arg(QString::fromStdString(File::GetUserPath(D_WIISDCARDSYNCFOLDER_IDX))) |
| 232 | .arg(QString::fromStdString(File::GetUserPath(F_WIISDCARDIMAGE_IDX))), |
| 233 | QMessageBox::Yes | QMessageBox::No); |
| 234 | if (result == QMessageBox::Yes) |
| 235 | { |
| 236 | ParallelProgressDialog progress_dialog(tr("Converting..."), tr("Cancel"), 0, 0, this); |
| 237 | progress_dialog.GetRaw()->setWindowModality(Qt::WindowModal); |
| 238 | progress_dialog.GetRaw()->setWindowTitle(tr("Progress")); |
| 239 | auto success = std::async(std::launch::async, [&] { |
| 240 | const bool good = Common::SyncSDFolderToSDImage( |
| 241 | [&progress_dialog] { return progress_dialog.WasCanceled(); }, false); |
| 242 | progress_dialog.Reset(); |
| 243 | return good; |
| 244 | }); |
| 245 | progress_dialog.GetRaw()->exec(); |
| 246 | if (!success.get()) |
| 247 | ModalMessageBox::warning(this, tr(Common::SD_PACK_TEXT), tr("Conversion failed.")); |
| 248 | } |
| 249 | }); |
| 250 | connect(m_sd_unpack_button, &QPushButton::clicked, [this] { |
| 251 | auto result = ModalMessageBox::warning( |
| 252 | this, tr(Common::SD_UNPACK_TEXT), |
| 253 | tr("You are about to unpack the content of the file at %2 into the folder at %1. All " |
| 254 | "current content of the folder will be deleted. Are you sure you want to continue?") |
| 255 | .arg(QString::fromStdString(File::GetUserPath(D_WIISDCARDSYNCFOLDER_IDX))) |
| 256 | .arg(QString::fromStdString(File::GetUserPath(F_WIISDCARDIMAGE_IDX))), |
| 257 | QMessageBox::Yes | QMessageBox::No); |
| 258 | if (result == QMessageBox::Yes) |
| 259 | { |
| 260 | ParallelProgressDialog progress_dialog(tr("Converting..."), tr("Cancel"), 0, 0, this); |
| 261 | progress_dialog.GetRaw()->setWindowModality(Qt::WindowModal); |
| 262 | progress_dialog.GetRaw()->setWindowTitle(tr("Progress")); |
| 263 | auto success = std::async(std::launch::async, [&] { |
| 264 | const bool good = Common::SyncSDImageToSDFolder( |
| 265 | [&progress_dialog] { return progress_dialog.WasCanceled(); }); |
| 266 | progress_dialog.Reset(); |
| 267 | return good; |
| 268 | }); |
| 269 | progress_dialog.GetRaw()->exec(); |
| 270 | if (!success.get()) |
| 271 | ModalMessageBox::warning(this, tr(Common::SD_UNPACK_TEXT), tr("Conversion failed.")); |
| 272 | } |
| 273 | }); |
| 274 | sd_settings_group_layout->addWidget(m_sd_pack_button, row, 0, 1, 1); |
| 275 | sd_settings_group_layout->addWidget(m_sd_unpack_button, row, 1, 1, 1); |
| 276 | ++row; |
| 277 | } |
| 278 | |
| 279 | void WiiPane::CreateWhitelistedUSBPassthroughDevices() |
| 280 | { |
| 281 | m_whitelist_usb_list = new QtUtils::MinimumSizeHintWidget<QListWidget>; |
| 282 | |
| 283 | m_whitelist_usb_add_button = new NonDefaultQPushButton(tr("Add...")); |
| 284 | m_whitelist_usb_remove_button = new NonDefaultQPushButton(tr("Remove")); |
| 285 | |
| 286 | QHBoxLayout* hlayout = new QHBoxLayout; |
| 287 | hlayout->addStretch(); |
| 288 | hlayout->addWidget(m_whitelist_usb_add_button); |
| 289 | hlayout->addWidget(m_whitelist_usb_remove_button); |
| 290 | |
| 291 | QVBoxLayout* vlayout = new QVBoxLayout; |
| 292 | vlayout->addWidget(m_whitelist_usb_list); |
| 293 | vlayout->addLayout(hlayout); |
| 294 | |
| 295 | auto* whitelisted_usb_passthrough_devices_group = |
| 296 | new QGroupBox(tr("Whitelisted USB Passthrough Devices")); |
| 297 | whitelisted_usb_passthrough_devices_group->setLayout(vlayout); |
| 298 | |
| 299 | m_main_layout->addWidget(whitelisted_usb_passthrough_devices_group); |
| 300 | } |
| 301 | |
| 302 | void WiiPane::CreateWiiRemoteSettings() |
| 303 | { |
| 304 | auto* wii_remote_settings_group = new QGroupBox(tr("Wii Remote Settings")); |
| 305 | auto* wii_remote_settings_group_layout = new QGridLayout(); |
| 306 | wii_remote_settings_group->setLayout(wii_remote_settings_group_layout); |
| 307 | m_main_layout->addWidget(wii_remote_settings_group); |
| 308 | m_wiimote_motor = new ConfigBool(tr("Enable Rumble"), Config::SYSCONF_WIIMOTE_MOTOR); |
| 309 | |
| 310 | m_wiimote_sensor_position_label = new QLabel(tr("Sensor Bar Position:")); |
| 311 | m_wiimote_ir_sensor_position = new ConfigChoiceMap<u32>({{tr("Top"), 1}, {tr("Bottom"), 0}}, |
| 312 | Config::SYSCONF_SENSOR_BAR_POSITION); |
| 313 | |
| 314 | // IR Sensitivity Slider |
| 315 | // i18n: IR stands for infrared and refers to the pointer functionality of Wii Remotes |
| 316 | m_wiimote_ir_sensitivity_label = new QLabel(tr("IR Sensitivity:")); |
| 317 | // Wii menu saves values from 1 to 5. |
| 318 | m_wiimote_ir_sensitivity = new ConfigSliderU32(1, 5, Config::SYSCONF_SENSOR_BAR_SENSITIVITY, 1); |
| 319 | |
| 320 | // Speaker Volume Slider |
| 321 | m_wiimote_speaker_volume_label = new QLabel(tr("Speaker Volume:")); |
| 322 | m_wiimote_speaker_volume = new ConfigSliderU32(0, 127, Config::SYSCONF_SPEAKER_VOLUME, 1); |
| 323 | |
| 324 | wii_remote_settings_group_layout->addWidget(m_wiimote_sensor_position_label, 0, 0); |
| 325 | wii_remote_settings_group_layout->addWidget(m_wiimote_ir_sensor_position, 0, 1); |
| 326 | wii_remote_settings_group_layout->addWidget(m_wiimote_ir_sensitivity_label, 1, 0); |
| 327 | wii_remote_settings_group_layout->addWidget(m_wiimote_ir_sensitivity, 1, 1); |
| 328 | wii_remote_settings_group_layout->addWidget(m_wiimote_speaker_volume_label, 2, 0); |
| 329 | wii_remote_settings_group_layout->addWidget(m_wiimote_speaker_volume, 2, 1); |
| 330 | wii_remote_settings_group_layout->addWidget(m_wiimote_motor, 3, 0, 1, -1); |
| 331 | } |
| 332 | |
| 333 | void WiiPane::OnEmulationStateChanged(bool running) |
| 334 | { |
| 335 | m_screensaver_checkbox->setEnabled(!running); |
| 336 | m_pal60_mode_checkbox->setEnabled(!running); |
| 337 | m_system_language_choice->setEnabled(!running); |
| 338 | m_aspect_ratio_choice->setEnabled(!running); |
| 339 | m_sound_mode_choice->setEnabled(!running); |
| 340 | m_sd_pack_button->setEnabled(!running); |
| 341 | m_sd_unpack_button->setEnabled(!running); |
| 342 | m_wiimote_motor->setEnabled(!running); |
| 343 | m_wiimote_speaker_volume->setEnabled(!running); |
| 344 | m_wiimote_ir_sensitivity->setEnabled(!running); |
| 345 | m_wiimote_ir_sensor_position->setEnabled(!running); |
| 346 | m_wiilink_checkbox->setEnabled(!running); |
| 347 | } |
| 348 | |
| 349 | void WiiPane::ValidateSelectionState() |
| 350 | { |
| 351 | m_whitelist_usb_remove_button->setEnabled(m_whitelist_usb_list->currentIndex().isValid()); |
| 352 | } |
| 353 | |
| 354 | void WiiPane::OnUSBWhitelistAddButton() |
| 355 | { |
| 356 | auto whitelist = Config::GetUSBDeviceWhitelist(); |
| 357 | |
| 358 | const std::optional<USBUtils::DeviceInfo> usb_device = USBDevicePicker::Run( |
| 359 | this, tr("Add New USB Device"), |
| 360 | [&whitelist](const USBUtils::DeviceInfo& device) { return !whitelist.contains(device); }); |
| 361 | if (!usb_device) |
| 362 | return; |
| 363 | |
| 364 | if (whitelist.contains(*usb_device)) |
| 365 | { |
| 366 | ModalMessageBox::critical(this, tr("USB Whitelist Error"), |
| 367 | tr("This USB device is already whitelisted.")); |
| 368 | return; |
| 369 | } |
| 370 | whitelist.emplace(*usb_device); |
| 371 | Config::SetUSBDeviceWhitelist(whitelist); |
| 372 | PopulateUSBPassthroughListWidget(); |
| 373 | } |
| 374 | |
| 375 | void WiiPane::OnUSBWhitelistRemoveButton() |
| 376 | { |
| 377 | auto* current_item = m_whitelist_usb_list->currentItem(); |
| 378 | if (!current_item) |
| 379 | return; |
| 380 | |
| 381 | QVariant item_data = current_item->data(Qt::UserRole); |
| 382 | USBUtils::DeviceInfo device = item_data.value<USBUtils::DeviceInfo>(); |
| 383 | |
| 384 | auto whitelist = Config::GetUSBDeviceWhitelist(); |
| 385 | whitelist.erase(device); |
| 386 | Config::SetUSBDeviceWhitelist(whitelist); |
| 387 | PopulateUSBPassthroughListWidget(); |
| 388 | } |
| 389 | |
| 390 | void WiiPane::PopulateUSBPassthroughListWidget() |
| 391 | { |
| 392 | m_whitelist_usb_list->clear(); |
| 393 | auto whitelist = Config::GetUSBDeviceWhitelist(); |
| 394 | for (auto& device : whitelist) |
| 395 | { |
| 396 | auto* item = |
| 397 | new QListWidgetItem(QString::fromStdString(device.ToDisplayString()), m_whitelist_usb_list); |
| 398 | QVariant device_data = QVariant::fromValue(device); |
| 399 | item->setData(Qt::UserRole, device_data); |
| 400 | } |
| 401 | ValidateSelectionState(); |
| 402 | } |
| 403 | |
| 404 | void WiiPane::BrowseSDRaw() |
| 405 | { |
| 406 | QString file = QDir::toNativeSeparators(DolphinFileDialog::getOpenFileName( |
| 407 | this, tr("Select SD Card Image"), |
| 408 | QString::fromStdString(Config::Get(Config::MAIN_WII_SD_CARD_IMAGE_PATH)), |
| 409 | tr("SD Card Image (*.raw);;" |
| 410 | "All Files (*)"))); |
| 411 | if (!file.isEmpty()) |
| 412 | m_sd_raw_edit->SetTextAndUpdate(file); |
| 413 | } |
| 414 | |
| 415 | void WiiPane::BrowseSDSyncFolder() |
| 416 | { |
| 417 | QString file = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory( |
| 418 | this, tr("Select a Folder to Sync with the SD Card Image"), |
| 419 | QString::fromStdString(File::GetUserPath(D_WIISDCARDSYNCFOLDER_IDX)))); |
| 420 | if (!file.isEmpty()) |
| 421 | m_sd_sync_folder_edit->SetTextAndUpdate(file); |
| 422 | } |