2015-12-31 03:03:13 +00:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <QFileDialog>
|
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>
|
|
|
|
|
2017-06-22 22:11:53 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinQt2/Settings.h"
|
2017-05-31 08:08:04 +00:00
|
|
|
#include "DolphinQt2/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
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
setWindowTitle(tr("Paths"));
|
2015-12-31 03:03:13 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout;
|
|
|
|
layout->addWidget(MakeGameFolderBox());
|
|
|
|
layout->addLayout(MakePathsLayout());
|
2015-12-31 03:03:13 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
setLayout(layout);
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
void PathPane::Browse()
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QString dir =
|
|
|
|
QFileDialog::getExistingDirectory(this, tr("Select a Directory"), QDir::currentPath());
|
|
|
|
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
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QString file = QFileDialog::getOpenFileName(
|
|
|
|
this, tr("Select a Game"), QDir::currentPath(),
|
2016-12-17 13:48:49 +00:00
|
|
|
tr("All GC/Wii files (*.elf *.dol *.gcm *.iso *.tgc *.wbfs *.ciso *.gcz *.wad);;"
|
2016-06-24 08:43:46 +00:00
|
|
|
"All Files (*)"));
|
|
|
|
if (!file.isEmpty())
|
|
|
|
{
|
|
|
|
m_game_edit->setText(file);
|
2017-06-22 22:11:53 +00:00
|
|
|
SConfig::GetInstance().m_strDefaultISO = file.toStdString();
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
void PathPane::BrowseDVDRoot()
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QString dir = QFileDialog::getExistingDirectory(this, tr("Select DVD Root"), QDir::currentPath());
|
|
|
|
if (!dir.isEmpty())
|
|
|
|
{
|
|
|
|
m_dvd_edit->setText(dir);
|
2017-06-22 22:11:53 +00:00
|
|
|
SConfig::GetInstance().m_strDVDRoot = dir.toStdString();
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
void PathPane::BrowseApploader()
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QString file = QFileDialog::getOpenFileName(this, tr("Select an Apploader"), QDir::currentPath(),
|
|
|
|
tr("Apploaders (*.img)"));
|
|
|
|
if (!file.isEmpty())
|
|
|
|
{
|
|
|
|
m_app_edit->setText(file);
|
2017-06-22 22:11:53 +00:00
|
|
|
SConfig::GetInstance().m_strApploader = file.toStdString();
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
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
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QString dir =
|
|
|
|
QFileDialog::getExistingDirectory(this, tr("Select Wii NAND Root"), QDir::currentPath());
|
|
|
|
if (!dir.isEmpty())
|
|
|
|
{
|
|
|
|
m_nand_edit->setText(dir);
|
2017-06-22 22:11:53 +00:00
|
|
|
SConfig::GetInstance().m_NANDPath = dir.toStdString();
|
2016-06-24 08:43:46 +00:00
|
|
|
}
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
QGroupBox* PathPane::MakeGameFolderBox()
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QGroupBox* game_box = new QGroupBox(tr("Game Folders"));
|
|
|
|
game_box->setMinimumSize(QSize(400, 250));
|
|
|
|
QVBoxLayout* vlayout = new QVBoxLayout;
|
2015-12-31 03:03:13 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
m_path_list = new QListWidget;
|
2017-05-31 07:17:39 +00:00
|
|
|
m_path_list->insertItems(0, Settings::Instance().GetPaths());
|
2016-06-24 08:43:46 +00:00
|
|
|
m_path_list->setSpacing(1);
|
2017-05-31 07:42:15 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::PathAdded,
|
|
|
|
[this](const QString& dir) { m_path_list->addItem(dir); });
|
|
|
|
connect(&Settings::Instance(), &Settings::PathRemoved, [this](const QString& dir) {
|
|
|
|
auto items = m_path_list->findItems(dir, Qt::MatchExactly);
|
|
|
|
for (auto& item : items)
|
|
|
|
delete item;
|
|
|
|
});
|
2016-06-24 08:43:46 +00:00
|
|
|
vlayout->addWidget(m_path_list);
|
2015-12-31 03:03:13 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
QHBoxLayout* hlayout = new QHBoxLayout;
|
2015-12-31 03:03:13 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
hlayout->addStretch();
|
|
|
|
QPushButton* add = new QPushButton(tr("Add"));
|
|
|
|
QPushButton* remove = new QPushButton(tr("Remove"));
|
|
|
|
hlayout->addWidget(add);
|
|
|
|
hlayout->addWidget(remove);
|
|
|
|
vlayout->addLayout(hlayout);
|
2015-12-31 03:03:13 +00:00
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
connect(add, &QPushButton::clicked, this, &PathPane::Browse);
|
|
|
|
connect(remove, &QPushButton::clicked, this, &PathPane::RemovePath);
|
2015-12-31 03:03:13 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
game_box->setLayout(vlayout);
|
|
|
|
return game_box;
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
2017-05-31 08:08:04 +00:00
|
|
|
QGridLayout* PathPane::MakePathsLayout()
|
2015-12-31 03:03:13 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
QGridLayout* layout = new QGridLayout;
|
|
|
|
layout->setColumnStretch(1, 1);
|
|
|
|
|
2017-06-22 22:11:53 +00:00
|
|
|
m_game_edit = new QLineEdit(QString::fromStdString(SConfig::GetInstance().m_strDefaultISO));
|
2016-06-24 08:43:46 +00:00
|
|
|
connect(m_game_edit, &QLineEdit::editingFinished,
|
2017-06-22 22:11:53 +00:00
|
|
|
[=] { SConfig::GetInstance().m_strDefaultISO = m_game_edit->text().toStdString(); });
|
2016-06-24 08:43:46 +00:00
|
|
|
QPushButton* game_open = new QPushButton;
|
2017-05-31 08:08:04 +00:00
|
|
|
connect(game_open, &QPushButton::clicked, this, &PathPane::BrowseDefaultGame);
|
2016-06-24 08:43:46 +00:00
|
|
|
layout->addWidget(new QLabel(tr("Default Game")), 0, 0);
|
|
|
|
layout->addWidget(m_game_edit, 0, 1);
|
|
|
|
layout->addWidget(game_open, 0, 2);
|
|
|
|
|
2017-06-22 22:11:53 +00:00
|
|
|
m_dvd_edit = new QLineEdit(QString::fromStdString(SConfig::GetInstance().m_strDVDRoot));
|
2016-06-24 08:43:46 +00:00
|
|
|
connect(m_dvd_edit, &QLineEdit::editingFinished,
|
2017-06-22 22:11:53 +00:00
|
|
|
[=] { SConfig::GetInstance().m_strDVDRoot = m_dvd_edit->text().toStdString(); });
|
2016-06-24 08:43:46 +00:00
|
|
|
QPushButton* dvd_open = new QPushButton;
|
2017-05-31 08:08:04 +00:00
|
|
|
connect(dvd_open, &QPushButton::clicked, this, &PathPane::BrowseDVDRoot);
|
2016-06-24 08:43:46 +00:00
|
|
|
layout->addWidget(new QLabel(tr("DVD Root")), 1, 0);
|
|
|
|
layout->addWidget(m_dvd_edit, 1, 1);
|
|
|
|
layout->addWidget(dvd_open, 1, 2);
|
|
|
|
|
2017-06-22 22:11:53 +00:00
|
|
|
m_app_edit = new QLineEdit(QString::fromStdString(SConfig::GetInstance().m_strApploader));
|
2016-06-24 08:43:46 +00:00
|
|
|
connect(m_app_edit, &QLineEdit::editingFinished,
|
2017-06-22 22:11:53 +00:00
|
|
|
[=] { SConfig::GetInstance().m_strApploader = m_app_edit->text().toStdString(); });
|
2016-06-24 08:43:46 +00:00
|
|
|
QPushButton* app_open = new QPushButton;
|
2017-05-31 08:08:04 +00:00
|
|
|
connect(app_open, &QPushButton::clicked, this, &PathPane::BrowseApploader);
|
2016-06-24 08:43:46 +00:00
|
|
|
layout->addWidget(new QLabel(tr("Apploader")), 2, 0);
|
|
|
|
layout->addWidget(m_app_edit, 2, 1);
|
|
|
|
layout->addWidget(app_open, 2, 2);
|
|
|
|
|
2017-06-22 22:11:53 +00:00
|
|
|
m_nand_edit = new QLineEdit(QString::fromStdString(SConfig::GetInstance().m_NANDPath));
|
2016-06-24 08:43:46 +00:00
|
|
|
connect(m_nand_edit, &QLineEdit::editingFinished,
|
2017-06-22 22:11:53 +00:00
|
|
|
[=] { SConfig::GetInstance().m_NANDPath = m_nand_edit->text().toStdString(); });
|
2016-06-24 08:43:46 +00:00
|
|
|
QPushButton* nand_open = new QPushButton;
|
2017-05-31 08:08:04 +00:00
|
|
|
connect(nand_open, &QPushButton::clicked, this, &PathPane::BrowseWiiNAND);
|
2016-06-24 08:43:46 +00:00
|
|
|
layout->addWidget(new QLabel(tr("Wii NAND Root")), 3, 0);
|
|
|
|
layout->addWidget(m_nand_edit, 3, 1);
|
|
|
|
layout->addWidget(nand_open, 3, 2);
|
|
|
|
|
|
|
|
return layout;
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|
|
|
|
|
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)
|
2016-06-24 08:43:46 +00:00
|
|
|
return;
|
2017-05-31 07:42:15 +00:00
|
|
|
Settings::Instance().RemovePath(item->text());
|
2015-12-31 03:03:13 +00:00
|
|
|
}
|