2015-12-31 03:03:13 +00:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-12-31 03:03:13 +00:00
|
|
|
|
2018-04-19 21:07:36 +00:00
|
|
|
#include <QCheckBox>
|
2018-05-13 19:43:57 +00:00
|
|
|
#include <QDir>
|
2017-05-31 08:08:04 +00:00
|
|
|
#include <QGroupBox>
|
2015-12-31 03:03:13 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
2018-05-23 13:55:48 +00:00
|
|
|
#include "Common/Config/Config.h"
|
2020-03-30 10:06:38 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2018-05-28 01:48:04 +00:00
|
|
|
|
2018-05-23 13:55:48 +00:00
|
|
|
#include "Core/Config/MainSettings.h"
|
2020-07-20 09:22:53 +00:00
|
|
|
#include "Core/Config/UISettings.h"
|
2017-06-22 22:11:53 +00:00
|
|
|
|
2021-10-10 02:28:59 +00:00
|
|
|
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Settings.h"
|
|
|
|
#include "DolphinQt/Settings/PathPane.h"
|
2015-12-31 03:03:13 +00:00
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
PathPane::PathPane(QWidget* parent) : QWidget(parent)
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
|
|
|
setWindowTitle(tr("Paths"));
|
|
|
|
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout;
|
|
|
|
layout->addWidget(MakeGameFolderBox());
|
|
|
|
layout->addLayout(MakePathsLayout());
|
|
|
|
|
|
|
|
setLayout(layout);
|
|
|
|
}
|
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
void PathPane::Browse()
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
2018-05-13 19:43:57 +00:00
|
|
|
QString dir = QDir::toNativeSeparators(
|
2021-10-10 02:28:59 +00:00
|
|
|
DolphinFileDialog::getExistingDirectory(this, tr("Select a Directory"), QDir::currentPath()));
|
2015-12-31 03:03:13 +00:00
|
|
|
if (!dir.isEmpty())
|
2017-05-31 07:42:15 +00:00
|
|
|
Settings::Instance().AddPath(dir);
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
void PathPane::BrowseDefaultGame()
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
QString file = QDir::toNativeSeparators(DolphinFileDialog::getOpenFileName(
|
|
|
|
this, tr("Select a Game"), Settings::Instance().GetDefaultGame(),
|
|
|
|
tr("All GC/Wii files (*.elf *.dol *.gcm *.iso *.tgc *.wbfs "
|
|
|
|
"*.ciso *.gcz *.wia *.rvz *.wad *.m3u);;All Files (*)")));
|
2018-07-01 16:20:01 +00:00
|
|
|
|
2015-12-31 03:03:13 +00:00
|
|
|
if (!file.isEmpty())
|
2018-07-01 16:20:01 +00:00
|
|
|
Settings::Instance().SetDefaultGame(file);
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
void PathPane::BrowseWiiNAND()
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
QString dir = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory(
|
2018-05-23 13:55:48 +00:00
|
|
|
this, tr("Select Wii NAND Root"), QString::fromStdString(Config::Get(Config::MAIN_FS_PATH))));
|
2015-12-31 03:03:13 +00:00
|
|
|
if (!dir.isEmpty())
|
|
|
|
{
|
|
|
|
m_nand_edit->setText(dir);
|
2018-04-28 23:01:14 +00:00
|
|
|
OnNANDPathChanged();
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-25 19:43:12 +00:00
|
|
|
void PathPane::BrowseDump()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
QString dir = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory(
|
2018-05-23 13:55:48 +00:00
|
|
|
this, tr("Select Dump Path"), QString::fromStdString(Config::Get(Config::MAIN_DUMP_PATH))));
|
2018-04-25 19:43:12 +00:00
|
|
|
if (!dir.isEmpty())
|
|
|
|
{
|
|
|
|
m_dump_edit->setText(dir);
|
2018-05-23 13:55:48 +00:00
|
|
|
Config::SetBase(Config::MAIN_DUMP_PATH, dir.toStdString());
|
2018-04-25 19:43:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-06 05:51:42 +00:00
|
|
|
void PathPane::BrowseLoad()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
QString dir = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory(
|
2019-10-06 05:51:42 +00:00
|
|
|
this, tr("Select Load Path"), QString::fromStdString(Config::Get(Config::MAIN_LOAD_PATH))));
|
|
|
|
if (!dir.isEmpty())
|
|
|
|
{
|
|
|
|
m_load_edit->setText(dir);
|
|
|
|
Config::SetBase(Config::MAIN_LOAD_PATH, dir.toStdString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-06 06:21:06 +00:00
|
|
|
void PathPane::BrowseResourcePack()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
QString dir = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory(
|
2019-10-06 06:21:06 +00:00
|
|
|
this, tr("Select Resource Pack Path"),
|
|
|
|
QString::fromStdString(Config::Get(Config::MAIN_RESOURCEPACK_PATH))));
|
|
|
|
if (!dir.isEmpty())
|
|
|
|
{
|
|
|
|
m_resource_pack_edit->setText(dir);
|
|
|
|
Config::SetBase(Config::MAIN_RESOURCEPACK_PATH, dir.toStdString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-25 19:43:12 +00:00
|
|
|
void PathPane::BrowseSDCard()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
QString file = QDir::toNativeSeparators(DolphinFileDialog::getOpenFileName(
|
2018-05-23 13:55:48 +00:00
|
|
|
this, tr("Select a SD Card Image"), QString::fromStdString(Config::Get(Config::MAIN_SD_PATH)),
|
2018-04-28 23:01:14 +00:00
|
|
|
tr("SD Card Image (*.raw);;"
|
2018-05-13 19:43:57 +00:00
|
|
|
"All Files (*)")));
|
2018-04-25 19:43:12 +00:00
|
|
|
if (!file.isEmpty())
|
|
|
|
{
|
|
|
|
m_sdcard_edit->setText(file);
|
2018-04-28 23:01:14 +00:00
|
|
|
OnSDCardPathChanged();
|
2018-04-25 19:43:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-28 23:01:14 +00:00
|
|
|
void PathPane::OnSDCardPathChanged()
|
|
|
|
{
|
2018-05-23 13:55:48 +00:00
|
|
|
Config::SetBase(Config::MAIN_SD_PATH, m_sdcard_edit->text().toStdString());
|
2018-04-28 23:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PathPane::OnNANDPathChanged()
|
|
|
|
{
|
2018-05-23 13:55:48 +00:00
|
|
|
Config::SetBase(Config::MAIN_FS_PATH, m_nand_edit->text().toStdString());
|
2018-04-28 23:01:14 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
QGroupBox* PathPane::MakeGameFolderBox()
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
|
|
|
QGroupBox* game_box = new QGroupBox(tr("Game Folders"));
|
|
|
|
QVBoxLayout* vlayout = new QVBoxLayout;
|
|
|
|
|
|
|
|
m_path_list = new QListWidget;
|
2017-05-31 07:17:39 +00:00
|
|
|
m_path_list->insertItems(0, Settings::Instance().GetPaths());
|
2015-12-31 03:03:13 +00:00
|
|
|
m_path_list->setSpacing(1);
|
2020-09-12 22:53:17 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::PathAdded, this,
|
2017-05-31 07:42:15 +00:00
|
|
|
[this](const QString& dir) { m_path_list->addItem(dir); });
|
2020-09-12 22:53:17 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::PathRemoved, this, [this](const QString& dir) {
|
2017-05-31 07:42:15 +00:00
|
|
|
auto items = m_path_list->findItems(dir, Qt::MatchExactly);
|
|
|
|
for (auto& item : items)
|
|
|
|
delete item;
|
|
|
|
});
|
2018-05-12 21:36:07 +00:00
|
|
|
connect(m_path_list, &QListWidget::itemSelectionChanged, this,
|
|
|
|
[this] { m_remove_path->setEnabled(m_path_list->selectedItems().count()); });
|
|
|
|
|
2015-12-31 03:03:13 +00:00
|
|
|
vlayout->addWidget(m_path_list);
|
|
|
|
|
|
|
|
QHBoxLayout* hlayout = new QHBoxLayout;
|
|
|
|
|
|
|
|
hlayout->addStretch();
|
2018-05-12 21:36:07 +00:00
|
|
|
QPushButton* add = new QPushButton(tr("Add..."));
|
|
|
|
m_remove_path = new QPushButton(tr("Remove"));
|
|
|
|
|
|
|
|
m_remove_path->setEnabled(false);
|
2018-04-19 21:07:36 +00:00
|
|
|
|
2018-06-06 08:52:27 +00:00
|
|
|
auto* recursive_checkbox = new QCheckBox(tr("Search Subfolders"));
|
2020-07-20 09:22:53 +00:00
|
|
|
recursive_checkbox->setChecked(Config::Get(Config::MAIN_RECURSIVE_ISO_PATHS));
|
2018-06-06 08:52:27 +00:00
|
|
|
|
|
|
|
auto* auto_checkbox = new QCheckBox(tr("Check for Game List Changes in the Background"));
|
|
|
|
auto_checkbox->setChecked(Settings::Instance().IsAutoRefreshEnabled());
|
2018-04-19 21:07:36 +00:00
|
|
|
|
2015-12-31 03:03:13 +00:00
|
|
|
hlayout->addWidget(add);
|
2018-05-12 21:36:07 +00:00
|
|
|
hlayout->addWidget(m_remove_path);
|
2015-12-31 03:03:13 +00:00
|
|
|
vlayout->addLayout(hlayout);
|
2018-06-06 08:52:27 +00:00
|
|
|
vlayout->addWidget(recursive_checkbox);
|
|
|
|
vlayout->addWidget(auto_checkbox);
|
2018-04-19 21:07:36 +00:00
|
|
|
|
2019-07-23 22:18:58 +00:00
|
|
|
connect(recursive_checkbox, &QCheckBox::toggled, [](bool checked) {
|
2020-07-20 09:22:53 +00:00
|
|
|
Config::SetBase(Config::MAIN_RECURSIVE_ISO_PATHS, checked);
|
2018-07-06 18:27:07 +00:00
|
|
|
Settings::Instance().RefreshGameList();
|
2018-04-19 21:07:36 +00:00
|
|
|
});
|
2015-12-31 03:03:13 +00:00
|
|
|
|
2018-06-06 08:52:27 +00:00
|
|
|
connect(auto_checkbox, &QCheckBox::toggled, &Settings::Instance(),
|
|
|
|
&Settings::SetAutoRefreshEnabled);
|
|
|
|
|
2019-04-22 23:44:00 +00:00
|
|
|
connect(add, &QPushButton::clicked, this, &PathPane::Browse);
|
2019-07-23 22:18:58 +00:00
|
|
|
connect(m_remove_path, &QPushButton::clicked, this, &PathPane::RemovePath);
|
2015-12-31 03:03:13 +00:00
|
|
|
|
|
|
|
game_box->setLayout(vlayout);
|
|
|
|
return game_box;
|
|
|
|
}
|
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
QGridLayout* PathPane::MakePathsLayout()
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
|
|
|
QGridLayout* layout = new QGridLayout;
|
|
|
|
layout->setColumnStretch(1, 1);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2018-01-31 18:58:02 +00:00
|
|
|
m_game_edit = new QLineEdit(Settings::Instance().GetDefaultGame());
|
2015-12-31 03:03:13 +00:00
|
|
|
connect(m_game_edit, &QLineEdit::editingFinished,
|
2018-01-31 18:58:02 +00:00
|
|
|
[this] { Settings::Instance().SetDefaultGame(m_game_edit->text()); });
|
2020-09-12 22:53:17 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::DefaultGameChanged, this,
|
2018-01-31 18:58:02 +00:00
|
|
|
[this](const QString& path) { m_game_edit->setText(path); });
|
2018-05-02 18:16:57 +00:00
|
|
|
QPushButton* game_open = new QPushButton(QStringLiteral("..."));
|
2019-07-23 22:18:58 +00:00
|
|
|
connect(game_open, &QPushButton::clicked, this, &PathPane::BrowseDefaultGame);
|
2017-07-23 10:58:32 +00:00
|
|
|
layout->addWidget(new QLabel(tr("Default ISO:")), 0, 0);
|
2015-12-31 03:03:13 +00:00
|
|
|
layout->addWidget(m_game_edit, 0, 1);
|
|
|
|
layout->addWidget(game_open, 0, 2);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2020-03-30 10:06:38 +00:00
|
|
|
m_nand_edit = new QLineEdit(QString::fromStdString(File::GetUserPath(D_WIIROOT_IDX)));
|
2018-04-28 23:01:14 +00:00
|
|
|
connect(m_nand_edit, &QLineEdit::editingFinished, this, &PathPane::OnNANDPathChanged);
|
2018-05-02 18:16:57 +00:00
|
|
|
QPushButton* nand_open = new QPushButton(QStringLiteral("..."));
|
2019-07-23 22:18:58 +00:00
|
|
|
connect(nand_open, &QPushButton::clicked, this, &PathPane::BrowseWiiNAND);
|
2017-06-08 12:14:56 +00:00
|
|
|
layout->addWidget(new QLabel(tr("Wii NAND Root:")), 1, 0);
|
|
|
|
layout->addWidget(m_nand_edit, 1, 1);
|
|
|
|
layout->addWidget(nand_open, 1, 2);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2020-03-30 10:06:38 +00:00
|
|
|
m_dump_edit = new QLineEdit(QString::fromStdString(File::GetUserPath(D_DUMP_IDX)));
|
2018-04-25 19:43:12 +00:00
|
|
|
connect(m_dump_edit, &QLineEdit::editingFinished,
|
2018-05-23 13:55:48 +00:00
|
|
|
[=] { Config::SetBase(Config::MAIN_DUMP_PATH, m_dump_edit->text().toStdString()); });
|
2018-05-02 18:16:57 +00:00
|
|
|
QPushButton* dump_open = new QPushButton(QStringLiteral("..."));
|
2019-07-23 22:18:58 +00:00
|
|
|
connect(dump_open, &QPushButton::clicked, this, &PathPane::BrowseDump);
|
2018-04-25 19:43:12 +00:00
|
|
|
layout->addWidget(new QLabel(tr("Dump Path:")), 2, 0);
|
|
|
|
layout->addWidget(m_dump_edit, 2, 1);
|
|
|
|
layout->addWidget(dump_open, 2, 2);
|
|
|
|
|
2020-03-30 10:06:38 +00:00
|
|
|
m_load_edit = new QLineEdit(QString::fromStdString(File::GetUserPath(D_LOAD_IDX)));
|
2019-10-06 05:51:42 +00:00
|
|
|
connect(m_load_edit, &QLineEdit::editingFinished,
|
|
|
|
[=] { Config::SetBase(Config::MAIN_LOAD_PATH, m_load_edit->text().toStdString()); });
|
|
|
|
QPushButton* load_open = new QPushButton(QStringLiteral("..."));
|
|
|
|
connect(load_open, &QPushButton::clicked, this, &PathPane::BrowseLoad);
|
|
|
|
layout->addWidget(new QLabel(tr("Load Path:")), 3, 0);
|
|
|
|
layout->addWidget(m_load_edit, 3, 1);
|
|
|
|
layout->addWidget(load_open, 3, 2);
|
|
|
|
|
2019-10-06 06:21:06 +00:00
|
|
|
m_resource_pack_edit =
|
2020-03-30 10:06:38 +00:00
|
|
|
new QLineEdit(QString::fromStdString(File::GetUserPath(D_RESOURCEPACK_IDX)));
|
2019-10-06 06:21:06 +00:00
|
|
|
connect(m_resource_pack_edit, &QLineEdit::editingFinished, [=] {
|
|
|
|
Config::SetBase(Config::MAIN_RESOURCEPACK_PATH, m_resource_pack_edit->text().toStdString());
|
|
|
|
});
|
|
|
|
QPushButton* resource_pack_open = new QPushButton(QStringLiteral("..."));
|
|
|
|
connect(resource_pack_open, &QPushButton::clicked, this, &PathPane::BrowseResourcePack);
|
|
|
|
layout->addWidget(new QLabel(tr("Resource Pack Path:")), 4, 0);
|
|
|
|
layout->addWidget(m_resource_pack_edit, 4, 1);
|
|
|
|
layout->addWidget(resource_pack_open, 4, 2);
|
|
|
|
|
2020-03-30 10:06:38 +00:00
|
|
|
m_sdcard_edit = new QLineEdit(QString::fromStdString(File::GetUserPath(F_WIISDCARD_IDX)));
|
2018-04-28 23:01:14 +00:00
|
|
|
connect(m_sdcard_edit, &QLineEdit::editingFinished, this, &PathPane::OnSDCardPathChanged);
|
2018-05-02 18:16:57 +00:00
|
|
|
QPushButton* sdcard_open = new QPushButton(QStringLiteral("..."));
|
2019-07-23 22:18:58 +00:00
|
|
|
connect(sdcard_open, &QPushButton::clicked, this, &PathPane::BrowseSDCard);
|
2019-10-06 06:21:06 +00:00
|
|
|
layout->addWidget(new QLabel(tr("SD Card Path:")), 5, 0);
|
|
|
|
layout->addWidget(m_sdcard_edit, 5, 1);
|
|
|
|
layout->addWidget(sdcard_open, 5, 2);
|
2018-04-25 19:43:12 +00:00
|
|
|
|
2015-12-31 03:03:13 +00:00
|
|
|
return layout;
|
|
|
|
}
|
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
void PathPane::RemovePath()
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
2017-05-31 07:42:15 +00:00
|
|
|
auto item = m_path_list->currentItem();
|
|
|
|
if (!item)
|
2015-12-31 03:03:13 +00:00
|
|
|
return;
|
2017-05-31 07:42:15 +00:00
|
|
|
Settings::Instance().RemovePath(item->text());
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|