1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
// Copyright 2015 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "DolphinQt/Settings/PathPane.h"
#include <QCheckBox>
#include <QDir>
#include <QGroupBox>
#include <QLabel>
#include <QListWidget>
#include <QPushButton>
#include <QVBoxLayout>
#include "Common/Config/Config.h"
#include "Common/FileUtil.h"
#include "Core/Config/MainSettings.h"
#include "Core/Config/UISettings.h"
#include "DolphinQt/Config/ConfigControls/ConfigBool.h"
#include "DolphinQt/Config/ConfigControls/ConfigText.h"
#include "DolphinQt/Config/ConfigControls/ConfigUserPath.h"
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
#include "DolphinQt/QtUtils/NonDefaultQPushButton.h"
#include "DolphinQt/Settings.h"
PathPane::PathPane(QWidget* parent) : QWidget(parent)
{
setWindowTitle(tr("Paths"));
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(MakeGameFolderBox());
layout->addLayout(MakePathsLayout());
setLayout(layout);
}
void PathPane::Browse()
{
QString dir = QDir::toNativeSeparators(
DolphinFileDialog::getExistingDirectory(this, tr("Select a Directory"), QDir::currentPath()));
if (!dir.isEmpty())
Settings::Instance().AddPath(dir);
}
void PathPane::BrowseDefaultGame()
{
QString file = QDir::toNativeSeparators(DolphinFileDialog::getOpenFileName(
this, tr("Select a Game"), Settings::Instance().GetDefaultGame(),
QStringLiteral("%1 (*.elf *.dol *.gcm *.bin *.iso *.tgc *.wbfs *.ciso *.gcz *.wia *.rvz "
"hif_000000.nfs *.wad *.m3u *.json);;%2 (*)")
.arg(tr("All GC/Wii files"))
.arg(tr("All Files"))));
if (!file.isEmpty())
Settings::Instance().SetDefaultGame(file);
}
void PathPane::BrowseWiiNAND()
{
QString dir = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory(
this, tr("Select Wii NAND Root"), QString::fromStdString(File::GetUserPath(D_WIIROOT_IDX))));
if (!dir.isEmpty())
m_nand_edit->SetTextAndUpdate(dir);
}
void PathPane::BrowseDump()
{
QString dir = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory(
this, tr("Select Dump Path"), QString::fromStdString(File::GetUserPath(D_DUMP_IDX))));
if (!dir.isEmpty())
m_dump_edit->SetTextAndUpdate(dir);
}
void PathPane::BrowseLoad()
{
QString dir = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory(
this, tr("Select Load Path"), QString::fromStdString(File::GetUserPath(D_LOAD_IDX))));
if (!dir.isEmpty())
{
m_load_edit->setText(dir);
Config::SetBase(Config::MAIN_LOAD_PATH, dir.toStdString());
}
}
void PathPane::BrowseResourcePack()
{
QString dir = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory(
this, tr("Select Resource Pack Path"),
QString::fromStdString(File::GetUserPath(D_RESOURCEPACK_IDX))));
if (!dir.isEmpty())
{
m_resource_pack_edit->setText(dir);
Config::SetBase(Config::MAIN_RESOURCEPACK_PATH, dir.toStdString());
}
}
void PathPane::BrowseWFS()
{
const QString dir = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory(
this, tr("Select WFS Path"), QString::fromStdString(File::GetUserPath(D_WFSROOT_IDX))));
if (!dir.isEmpty())
{
m_wfs_edit->setText(dir);
Config::SetBase(Config::MAIN_WFS_PATH, dir.toStdString());
}
}
QGroupBox* PathPane::MakeGameFolderBox()
{
QGroupBox* game_box = new QGroupBox(tr("Game Folders"));
QVBoxLayout* vlayout = new QVBoxLayout;
m_path_list = new QListWidget;
m_path_list->insertItems(0, Settings::Instance().GetPaths());
m_path_list->setSpacing(1);
connect(&Settings::Instance(), &Settings::PathAdded, this,
[this](const QString& dir) { m_path_list->addItem(dir); });
connect(&Settings::Instance(), &Settings::PathRemoved, this, [this](const QString& dir) {
auto items = m_path_list->findItems(dir, Qt::MatchExactly);
for (auto& item : items)
delete item;
});
connect(m_path_list, &QListWidget::itemSelectionChanged, this,
[this] { m_remove_path->setEnabled(m_path_list->selectedItems().count()); });
vlayout->addWidget(m_path_list);
QHBoxLayout* hlayout = new QHBoxLayout;
hlayout->addStretch();
QPushButton* add = new NonDefaultQPushButton(tr("Add..."));
m_remove_path = new NonDefaultQPushButton(tr("Remove"));
m_remove_path->setEnabled(false);
auto* recursive_checkbox =
new ConfigBool(tr("Search Subfolders"), Config::MAIN_RECURSIVE_ISO_PATHS);
auto* auto_checkbox = new QCheckBox(tr("Check for Game List Changes in the Background"));
auto_checkbox->setChecked(Settings::Instance().IsAutoRefreshEnabled());
hlayout->addWidget(add);
hlayout->addWidget(m_remove_path);
vlayout->addLayout(hlayout);
vlayout->addWidget(recursive_checkbox);
vlayout->addWidget(auto_checkbox);
connect(recursive_checkbox, &QCheckBox::toggled,
[](bool checked) { Settings::Instance().RefreshGameList(); });
connect(auto_checkbox, &QCheckBox::toggled, &Settings::Instance(),
&Settings::SetAutoRefreshEnabled);
connect(add, &QPushButton::clicked, this, &PathPane::Browse);
connect(m_remove_path, &QPushButton::clicked, this, &PathPane::RemovePath);
game_box->setLayout(vlayout);
return game_box;
}
QGridLayout* PathPane::MakePathsLayout()
{
QGridLayout* layout = new QGridLayout;
layout->setColumnStretch(1, 1);
m_game_edit = new ConfigText(Config::MAIN_DEFAULT_ISO);
connect(&Settings::Instance(), &Settings::DefaultGameChanged, this,
[this](const QString& path) { m_game_edit->setText(path); });
QPushButton* game_open = new NonDefaultQPushButton(QStringLiteral("..."));
connect(game_open, &QPushButton::clicked, this, &PathPane::BrowseDefaultGame);
layout->addWidget(new QLabel(tr("Default ISO:")), 0, 0);
layout->addWidget(m_game_edit, 0, 1);
layout->addWidget(game_open, 0, 2);
m_nand_edit = new ConfigUserPath(D_WIIROOT_IDX, Config::MAIN_FS_PATH);
QPushButton* nand_open = new NonDefaultQPushButton(QStringLiteral("..."));
connect(nand_open, &QPushButton::clicked, this, &PathPane::BrowseWiiNAND);
layout->addWidget(new QLabel(tr("Wii NAND Root:")), 1, 0);
layout->addWidget(m_nand_edit, 1, 1);
layout->addWidget(nand_open, 1, 2);
m_dump_edit = new ConfigUserPath(D_DUMP_IDX, Config::MAIN_DUMP_PATH);
QPushButton* dump_open = new NonDefaultQPushButton(QStringLiteral("..."));
connect(dump_open, &QPushButton::clicked, this, &PathPane::BrowseDump);
layout->addWidget(new QLabel(tr("Dump Path:")), 2, 0);
layout->addWidget(m_dump_edit, 2, 1);
layout->addWidget(dump_open, 2, 2);
m_load_edit = new ConfigUserPath(D_LOAD_IDX, Config::MAIN_LOAD_PATH);
QPushButton* load_open = new NonDefaultQPushButton(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);
m_resource_pack_edit = new ConfigUserPath(D_RESOURCEPACK_IDX, Config::MAIN_RESOURCEPACK_PATH);
QPushButton* resource_pack_open = new NonDefaultQPushButton(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);
m_wfs_edit = new ConfigUserPath(D_WFSROOT_IDX, Config::MAIN_WFS_PATH);
QPushButton* wfs_open = new NonDefaultQPushButton(QStringLiteral("..."));
connect(wfs_open, &QPushButton::clicked, this, &PathPane::BrowseWFS);
layout->addWidget(new QLabel(tr("WFS Path:")), 5, 0);
layout->addWidget(m_wfs_edit, 5, 1);
layout->addWidget(wfs_open, 5, 2);
return layout;
}
void PathPane::RemovePath()
{
auto item = m_path_list->currentItem();
if (!item)
return;
Settings::Instance().RemovePath(item->text());
}
|