Qt: Put Wii SD card path and SD sync folder fields in the WiiPane.

This commit is contained in:
Admiral H. Curtiss 2022-06-16 03:26:14 +02:00
parent a5b1bfef68
commit 1d12e95404
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
4 changed files with 93 additions and 43 deletions

View File

@ -99,20 +99,6 @@ void PathPane::BrowseResourcePack()
}
}
void PathPane::BrowseSDCard()
{
QString file = QDir::toNativeSeparators(DolphinFileDialog::getOpenFileName(
this, tr("Select a SD Card Image"),
QString::fromStdString(Config::Get(Config::MAIN_WII_SD_CARD_IMAGE_PATH)),
tr("SD Card Image (*.raw);;"
"All Files (*)")));
if (!file.isEmpty())
{
m_sdcard_edit->setText(file);
OnSDCardPathChanged();
}
}
void PathPane::BrowseWFS()
{
const QString dir = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory(
@ -124,11 +110,6 @@ void PathPane::BrowseWFS()
}
}
void PathPane::OnSDCardPathChanged()
{
Config::SetBase(Config::MAIN_WII_SD_CARD_IMAGE_PATH, m_sdcard_edit->text().toStdString());
}
void PathPane::OnNANDPathChanged()
{
Config::SetBase(Config::MAIN_FS_PATH, m_nand_edit->text().toStdString());
@ -242,22 +223,14 @@ QGridLayout* PathPane::MakePathsLayout()
layout->addWidget(m_resource_pack_edit, 4, 1);
layout->addWidget(resource_pack_open, 4, 2);
m_sdcard_edit = new QLineEdit(QString::fromStdString(File::GetUserPath(F_WIISDCARDIMAGE_IDX)));
connect(m_sdcard_edit, &QLineEdit::editingFinished, this, &PathPane::OnSDCardPathChanged);
QPushButton* sdcard_open = new NonDefaultQPushButton(QStringLiteral("..."));
connect(sdcard_open, &QPushButton::clicked, this, &PathPane::BrowseSDCard);
layout->addWidget(new QLabel(tr("SD Card Path:")), 5, 0);
layout->addWidget(m_sdcard_edit, 5, 1);
layout->addWidget(sdcard_open, 5, 2);
m_wfs_edit = new QLineEdit(QString::fromStdString(File::GetUserPath(D_WFSROOT_IDX)));
connect(m_load_edit, &QLineEdit::editingFinished,
[=] { Config::SetBase(Config::MAIN_WFS_PATH, m_wfs_edit->text().toStdString()); });
QPushButton* wfs_open = new NonDefaultQPushButton(QStringLiteral("..."));
connect(wfs_open, &QPushButton::clicked, this, &PathPane::BrowseWFS);
layout->addWidget(new QLabel(tr("WFS Path:")), 6, 0);
layout->addWidget(m_wfs_edit, 6, 1);
layout->addWidget(wfs_open, 6, 2);
layout->addWidget(new QLabel(tr("WFS Path:")), 5, 0);
layout->addWidget(m_wfs_edit, 5, 1);
layout->addWidget(wfs_open, 5, 2);
return layout;
}

View File

@ -24,13 +24,11 @@ private:
void BrowseDump();
void BrowseLoad();
void BrowseResourcePack();
void BrowseSDCard();
void BrowseWFS();
QGroupBox* MakeGameFolderBox();
QGridLayout* MakePathsLayout();
void RemovePath();
void OnSDCardPathChanged();
void OnNANDPathChanged();
QListWidget* m_path_list;
@ -39,7 +37,6 @@ private:
QLineEdit* m_dump_edit;
QLineEdit* m_load_edit;
QLineEdit* m_resource_pack_edit;
QLineEdit* m_sdcard_edit;
QLineEdit* m_wfs_edit;
QPushButton* m_remove_path;

View File

@ -5,10 +5,12 @@
#include <QCheckBox>
#include <QComboBox>
#include <QDir>
#include <QGridLayout>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
#include <QPushButton>
#include <QSlider>
@ -16,6 +18,7 @@
#include <QStringList>
#include "Common/Config/Config.h"
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
#include "Core/Config/MainSettings.h"
@ -23,7 +26,9 @@
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/NonDefaultQPushButton.h"
#include "DolphinQt/QtUtils/SignalBlocking.h"
#include "DolphinQt/Settings.h"
#include "DolphinQt/Settings/USBDeviceAddToWhitelistDialog.h"
@ -163,15 +168,49 @@ void WiiPane::CreateSDCard()
sd_settings_group->setLayout(sd_settings_group_layout);
m_main_layout->addWidget(sd_settings_group);
int row = 0;
m_sd_card_checkbox = new QCheckBox(tr("Insert SD Card"));
m_allow_sd_writes_checkbox = new QCheckBox(tr("Allow Writes to SD Card"));
m_sync_sd_folder_checkbox = new QCheckBox(tr("Sync with Folder"));
m_sd_card_checkbox->setToolTip(tr("Supports SD and SDHC. Default size is 128 MB."));
m_allow_sd_writes_checkbox = new QCheckBox(tr("Allow Writes to SD Card"));
sd_settings_group_layout->addWidget(m_sd_card_checkbox, row, 0, 1, 1);
sd_settings_group_layout->addWidget(m_allow_sd_writes_checkbox, row, 1, 1, 1);
++row;
sd_settings_group_layout->addWidget(m_sd_card_checkbox, 0, 0, 1, 1);
sd_settings_group_layout->addWidget(m_allow_sd_writes_checkbox, 0, 1, 1, 1);
sd_settings_group_layout->addWidget(m_sync_sd_folder_checkbox, 1, 0, 1, 1);
{
QHBoxLayout* hlayout = new QHBoxLayout;
m_sd_raw_edit = new QLineEdit(QString::fromStdString(File::GetUserPath(F_WIISDCARDIMAGE_IDX)));
connect(m_sd_raw_edit, &QLineEdit::editingFinished,
[this] { SetSDRaw(m_sd_raw_edit->text()); });
QPushButton* sdcard_open = new NonDefaultQPushButton(QStringLiteral("..."));
connect(sdcard_open, &QPushButton::clicked, this, &WiiPane::BrowseSDRaw);
hlayout->addWidget(new QLabel(tr("SD Card Path:")));
hlayout->addWidget(m_sd_raw_edit);
hlayout->addWidget(sdcard_open);
sd_settings_group_layout->addLayout(hlayout, row, 0, 1, 2);
++row;
}
m_sync_sd_folder_checkbox =
new QCheckBox(tr("Automatically sync with Folder on emulation start and end"));
sd_settings_group_layout->addWidget(m_sync_sd_folder_checkbox, row, 0, 1, 2);
++row;
{
QHBoxLayout* hlayout = new QHBoxLayout;
m_sd_sync_folder_edit =
new QLineEdit(QString::fromStdString(File::GetUserPath(D_WIISDCARDSYNCFOLDER_IDX)));
connect(m_sd_sync_folder_edit, &QLineEdit::editingFinished,
[this] { SetSDSyncFolder(m_sd_sync_folder_edit->text()); });
QPushButton* sdcard_open = new NonDefaultQPushButton(QStringLiteral("..."));
connect(sdcard_open, &QPushButton::clicked, this, &WiiPane::BrowseSDSyncFolder);
hlayout->addWidget(new QLabel(tr("SD Sync Folder:")));
hlayout->addWidget(m_sd_sync_folder_edit);
hlayout->addWidget(sdcard_open);
sd_settings_group_layout->addLayout(hlayout, row, 0, 1, 2);
++row;
}
}
void WiiPane::CreateWhitelistedUSBPassthroughDevices()
@ -329,3 +368,35 @@ void WiiPane::PopulateUSBPassthroughListWidget()
}
ValidateSelectionState();
}
void WiiPane::BrowseSDRaw()
{
QString file = QDir::toNativeSeparators(DolphinFileDialog::getOpenFileName(
this, tr("Select a SD Card Image"),
QString::fromStdString(Config::Get(Config::MAIN_WII_SD_CARD_IMAGE_PATH)),
tr("SD Card Image (*.raw);;"
"All Files (*)")));
if (!file.isEmpty())
SetSDRaw(file);
}
void WiiPane::SetSDRaw(const QString& path)
{
Config::SetBase(Config::MAIN_WII_SD_CARD_IMAGE_PATH, path.toStdString());
SignalBlocking(m_sd_raw_edit)->setText(path);
}
void WiiPane::BrowseSDSyncFolder()
{
QString file = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory(
this, tr("Select a Folder to sync with the SD Card Image"),
QString::fromStdString(Config::Get(Config::MAIN_WII_SD_CARD_SYNC_FOLDER_PATH))));
if (!file.isEmpty())
SetSDSyncFolder(file);
}
void WiiPane::SetSDSyncFolder(const QString& path)
{
Config::SetBase(Config::MAIN_WII_SD_CARD_SYNC_FOLDER_PATH, path.toStdString());
SignalBlocking(m_sd_sync_folder_edit)->setText(path);
}

View File

@ -5,13 +5,15 @@
#include <QWidget>
class QCheckBox;
class QComboBox;
class QLabel;
class QSlider;
class QVBoxLayout;
class QLineEdit;
class QListWidget;
class QPushButton;
class QComboBox;
class QCheckBox;
class QSlider;
class QString;
class QVBoxLayout;
class WiiPane : public QWidget
{
@ -37,6 +39,11 @@ private:
void OnUSBWhitelistAddButton();
void OnUSBWhitelistRemoveButton();
void BrowseSDRaw();
void SetSDRaw(const QString& path);
void BrowseSDSyncFolder();
void SetSDSyncFolder(const QString& path);
// Widgets
QVBoxLayout* m_main_layout;
@ -55,6 +62,8 @@ private:
QCheckBox* m_sd_card_checkbox;
QCheckBox* m_allow_sd_writes_checkbox;
QCheckBox* m_sync_sd_folder_checkbox;
QLineEdit* m_sd_raw_edit;
QLineEdit* m_sd_sync_folder_edit;
// Whitelisted USB Passthrough Devices
QListWidget* m_whitelist_usb_list;