mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Reformat all the things. Have fun with merge conflicts.
This commit is contained in:
@ -10,59 +10,67 @@
|
||||
#include "DolphinQt2/AboutDialog.h"
|
||||
#include "DolphinQt2/Resources.h"
|
||||
|
||||
AboutDialog::AboutDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent)
|
||||
{
|
||||
setWindowTitle(tr("About Dolphin"));
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setWindowTitle(tr("About Dolphin"));
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
QString text = QStringLiteral("");
|
||||
QString small = QStringLiteral("<p style='margin-top:0px; margin-bottom:0px; font-size:9pt;'>");
|
||||
QString medium = QStringLiteral("<p style='margin-top:15px; font-size:11pt;'>");
|
||||
QString text = QStringLiteral("");
|
||||
QString small = QStringLiteral("<p style='margin-top:0px; margin-bottom:0px; font-size:9pt;'>");
|
||||
QString medium = QStringLiteral("<p style='margin-top:15px; font-size:11pt;'>");
|
||||
|
||||
text.append(QStringLiteral("<p style='font-size:50pt; font-weight:400; margin-bottom:0px;'>") +
|
||||
tr("Dolphin") + QStringLiteral("</p>"));
|
||||
text.append(QStringLiteral("<p style='font-size:18pt; margin-top:0px;'>%1</p>")
|
||||
.arg(QString::fromUtf8(scm_desc_str.c_str())));
|
||||
text.append(QStringLiteral("<p style='font-size:50pt; font-weight:400; margin-bottom:0px;'>") +
|
||||
tr("Dolphin") + QStringLiteral("</p>"));
|
||||
text.append(QStringLiteral("<p style='font-size:18pt; margin-top:0px;'>%1</p>")
|
||||
.arg(QString::fromUtf8(scm_desc_str.c_str())));
|
||||
|
||||
text.append(small + tr("Branch: ") + QString::fromUtf8(scm_branch_str.c_str()) + QStringLiteral("</p>"));
|
||||
text.append(small + tr("Revision: ") + QString::fromUtf8(scm_rev_git_str.c_str()) + QStringLiteral("</p>"));
|
||||
text.append(small + tr("Compiled: ") + QStringLiteral(__DATE__ " " __TIME__ "</p>"));
|
||||
text.append(small + tr("Branch: ") + QString::fromUtf8(scm_branch_str.c_str()) +
|
||||
QStringLiteral("</p>"));
|
||||
text.append(small + tr("Revision: ") + QString::fromUtf8(scm_rev_git_str.c_str()) +
|
||||
QStringLiteral("</p>"));
|
||||
text.append(small + tr("Compiled: ") + QStringLiteral(__DATE__ " " __TIME__ "</p>"));
|
||||
|
||||
text.append(medium + tr("Check for updates: ") +
|
||||
QStringLiteral("<a href='https://dolphin-emu.org/download'>dolphin-emu.org/download</a></p>"));
|
||||
text.append(medium + tr("Dolphin is a free and open-source GameCube and Wii emulator.") + QStringLiteral("</p>"));
|
||||
text.append(medium + tr("This software should not be used to play games you do not legally own.") + QStringLiteral("</p>"));
|
||||
text.append(medium + QStringLiteral(
|
||||
"<a href='https://github.com/dolphin-emu/dolphin/blob/master/license.txt'>%1</a> | "
|
||||
"<a href='https://github.com/dolphin-emu/dolphin/graphs/contributors'>%2</a> | "
|
||||
"<a href='https://forums.dolphin-emu.org/'>%3</a></p>"
|
||||
).arg(tr("Licence")).arg(tr("Authors")).arg(tr("Support")));
|
||||
text.append(medium + tr("Check for updates: ") +
|
||||
QStringLiteral(
|
||||
"<a href='https://dolphin-emu.org/download'>dolphin-emu.org/download</a></p>"));
|
||||
text.append(medium + tr("Dolphin is a free and open-source GameCube and Wii emulator.") +
|
||||
QStringLiteral("</p>"));
|
||||
text.append(medium +
|
||||
tr("This software should not be used to play games you do not legally own.") +
|
||||
QStringLiteral("</p>"));
|
||||
text.append(
|
||||
medium +
|
||||
QStringLiteral(
|
||||
"<a href='https://github.com/dolphin-emu/dolphin/blob/master/license.txt'>%1</a> | "
|
||||
"<a href='https://github.com/dolphin-emu/dolphin/graphs/contributors'>%2</a> | "
|
||||
"<a href='https://forums.dolphin-emu.org/'>%3</a></p>")
|
||||
.arg(tr("Licence"))
|
||||
.arg(tr("Authors"))
|
||||
.arg(tr("Support")));
|
||||
|
||||
QLabel* text_label = new QLabel(text);
|
||||
text_label->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
text_label->setOpenExternalLinks(true);
|
||||
QLabel* text_label = new QLabel(text);
|
||||
text_label->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
text_label->setOpenExternalLinks(true);
|
||||
|
||||
QLabel* copyright = new QLabel(tr(
|
||||
"© 2003-%1 Dolphin Team. “GameCube” and “Wii” are"
|
||||
" trademarks of Nintendo. Dolphin is not affiliated with Nintendo in any way."
|
||||
).arg(QStringLiteral(__DATE__).right(4)));
|
||||
QLabel* copyright =
|
||||
new QLabel(tr("© 2003-%1 Dolphin Team. “GameCube” and “Wii” are"
|
||||
" trademarks of Nintendo. Dolphin is not affiliated with Nintendo in any way.")
|
||||
.arg(QStringLiteral(__DATE__).right(4)));
|
||||
|
||||
QLabel* logo = new QLabel();
|
||||
logo->setPixmap(Resources::GetMisc(Resources::LOGO_LARGE));
|
||||
logo->setContentsMargins(30, 0, 30, 0);
|
||||
QLabel* logo = new QLabel();
|
||||
logo->setPixmap(Resources::GetMisc(Resources::LOGO_LARGE));
|
||||
logo->setContentsMargins(30, 0, 30, 0);
|
||||
|
||||
QVBoxLayout* main_layout = new QVBoxLayout;
|
||||
QHBoxLayout* h_layout = new QHBoxLayout;
|
||||
QVBoxLayout* main_layout = new QVBoxLayout;
|
||||
QHBoxLayout* h_layout = new QHBoxLayout;
|
||||
|
||||
setLayout(main_layout);
|
||||
main_layout->addLayout(h_layout);
|
||||
main_layout->addWidget(copyright);
|
||||
copyright->setAlignment(Qt::AlignCenter);
|
||||
copyright->setContentsMargins(0, 15, 0, 0);
|
||||
setLayout(main_layout);
|
||||
main_layout->addLayout(h_layout);
|
||||
main_layout->addWidget(copyright);
|
||||
copyright->setAlignment(Qt::AlignCenter);
|
||||
copyright->setContentsMargins(0, 15, 0, 0);
|
||||
|
||||
h_layout->setAlignment(Qt::AlignLeft);
|
||||
h_layout->addWidget(logo);
|
||||
h_layout->addWidget(text_label);
|
||||
h_layout->setAlignment(Qt::AlignLeft);
|
||||
h_layout->addWidget(logo);
|
||||
h_layout->addWidget(text_label);
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
class AboutDialog final : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AboutDialog(QWidget* parent = nullptr);
|
||||
explicit AboutDialog(QWidget* parent = nullptr);
|
||||
};
|
||||
|
||||
|
@ -14,171 +14,163 @@
|
||||
#include <QSize>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "DolphinQt2/Config/PathDialog.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
|
||||
PathDialog::PathDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
PathDialog::PathDialog(QWidget* parent) : QDialog(parent)
|
||||
{
|
||||
setWindowTitle(tr("Paths"));
|
||||
setWindowTitle(tr("Paths"));
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout;
|
||||
layout->addWidget(MakeGameFolderBox());
|
||||
layout->addLayout(MakePathsLayout());
|
||||
QVBoxLayout* layout = new QVBoxLayout;
|
||||
layout->addWidget(MakeGameFolderBox());
|
||||
layout->addLayout(MakePathsLayout());
|
||||
|
||||
QDialogButtonBox* ok_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
connect(ok_box, &QDialogButtonBox::accepted, this, &PathDialog::accept);
|
||||
layout->addWidget(ok_box);
|
||||
QDialogButtonBox* ok_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
connect(ok_box, &QDialogButtonBox::accepted, this, &PathDialog::accept);
|
||||
layout->addWidget(ok_box);
|
||||
|
||||
setLayout(layout);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void PathDialog::Browse()
|
||||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(this,
|
||||
tr("Select a Directory"),
|
||||
QDir::currentPath());
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
Settings settings;
|
||||
QStringList game_folders = settings.GetPaths();
|
||||
if (!game_folders.contains(dir))
|
||||
{
|
||||
game_folders << dir;
|
||||
settings.SetPaths(game_folders);
|
||||
m_path_list->addItem(dir);
|
||||
emit PathAdded(dir);
|
||||
}
|
||||
}
|
||||
QString dir =
|
||||
QFileDialog::getExistingDirectory(this, tr("Select a Directory"), QDir::currentPath());
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
Settings settings;
|
||||
QStringList game_folders = settings.GetPaths();
|
||||
if (!game_folders.contains(dir))
|
||||
{
|
||||
game_folders << dir;
|
||||
settings.SetPaths(game_folders);
|
||||
m_path_list->addItem(dir);
|
||||
emit PathAdded(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PathDialog::BrowseDefaultGame()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this,
|
||||
tr("Select a Game"),
|
||||
QDir::currentPath(),
|
||||
tr("All GC/Wii files (*.elf *.dol *.gcm *.iso *.wbfs *.ciso *.gcz *.wad);;"
|
||||
"All Files (*)"));
|
||||
if (!file.isEmpty())
|
||||
{
|
||||
m_game_edit->setText(file);
|
||||
Settings().SetDefaultGame(file);
|
||||
}
|
||||
QString file = QFileDialog::getOpenFileName(
|
||||
this, tr("Select a Game"), QDir::currentPath(),
|
||||
tr("All GC/Wii files (*.elf *.dol *.gcm *.iso *.wbfs *.ciso *.gcz *.wad);;"
|
||||
"All Files (*)"));
|
||||
if (!file.isEmpty())
|
||||
{
|
||||
m_game_edit->setText(file);
|
||||
Settings().SetDefaultGame(file);
|
||||
}
|
||||
}
|
||||
|
||||
void PathDialog::BrowseDVDRoot()
|
||||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(this,
|
||||
tr("Select DVD Root"),
|
||||
QDir::currentPath());
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
m_dvd_edit->setText(dir);
|
||||
Settings().SetDVDRoot(dir);
|
||||
}
|
||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Select DVD Root"), QDir::currentPath());
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
m_dvd_edit->setText(dir);
|
||||
Settings().SetDVDRoot(dir);
|
||||
}
|
||||
}
|
||||
|
||||
void PathDialog::BrowseApploader()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this,
|
||||
tr("Select an Apploader"),
|
||||
QDir::currentPath(),
|
||||
tr("Apploaders (*.img)"));
|
||||
if (!file.isEmpty())
|
||||
{
|
||||
m_app_edit->setText(file);
|
||||
Settings().SetApploader(file);
|
||||
}
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Select an Apploader"), QDir::currentPath(),
|
||||
tr("Apploaders (*.img)"));
|
||||
if (!file.isEmpty())
|
||||
{
|
||||
m_app_edit->setText(file);
|
||||
Settings().SetApploader(file);
|
||||
}
|
||||
}
|
||||
|
||||
void PathDialog::BrowseWiiNAND()
|
||||
{
|
||||
QString dir = QFileDialog::getExistingDirectory(this,
|
||||
tr("Select Wii NAND Root"),
|
||||
QDir::currentPath());
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
m_nand_edit->setText(dir);
|
||||
Settings().SetWiiNAND(dir);
|
||||
}
|
||||
QString dir =
|
||||
QFileDialog::getExistingDirectory(this, tr("Select Wii NAND Root"), QDir::currentPath());
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
m_nand_edit->setText(dir);
|
||||
Settings().SetWiiNAND(dir);
|
||||
}
|
||||
}
|
||||
|
||||
QGroupBox* PathDialog::MakeGameFolderBox()
|
||||
{
|
||||
QGroupBox* game_box = new QGroupBox(tr("Game Folders"));
|
||||
game_box->setMinimumSize(QSize(400, 250));
|
||||
QVBoxLayout* vlayout = new QVBoxLayout;
|
||||
QGroupBox* game_box = new QGroupBox(tr("Game Folders"));
|
||||
game_box->setMinimumSize(QSize(400, 250));
|
||||
QVBoxLayout* vlayout = new QVBoxLayout;
|
||||
|
||||
m_path_list = new QListWidget;
|
||||
m_path_list->insertItems(0, Settings().GetPaths());
|
||||
m_path_list->setSpacing(1);
|
||||
vlayout->addWidget(m_path_list);
|
||||
m_path_list = new QListWidget;
|
||||
m_path_list->insertItems(0, Settings().GetPaths());
|
||||
m_path_list->setSpacing(1);
|
||||
vlayout->addWidget(m_path_list);
|
||||
|
||||
QHBoxLayout* hlayout = new QHBoxLayout;
|
||||
QHBoxLayout* hlayout = new QHBoxLayout;
|
||||
|
||||
hlayout->addStretch();
|
||||
QPushButton* add = new QPushButton(tr("Add"));
|
||||
QPushButton* remove = new QPushButton(tr("Remove"));
|
||||
hlayout->addWidget(add);
|
||||
hlayout->addWidget(remove);
|
||||
vlayout->addLayout(hlayout);
|
||||
hlayout->addStretch();
|
||||
QPushButton* add = new QPushButton(tr("Add"));
|
||||
QPushButton* remove = new QPushButton(tr("Remove"));
|
||||
hlayout->addWidget(add);
|
||||
hlayout->addWidget(remove);
|
||||
vlayout->addLayout(hlayout);
|
||||
|
||||
connect(add, &QPushButton::clicked, this, &PathDialog::Browse);
|
||||
connect(remove, &QPushButton::clicked, this, &PathDialog::RemovePath);
|
||||
connect(add, &QPushButton::clicked, this, &PathDialog::Browse);
|
||||
connect(remove, &QPushButton::clicked, this, &PathDialog::RemovePath);
|
||||
|
||||
game_box->setLayout(vlayout);
|
||||
return game_box;
|
||||
game_box->setLayout(vlayout);
|
||||
return game_box;
|
||||
}
|
||||
|
||||
QGridLayout* PathDialog::MakePathsLayout()
|
||||
{
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
layout->setColumnStretch(1, 1);
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
layout->setColumnStretch(1, 1);
|
||||
|
||||
m_game_edit = new QLineEdit(Settings().GetDefaultGame());
|
||||
connect(m_game_edit, &QLineEdit::editingFinished,
|
||||
[=]{ Settings().SetDefaultGame(m_game_edit->text()); });
|
||||
QPushButton* game_open = new QPushButton;
|
||||
connect(game_open, &QPushButton::clicked, this, &PathDialog::BrowseDefaultGame);
|
||||
layout->addWidget(new QLabel(tr("Default Game")), 0, 0);
|
||||
layout->addWidget(m_game_edit, 0, 1);
|
||||
layout->addWidget(game_open, 0, 2);
|
||||
m_game_edit = new QLineEdit(Settings().GetDefaultGame());
|
||||
connect(m_game_edit, &QLineEdit::editingFinished,
|
||||
[=] { Settings().SetDefaultGame(m_game_edit->text()); });
|
||||
QPushButton* game_open = new QPushButton;
|
||||
connect(game_open, &QPushButton::clicked, this, &PathDialog::BrowseDefaultGame);
|
||||
layout->addWidget(new QLabel(tr("Default Game")), 0, 0);
|
||||
layout->addWidget(m_game_edit, 0, 1);
|
||||
layout->addWidget(game_open, 0, 2);
|
||||
|
||||
m_dvd_edit = new QLineEdit(Settings().GetDVDRoot());
|
||||
connect(m_dvd_edit, &QLineEdit::editingFinished,
|
||||
[=]{ Settings().SetDVDRoot(m_dvd_edit->text()); });
|
||||
QPushButton* dvd_open = new QPushButton;
|
||||
connect(dvd_open, &QPushButton::clicked, this, &PathDialog::BrowseDVDRoot);
|
||||
layout->addWidget(new QLabel(tr("DVD Root")), 1, 0);
|
||||
layout->addWidget(m_dvd_edit, 1, 1);
|
||||
layout->addWidget(dvd_open, 1, 2);
|
||||
m_dvd_edit = new QLineEdit(Settings().GetDVDRoot());
|
||||
connect(m_dvd_edit, &QLineEdit::editingFinished,
|
||||
[=] { Settings().SetDVDRoot(m_dvd_edit->text()); });
|
||||
QPushButton* dvd_open = new QPushButton;
|
||||
connect(dvd_open, &QPushButton::clicked, this, &PathDialog::BrowseDVDRoot);
|
||||
layout->addWidget(new QLabel(tr("DVD Root")), 1, 0);
|
||||
layout->addWidget(m_dvd_edit, 1, 1);
|
||||
layout->addWidget(dvd_open, 1, 2);
|
||||
|
||||
m_app_edit = new QLineEdit(Settings().GetApploader());
|
||||
connect(m_app_edit, &QLineEdit::editingFinished,
|
||||
[=]{ Settings().SetApploader(m_app_edit->text()); });
|
||||
QPushButton* app_open = new QPushButton;
|
||||
connect(app_open, &QPushButton::clicked, this, &PathDialog::BrowseApploader);
|
||||
layout->addWidget(new QLabel(tr("Apploader")), 2, 0);
|
||||
layout->addWidget(m_app_edit, 2, 1);
|
||||
layout->addWidget(app_open, 2, 2);
|
||||
m_app_edit = new QLineEdit(Settings().GetApploader());
|
||||
connect(m_app_edit, &QLineEdit::editingFinished,
|
||||
[=] { Settings().SetApploader(m_app_edit->text()); });
|
||||
QPushButton* app_open = new QPushButton;
|
||||
connect(app_open, &QPushButton::clicked, this, &PathDialog::BrowseApploader);
|
||||
layout->addWidget(new QLabel(tr("Apploader")), 2, 0);
|
||||
layout->addWidget(m_app_edit, 2, 1);
|
||||
layout->addWidget(app_open, 2, 2);
|
||||
|
||||
m_nand_edit = new QLineEdit(Settings().GetWiiNAND());
|
||||
connect(m_nand_edit, &QLineEdit::editingFinished,
|
||||
[=]{ Settings().SetWiiNAND(m_nand_edit->text()); });
|
||||
QPushButton* nand_open = new QPushButton;
|
||||
connect(nand_open, &QPushButton::clicked, this, &PathDialog::BrowseWiiNAND);
|
||||
layout->addWidget(new QLabel(tr("Wii NAND Root")), 3, 0);
|
||||
layout->addWidget(m_nand_edit, 3, 1);
|
||||
layout->addWidget(nand_open, 3, 2);
|
||||
m_nand_edit = new QLineEdit(Settings().GetWiiNAND());
|
||||
connect(m_nand_edit, &QLineEdit::editingFinished,
|
||||
[=] { Settings().SetWiiNAND(m_nand_edit->text()); });
|
||||
QPushButton* nand_open = new QPushButton;
|
||||
connect(nand_open, &QPushButton::clicked, this, &PathDialog::BrowseWiiNAND);
|
||||
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;
|
||||
return layout;
|
||||
}
|
||||
|
||||
void PathDialog::RemovePath()
|
||||
{
|
||||
int row = m_path_list->currentRow();
|
||||
if (row < 0)
|
||||
return;
|
||||
emit PathRemoved(m_path_list->takeItem(row)->text());
|
||||
Settings().RemovePath(row);
|
||||
int row = m_path_list->currentRow();
|
||||
if (row < 0)
|
||||
return;
|
||||
emit PathRemoved(m_path_list->takeItem(row)->text());
|
||||
Settings().RemovePath(row);
|
||||
}
|
||||
|
@ -12,29 +12,29 @@
|
||||
|
||||
class PathDialog final : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PathDialog(QWidget* parent = nullptr);
|
||||
explicit PathDialog(QWidget* parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void Browse();
|
||||
void BrowseDefaultGame();
|
||||
void BrowseDVDRoot();
|
||||
void BrowseApploader();
|
||||
void BrowseWiiNAND();
|
||||
void Browse();
|
||||
void BrowseDefaultGame();
|
||||
void BrowseDVDRoot();
|
||||
void BrowseApploader();
|
||||
void BrowseWiiNAND();
|
||||
|
||||
signals:
|
||||
void PathAdded(QString path);
|
||||
void PathRemoved(QString path);
|
||||
void PathAdded(QString path);
|
||||
void PathRemoved(QString path);
|
||||
|
||||
private:
|
||||
QGroupBox* MakeGameFolderBox();
|
||||
QGridLayout* MakePathsLayout();
|
||||
void RemovePath();
|
||||
QGroupBox* MakeGameFolderBox();
|
||||
QGridLayout* MakePathsLayout();
|
||||
void RemovePath();
|
||||
|
||||
QListWidget* m_path_list;
|
||||
QLineEdit* m_game_edit;
|
||||
QLineEdit* m_dvd_edit;
|
||||
QLineEdit* m_app_edit;
|
||||
QLineEdit* m_nand_edit;
|
||||
QListWidget* m_path_list;
|
||||
QLineEdit* m_game_edit;
|
||||
QLineEdit* m_dvd_edit;
|
||||
QLineEdit* m_app_edit;
|
||||
QLineEdit* m_nand_edit;
|
||||
};
|
||||
|
@ -5,89 +5,87 @@
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "DolphinQt2/Config/SettingsWindow.h"
|
||||
|
||||
SettingsWindow::SettingsWindow(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
SettingsWindow::SettingsWindow(QWidget* parent) : QDialog(parent)
|
||||
{
|
||||
// Set Window Properties
|
||||
setWindowTitle(tr("Settings"));
|
||||
resize(720, 600);
|
||||
// Set Window Properties
|
||||
setWindowTitle(tr("Settings"));
|
||||
resize(720, 600);
|
||||
|
||||
// Main Layout
|
||||
QVBoxLayout* layout = new QVBoxLayout;
|
||||
QHBoxLayout* content = new QHBoxLayout;
|
||||
QVBoxLayout* content_inner = new QVBoxLayout;
|
||||
// Content's widgets
|
||||
{
|
||||
// Category list
|
||||
MakeCategoryList();
|
||||
content->addWidget(m_categories);
|
||||
// Main Layout
|
||||
QVBoxLayout* layout = new QVBoxLayout;
|
||||
QHBoxLayout* content = new QHBoxLayout;
|
||||
QVBoxLayout* content_inner = new QVBoxLayout;
|
||||
// Content's widgets
|
||||
{
|
||||
// Category list
|
||||
MakeCategoryList();
|
||||
content->addWidget(m_categories);
|
||||
|
||||
// Actual Settings UI
|
||||
SetupSettingsWidget();
|
||||
// Actual Settings UI
|
||||
SetupSettingsWidget();
|
||||
|
||||
MakeUnfinishedWarning();
|
||||
MakeUnfinishedWarning();
|
||||
|
||||
content_inner->addWidget(m_warning_group);
|
||||
content_inner->addWidget(m_settings_outer);
|
||||
content_inner->addWidget(m_warning_group);
|
||||
content_inner->addWidget(m_settings_outer);
|
||||
|
||||
content->addLayout(content_inner);
|
||||
}
|
||||
content->addLayout(content_inner);
|
||||
}
|
||||
|
||||
// Add content to layout before dialog buttons.
|
||||
layout->addLayout(content);
|
||||
// Add content to layout before dialog buttons.
|
||||
layout->addLayout(content);
|
||||
|
||||
// Dialog box buttons
|
||||
QDialogButtonBox* ok_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
connect(ok_box, &QDialogButtonBox::accepted, this, &SettingsWindow::accept);
|
||||
layout->addWidget(ok_box);
|
||||
// Dialog box buttons
|
||||
QDialogButtonBox* ok_box = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
connect(ok_box, &QDialogButtonBox::accepted, this, &SettingsWindow::accept);
|
||||
layout->addWidget(ok_box);
|
||||
|
||||
setLayout(layout);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void SettingsWindow::SetupSettingsWidget()
|
||||
{
|
||||
m_settings_outer = new QStackedWidget;
|
||||
m_settings_outer->setCurrentIndex(0);
|
||||
m_settings_outer = new QStackedWidget;
|
||||
m_settings_outer->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void SettingsWindow::MakeUnfinishedWarning()
|
||||
{
|
||||
m_warning_group = new QGroupBox(tr("Warning"));
|
||||
QHBoxLayout* m_warning_group_layout = new QHBoxLayout;
|
||||
QLabel* warning_text = new QLabel(
|
||||
tr("Some categories and settings will not work.\n"
|
||||
"This Settings Window is under active development."));
|
||||
m_warning_group_layout->addWidget(warning_text);
|
||||
m_warning_group->setLayout(m_warning_group_layout);
|
||||
m_warning_group = new QGroupBox(tr("Warning"));
|
||||
QHBoxLayout* m_warning_group_layout = new QHBoxLayout;
|
||||
QLabel* warning_text = new QLabel(tr("Some categories and settings will not work.\n"
|
||||
"This Settings Window is under active development."));
|
||||
m_warning_group_layout->addWidget(warning_text);
|
||||
m_warning_group->setLayout(m_warning_group_layout);
|
||||
}
|
||||
|
||||
void SettingsWindow::AddCategoryToList(const QString& title, const QString& icon)
|
||||
{
|
||||
QListWidgetItem* button = new QListWidgetItem();
|
||||
button->setIcon(QIcon(icon));
|
||||
button->setText(title);
|
||||
button->setTextAlignment(Qt::AlignVCenter);
|
||||
button->setSizeHint(QSize(28, 28));
|
||||
button->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
m_categories->addItem(button);
|
||||
QListWidgetItem* button = new QListWidgetItem();
|
||||
button->setIcon(QIcon(icon));
|
||||
button->setText(title);
|
||||
button->setTextAlignment(Qt::AlignVCenter);
|
||||
button->setSizeHint(QSize(28, 28));
|
||||
button->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
m_categories->addItem(button);
|
||||
}
|
||||
|
||||
void SettingsWindow::MakeCategoryList()
|
||||
{
|
||||
QString dir = Settings().GetThemeDir();
|
||||
QString dir = Settings().GetThemeDir();
|
||||
|
||||
m_categories = new QListWidget;
|
||||
m_categories->setMaximumWidth(175);
|
||||
m_categories->setIconSize(QSize(32, 32));
|
||||
m_categories->setMovement(QListView::Static);
|
||||
m_categories->setSpacing(0);
|
||||
m_categories = new QListWidget;
|
||||
m_categories->setMaximumWidth(175);
|
||||
m_categories->setIconSize(QSize(32, 32));
|
||||
m_categories->setMovement(QListView::Static);
|
||||
m_categories->setSpacing(0);
|
||||
|
||||
connect(m_categories, &QListWidget::currentItemChanged, this, &SettingsWindow::changePage);
|
||||
connect(m_categories, &QListWidget::currentItemChanged, this, &SettingsWindow::changePage);
|
||||
}
|
||||
|
||||
void SettingsWindow::changePage(QListWidgetItem* current, QListWidgetItem* previous)
|
||||
{
|
||||
if (!current)
|
||||
current = previous;
|
||||
m_settings_outer->setCurrentIndex(m_categories->row(current));
|
||||
if (!current)
|
||||
current = previous;
|
||||
m_settings_outer->setCurrentIndex(m_categories->row(current));
|
||||
}
|
||||
|
@ -19,19 +19,19 @@
|
||||
|
||||
class SettingsWindow final : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SettingsWindow(QWidget* parent = nullptr);
|
||||
explicit SettingsWindow(QWidget* parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void changePage(QListWidgetItem* current, QListWidgetItem* previous);
|
||||
void changePage(QListWidgetItem* current, QListWidgetItem* previous);
|
||||
|
||||
private:
|
||||
void MakeCategoryList();
|
||||
void MakeUnfinishedWarning();
|
||||
void AddCategoryToList(const QString& title, const QString& icon);
|
||||
void SetupSettingsWidget();
|
||||
QStackedWidget* m_settings_outer;
|
||||
QListWidget* m_categories;
|
||||
QGroupBox* m_warning_group;
|
||||
void MakeCategoryList();
|
||||
void MakeUnfinishedWarning();
|
||||
void AddCategoryToList(const QString& title, const QString& icon);
|
||||
void SetupSettingsWidget();
|
||||
QStackedWidget* m_settings_outer;
|
||||
QListWidget* m_categories;
|
||||
QGroupBox* m_warning_group;
|
||||
};
|
||||
|
@ -13,193 +13,190 @@
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "DiscIO/VolumeCreator.h"
|
||||
#include "DolphinQt2/GameList/GameFile.h"
|
||||
#include "DolphinQt2/Resources.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "DolphinQt2/GameList/GameFile.h"
|
||||
|
||||
static const int CACHE_VERSION = 13; // Last changed in PR #3261
|
||||
static const int CACHE_VERSION = 13; // Last changed in PR #3261
|
||||
static const int DATASTREAM_VERSION = QDataStream::Qt_5_5;
|
||||
|
||||
static QMap<DiscIO::IVolume::ELanguage, QString> ConvertLanguageMap(
|
||||
const std::map<DiscIO::IVolume::ELanguage, std::string>& map)
|
||||
static QMap<DiscIO::IVolume::ELanguage, QString>
|
||||
ConvertLanguageMap(const std::map<DiscIO::IVolume::ELanguage, std::string>& map)
|
||||
{
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> result;
|
||||
for (auto entry : map)
|
||||
result.insert(entry.first, QString::fromStdString(entry.second).trimmed());
|
||||
return result;
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> result;
|
||||
for (auto entry : map)
|
||||
result.insert(entry.first, QString::fromStdString(entry.second).trimmed());
|
||||
return result;
|
||||
}
|
||||
|
||||
GameFile::GameFile(const QString& path) : m_path(path)
|
||||
{
|
||||
m_valid = false;
|
||||
m_valid = false;
|
||||
|
||||
if (!LoadFileInfo(path))
|
||||
return;
|
||||
if (!LoadFileInfo(path))
|
||||
return;
|
||||
|
||||
if (!TryLoadCache())
|
||||
{
|
||||
if (TryLoadVolume())
|
||||
{
|
||||
LoadState();
|
||||
}
|
||||
else if (!TryLoadElfDol())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!TryLoadCache())
|
||||
{
|
||||
if (TryLoadVolume())
|
||||
{
|
||||
LoadState();
|
||||
}
|
||||
else if (!TryLoadElfDol())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_valid = true;
|
||||
m_valid = true;
|
||||
}
|
||||
|
||||
QString GameFile::GetCacheFileName() const
|
||||
{
|
||||
QString folder = QString::fromStdString(File::GetUserPath(D_CACHE_IDX));
|
||||
// Append a hash of the full path to prevent name clashes between
|
||||
// files with the same names in different folders.
|
||||
QString hash = QString::fromUtf8(
|
||||
QCryptographicHash::hash(m_path.toUtf8(),
|
||||
QCryptographicHash::Md5).toHex());
|
||||
return folder + m_file_name + hash;
|
||||
QString folder = QString::fromStdString(File::GetUserPath(D_CACHE_IDX));
|
||||
// Append a hash of the full path to prevent name clashes between
|
||||
// files with the same names in different folders.
|
||||
QString hash =
|
||||
QString::fromUtf8(QCryptographicHash::hash(m_path.toUtf8(), QCryptographicHash::Md5).toHex());
|
||||
return folder + m_file_name + hash;
|
||||
}
|
||||
|
||||
void GameFile::ReadBanner(const DiscIO::IVolume& volume)
|
||||
{
|
||||
int width, height;
|
||||
std::vector<u32> buffer = volume.GetBanner(&width, &height);
|
||||
QImage banner(width, height, QImage::Format_RGB888);
|
||||
for (int i = 0; i < width * height; i++)
|
||||
{
|
||||
int x = i % width, y = i / width;
|
||||
banner.setPixel(x, y, qRgb((buffer[i] & 0xFF0000) >> 16,
|
||||
(buffer[i] & 0x00FF00) >> 8,
|
||||
(buffer[i] & 0x0000FF) >> 0));
|
||||
}
|
||||
int width, height;
|
||||
std::vector<u32> buffer = volume.GetBanner(&width, &height);
|
||||
QImage banner(width, height, QImage::Format_RGB888);
|
||||
for (int i = 0; i < width * height; i++)
|
||||
{
|
||||
int x = i % width, y = i / width;
|
||||
banner.setPixel(x, y, qRgb((buffer[i] & 0xFF0000) >> 16, (buffer[i] & 0x00FF00) >> 8,
|
||||
(buffer[i] & 0x0000FF) >> 0));
|
||||
}
|
||||
|
||||
if (!banner.isNull())
|
||||
m_banner = QPixmap::fromImage(banner);
|
||||
else
|
||||
m_banner = Resources::GetMisc(Resources::BANNER_MISSING);
|
||||
if (!banner.isNull())
|
||||
m_banner = QPixmap::fromImage(banner);
|
||||
else
|
||||
m_banner = Resources::GetMisc(Resources::BANNER_MISSING);
|
||||
}
|
||||
|
||||
bool GameFile::LoadFileInfo(const QString& path)
|
||||
{
|
||||
QFileInfo info(path);
|
||||
if (!info.exists() || !info.isReadable())
|
||||
return false;
|
||||
QFileInfo info(path);
|
||||
if (!info.exists() || !info.isReadable())
|
||||
return false;
|
||||
|
||||
m_file_name = info.fileName();
|
||||
m_extension = info.suffix();
|
||||
m_folder = info.dir().dirName();
|
||||
m_last_modified = info.lastModified();
|
||||
m_size = info.size();
|
||||
m_file_name = info.fileName();
|
||||
m_extension = info.suffix();
|
||||
m_folder = info.dir().dirName();
|
||||
m_last_modified = info.lastModified();
|
||||
m_size = info.size();
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GameFile::LoadState()
|
||||
{
|
||||
IniFile ini = SConfig::LoadGameIni(m_unique_id.toStdString(), m_revision);
|
||||
std::string issues_temp;
|
||||
ini.GetIfExists("EmuState", "EmulationStateId", &m_rating);
|
||||
ini.GetIfExists("EmuState", "EmulationIssues", &issues_temp);
|
||||
m_issues = QString::fromStdString(issues_temp);
|
||||
IniFile ini = SConfig::LoadGameIni(m_unique_id.toStdString(), m_revision);
|
||||
std::string issues_temp;
|
||||
ini.GetIfExists("EmuState", "EmulationStateId", &m_rating);
|
||||
ini.GetIfExists("EmuState", "EmulationIssues", &issues_temp);
|
||||
m_issues = QString::fromStdString(issues_temp);
|
||||
}
|
||||
|
||||
bool GameFile::IsElfOrDol()
|
||||
{
|
||||
return m_extension == QStringLiteral("elf") ||
|
||||
m_extension == QStringLiteral("dol");
|
||||
return m_extension == QStringLiteral("elf") || m_extension == QStringLiteral("dol");
|
||||
}
|
||||
|
||||
bool GameFile::TryLoadCache()
|
||||
{
|
||||
QFile cache(GetCacheFileName());
|
||||
if (!cache.exists())
|
||||
return false;
|
||||
if (!cache.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
if (QFileInfo(cache).lastModified() < m_last_modified)
|
||||
return false;
|
||||
QFile cache(GetCacheFileName());
|
||||
if (!cache.exists())
|
||||
return false;
|
||||
if (!cache.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
if (QFileInfo(cache).lastModified() < m_last_modified)
|
||||
return false;
|
||||
|
||||
QDataStream in(&cache);
|
||||
in.setVersion(DATASTREAM_VERSION);
|
||||
QDataStream in(&cache);
|
||||
in.setVersion(DATASTREAM_VERSION);
|
||||
|
||||
int cache_version;
|
||||
in >> cache_version;
|
||||
if (cache_version != CACHE_VERSION)
|
||||
return false;
|
||||
int cache_version;
|
||||
in >> cache_version;
|
||||
if (cache_version != CACHE_VERSION)
|
||||
return false;
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GameFile::TryLoadVolume()
|
||||
{
|
||||
QSharedPointer<DiscIO::IVolume> volume(
|
||||
DiscIO::CreateVolumeFromFilename(m_path.toStdString()).release());
|
||||
if (volume == nullptr)
|
||||
return false;
|
||||
QSharedPointer<DiscIO::IVolume> volume(
|
||||
DiscIO::CreateVolumeFromFilename(m_path.toStdString()).release());
|
||||
if (volume == nullptr)
|
||||
return false;
|
||||
|
||||
m_unique_id = QString::fromStdString(volume->GetUniqueID());
|
||||
m_maker_id = QString::fromStdString(volume->GetMakerID());
|
||||
m_revision = volume->GetRevision();
|
||||
m_internal_name = QString::fromStdString(volume->GetInternalName());
|
||||
m_short_names = ConvertLanguageMap(volume->GetNames(false));
|
||||
m_long_names = ConvertLanguageMap(volume->GetNames(true));
|
||||
m_descriptions = ConvertLanguageMap(volume->GetDescriptions());
|
||||
m_company = QString::fromStdString(volume->GetCompany());
|
||||
m_disc_number = volume->GetDiscNumber();
|
||||
m_platform = volume->GetVolumeType();
|
||||
m_country = volume->GetCountry();
|
||||
m_blob_type = volume->GetBlobType();
|
||||
m_raw_size = volume->GetRawSize();
|
||||
m_unique_id = QString::fromStdString(volume->GetUniqueID());
|
||||
m_maker_id = QString::fromStdString(volume->GetMakerID());
|
||||
m_revision = volume->GetRevision();
|
||||
m_internal_name = QString::fromStdString(volume->GetInternalName());
|
||||
m_short_names = ConvertLanguageMap(volume->GetNames(false));
|
||||
m_long_names = ConvertLanguageMap(volume->GetNames(true));
|
||||
m_descriptions = ConvertLanguageMap(volume->GetDescriptions());
|
||||
m_company = QString::fromStdString(volume->GetCompany());
|
||||
m_disc_number = volume->GetDiscNumber();
|
||||
m_platform = volume->GetVolumeType();
|
||||
m_country = volume->GetCountry();
|
||||
m_blob_type = volume->GetBlobType();
|
||||
m_raw_size = volume->GetRawSize();
|
||||
|
||||
if (m_company.isEmpty() && m_unique_id.size() >= 6)
|
||||
m_company = QString::fromStdString(
|
||||
DiscIO::GetCompanyFromID(m_unique_id.mid(4, 2).toStdString()));
|
||||
if (m_company.isEmpty() && m_unique_id.size() >= 6)
|
||||
m_company =
|
||||
QString::fromStdString(DiscIO::GetCompanyFromID(m_unique_id.mid(4, 2).toStdString()));
|
||||
|
||||
ReadBanner(*volume);
|
||||
ReadBanner(*volume);
|
||||
|
||||
SaveCache();
|
||||
return true;
|
||||
SaveCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameFile::TryLoadElfDol()
|
||||
{
|
||||
if (!IsElfOrDol())
|
||||
return false;
|
||||
if (!IsElfOrDol())
|
||||
return false;
|
||||
|
||||
m_revision = 0;
|
||||
m_long_names[DiscIO::IVolume::LANGUAGE_ENGLISH] = m_file_name;
|
||||
m_platform = DiscIO::IVolume::ELF_DOL;
|
||||
m_country = DiscIO::IVolume::COUNTRY_UNKNOWN;
|
||||
m_blob_type = DiscIO::BlobType::DIRECTORY;
|
||||
m_raw_size = m_size;
|
||||
m_banner = Resources::GetMisc(Resources::BANNER_MISSING);
|
||||
m_rating = 0;
|
||||
m_revision = 0;
|
||||
m_long_names[DiscIO::IVolume::LANGUAGE_ENGLISH] = m_file_name;
|
||||
m_platform = DiscIO::IVolume::ELF_DOL;
|
||||
m_country = DiscIO::IVolume::COUNTRY_UNKNOWN;
|
||||
m_blob_type = DiscIO::BlobType::DIRECTORY;
|
||||
m_raw_size = m_size;
|
||||
m_banner = Resources::GetMisc(Resources::BANNER_MISSING);
|
||||
m_rating = 0;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
void GameFile::SaveCache()
|
||||
{
|
||||
// TODO
|
||||
// TODO
|
||||
}
|
||||
|
||||
QString GameFile::GetLanguageString(const QMap<DiscIO::IVolume::ELanguage, QString>& m) const
|
||||
{
|
||||
// Try the settings language, then English, then just pick one.
|
||||
if (m.isEmpty())
|
||||
return QString();
|
||||
// Try the settings language, then English, then just pick one.
|
||||
if (m.isEmpty())
|
||||
return QString();
|
||||
|
||||
bool wii = m_platform != DiscIO::IVolume::GAMECUBE_DISC;
|
||||
DiscIO::IVolume::ELanguage current_lang;
|
||||
if (wii)
|
||||
current_lang = Settings().GetWiiSystemLanguage();
|
||||
else
|
||||
current_lang = Settings().GetGCSystemLanguage();
|
||||
bool wii = m_platform != DiscIO::IVolume::GAMECUBE_DISC;
|
||||
DiscIO::IVolume::ELanguage current_lang;
|
||||
if (wii)
|
||||
current_lang = Settings().GetWiiSystemLanguage();
|
||||
else
|
||||
current_lang = Settings().GetGCSystemLanguage();
|
||||
|
||||
if (m.contains(current_lang))
|
||||
return m[current_lang];
|
||||
if (m.contains(DiscIO::IVolume::LANGUAGE_ENGLISH))
|
||||
return m[DiscIO::IVolume::LANGUAGE_ENGLISH];
|
||||
return m.first();
|
||||
if (m.contains(current_lang))
|
||||
return m[current_lang];
|
||||
if (m.contains(DiscIO::IVolume::LANGUAGE_ENGLISH))
|
||||
return m[DiscIO::IVolume::LANGUAGE_ENGLISH];
|
||||
return m.first();
|
||||
}
|
||||
|
@ -15,87 +15,71 @@
|
||||
class GameFile final
|
||||
{
|
||||
public:
|
||||
explicit GameFile(const QString& path);
|
||||
|
||||
bool IsValid() const { return m_valid; }
|
||||
|
||||
// These will be properly initialized before we try to load the file.
|
||||
QString GetPath() const { return m_path; }
|
||||
QString GetFileName() const { return m_file_name; }
|
||||
QString GetExtension() const { return m_extension; }
|
||||
QString GetFolder() const { return m_folder; }
|
||||
qint64 GetFileSize() const { return m_size; }
|
||||
|
||||
// The rest will not.
|
||||
QString GetUniqueID() const { return m_unique_id; }
|
||||
QString GetMakerID() const { return m_maker_id; }
|
||||
u16 GetRevision() const { return m_revision; }
|
||||
QString GetInternalName() const { return m_internal_name; }
|
||||
QString GetCompany() const { return m_company; }
|
||||
u8 GetDiscNumber() const { return m_disc_number; }
|
||||
u64 GetRawSize() const { return m_raw_size; }
|
||||
QPixmap GetBanner() const { return m_banner; }
|
||||
QString GetIssues() const { return m_issues; }
|
||||
int GetRating() const { return m_rating; }
|
||||
|
||||
DiscIO::IVolume::EPlatform GetPlatform() const { return m_platform; }
|
||||
DiscIO::IVolume::ECountry GetCountry() const { return m_country; }
|
||||
DiscIO::BlobType GetBlobType() const { return m_blob_type; }
|
||||
|
||||
QString GetShortName() const { return GetLanguageString(m_short_names); }
|
||||
QString GetShortName(DiscIO::IVolume::ELanguage lang) const
|
||||
{
|
||||
return m_short_names[lang];
|
||||
}
|
||||
|
||||
QString GetLongName() const { return GetLanguageString(m_long_names); }
|
||||
QString GetLongName(DiscIO::IVolume::ELanguage lang) const
|
||||
{
|
||||
return m_long_names[lang];
|
||||
}
|
||||
|
||||
QString GetDescription() const { return GetLanguageString(m_descriptions); }
|
||||
QString GetDescription(DiscIO::IVolume::ELanguage lang) const
|
||||
{
|
||||
return m_descriptions[lang];
|
||||
}
|
||||
explicit GameFile(const QString& path);
|
||||
|
||||
bool IsValid() const { return m_valid; }
|
||||
// These will be properly initialized before we try to load the file.
|
||||
QString GetPath() const { return m_path; }
|
||||
QString GetFileName() const { return m_file_name; }
|
||||
QString GetExtension() const { return m_extension; }
|
||||
QString GetFolder() const { return m_folder; }
|
||||
qint64 GetFileSize() const { return m_size; }
|
||||
// The rest will not.
|
||||
QString GetUniqueID() const { return m_unique_id; }
|
||||
QString GetMakerID() const { return m_maker_id; }
|
||||
u16 GetRevision() const { return m_revision; }
|
||||
QString GetInternalName() const { return m_internal_name; }
|
||||
QString GetCompany() const { return m_company; }
|
||||
u8 GetDiscNumber() const { return m_disc_number; }
|
||||
u64 GetRawSize() const { return m_raw_size; }
|
||||
QPixmap GetBanner() const { return m_banner; }
|
||||
QString GetIssues() const { return m_issues; }
|
||||
int GetRating() const { return m_rating; }
|
||||
DiscIO::IVolume::EPlatform GetPlatform() const { return m_platform; }
|
||||
DiscIO::IVolume::ECountry GetCountry() const { return m_country; }
|
||||
DiscIO::BlobType GetBlobType() const { return m_blob_type; }
|
||||
QString GetShortName() const { return GetLanguageString(m_short_names); }
|
||||
QString GetShortName(DiscIO::IVolume::ELanguage lang) const { return m_short_names[lang]; }
|
||||
QString GetLongName() const { return GetLanguageString(m_long_names); }
|
||||
QString GetLongName(DiscIO::IVolume::ELanguage lang) const { return m_long_names[lang]; }
|
||||
QString GetDescription() const { return GetLanguageString(m_descriptions); }
|
||||
QString GetDescription(DiscIO::IVolume::ELanguage lang) const { return m_descriptions[lang]; }
|
||||
private:
|
||||
DiscIO::IVolume::ELanguage GetDefaultLanguage() const;
|
||||
QString GetLanguageString(const QMap<DiscIO::IVolume::ELanguage, QString>& m) const;
|
||||
DiscIO::IVolume::ELanguage GetDefaultLanguage() const;
|
||||
QString GetLanguageString(const QMap<DiscIO::IVolume::ELanguage, QString>& m) const;
|
||||
|
||||
QString GetCacheFileName() const;
|
||||
void ReadBanner(const DiscIO::IVolume& volume);
|
||||
bool LoadFileInfo(const QString& path);
|
||||
void LoadState();
|
||||
bool IsElfOrDol();
|
||||
bool TryLoadElfDol();
|
||||
bool TryLoadCache();
|
||||
bool TryLoadVolume();
|
||||
void SaveCache();
|
||||
QString GetCacheFileName() const;
|
||||
void ReadBanner(const DiscIO::IVolume& volume);
|
||||
bool LoadFileInfo(const QString& path);
|
||||
void LoadState();
|
||||
bool IsElfOrDol();
|
||||
bool TryLoadElfDol();
|
||||
bool TryLoadCache();
|
||||
bool TryLoadVolume();
|
||||
void SaveCache();
|
||||
|
||||
bool m_valid;
|
||||
QString m_path;
|
||||
QString m_file_name;
|
||||
QString m_extension;
|
||||
QString m_folder;
|
||||
QDateTime m_last_modified;
|
||||
qint64 m_size = 0;
|
||||
bool m_valid;
|
||||
QString m_path;
|
||||
QString m_file_name;
|
||||
QString m_extension;
|
||||
QString m_folder;
|
||||
QDateTime m_last_modified;
|
||||
qint64 m_size = 0;
|
||||
|
||||
QString m_unique_id;
|
||||
QString m_maker_id;
|
||||
u16 m_revision = 0;
|
||||
QString m_internal_name;
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> m_short_names;
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> m_long_names;
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> m_descriptions;
|
||||
QString m_company;
|
||||
u8 m_disc_number = 0;
|
||||
DiscIO::IVolume::EPlatform m_platform;
|
||||
DiscIO::IVolume::ECountry m_country;
|
||||
DiscIO::BlobType m_blob_type;
|
||||
u64 m_raw_size = 0;
|
||||
QPixmap m_banner;
|
||||
QString m_issues;
|
||||
int m_rating = 0;
|
||||
QString m_unique_id;
|
||||
QString m_maker_id;
|
||||
u16 m_revision = 0;
|
||||
QString m_internal_name;
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> m_short_names;
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> m_long_names;
|
||||
QMap<DiscIO::IVolume::ELanguage, QString> m_descriptions;
|
||||
QString m_company;
|
||||
u8 m_disc_number = 0;
|
||||
DiscIO::IVolume::EPlatform m_platform;
|
||||
DiscIO::IVolume::ECountry m_country;
|
||||
DiscIO::BlobType m_blob_type;
|
||||
u64 m_raw_size = 0;
|
||||
QPixmap m_banner;
|
||||
QString m_issues;
|
||||
int m_rating = 0;
|
||||
};
|
||||
|
@ -8,167 +8,167 @@
|
||||
#include <QMenu>
|
||||
#include <QUrl>
|
||||
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "DolphinQt2/GameList/GameList.h"
|
||||
#include "DolphinQt2/GameList/ListProxyModel.h"
|
||||
#include "DolphinQt2/GameList/TableDelegate.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
|
||||
GameList::GameList(QWidget* parent): QStackedWidget(parent)
|
||||
GameList::GameList(QWidget* parent) : QStackedWidget(parent)
|
||||
{
|
||||
m_model = new GameListModel(this);
|
||||
m_table_proxy = new QSortFilterProxyModel(this);
|
||||
m_table_proxy->setSourceModel(m_model);
|
||||
m_list_proxy = new ListProxyModel(this);
|
||||
m_list_proxy->setSourceModel(m_model);
|
||||
m_model = new GameListModel(this);
|
||||
m_table_proxy = new QSortFilterProxyModel(this);
|
||||
m_table_proxy->setSourceModel(m_model);
|
||||
m_list_proxy = new ListProxyModel(this);
|
||||
m_list_proxy->setSourceModel(m_model);
|
||||
|
||||
m_delegate = new TableDelegate(this);
|
||||
m_delegate = new TableDelegate(this);
|
||||
|
||||
MakeTableView();
|
||||
MakeListView();
|
||||
MakeEmptyView();
|
||||
MakeTableView();
|
||||
MakeListView();
|
||||
MakeEmptyView();
|
||||
|
||||
connect(m_table, &QTableView::doubleClicked, this, &GameList::GameSelected);
|
||||
connect(m_list, &QListView::doubleClicked, this, &GameList::GameSelected);
|
||||
connect(this, &GameList::DirectoryAdded, m_model, &GameListModel::DirectoryAdded);
|
||||
connect(this, &GameList::DirectoryRemoved, m_model, &GameListModel::DirectoryRemoved);
|
||||
connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange);
|
||||
connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange);
|
||||
connect(m_table, &QTableView::doubleClicked, this, &GameList::GameSelected);
|
||||
connect(m_list, &QListView::doubleClicked, this, &GameList::GameSelected);
|
||||
connect(this, &GameList::DirectoryAdded, m_model, &GameListModel::DirectoryAdded);
|
||||
connect(this, &GameList::DirectoryRemoved, m_model, &GameListModel::DirectoryRemoved);
|
||||
connect(m_model, &QAbstractItemModel::rowsInserted, this, &GameList::ConsiderViewChange);
|
||||
connect(m_model, &QAbstractItemModel::rowsRemoved, this, &GameList::ConsiderViewChange);
|
||||
|
||||
addWidget(m_table);
|
||||
addWidget(m_list);
|
||||
addWidget(m_empty);
|
||||
m_prefer_table = Settings().GetPreferredView();
|
||||
ConsiderViewChange();
|
||||
addWidget(m_table);
|
||||
addWidget(m_list);
|
||||
addWidget(m_empty);
|
||||
m_prefer_table = Settings().GetPreferredView();
|
||||
ConsiderViewChange();
|
||||
}
|
||||
|
||||
void GameList::MakeTableView()
|
||||
{
|
||||
m_table = new QTableView(this);
|
||||
m_table->setModel(m_table_proxy);
|
||||
m_table->setItemDelegate(m_delegate);
|
||||
m_table->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_table->setAlternatingRowColors(true);
|
||||
m_table->setShowGrid(false);
|
||||
m_table->setSortingEnabled(true);
|
||||
m_table->setCurrentIndex(QModelIndex());
|
||||
m_table->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_table, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
|
||||
m_table = new QTableView(this);
|
||||
m_table->setModel(m_table_proxy);
|
||||
m_table->setItemDelegate(m_delegate);
|
||||
m_table->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_table->setAlternatingRowColors(true);
|
||||
m_table->setShowGrid(false);
|
||||
m_table->setSortingEnabled(true);
|
||||
m_table->setCurrentIndex(QModelIndex());
|
||||
m_table->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_table, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
|
||||
|
||||
// TODO load from config
|
||||
m_table->setColumnHidden(GameListModel::COL_PLATFORM, false);
|
||||
m_table->setColumnHidden(GameListModel::COL_ID, true);
|
||||
m_table->setColumnHidden(GameListModel::COL_BANNER, false);
|
||||
m_table->setColumnHidden(GameListModel::COL_TITLE, false);
|
||||
m_table->setColumnHidden(GameListModel::COL_DESCRIPTION, true);
|
||||
m_table->setColumnHidden(GameListModel::COL_MAKER, false);
|
||||
m_table->setColumnHidden(GameListModel::COL_SIZE, false);
|
||||
m_table->setColumnHidden(GameListModel::COL_COUNTRY, false);
|
||||
m_table->setColumnHidden(GameListModel::COL_RATING, false);
|
||||
// TODO load from config
|
||||
m_table->setColumnHidden(GameListModel::COL_PLATFORM, false);
|
||||
m_table->setColumnHidden(GameListModel::COL_ID, true);
|
||||
m_table->setColumnHidden(GameListModel::COL_BANNER, false);
|
||||
m_table->setColumnHidden(GameListModel::COL_TITLE, false);
|
||||
m_table->setColumnHidden(GameListModel::COL_DESCRIPTION, true);
|
||||
m_table->setColumnHidden(GameListModel::COL_MAKER, false);
|
||||
m_table->setColumnHidden(GameListModel::COL_SIZE, false);
|
||||
m_table->setColumnHidden(GameListModel::COL_COUNTRY, false);
|
||||
m_table->setColumnHidden(GameListModel::COL_RATING, false);
|
||||
|
||||
QHeaderView* hor_header = m_table->horizontalHeader();
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_PLATFORM, QHeaderView::ResizeToContents);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_COUNTRY, QHeaderView::ResizeToContents);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_ID, QHeaderView::ResizeToContents);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_BANNER, QHeaderView::ResizeToContents);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_TITLE, QHeaderView::Stretch);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_MAKER, QHeaderView::Stretch);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_SIZE, QHeaderView::ResizeToContents);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_DESCRIPTION, QHeaderView::Stretch);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_RATING, QHeaderView::ResizeToContents);
|
||||
QHeaderView* hor_header = m_table->horizontalHeader();
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_PLATFORM, QHeaderView::ResizeToContents);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_COUNTRY, QHeaderView::ResizeToContents);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_ID, QHeaderView::ResizeToContents);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_BANNER, QHeaderView::ResizeToContents);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_TITLE, QHeaderView::Stretch);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_MAKER, QHeaderView::Stretch);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_SIZE, QHeaderView::ResizeToContents);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_DESCRIPTION, QHeaderView::Stretch);
|
||||
hor_header->setSectionResizeMode(GameListModel::COL_RATING, QHeaderView::ResizeToContents);
|
||||
|
||||
QHeaderView* ver_header = m_table->verticalHeader();
|
||||
ver_header->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
QHeaderView* ver_header = m_table->verticalHeader();
|
||||
ver_header->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
}
|
||||
|
||||
void GameList::MakeEmptyView()
|
||||
{
|
||||
m_empty = new QLabel(this);
|
||||
m_empty->setText(tr("Dolphin did not find any game files.\n"
|
||||
"Open the Paths dialog to add game folders."));
|
||||
m_empty->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
m_empty = new QLabel(this);
|
||||
m_empty->setText(tr("Dolphin did not find any game files.\n"
|
||||
"Open the Paths dialog to add game folders."));
|
||||
m_empty->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
void GameList::MakeListView()
|
||||
{
|
||||
m_list = new QListView(this);
|
||||
m_list->setModel(m_list_proxy);
|
||||
m_list->setViewMode(QListView::IconMode);
|
||||
m_list->setResizeMode(QListView::Adjust);
|
||||
m_list->setUniformItemSizes(true);
|
||||
m_list->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_list, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
|
||||
m_list = new QListView(this);
|
||||
m_list->setModel(m_list_proxy);
|
||||
m_list->setViewMode(QListView::IconMode);
|
||||
m_list->setResizeMode(QListView::Adjust);
|
||||
m_list->setUniformItemSizes(true);
|
||||
m_list->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_list, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu);
|
||||
}
|
||||
|
||||
void GameList::ShowContextMenu(const QPoint&)
|
||||
{
|
||||
QMenu* menu = new QMenu(this);
|
||||
menu->addAction(tr("Properties"));
|
||||
menu->addAction(tr("Open Wiki Page"), this, SLOT(OpenWiki()));
|
||||
menu->addAction(tr("Set as Default ISO"), this, SLOT(SetDefaultISO()));
|
||||
menu->exec(QCursor::pos());
|
||||
QMenu* menu = new QMenu(this);
|
||||
menu->addAction(tr("Properties"));
|
||||
menu->addAction(tr("Open Wiki Page"), this, SLOT(OpenWiki()));
|
||||
menu->addAction(tr("Set as Default ISO"), this, SLOT(SetDefaultISO()));
|
||||
menu->exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void GameList::OpenWiki()
|
||||
{
|
||||
QString game_id = GameFile(GetSelectedGame()).GetUniqueID();
|
||||
QString url = QStringLiteral("https://wiki.dolphin-emu.org/index.php?title=").append(game_id);
|
||||
QDesktopServices::openUrl(QUrl(url));
|
||||
QString game_id = GameFile(GetSelectedGame()).GetUniqueID();
|
||||
QString url = QStringLiteral("https://wiki.dolphin-emu.org/index.php?title=").append(game_id);
|
||||
QDesktopServices::openUrl(QUrl(url));
|
||||
}
|
||||
|
||||
void GameList::SetDefaultISO()
|
||||
{
|
||||
Settings().SetDefaultGame(GetSelectedGame());
|
||||
Settings().SetDefaultGame(GetSelectedGame());
|
||||
}
|
||||
|
||||
QString GameList::GetSelectedGame() const
|
||||
{
|
||||
QAbstractItemView* view;
|
||||
QSortFilterProxyModel* proxy;
|
||||
if (currentWidget() == m_table)
|
||||
{
|
||||
view = m_table;
|
||||
proxy = m_table_proxy;
|
||||
}
|
||||
else
|
||||
{
|
||||
view = m_list;
|
||||
proxy = m_list_proxy;
|
||||
}
|
||||
QItemSelectionModel* sel_model = view->selectionModel();
|
||||
if (sel_model->hasSelection())
|
||||
{
|
||||
QModelIndex model_index = proxy->mapToSource(sel_model->selectedIndexes()[0]);
|
||||
return m_model->GetPath(model_index.row());
|
||||
}
|
||||
return QStringLiteral("");
|
||||
QAbstractItemView* view;
|
||||
QSortFilterProxyModel* proxy;
|
||||
if (currentWidget() == m_table)
|
||||
{
|
||||
view = m_table;
|
||||
proxy = m_table_proxy;
|
||||
}
|
||||
else
|
||||
{
|
||||
view = m_list;
|
||||
proxy = m_list_proxy;
|
||||
}
|
||||
QItemSelectionModel* sel_model = view->selectionModel();
|
||||
if (sel_model->hasSelection())
|
||||
{
|
||||
QModelIndex model_index = proxy->mapToSource(sel_model->selectedIndexes()[0]);
|
||||
return m_model->GetPath(model_index.row());
|
||||
}
|
||||
return QStringLiteral("");
|
||||
}
|
||||
|
||||
void GameList::SetPreferredView(bool table)
|
||||
{
|
||||
m_prefer_table = table;
|
||||
Settings().SetPreferredView(table);
|
||||
ConsiderViewChange();
|
||||
m_prefer_table = table;
|
||||
Settings().SetPreferredView(table);
|
||||
ConsiderViewChange();
|
||||
}
|
||||
|
||||
void GameList::ConsiderViewChange()
|
||||
{
|
||||
if (m_model->rowCount(QModelIndex()) > 0)
|
||||
{
|
||||
if (m_prefer_table)
|
||||
setCurrentWidget(m_table);
|
||||
else
|
||||
setCurrentWidget(m_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
setCurrentWidget(m_empty);
|
||||
}
|
||||
if (m_model->rowCount(QModelIndex()) > 0)
|
||||
{
|
||||
if (m_prefer_table)
|
||||
setCurrentWidget(m_table);
|
||||
else
|
||||
setCurrentWidget(m_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
setCurrentWidget(m_empty);
|
||||
}
|
||||
}
|
||||
void GameList::keyReleaseEvent(QKeyEvent* event)
|
||||
{
|
||||
if (event->key() == Qt::Key_Return)
|
||||
emit GameSelected();
|
||||
else
|
||||
QStackedWidget::keyReleaseEvent(event);
|
||||
if (event->key() == Qt::Key_Return)
|
||||
emit GameSelected();
|
||||
else
|
||||
QStackedWidget::keyReleaseEvent(event);
|
||||
}
|
||||
|
@ -17,44 +17,44 @@ class TableDelegate;
|
||||
|
||||
class GameList final : public QStackedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GameList(QWidget* parent = nullptr);
|
||||
QString GetSelectedGame() const;
|
||||
explicit GameList(QWidget* parent = nullptr);
|
||||
QString GetSelectedGame() const;
|
||||
|
||||
public slots:
|
||||
void SetTableView() { SetPreferredView(true); }
|
||||
void SetListView() { SetPreferredView(false); }
|
||||
void SetViewColumn(int col, bool view) { m_table->setColumnHidden(col, !view); }
|
||||
|
||||
void SetTableView() { SetPreferredView(true); }
|
||||
void SetListView() { SetPreferredView(false); }
|
||||
void SetViewColumn(int col, bool view) { m_table->setColumnHidden(col, !view); }
|
||||
private slots:
|
||||
void ShowContextMenu(const QPoint&);
|
||||
void OpenWiki();
|
||||
void SetDefaultISO();
|
||||
void ShowContextMenu(const QPoint&);
|
||||
void OpenWiki();
|
||||
void SetDefaultISO();
|
||||
|
||||
signals:
|
||||
void GameSelected();
|
||||
void DirectoryAdded(const QString& dir);
|
||||
void DirectoryRemoved(const QString& dir);
|
||||
void GameSelected();
|
||||
void DirectoryAdded(const QString& dir);
|
||||
void DirectoryRemoved(const QString& dir);
|
||||
|
||||
private:
|
||||
void MakeTableView();
|
||||
void MakeListView();
|
||||
void MakeEmptyView();
|
||||
// We only have two views, just use a bool to distinguish.
|
||||
void SetPreferredView(bool table);
|
||||
void ConsiderViewChange();
|
||||
void MakeTableView();
|
||||
void MakeListView();
|
||||
void MakeEmptyView();
|
||||
// We only have two views, just use a bool to distinguish.
|
||||
void SetPreferredView(bool table);
|
||||
void ConsiderViewChange();
|
||||
|
||||
GameListModel* m_model;
|
||||
TableDelegate* m_delegate;
|
||||
QSortFilterProxyModel* m_table_proxy;
|
||||
QSortFilterProxyModel* m_list_proxy;
|
||||
GameListModel* m_model;
|
||||
TableDelegate* m_delegate;
|
||||
QSortFilterProxyModel* m_table_proxy;
|
||||
QSortFilterProxyModel* m_list_proxy;
|
||||
|
||||
QListView* m_list;
|
||||
QTableView* m_table;
|
||||
QLabel* m_empty;
|
||||
bool m_prefer_table;
|
||||
|
||||
QListView* m_list;
|
||||
QTableView* m_table;
|
||||
QLabel* m_empty;
|
||||
bool m_prefer_table;
|
||||
protected:
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
};
|
||||
|
@ -2,102 +2,117 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinQt2/Resources.h"
|
||||
#include "DolphinQt2/GameList/GameListModel.h"
|
||||
#include "DolphinQt2/Resources.h"
|
||||
|
||||
GameListModel::GameListModel(QObject* parent)
|
||||
: QAbstractTableModel(parent)
|
||||
GameListModel::GameListModel(QObject* parent) : QAbstractTableModel(parent)
|
||||
{
|
||||
connect(&m_tracker, &GameTracker::GameLoaded, this, &GameListModel::UpdateGame);
|
||||
connect(&m_tracker, &GameTracker::GameRemoved, this, &GameListModel::RemoveGame);
|
||||
connect(this, &GameListModel::DirectoryAdded, &m_tracker, &GameTracker::AddDirectory);
|
||||
connect(this, &GameListModel::DirectoryRemoved, &m_tracker, &GameTracker::RemoveDirectory);
|
||||
connect(&m_tracker, &GameTracker::GameLoaded, this, &GameListModel::UpdateGame);
|
||||
connect(&m_tracker, &GameTracker::GameRemoved, this, &GameListModel::RemoveGame);
|
||||
connect(this, &GameListModel::DirectoryAdded, &m_tracker, &GameTracker::AddDirectory);
|
||||
connect(this, &GameListModel::DirectoryRemoved, &m_tracker, &GameTracker::RemoveDirectory);
|
||||
}
|
||||
|
||||
QVariant GameListModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
QSharedPointer<GameFile> game = m_games[index.row()];
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case COL_PLATFORM: return game->GetPlatform();
|
||||
case COL_BANNER: return game->GetBanner();
|
||||
case COL_TITLE: return game->GetLongName();
|
||||
case COL_ID: return game->GetUniqueID();
|
||||
case COL_DESCRIPTION: return game->GetDescription();
|
||||
case COL_MAKER: return game->GetCompany();
|
||||
case COL_SIZE: return game->GetFileSize();
|
||||
case COL_COUNTRY: return game->GetCountry();
|
||||
case COL_RATING: return game->GetRating();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
QSharedPointer<GameFile> game = m_games[index.row()];
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case COL_PLATFORM:
|
||||
return game->GetPlatform();
|
||||
case COL_BANNER:
|
||||
return game->GetBanner();
|
||||
case COL_TITLE:
|
||||
return game->GetLongName();
|
||||
case COL_ID:
|
||||
return game->GetUniqueID();
|
||||
case COL_DESCRIPTION:
|
||||
return game->GetDescription();
|
||||
case COL_MAKER:
|
||||
return game->GetCompany();
|
||||
case COL_SIZE:
|
||||
return game->GetFileSize();
|
||||
case COL_COUNTRY:
|
||||
return game->GetCountry();
|
||||
case COL_RATING:
|
||||
return game->GetRating();
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant GameListModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (orientation == Qt::Vertical || role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
if (orientation == Qt::Vertical || role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
switch (section)
|
||||
{
|
||||
case COL_TITLE: return tr("Title");
|
||||
case COL_ID: return tr("ID");
|
||||
case COL_BANNER: return tr("Banner");
|
||||
case COL_DESCRIPTION: return tr("Description");
|
||||
case COL_MAKER: return tr("Maker");
|
||||
case COL_SIZE: return tr("Size");
|
||||
case COL_RATING: return tr("Quality");
|
||||
}
|
||||
return QVariant();
|
||||
switch (section)
|
||||
{
|
||||
case COL_TITLE:
|
||||
return tr("Title");
|
||||
case COL_ID:
|
||||
return tr("ID");
|
||||
case COL_BANNER:
|
||||
return tr("Banner");
|
||||
case COL_DESCRIPTION:
|
||||
return tr("Description");
|
||||
case COL_MAKER:
|
||||
return tr("Maker");
|
||||
case COL_SIZE:
|
||||
return tr("Size");
|
||||
case COL_RATING:
|
||||
return tr("Quality");
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int GameListModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
return m_games.size();
|
||||
if (parent.isValid())
|
||||
return 0;
|
||||
return m_games.size();
|
||||
}
|
||||
|
||||
int GameListModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
return NUM_COLS;
|
||||
return NUM_COLS;
|
||||
}
|
||||
|
||||
void GameListModel::UpdateGame(QSharedPointer<GameFile> game)
|
||||
{
|
||||
QString path = game->GetPath();
|
||||
QString path = game->GetPath();
|
||||
|
||||
int entry = FindGame(path);
|
||||
if (entry < 0)
|
||||
entry = m_games.size();
|
||||
int entry = FindGame(path);
|
||||
if (entry < 0)
|
||||
entry = m_games.size();
|
||||
|
||||
beginInsertRows(QModelIndex(), entry, entry);
|
||||
m_games.insert(entry, game);
|
||||
endInsertRows();
|
||||
beginInsertRows(QModelIndex(), entry, entry);
|
||||
m_games.insert(entry, game);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void GameListModel::RemoveGame(const QString& path)
|
||||
{
|
||||
int entry = FindGame(path);
|
||||
if (entry < 0)
|
||||
return;
|
||||
int entry = FindGame(path);
|
||||
if (entry < 0)
|
||||
return;
|
||||
|
||||
beginRemoveRows(QModelIndex(), entry, entry);
|
||||
m_games.removeAt(entry);
|
||||
endRemoveRows();
|
||||
beginRemoveRows(QModelIndex(), entry, entry);
|
||||
m_games.removeAt(entry);
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
int GameListModel::FindGame(const QString& path) const
|
||||
{
|
||||
for (int i = 0; i < m_games.size(); i++)
|
||||
{
|
||||
if (m_games[i]->GetPath() == path)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
for (int i = 0; i < m_games.size(); i++)
|
||||
{
|
||||
if (m_games[i]->GetPath() == path)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -12,46 +12,46 @@
|
||||
|
||||
class GameListModel final : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GameListModel(QObject* parent = nullptr);
|
||||
explicit GameListModel(QObject* parent = nullptr);
|
||||
|
||||
// Qt's Model/View stuff uses these overrides.
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
int rowCount(const QModelIndex& parent) const override;
|
||||
int columnCount(const QModelIndex& parent) const override;
|
||||
// Qt's Model/View stuff uses these overrides.
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const override;
|
||||
int rowCount(const QModelIndex& parent) const override;
|
||||
int columnCount(const QModelIndex& parent) const override;
|
||||
|
||||
// Path of the Game at the specified index.
|
||||
QString GetPath(int index) const { return m_games[index]->GetPath(); }
|
||||
|
||||
enum
|
||||
{
|
||||
COL_PLATFORM = 0,
|
||||
COL_ID,
|
||||
COL_BANNER,
|
||||
COL_TITLE,
|
||||
COL_DESCRIPTION,
|
||||
COL_MAKER,
|
||||
COL_SIZE,
|
||||
COL_COUNTRY,
|
||||
COL_RATING,
|
||||
NUM_COLS
|
||||
};
|
||||
// Path of the Game at the specified index.
|
||||
QString GetPath(int index) const { return m_games[index]->GetPath(); }
|
||||
enum
|
||||
{
|
||||
COL_PLATFORM = 0,
|
||||
COL_ID,
|
||||
COL_BANNER,
|
||||
COL_TITLE,
|
||||
COL_DESCRIPTION,
|
||||
COL_MAKER,
|
||||
COL_SIZE,
|
||||
COL_COUNTRY,
|
||||
COL_RATING,
|
||||
NUM_COLS
|
||||
};
|
||||
|
||||
public slots:
|
||||
void UpdateGame(QSharedPointer<GameFile> game);
|
||||
void RemoveGame(const QString& path);
|
||||
void UpdateGame(QSharedPointer<GameFile> game);
|
||||
void RemoveGame(const QString& path);
|
||||
|
||||
signals:
|
||||
void DirectoryAdded(const QString& dir);
|
||||
void DirectoryRemoved(const QString& dir);
|
||||
void DirectoryAdded(const QString& dir);
|
||||
void DirectoryRemoved(const QString& dir);
|
||||
|
||||
private:
|
||||
// Index in m_games, or -1 if it isn't found
|
||||
int FindGame(const QString& path) const;
|
||||
// Index in m_games, or -1 if it isn't found
|
||||
int FindGame(const QString& path) const;
|
||||
|
||||
GameTracker m_tracker;
|
||||
QList<QSharedPointer<GameFile>> m_games;
|
||||
GameTracker m_tracker;
|
||||
QList<QSharedPointer<GameFile>> m_games;
|
||||
};
|
||||
|
@ -6,101 +6,94 @@
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "DolphinQt2/GameList/GameTracker.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
|
||||
static const QStringList game_filters{
|
||||
QStringLiteral("*.gcm"),
|
||||
QStringLiteral("*.iso"),
|
||||
QStringLiteral("*.ciso"),
|
||||
QStringLiteral("*.gcz"),
|
||||
QStringLiteral("*.wbfs"),
|
||||
QStringLiteral("*.wad"),
|
||||
QStringLiteral("*.elf"),
|
||||
QStringLiteral("*.dol")
|
||||
};
|
||||
static const QStringList game_filters{QStringLiteral("*.gcm"), QStringLiteral("*.iso"),
|
||||
QStringLiteral("*.ciso"), QStringLiteral("*.gcz"),
|
||||
QStringLiteral("*.wbfs"), QStringLiteral("*.wad"),
|
||||
QStringLiteral("*.elf"), QStringLiteral("*.dol")};
|
||||
|
||||
GameTracker::GameTracker(QObject* parent)
|
||||
: QFileSystemWatcher(parent)
|
||||
GameTracker::GameTracker(QObject* parent) : QFileSystemWatcher(parent)
|
||||
{
|
||||
m_loader = new GameLoader;
|
||||
m_loader->moveToThread(&m_loader_thread);
|
||||
m_loader = new GameLoader;
|
||||
m_loader->moveToThread(&m_loader_thread);
|
||||
|
||||
qRegisterMetaType<QSharedPointer<GameFile>>();
|
||||
connect(&m_loader_thread, &QThread::finished, m_loader, &QObject::deleteLater);
|
||||
connect(this, &QFileSystemWatcher::directoryChanged, this, &GameTracker::UpdateDirectory);
|
||||
connect(this, &QFileSystemWatcher::fileChanged, this, &GameTracker::UpdateFile);
|
||||
connect(this, &GameTracker::PathChanged, m_loader, &GameLoader::LoadGame);
|
||||
connect(m_loader, &GameLoader::GameLoaded, this, &GameTracker::GameLoaded);
|
||||
qRegisterMetaType<QSharedPointer<GameFile>>();
|
||||
connect(&m_loader_thread, &QThread::finished, m_loader, &QObject::deleteLater);
|
||||
connect(this, &QFileSystemWatcher::directoryChanged, this, &GameTracker::UpdateDirectory);
|
||||
connect(this, &QFileSystemWatcher::fileChanged, this, &GameTracker::UpdateFile);
|
||||
connect(this, &GameTracker::PathChanged, m_loader, &GameLoader::LoadGame);
|
||||
connect(m_loader, &GameLoader::GameLoaded, this, &GameTracker::GameLoaded);
|
||||
|
||||
m_loader_thread.start();
|
||||
m_loader_thread.start();
|
||||
|
||||
for (QString dir : Settings().GetPaths())
|
||||
AddDirectory(dir);
|
||||
for (QString dir : Settings().GetPaths())
|
||||
AddDirectory(dir);
|
||||
}
|
||||
|
||||
GameTracker::~GameTracker()
|
||||
{
|
||||
m_loader_thread.quit();
|
||||
m_loader_thread.wait();
|
||||
m_loader_thread.quit();
|
||||
m_loader_thread.wait();
|
||||
}
|
||||
|
||||
void GameTracker::AddDirectory(const QString& dir)
|
||||
{
|
||||
if (!QFileInfo(dir).exists())
|
||||
return;
|
||||
addPath(dir);
|
||||
UpdateDirectory(dir);
|
||||
if (!QFileInfo(dir).exists())
|
||||
return;
|
||||
addPath(dir);
|
||||
UpdateDirectory(dir);
|
||||
}
|
||||
|
||||
void GameTracker::RemoveDirectory(const QString& dir)
|
||||
{
|
||||
removePath(dir);
|
||||
QDirIterator it(dir, game_filters, QDir::NoFilter, QDirIterator::Subdirectories);
|
||||
while (it.hasNext())
|
||||
{
|
||||
QString path = QFileInfo(it.next()).canonicalFilePath();
|
||||
if (m_tracked_files.contains(path))
|
||||
{
|
||||
m_tracked_files[path]--;
|
||||
if (m_tracked_files[path] == 0)
|
||||
{
|
||||
removePath(path);
|
||||
m_tracked_files.remove(path);
|
||||
emit GameRemoved(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
removePath(dir);
|
||||
QDirIterator it(dir, game_filters, QDir::NoFilter, QDirIterator::Subdirectories);
|
||||
while (it.hasNext())
|
||||
{
|
||||
QString path = QFileInfo(it.next()).canonicalFilePath();
|
||||
if (m_tracked_files.contains(path))
|
||||
{
|
||||
m_tracked_files[path]--;
|
||||
if (m_tracked_files[path] == 0)
|
||||
{
|
||||
removePath(path);
|
||||
m_tracked_files.remove(path);
|
||||
emit GameRemoved(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameTracker::UpdateDirectory(const QString& dir)
|
||||
{
|
||||
QDirIterator it(dir, game_filters, QDir::NoFilter, QDirIterator::Subdirectories);
|
||||
while (it.hasNext())
|
||||
{
|
||||
QString path = QFileInfo(it.next()).canonicalFilePath();
|
||||
if (m_tracked_files.contains(path))
|
||||
{
|
||||
m_tracked_files[path]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
addPath(path);
|
||||
m_tracked_files[path] = 1;
|
||||
emit PathChanged(path);
|
||||
}
|
||||
}
|
||||
QDirIterator it(dir, game_filters, QDir::NoFilter, QDirIterator::Subdirectories);
|
||||
while (it.hasNext())
|
||||
{
|
||||
QString path = QFileInfo(it.next()).canonicalFilePath();
|
||||
if (m_tracked_files.contains(path))
|
||||
{
|
||||
m_tracked_files[path]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
addPath(path);
|
||||
m_tracked_files[path] = 1;
|
||||
emit PathChanged(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GameTracker::UpdateFile(const QString& file)
|
||||
{
|
||||
if (QFileInfo(file).exists())
|
||||
{
|
||||
emit PathChanged(file);
|
||||
}
|
||||
else if (removePath(file))
|
||||
{
|
||||
m_tracked_files.remove(file);
|
||||
emit GameRemoved(file);
|
||||
}
|
||||
if (QFileInfo(file).exists())
|
||||
{
|
||||
emit PathChanged(file);
|
||||
}
|
||||
else if (removePath(file))
|
||||
{
|
||||
m_tracked_files.remove(file);
|
||||
emit GameRemoved(file);
|
||||
}
|
||||
}
|
||||
|
@ -23,46 +23,46 @@ class GameLoader;
|
||||
// private.
|
||||
class GameTracker final : public QFileSystemWatcher
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GameTracker(QObject* parent = nullptr);
|
||||
~GameTracker();
|
||||
explicit GameTracker(QObject* parent = nullptr);
|
||||
~GameTracker();
|
||||
|
||||
public slots:
|
||||
void AddDirectory(const QString& dir);
|
||||
void RemoveDirectory(const QString& dir);
|
||||
void AddDirectory(const QString& dir);
|
||||
void RemoveDirectory(const QString& dir);
|
||||
|
||||
signals:
|
||||
void GameLoaded(QSharedPointer<GameFile> game);
|
||||
void GameRemoved(const QString& path);
|
||||
void GameLoaded(QSharedPointer<GameFile> game);
|
||||
void GameRemoved(const QString& path);
|
||||
|
||||
void PathChanged(const QString& path);
|
||||
void PathChanged(const QString& path);
|
||||
|
||||
private:
|
||||
void UpdateDirectory(const QString& dir);
|
||||
void UpdateFile(const QString& path);
|
||||
void UpdateDirectory(const QString& dir);
|
||||
void UpdateFile(const QString& path);
|
||||
|
||||
// game path -> number of directories that track it
|
||||
QMap<QString, int> m_tracked_files;
|
||||
QThread m_loader_thread;
|
||||
GameLoader* m_loader;
|
||||
// game path -> number of directories that track it
|
||||
QMap<QString, int> m_tracked_files;
|
||||
QThread m_loader_thread;
|
||||
GameLoader* m_loader;
|
||||
};
|
||||
|
||||
class GameLoader final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void LoadGame(const QString& path)
|
||||
{
|
||||
GameFile* game = new GameFile(path);
|
||||
if (game->IsValid())
|
||||
emit GameLoaded(QSharedPointer<GameFile>(game));
|
||||
}
|
||||
void LoadGame(const QString& path)
|
||||
{
|
||||
GameFile* game = new GameFile(path);
|
||||
if (game->IsValid())
|
||||
emit GameLoaded(QSharedPointer<GameFile>(game));
|
||||
}
|
||||
|
||||
signals:
|
||||
void GameLoaded(QSharedPointer<GameFile> game);
|
||||
void GameLoaded(QSharedPointer<GameFile> game);
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(QSharedPointer<GameFile>)
|
||||
|
@ -9,30 +9,26 @@
|
||||
|
||||
static QSize LARGE_BANNER_SIZE(144, 48);
|
||||
|
||||
ListProxyModel::ListProxyModel(QObject* parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
ListProxyModel::ListProxyModel(QObject* parent) : QSortFilterProxyModel(parent)
|
||||
{
|
||||
setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
sort(GameListModel::COL_TITLE);
|
||||
setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
sort(GameListModel::COL_TITLE);
|
||||
}
|
||||
|
||||
QVariant ListProxyModel::data(const QModelIndex& i, int role) const
|
||||
{
|
||||
QModelIndex source_index = mapToSource(i);
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return sourceModel()->data(
|
||||
sourceModel()->index(source_index.row(), GameListModel::COL_TITLE),
|
||||
Qt::DisplayRole);
|
||||
}
|
||||
else if (role == Qt::DecorationRole)
|
||||
{
|
||||
return sourceModel()->data(
|
||||
sourceModel()->index(source_index.row(), GameListModel::COL_BANNER),
|
||||
Qt::DisplayRole).value<QPixmap>().scaled(
|
||||
LARGE_BANNER_SIZE,
|
||||
Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
}
|
||||
return QVariant();
|
||||
QModelIndex source_index = mapToSource(i);
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return sourceModel()->data(sourceModel()->index(source_index.row(), GameListModel::COL_TITLE),
|
||||
Qt::DisplayRole);
|
||||
}
|
||||
else if (role == Qt::DecorationRole)
|
||||
{
|
||||
return sourceModel()
|
||||
->data(sourceModel()->index(source_index.row(), GameListModel::COL_BANNER), Qt::DisplayRole)
|
||||
.value<QPixmap>()
|
||||
.scaled(LARGE_BANNER_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -8,9 +8,9 @@
|
||||
// single-column large icon + name to be displayed in a QListView.
|
||||
class ListProxyModel final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ListProxyModel(QObject* parent = nullptr);
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
explicit ListProxyModel(QObject* parent = nullptr);
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
};
|
||||
|
@ -4,91 +4,87 @@
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#include "DolphinQt2/Resources.h"
|
||||
#include "DolphinQt2/GameList/GameListModel.h"
|
||||
#include "DolphinQt2/GameList/TableDelegate.h"
|
||||
#include "DolphinQt2/Resources.h"
|
||||
|
||||
static QSize NORMAL_BANNER_SIZE(96, 32);
|
||||
|
||||
// Convert an integer size to a friendly string representation.
|
||||
static QString FormatSize(qint64 size)
|
||||
{
|
||||
QStringList units{
|
||||
QStringLiteral("KB"),
|
||||
QStringLiteral("MB"),
|
||||
QStringLiteral("GB"),
|
||||
QStringLiteral("TB")
|
||||
};
|
||||
QStringListIterator i(units);
|
||||
QString unit = QStringLiteral("B");
|
||||
double num = (double) size;
|
||||
while (num > 1024.0 && i.hasNext())
|
||||
{
|
||||
unit = i.next();
|
||||
num /= 1024.0;
|
||||
}
|
||||
return QStringLiteral("%1 %2").arg(QString::number(num, 'f', 1)).arg(unit);
|
||||
QStringList units{QStringLiteral("KB"), QStringLiteral("MB"), QStringLiteral("GB"),
|
||||
QStringLiteral("TB")};
|
||||
QStringListIterator i(units);
|
||||
QString unit = QStringLiteral("B");
|
||||
double num = (double)size;
|
||||
while (num > 1024.0 && i.hasNext())
|
||||
{
|
||||
unit = i.next();
|
||||
num /= 1024.0;
|
||||
}
|
||||
return QStringLiteral("%1 %2").arg(QString::number(num, 'f', 1)).arg(unit);
|
||||
}
|
||||
|
||||
TableDelegate::TableDelegate(QWidget* parent) : QStyledItemDelegate(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void TableDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
void TableDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
QVariant data = index.data(Qt::DisplayRole);
|
||||
switch (index.column())
|
||||
{
|
||||
case GameListModel::COL_PLATFORM:
|
||||
DrawPixmap(painter, option.rect, Resources::GetPlatform(data.toInt()));
|
||||
break;
|
||||
case GameListModel::COL_COUNTRY:
|
||||
DrawPixmap(painter, option.rect, Resources::GetCountry(data.toInt()));
|
||||
break;
|
||||
case GameListModel::COL_RATING:
|
||||
DrawPixmap(painter, option.rect, Resources::GetRating(data.toInt()));
|
||||
break;
|
||||
case GameListModel::COL_BANNER:
|
||||
DrawPixmap(painter, option.rect, data.value<QPixmap>().scaled(
|
||||
NORMAL_BANNER_SIZE,
|
||||
Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation));
|
||||
break;
|
||||
case GameListModel::COL_SIZE:
|
||||
painter->drawText(option.rect, Qt::AlignCenter, FormatSize(data.toULongLong()));
|
||||
break;
|
||||
// Fall through.
|
||||
case GameListModel::COL_ID:
|
||||
case GameListModel::COL_TITLE:
|
||||
case GameListModel::COL_DESCRIPTION:
|
||||
case GameListModel::COL_MAKER:
|
||||
painter->drawText(option.rect, Qt::AlignVCenter, data.toString());
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
QVariant data = index.data(Qt::DisplayRole);
|
||||
switch (index.column())
|
||||
{
|
||||
case GameListModel::COL_PLATFORM:
|
||||
DrawPixmap(painter, option.rect, Resources::GetPlatform(data.toInt()));
|
||||
break;
|
||||
case GameListModel::COL_COUNTRY:
|
||||
DrawPixmap(painter, option.rect, Resources::GetCountry(data.toInt()));
|
||||
break;
|
||||
case GameListModel::COL_RATING:
|
||||
DrawPixmap(painter, option.rect, Resources::GetRating(data.toInt()));
|
||||
break;
|
||||
case GameListModel::COL_BANNER:
|
||||
DrawPixmap(painter, option.rect,
|
||||
data.value<QPixmap>().scaled(NORMAL_BANNER_SIZE, Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation));
|
||||
break;
|
||||
case GameListModel::COL_SIZE:
|
||||
painter->drawText(option.rect, Qt::AlignCenter, FormatSize(data.toULongLong()));
|
||||
break;
|
||||
// Fall through.
|
||||
case GameListModel::COL_ID:
|
||||
case GameListModel::COL_TITLE:
|
||||
case GameListModel::COL_DESCRIPTION:
|
||||
case GameListModel::COL_MAKER:
|
||||
painter->drawText(option.rect, Qt::AlignVCenter, data.toString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QSize TableDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case GameListModel::COL_PLATFORM:
|
||||
return Resources::GetPlatform(0).size();
|
||||
case GameListModel::COL_COUNTRY:
|
||||
return Resources::GetCountry(0).size();
|
||||
case GameListModel::COL_RATING:
|
||||
return Resources::GetRating(0).size();
|
||||
case GameListModel::COL_BANNER:
|
||||
return NORMAL_BANNER_SIZE;
|
||||
default: return QSize(0, 0);
|
||||
}
|
||||
switch (index.column())
|
||||
{
|
||||
case GameListModel::COL_PLATFORM:
|
||||
return Resources::GetPlatform(0).size();
|
||||
case GameListModel::COL_COUNTRY:
|
||||
return Resources::GetCountry(0).size();
|
||||
case GameListModel::COL_RATING:
|
||||
return Resources::GetRating(0).size();
|
||||
case GameListModel::COL_BANNER:
|
||||
return NORMAL_BANNER_SIZE;
|
||||
default:
|
||||
return QSize(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void TableDelegate::DrawPixmap(QPainter* painter, const QRect& rect, const QPixmap& pixmap) const
|
||||
{
|
||||
// We don't want to stretch the pixmap out, so center it in the rect.
|
||||
painter->drawPixmap(
|
||||
rect.left() + (rect.width() - pixmap.width()) / 2,
|
||||
rect.top() + (rect.height() - pixmap.height()) / 2,
|
||||
pixmap);
|
||||
// We don't want to stretch the pixmap out, so center it in the rect.
|
||||
painter->drawPixmap(rect.left() + (rect.width() - pixmap.width()) / 2,
|
||||
rect.top() + (rect.height() - pixmap.height()) / 2, pixmap);
|
||||
}
|
||||
|
@ -8,13 +8,13 @@
|
||||
|
||||
class TableDelegate final : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TableDelegate(QWidget* parent = nullptr);
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
explicit TableDelegate(QWidget* parent = nullptr);
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
||||
|
||||
private:
|
||||
void DrawPixmap(QPainter* painter, const QRect& rect, const QPixmap& pixmap) const;
|
||||
void DrawPixmap(QPainter* painter, const QRect& rect, const QPixmap& pixmap) const;
|
||||
};
|
||||
|
@ -15,92 +15,116 @@ Host* Host::m_instance = nullptr;
|
||||
|
||||
Host* Host::GetInstance()
|
||||
{
|
||||
if (m_instance == nullptr)
|
||||
m_instance = new Host();
|
||||
return m_instance;
|
||||
if (m_instance == nullptr)
|
||||
m_instance = new Host();
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
void* Host::GetRenderHandle()
|
||||
{
|
||||
QMutexLocker locker(&m_lock);
|
||||
return m_render_handle;
|
||||
QMutexLocker locker(&m_lock);
|
||||
return m_render_handle;
|
||||
}
|
||||
|
||||
void Host::SetRenderHandle(void* handle)
|
||||
{
|
||||
QMutexLocker locker(&m_lock);
|
||||
m_render_handle = handle;
|
||||
QMutexLocker locker(&m_lock);
|
||||
m_render_handle = handle;
|
||||
}
|
||||
|
||||
bool Host::GetRenderFocus()
|
||||
{
|
||||
QMutexLocker locker(&m_lock);
|
||||
return m_render_focus;
|
||||
QMutexLocker locker(&m_lock);
|
||||
return m_render_focus;
|
||||
}
|
||||
|
||||
void Host::SetRenderFocus(bool focus)
|
||||
{
|
||||
QMutexLocker locker(&m_lock);
|
||||
m_render_focus = focus;
|
||||
QMutexLocker locker(&m_lock);
|
||||
m_render_focus = focus;
|
||||
}
|
||||
|
||||
bool Host::GetRenderFullscreen()
|
||||
{
|
||||
QMutexLocker locker(&m_lock);
|
||||
return m_render_fullscreen;
|
||||
QMutexLocker locker(&m_lock);
|
||||
return m_render_fullscreen;
|
||||
}
|
||||
|
||||
void Host::SetRenderFullscreen(bool fullscreen)
|
||||
{
|
||||
QMutexLocker locker(&m_lock);
|
||||
m_render_fullscreen = fullscreen;
|
||||
QMutexLocker locker(&m_lock);
|
||||
m_render_fullscreen = fullscreen;
|
||||
}
|
||||
|
||||
void Host_Message(int id)
|
||||
{
|
||||
if (id == WM_USER_STOP)
|
||||
{
|
||||
emit Host::GetInstance()->RequestStop();
|
||||
}
|
||||
else if (id == WM_USER_JOB_DISPATCH)
|
||||
{
|
||||
// Just poke the main thread to get it to wake up, job dispatch
|
||||
// will happen automatically before it goes back to sleep again.
|
||||
QAbstractEventDispatcher::instance(qApp->thread())->wakeUp();
|
||||
}
|
||||
if (id == WM_USER_STOP)
|
||||
{
|
||||
emit Host::GetInstance()->RequestStop();
|
||||
}
|
||||
else if (id == WM_USER_JOB_DISPATCH)
|
||||
{
|
||||
// Just poke the main thread to get it to wake up, job dispatch
|
||||
// will happen automatically before it goes back to sleep again.
|
||||
QAbstractEventDispatcher::instance(qApp->thread())->wakeUp();
|
||||
}
|
||||
}
|
||||
|
||||
void Host_UpdateTitle(const std::string& title)
|
||||
{
|
||||
emit Host::GetInstance()->RequestTitle(QString::fromStdString(title));
|
||||
emit Host::GetInstance()->RequestTitle(QString::fromStdString(title));
|
||||
}
|
||||
|
||||
void* Host_GetRenderHandle()
|
||||
{
|
||||
return Host::GetInstance()->GetRenderHandle();
|
||||
return Host::GetInstance()->GetRenderHandle();
|
||||
}
|
||||
|
||||
bool Host_RendererHasFocus()
|
||||
{
|
||||
return Host::GetInstance()->GetRenderFocus();
|
||||
return Host::GetInstance()->GetRenderFocus();
|
||||
}
|
||||
|
||||
bool Host_RendererIsFullscreen() {
|
||||
return Host::GetInstance()->GetRenderFullscreen();
|
||||
bool Host_RendererIsFullscreen()
|
||||
{
|
||||
return Host::GetInstance()->GetRenderFullscreen();
|
||||
}
|
||||
|
||||
// We ignore these, and their purpose should be questioned individually.
|
||||
// In particular, RequestRenderWindowSize, RequestFullscreen, and
|
||||
// UpdateMainFrame should almost certainly be removed.
|
||||
void Host_UpdateMainFrame() {}
|
||||
void Host_RequestFullscreen(bool enable) {}
|
||||
void Host_RequestRenderWindowSize(int w, int h) {}
|
||||
bool Host_UIHasFocus() { return false; }
|
||||
void Host_NotifyMapLoaded() {}
|
||||
void Host_UpdateDisasmDialog() {}
|
||||
void Host_SetStartupDebuggingParameters() {}
|
||||
void Host_SetWiiMoteConnectionState(int state) {}
|
||||
void Host_ConnectWiimote(int wm_idx, bool connect) {}
|
||||
void Host_UpdateMainFrame()
|
||||
{
|
||||
}
|
||||
void Host_RequestFullscreen(bool enable)
|
||||
{
|
||||
}
|
||||
void Host_RequestRenderWindowSize(int w, int h)
|
||||
{
|
||||
}
|
||||
bool Host_UIHasFocus()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
void Host_NotifyMapLoaded()
|
||||
{
|
||||
}
|
||||
void Host_UpdateDisasmDialog()
|
||||
{
|
||||
}
|
||||
void Host_SetStartupDebuggingParameters()
|
||||
{
|
||||
}
|
||||
void Host_SetWiiMoteConnectionState(int state)
|
||||
{
|
||||
}
|
||||
void Host_ConnectWiimote(int wm_idx, bool connect)
|
||||
{
|
||||
}
|
||||
void Host_ShowVideoConfig(void* parent, const std::string& backend_name,
|
||||
const std::string& config_name) {}
|
||||
void Host_RefreshDSPDebuggerWindow() {}
|
||||
const std::string& config_name)
|
||||
{
|
||||
}
|
||||
void Host_RefreshDSPDebuggerWindow()
|
||||
{
|
||||
}
|
||||
|
@ -15,31 +15,31 @@
|
||||
// Many of the Host_* functions are ignored, and some shouldn't exist.
|
||||
class Host final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static Host* GetInstance();
|
||||
static Host* GetInstance();
|
||||
|
||||
void* GetRenderHandle();
|
||||
bool GetRenderFocus();
|
||||
bool GetRenderFullscreen();
|
||||
void* GetRenderHandle();
|
||||
bool GetRenderFocus();
|
||||
bool GetRenderFullscreen();
|
||||
|
||||
public slots:
|
||||
void SetRenderHandle(void* handle);
|
||||
void SetRenderFocus(bool focus);
|
||||
void SetRenderFullscreen(bool fullscreen);
|
||||
void SetRenderHandle(void* handle);
|
||||
void SetRenderFocus(bool focus);
|
||||
void SetRenderFullscreen(bool fullscreen);
|
||||
|
||||
signals:
|
||||
void RequestTitle(const QString& title);
|
||||
void RequestStop();
|
||||
void RequestRenderSize(int w, int h);
|
||||
void RequestTitle(const QString& title);
|
||||
void RequestStop();
|
||||
void RequestRenderSize(int w, int h);
|
||||
|
||||
private:
|
||||
Host() {}
|
||||
static Host* m_instance;
|
||||
QMutex m_lock;
|
||||
Host() {}
|
||||
static Host* m_instance;
|
||||
QMutex m_lock;
|
||||
|
||||
void* m_render_handle;
|
||||
bool m_render_focus;
|
||||
bool m_render_fullscreen;
|
||||
void* m_render_handle;
|
||||
bool m_render_focus;
|
||||
bool m_render_fullscreen;
|
||||
};
|
||||
|
@ -14,27 +14,26 @@
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
QApplication app(argc, argv);
|
||||
|
||||
UICommon::SetUserDirectory("");
|
||||
UICommon::CreateDirectories();
|
||||
UICommon::Init();
|
||||
Resources::Init();
|
||||
UICommon::SetUserDirectory("");
|
||||
UICommon::CreateDirectories();
|
||||
UICommon::Init();
|
||||
Resources::Init();
|
||||
|
||||
// Whenever the event loop is about to go to sleep, dispatch the jobs
|
||||
// queued in the Core first.
|
||||
QObject::connect(QAbstractEventDispatcher::instance(),
|
||||
&QAbstractEventDispatcher::aboutToBlock,
|
||||
&app, &Core::HostDispatchJobs);
|
||||
// Whenever the event loop is about to go to sleep, dispatch the jobs
|
||||
// queued in the Core first.
|
||||
QObject::connect(QAbstractEventDispatcher::instance(), &QAbstractEventDispatcher::aboutToBlock,
|
||||
&app, &Core::HostDispatchJobs);
|
||||
|
||||
MainWindow win;
|
||||
win.show();
|
||||
int retval = app.exec();
|
||||
MainWindow win;
|
||||
win.show();
|
||||
int retval = app.exec();
|
||||
|
||||
BootManager::Stop();
|
||||
Core::Shutdown();
|
||||
UICommon::Shutdown();
|
||||
Host::GetInstance()->deleteLater();
|
||||
BootManager::Stop();
|
||||
Core::Shutdown();
|
||||
UICommon::Shutdown();
|
||||
Host::GetInstance()->deleteLater();
|
||||
|
||||
return retval;
|
||||
return retval;
|
||||
}
|
||||
|
@ -9,372 +9,371 @@
|
||||
|
||||
#include "Core/BootManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HW/ProcessorInterface.h"
|
||||
#include "Core/Movie.h"
|
||||
#include "Core/State.h"
|
||||
#include "Core/HW/ProcessorInterface.h"
|
||||
|
||||
#include "DolphinQt2/AboutDialog.h"
|
||||
#include "DolphinQt2/Config/PathDialog.h"
|
||||
#include "DolphinQt2/Config/SettingsWindow.h"
|
||||
#include "DolphinQt2/Host.h"
|
||||
#include "DolphinQt2/MainWindow.h"
|
||||
#include "DolphinQt2/Resources.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "DolphinQt2/Config/PathDialog.h"
|
||||
#include "DolphinQt2/Config/SettingsWindow.h"
|
||||
|
||||
MainWindow::MainWindow() : QMainWindow(nullptr)
|
||||
{
|
||||
setWindowTitle(tr("Dolphin"));
|
||||
setWindowIcon(QIcon(Resources::GetMisc(Resources::LOGO_SMALL)));
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
setWindowTitle(tr("Dolphin"));
|
||||
setWindowIcon(QIcon(Resources::GetMisc(Resources::LOGO_SMALL)));
|
||||
setUnifiedTitleAndToolBarOnMac(true);
|
||||
|
||||
CreateComponents();
|
||||
CreateComponents();
|
||||
|
||||
ConnectGameList();
|
||||
ConnectPathsDialog();
|
||||
ConnectToolBar();
|
||||
ConnectRenderWidget();
|
||||
ConnectStack();
|
||||
ConnectMenuBar();
|
||||
ConnectGameList();
|
||||
ConnectPathsDialog();
|
||||
ConnectToolBar();
|
||||
ConnectRenderWidget();
|
||||
ConnectStack();
|
||||
ConnectMenuBar();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
m_render_widget->deleteLater();
|
||||
m_render_widget->deleteLater();
|
||||
}
|
||||
|
||||
void MainWindow::CreateComponents()
|
||||
{
|
||||
m_menu_bar = new MenuBar(this);
|
||||
m_tool_bar = new ToolBar(this);
|
||||
m_game_list = new GameList(this);
|
||||
m_render_widget = new RenderWidget;
|
||||
m_stack = new QStackedWidget(this);
|
||||
m_paths_dialog = new PathDialog(this);
|
||||
m_settings_window = new SettingsWindow(this);
|
||||
m_menu_bar = new MenuBar(this);
|
||||
m_tool_bar = new ToolBar(this);
|
||||
m_game_list = new GameList(this);
|
||||
m_render_widget = new RenderWidget;
|
||||
m_stack = new QStackedWidget(this);
|
||||
m_paths_dialog = new PathDialog(this);
|
||||
m_settings_window = new SettingsWindow(this);
|
||||
}
|
||||
|
||||
void MainWindow::ConnectMenuBar()
|
||||
{
|
||||
setMenuBar(m_menu_bar);
|
||||
// File
|
||||
connect(m_menu_bar, &MenuBar::Open, this, &MainWindow::Open);
|
||||
connect(m_menu_bar, &MenuBar::Exit, this, &MainWindow::close);
|
||||
setMenuBar(m_menu_bar);
|
||||
// File
|
||||
connect(m_menu_bar, &MenuBar::Open, this, &MainWindow::Open);
|
||||
connect(m_menu_bar, &MenuBar::Exit, this, &MainWindow::close);
|
||||
|
||||
// Emulation
|
||||
connect(m_menu_bar, &MenuBar::Pause, this, &MainWindow::Pause);
|
||||
connect(m_menu_bar, &MenuBar::Play, this, &MainWindow::Play);
|
||||
connect(m_menu_bar, &MenuBar::Stop, this, &MainWindow::Stop);
|
||||
connect(m_menu_bar, &MenuBar::Reset, this, &MainWindow::Reset);
|
||||
connect(m_menu_bar, &MenuBar::Fullscreen, this, &MainWindow::FullScreen);
|
||||
connect(m_menu_bar, &MenuBar::FrameAdvance, this, &MainWindow::FrameAdvance);
|
||||
connect(m_menu_bar, &MenuBar::Screenshot, this, &MainWindow::ScreenShot);
|
||||
connect(m_menu_bar, &MenuBar::StateLoad, this, &MainWindow::StateLoad);
|
||||
connect(m_menu_bar, &MenuBar::StateSave, this, &MainWindow::StateSave);
|
||||
connect(m_menu_bar, &MenuBar::StateLoadSlot, this, &MainWindow::StateLoadSlot);
|
||||
connect(m_menu_bar, &MenuBar::StateSaveSlot, this, &MainWindow::StateSaveSlot);
|
||||
connect(m_menu_bar, &MenuBar::StateLoadSlotAt, this, &MainWindow::StateLoadSlotAt);
|
||||
connect(m_menu_bar, &MenuBar::StateSaveSlotAt, this, &MainWindow::StateSaveSlotAt);
|
||||
connect(m_menu_bar, &MenuBar::StateLoadUndo, this, &MainWindow::StateLoadUndo);
|
||||
connect(m_menu_bar, &MenuBar::StateSaveUndo, this, &MainWindow::StateSaveUndo);
|
||||
connect(m_menu_bar, &MenuBar::StateSaveOldest, this, &MainWindow::StateSaveOldest);
|
||||
connect(m_menu_bar, &MenuBar::SetStateSlot, this, &MainWindow::SetStateSlot);
|
||||
// Emulation
|
||||
connect(m_menu_bar, &MenuBar::Pause, this, &MainWindow::Pause);
|
||||
connect(m_menu_bar, &MenuBar::Play, this, &MainWindow::Play);
|
||||
connect(m_menu_bar, &MenuBar::Stop, this, &MainWindow::Stop);
|
||||
connect(m_menu_bar, &MenuBar::Reset, this, &MainWindow::Reset);
|
||||
connect(m_menu_bar, &MenuBar::Fullscreen, this, &MainWindow::FullScreen);
|
||||
connect(m_menu_bar, &MenuBar::FrameAdvance, this, &MainWindow::FrameAdvance);
|
||||
connect(m_menu_bar, &MenuBar::Screenshot, this, &MainWindow::ScreenShot);
|
||||
connect(m_menu_bar, &MenuBar::StateLoad, this, &MainWindow::StateLoad);
|
||||
connect(m_menu_bar, &MenuBar::StateSave, this, &MainWindow::StateSave);
|
||||
connect(m_menu_bar, &MenuBar::StateLoadSlot, this, &MainWindow::StateLoadSlot);
|
||||
connect(m_menu_bar, &MenuBar::StateSaveSlot, this, &MainWindow::StateSaveSlot);
|
||||
connect(m_menu_bar, &MenuBar::StateLoadSlotAt, this, &MainWindow::StateLoadSlotAt);
|
||||
connect(m_menu_bar, &MenuBar::StateSaveSlotAt, this, &MainWindow::StateSaveSlotAt);
|
||||
connect(m_menu_bar, &MenuBar::StateLoadUndo, this, &MainWindow::StateLoadUndo);
|
||||
connect(m_menu_bar, &MenuBar::StateSaveUndo, this, &MainWindow::StateSaveUndo);
|
||||
connect(m_menu_bar, &MenuBar::StateSaveOldest, this, &MainWindow::StateSaveOldest);
|
||||
connect(m_menu_bar, &MenuBar::SetStateSlot, this, &MainWindow::SetStateSlot);
|
||||
|
||||
// View
|
||||
connect(m_menu_bar, &MenuBar::ShowTable, m_game_list, &GameList::SetTableView);
|
||||
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
|
||||
connect(m_menu_bar, &MenuBar::ShowAboutDialog, this, &MainWindow::ShowAboutDialog);
|
||||
// View
|
||||
connect(m_menu_bar, &MenuBar::ShowTable, m_game_list, &GameList::SetTableView);
|
||||
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
|
||||
connect(m_menu_bar, &MenuBar::ShowAboutDialog, this, &MainWindow::ShowAboutDialog);
|
||||
|
||||
connect(this, &MainWindow::EmulationStarted, m_menu_bar, &MenuBar::EmulationStarted);
|
||||
connect(this, &MainWindow::EmulationPaused, m_menu_bar, &MenuBar::EmulationPaused);
|
||||
connect(this, &MainWindow::EmulationStopped, m_menu_bar, &MenuBar::EmulationStopped);
|
||||
connect(this, &MainWindow::EmulationStarted, m_menu_bar, &MenuBar::EmulationStarted);
|
||||
connect(this, &MainWindow::EmulationPaused, m_menu_bar, &MenuBar::EmulationPaused);
|
||||
connect(this, &MainWindow::EmulationStopped, m_menu_bar, &MenuBar::EmulationStopped);
|
||||
}
|
||||
|
||||
void MainWindow::ConnectToolBar()
|
||||
{
|
||||
addToolBar(m_tool_bar);
|
||||
connect(m_tool_bar, &ToolBar::OpenPressed, this, &MainWindow::Open);
|
||||
connect(m_tool_bar, &ToolBar::PlayPressed, this, &MainWindow::Play);
|
||||
connect(m_tool_bar, &ToolBar::PausePressed, this, &MainWindow::Pause);
|
||||
connect(m_tool_bar, &ToolBar::StopPressed, this, &MainWindow::Stop);
|
||||
connect(m_tool_bar, &ToolBar::FullScreenPressed, this, &MainWindow::FullScreen);
|
||||
connect(m_tool_bar, &ToolBar::ScreenShotPressed, this, &MainWindow::ScreenShot);
|
||||
connect(m_tool_bar, &ToolBar::PathsPressed, this, &MainWindow::ShowPathsDialog);
|
||||
connect(m_tool_bar, &ToolBar::SettingsPressed, this, &MainWindow::ShowSettingsWindow);
|
||||
addToolBar(m_tool_bar);
|
||||
connect(m_tool_bar, &ToolBar::OpenPressed, this, &MainWindow::Open);
|
||||
connect(m_tool_bar, &ToolBar::PlayPressed, this, &MainWindow::Play);
|
||||
connect(m_tool_bar, &ToolBar::PausePressed, this, &MainWindow::Pause);
|
||||
connect(m_tool_bar, &ToolBar::StopPressed, this, &MainWindow::Stop);
|
||||
connect(m_tool_bar, &ToolBar::FullScreenPressed, this, &MainWindow::FullScreen);
|
||||
connect(m_tool_bar, &ToolBar::ScreenShotPressed, this, &MainWindow::ScreenShot);
|
||||
connect(m_tool_bar, &ToolBar::PathsPressed, this, &MainWindow::ShowPathsDialog);
|
||||
connect(m_tool_bar, &ToolBar::SettingsPressed, this, &MainWindow::ShowSettingsWindow);
|
||||
|
||||
connect(this, &MainWindow::EmulationStarted, m_tool_bar, &ToolBar::EmulationStarted);
|
||||
connect(this, &MainWindow::EmulationPaused, m_tool_bar, &ToolBar::EmulationPaused);
|
||||
connect(this, &MainWindow::EmulationStopped, m_tool_bar, &ToolBar::EmulationStopped);
|
||||
connect(this, &MainWindow::EmulationStarted, m_tool_bar, &ToolBar::EmulationStarted);
|
||||
connect(this, &MainWindow::EmulationPaused, m_tool_bar, &ToolBar::EmulationPaused);
|
||||
connect(this, &MainWindow::EmulationStopped, m_tool_bar, &ToolBar::EmulationStopped);
|
||||
}
|
||||
|
||||
void MainWindow::ConnectGameList()
|
||||
{
|
||||
connect(m_game_list, &GameList::GameSelected, this, &MainWindow::Play);
|
||||
connect(m_game_list, &GameList::GameSelected, this, &MainWindow::Play);
|
||||
}
|
||||
|
||||
void MainWindow::ConnectRenderWidget()
|
||||
{
|
||||
m_rendering_to_main = false;
|
||||
m_render_widget->hide();
|
||||
connect(m_render_widget, &RenderWidget::EscapePressed, this, &MainWindow::Stop);
|
||||
connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
|
||||
m_rendering_to_main = false;
|
||||
m_render_widget->hide();
|
||||
connect(m_render_widget, &RenderWidget::EscapePressed, this, &MainWindow::Stop);
|
||||
connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
|
||||
}
|
||||
|
||||
void MainWindow::ConnectStack()
|
||||
{
|
||||
m_stack->setMinimumSize(800, 600);
|
||||
m_stack->addWidget(m_game_list);
|
||||
setCentralWidget(m_stack);
|
||||
m_stack->setMinimumSize(800, 600);
|
||||
m_stack->addWidget(m_game_list);
|
||||
setCentralWidget(m_stack);
|
||||
}
|
||||
|
||||
void MainWindow::ConnectPathsDialog()
|
||||
{
|
||||
connect(m_paths_dialog, &PathDialog::PathAdded, m_game_list, &GameList::DirectoryAdded);
|
||||
connect(m_paths_dialog, &PathDialog::PathRemoved, m_game_list, &GameList::DirectoryRemoved);
|
||||
connect(m_paths_dialog, &PathDialog::PathAdded, m_game_list, &GameList::DirectoryAdded);
|
||||
connect(m_paths_dialog, &PathDialog::PathRemoved, m_game_list, &GameList::DirectoryRemoved);
|
||||
}
|
||||
|
||||
void MainWindow::Open()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this,
|
||||
tr("Select a File"),
|
||||
QDir::currentPath(),
|
||||
tr("All GC/Wii files (*.elf *.dol *.gcm *.iso *.wbfs *.ciso *.gcz *.wad);;"
|
||||
"All Files (*)"));
|
||||
if (!file.isEmpty())
|
||||
StartGame(file);
|
||||
QString file = QFileDialog::getOpenFileName(
|
||||
this, tr("Select a File"), QDir::currentPath(),
|
||||
tr("All GC/Wii files (*.elf *.dol *.gcm *.iso *.wbfs *.ciso *.gcz *.wad);;"
|
||||
"All Files (*)"));
|
||||
if (!file.isEmpty())
|
||||
StartGame(file);
|
||||
}
|
||||
|
||||
void MainWindow::Play()
|
||||
{
|
||||
// If we're in a paused game, start it up again.
|
||||
// Otherwise, play the selected game, if there is one.
|
||||
// Otherwise, play the default game.
|
||||
// Otherwise, play the last played game, if there is one.
|
||||
// Otherwise, prompt for a new game.
|
||||
if (Core::GetState() == Core::CORE_PAUSE)
|
||||
{
|
||||
Core::SetState(Core::CORE_RUN);
|
||||
emit EmulationStarted();
|
||||
}
|
||||
else
|
||||
{
|
||||
QString selection = m_game_list->GetSelectedGame();
|
||||
if (selection.length() > 0)
|
||||
{
|
||||
StartGame(selection);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString default_path = Settings().GetDefaultGame();
|
||||
if (!default_path.isEmpty() && QFile::exists(default_path))
|
||||
{
|
||||
StartGame(default_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString last_path = Settings().GetLastGame();
|
||||
if (!last_path.isEmpty() && QFile::exists(last_path))
|
||||
StartGame(last_path);
|
||||
else
|
||||
Open();
|
||||
}
|
||||
}
|
||||
}
|
||||
// If we're in a paused game, start it up again.
|
||||
// Otherwise, play the selected game, if there is one.
|
||||
// Otherwise, play the default game.
|
||||
// Otherwise, play the last played game, if there is one.
|
||||
// Otherwise, prompt for a new game.
|
||||
if (Core::GetState() == Core::CORE_PAUSE)
|
||||
{
|
||||
Core::SetState(Core::CORE_RUN);
|
||||
emit EmulationStarted();
|
||||
}
|
||||
else
|
||||
{
|
||||
QString selection = m_game_list->GetSelectedGame();
|
||||
if (selection.length() > 0)
|
||||
{
|
||||
StartGame(selection);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString default_path = Settings().GetDefaultGame();
|
||||
if (!default_path.isEmpty() && QFile::exists(default_path))
|
||||
{
|
||||
StartGame(default_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString last_path = Settings().GetLastGame();
|
||||
if (!last_path.isEmpty() && QFile::exists(last_path))
|
||||
StartGame(last_path);
|
||||
else
|
||||
Open();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::Pause()
|
||||
{
|
||||
Core::SetState(Core::CORE_PAUSE);
|
||||
emit EmulationPaused();
|
||||
Core::SetState(Core::CORE_PAUSE);
|
||||
emit EmulationPaused();
|
||||
}
|
||||
|
||||
bool MainWindow::Stop()
|
||||
{
|
||||
bool stop = true;
|
||||
if (Settings().GetConfirmStop())
|
||||
{
|
||||
// We could pause the game here and resume it if they say no.
|
||||
QMessageBox::StandardButton confirm;
|
||||
confirm = QMessageBox::question(m_render_widget, tr("Confirm"), tr("Stop emulation?"));
|
||||
stop = (confirm == QMessageBox::Yes);
|
||||
}
|
||||
bool stop = true;
|
||||
if (Settings().GetConfirmStop())
|
||||
{
|
||||
// We could pause the game here and resume it if they say no.
|
||||
QMessageBox::StandardButton confirm;
|
||||
confirm = QMessageBox::question(m_render_widget, tr("Confirm"), tr("Stop emulation?"));
|
||||
stop = (confirm == QMessageBox::Yes);
|
||||
}
|
||||
|
||||
if (stop)
|
||||
ForceStop();
|
||||
if (stop)
|
||||
ForceStop();
|
||||
|
||||
return stop;
|
||||
return stop;
|
||||
}
|
||||
|
||||
void MainWindow::ForceStop()
|
||||
{
|
||||
BootManager::Stop();
|
||||
HideRenderWidget();
|
||||
emit EmulationStopped();
|
||||
BootManager::Stop();
|
||||
HideRenderWidget();
|
||||
emit EmulationStopped();
|
||||
}
|
||||
|
||||
void MainWindow::Reset()
|
||||
{
|
||||
if (Movie::IsRecordingInput())
|
||||
Movie::g_bReset = true;
|
||||
ProcessorInterface::ResetButton_Tap();
|
||||
if (Movie::IsRecordingInput())
|
||||
Movie::g_bReset = true;
|
||||
ProcessorInterface::ResetButton_Tap();
|
||||
}
|
||||
|
||||
void MainWindow::FrameAdvance()
|
||||
{
|
||||
Movie::DoFrameStep();
|
||||
EmulationPaused();
|
||||
Movie::DoFrameStep();
|
||||
EmulationPaused();
|
||||
}
|
||||
|
||||
void MainWindow::FullScreen()
|
||||
{
|
||||
// If the render widget is fullscreen we want to reset it to whatever is in
|
||||
// settings. If it's set to be fullscreen then it just remakes the window,
|
||||
// which probably isn't ideal.
|
||||
bool was_fullscreen = m_render_widget->isFullScreen();
|
||||
HideRenderWidget();
|
||||
if (was_fullscreen)
|
||||
ShowRenderWidget();
|
||||
else
|
||||
m_render_widget->showFullScreen();
|
||||
// If the render widget is fullscreen we want to reset it to whatever is in
|
||||
// settings. If it's set to be fullscreen then it just remakes the window,
|
||||
// which probably isn't ideal.
|
||||
bool was_fullscreen = m_render_widget->isFullScreen();
|
||||
HideRenderWidget();
|
||||
if (was_fullscreen)
|
||||
ShowRenderWidget();
|
||||
else
|
||||
m_render_widget->showFullScreen();
|
||||
}
|
||||
|
||||
void MainWindow::ScreenShot()
|
||||
{
|
||||
Core::SaveScreenShot();
|
||||
Core::SaveScreenShot();
|
||||
}
|
||||
|
||||
void MainWindow::StartGame(const QString& path)
|
||||
{
|
||||
// If we're running, only start a new game once we've stopped the last.
|
||||
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
||||
{
|
||||
if (!Stop())
|
||||
return;
|
||||
}
|
||||
// Boot up, show an error if it fails to load the game.
|
||||
if (!BootManager::BootCore(path.toStdString()))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
Settings().SetLastGame(path);
|
||||
ShowRenderWidget();
|
||||
emit EmulationStarted();
|
||||
// If we're running, only start a new game once we've stopped the last.
|
||||
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
||||
{
|
||||
if (!Stop())
|
||||
return;
|
||||
}
|
||||
// Boot up, show an error if it fails to load the game.
|
||||
if (!BootManager::BootCore(path.toStdString()))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
Settings().SetLastGame(path);
|
||||
ShowRenderWidget();
|
||||
emit EmulationStarted();
|
||||
}
|
||||
|
||||
void MainWindow::ShowRenderWidget()
|
||||
{
|
||||
Settings settings;
|
||||
if (settings.GetRenderToMain())
|
||||
{
|
||||
// If we're rendering to main, add it to the stack and update our title when necessary.
|
||||
m_rendering_to_main = true;
|
||||
m_stack->setCurrentIndex(m_stack->addWidget(m_render_widget));
|
||||
connect(Host::GetInstance(), &Host::RequestTitle, this, &MainWindow::setWindowTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, just show it.
|
||||
m_rendering_to_main = false;
|
||||
if (settings.GetFullScreen())
|
||||
{
|
||||
m_render_widget->showFullScreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_render_widget->setFixedSize(settings.GetRenderWindowSize());
|
||||
m_render_widget->showNormal();
|
||||
}
|
||||
}
|
||||
Settings settings;
|
||||
if (settings.GetRenderToMain())
|
||||
{
|
||||
// If we're rendering to main, add it to the stack and update our title when necessary.
|
||||
m_rendering_to_main = true;
|
||||
m_stack->setCurrentIndex(m_stack->addWidget(m_render_widget));
|
||||
connect(Host::GetInstance(), &Host::RequestTitle, this, &MainWindow::setWindowTitle);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, just show it.
|
||||
m_rendering_to_main = false;
|
||||
if (settings.GetFullScreen())
|
||||
{
|
||||
m_render_widget->showFullScreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_render_widget->setFixedSize(settings.GetRenderWindowSize());
|
||||
m_render_widget->showNormal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::HideRenderWidget()
|
||||
{
|
||||
if (m_rendering_to_main)
|
||||
{
|
||||
// Remove the widget from the stack and reparent it to nullptr, so that it can draw
|
||||
// itself in a new window if it wants. Disconnect the title updates.
|
||||
m_stack->removeWidget(m_render_widget);
|
||||
m_render_widget->setParent(nullptr);
|
||||
m_rendering_to_main = false;
|
||||
disconnect(Host::GetInstance(), &Host::RequestTitle, this, &MainWindow::setWindowTitle);
|
||||
setWindowTitle(tr("Dolphin"));
|
||||
}
|
||||
m_render_widget->hide();
|
||||
if (m_rendering_to_main)
|
||||
{
|
||||
// Remove the widget from the stack and reparent it to nullptr, so that it can draw
|
||||
// itself in a new window if it wants. Disconnect the title updates.
|
||||
m_stack->removeWidget(m_render_widget);
|
||||
m_render_widget->setParent(nullptr);
|
||||
m_rendering_to_main = false;
|
||||
disconnect(Host::GetInstance(), &Host::RequestTitle, this, &MainWindow::setWindowTitle);
|
||||
setWindowTitle(tr("Dolphin"));
|
||||
}
|
||||
m_render_widget->hide();
|
||||
}
|
||||
|
||||
void MainWindow::ShowPathsDialog()
|
||||
{
|
||||
m_paths_dialog->show();
|
||||
m_paths_dialog->raise();
|
||||
m_paths_dialog->activateWindow();
|
||||
m_paths_dialog->show();
|
||||
m_paths_dialog->raise();
|
||||
m_paths_dialog->activateWindow();
|
||||
}
|
||||
|
||||
void MainWindow::ShowSettingsWindow()
|
||||
{
|
||||
m_settings_window->show();
|
||||
m_settings_window->raise();
|
||||
m_settings_window->activateWindow();
|
||||
m_settings_window->show();
|
||||
m_settings_window->raise();
|
||||
m_settings_window->activateWindow();
|
||||
}
|
||||
|
||||
void MainWindow::ShowAboutDialog()
|
||||
{
|
||||
AboutDialog* about = new AboutDialog(this);
|
||||
about->show();
|
||||
AboutDialog* about = new AboutDialog(this);
|
||||
about->show();
|
||||
}
|
||||
|
||||
void MainWindow::StateLoad()
|
||||
{
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Select a File"), QDir::currentPath(),
|
||||
tr("All Save States (*.sav *.s##);; All Files (*)"));
|
||||
State::LoadAs(path.toStdString());
|
||||
QString path = QFileDialog::getOpenFileName(this, tr("Select a File"), QDir::currentPath(),
|
||||
tr("All Save States (*.sav *.s##);; All Files (*)"));
|
||||
State::LoadAs(path.toStdString());
|
||||
}
|
||||
|
||||
void MainWindow::StateSave()
|
||||
{
|
||||
QString path = QFileDialog::getSaveFileName(this, tr("Select a File"), QDir::currentPath(),
|
||||
tr("All Save States (*.sav *.s##);; All Files (*)"));
|
||||
State::SaveAs(path.toStdString());
|
||||
QString path = QFileDialog::getSaveFileName(this, tr("Select a File"), QDir::currentPath(),
|
||||
tr("All Save States (*.sav *.s##);; All Files (*)"));
|
||||
State::SaveAs(path.toStdString());
|
||||
}
|
||||
|
||||
void MainWindow::StateLoadSlot()
|
||||
{
|
||||
State::Load(m_state_slot);
|
||||
State::Load(m_state_slot);
|
||||
}
|
||||
|
||||
void MainWindow::StateSaveSlot()
|
||||
{
|
||||
State::Save(m_state_slot, true);
|
||||
m_menu_bar->UpdateStateSlotMenu();
|
||||
State::Save(m_state_slot, true);
|
||||
m_menu_bar->UpdateStateSlotMenu();
|
||||
}
|
||||
|
||||
void MainWindow::StateLoadSlotAt(int slot)
|
||||
{
|
||||
State::Load(slot);
|
||||
State::Load(slot);
|
||||
}
|
||||
|
||||
void MainWindow::StateSaveSlotAt(int slot)
|
||||
{
|
||||
State::Save(slot, true);
|
||||
m_menu_bar->UpdateStateSlotMenu();
|
||||
State::Save(slot, true);
|
||||
m_menu_bar->UpdateStateSlotMenu();
|
||||
}
|
||||
|
||||
void MainWindow::StateLoadUndo()
|
||||
{
|
||||
State::UndoLoadState();
|
||||
State::UndoLoadState();
|
||||
}
|
||||
|
||||
void MainWindow::StateSaveUndo()
|
||||
{
|
||||
State::UndoSaveState();
|
||||
State::UndoSaveState();
|
||||
}
|
||||
|
||||
void MainWindow::StateSaveOldest()
|
||||
{
|
||||
State::SaveFirstSaved();
|
||||
State::SaveFirstSaved();
|
||||
}
|
||||
|
||||
void MainWindow::SetStateSlot(int slot)
|
||||
{
|
||||
Settings().SetStateSlot(slot);
|
||||
m_state_slot = slot;
|
||||
Settings().SetStateSlot(slot);
|
||||
m_state_slot = slot;
|
||||
}
|
||||
|
@ -9,77 +9,77 @@
|
||||
#include <QString>
|
||||
#include <QToolBar>
|
||||
|
||||
#include "DolphinQt2/GameList/GameList.h"
|
||||
#include "DolphinQt2/MenuBar.h"
|
||||
#include "DolphinQt2/RenderWidget.h"
|
||||
#include "DolphinQt2/ToolBar.h"
|
||||
#include "DolphinQt2/GameList/GameList.h"
|
||||
|
||||
class PathDialog;
|
||||
class SettingsWindow;
|
||||
|
||||
class MainWindow final : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow();
|
||||
~MainWindow();
|
||||
explicit MainWindow();
|
||||
~MainWindow();
|
||||
|
||||
signals:
|
||||
void EmulationStarted();
|
||||
void EmulationPaused();
|
||||
void EmulationStopped();
|
||||
void EmulationStarted();
|
||||
void EmulationPaused();
|
||||
void EmulationStopped();
|
||||
|
||||
private slots:
|
||||
void Open();
|
||||
void Play();
|
||||
void Pause();
|
||||
void Open();
|
||||
void Play();
|
||||
void Pause();
|
||||
|
||||
// May ask for confirmation. Returns whether or not it actually stopped.
|
||||
bool Stop();
|
||||
void ForceStop();
|
||||
void Reset();
|
||||
void FrameAdvance();
|
||||
void StateLoad();
|
||||
void StateSave();
|
||||
void StateLoadSlot();
|
||||
void StateSaveSlot();
|
||||
void StateLoadSlotAt(int slot);
|
||||
void StateSaveSlotAt(int slot);
|
||||
void StateLoadUndo();
|
||||
void StateSaveUndo();
|
||||
void StateSaveOldest();
|
||||
void SetStateSlot(int slot);
|
||||
// May ask for confirmation. Returns whether or not it actually stopped.
|
||||
bool Stop();
|
||||
void ForceStop();
|
||||
void Reset();
|
||||
void FrameAdvance();
|
||||
void StateLoad();
|
||||
void StateSave();
|
||||
void StateLoadSlot();
|
||||
void StateSaveSlot();
|
||||
void StateLoadSlotAt(int slot);
|
||||
void StateSaveSlotAt(int slot);
|
||||
void StateLoadUndo();
|
||||
void StateSaveUndo();
|
||||
void StateSaveOldest();
|
||||
void SetStateSlot(int slot);
|
||||
|
||||
void FullScreen();
|
||||
void ScreenShot();
|
||||
void FullScreen();
|
||||
void ScreenShot();
|
||||
|
||||
private:
|
||||
void CreateComponents();
|
||||
void CreateComponents();
|
||||
|
||||
void ConnectGameList();
|
||||
void ConnectMenuBar();
|
||||
void ConnectRenderWidget();
|
||||
void ConnectStack();
|
||||
void ConnectToolBar();
|
||||
void ConnectPathsDialog();
|
||||
void ConnectGameList();
|
||||
void ConnectMenuBar();
|
||||
void ConnectRenderWidget();
|
||||
void ConnectStack();
|
||||
void ConnectToolBar();
|
||||
void ConnectPathsDialog();
|
||||
|
||||
void StartGame(const QString& path);
|
||||
void ShowRenderWidget();
|
||||
void HideRenderWidget();
|
||||
void StartGame(const QString& path);
|
||||
void ShowRenderWidget();
|
||||
void HideRenderWidget();
|
||||
|
||||
void ShowPathsDialog();
|
||||
void ShowSettingsWindow();
|
||||
void ShowAboutDialog();
|
||||
void ShowPathsDialog();
|
||||
void ShowSettingsWindow();
|
||||
void ShowAboutDialog();
|
||||
|
||||
QStackedWidget* m_stack;
|
||||
ToolBar* m_tool_bar;
|
||||
MenuBar* m_menu_bar;
|
||||
GameList* m_game_list;
|
||||
RenderWidget* m_render_widget;
|
||||
bool m_rendering_to_main;
|
||||
int m_state_slot = 1;
|
||||
QStackedWidget* m_stack;
|
||||
ToolBar* m_tool_bar;
|
||||
MenuBar* m_menu_bar;
|
||||
GameList* m_game_list;
|
||||
RenderWidget* m_render_widget;
|
||||
bool m_rendering_to_main;
|
||||
int m_state_slot = 1;
|
||||
|
||||
PathDialog* m_paths_dialog;
|
||||
SettingsWindow* m_settings_window;
|
||||
PathDialog* m_paths_dialog;
|
||||
SettingsWindow* m_settings_window;
|
||||
};
|
||||
|
@ -11,215 +11,198 @@
|
||||
#include "DolphinQt2/MenuBar.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
|
||||
MenuBar::MenuBar(QWidget* parent)
|
||||
: QMenuBar(parent)
|
||||
MenuBar::MenuBar(QWidget* parent) : QMenuBar(parent)
|
||||
{
|
||||
AddFileMenu();
|
||||
AddEmulationMenu();
|
||||
addMenu(tr("Movie"));
|
||||
addMenu(tr("Options"));
|
||||
addMenu(tr("Tools"));
|
||||
AddViewMenu();
|
||||
AddHelpMenu();
|
||||
AddFileMenu();
|
||||
AddEmulationMenu();
|
||||
addMenu(tr("Movie"));
|
||||
addMenu(tr("Options"));
|
||||
addMenu(tr("Tools"));
|
||||
AddViewMenu();
|
||||
AddHelpMenu();
|
||||
|
||||
EmulationStopped();
|
||||
EmulationStopped();
|
||||
}
|
||||
|
||||
void MenuBar::EmulationStarted()
|
||||
{
|
||||
// Emulation
|
||||
m_play_action->setEnabled(false);
|
||||
m_play_action->setVisible(false);
|
||||
m_pause_action->setEnabled(true);
|
||||
m_pause_action->setVisible(true);
|
||||
m_stop_action->setEnabled(true);
|
||||
m_reset_action->setEnabled(true);
|
||||
m_fullscreen_action->setEnabled(true);
|
||||
m_frame_advance_action->setEnabled(true);
|
||||
m_screenshot_action->setEnabled(true);
|
||||
m_state_load_menu->setEnabled(true);
|
||||
m_state_save_menu->setEnabled(true);
|
||||
UpdateStateSlotMenu();
|
||||
// Emulation
|
||||
m_play_action->setEnabled(false);
|
||||
m_play_action->setVisible(false);
|
||||
m_pause_action->setEnabled(true);
|
||||
m_pause_action->setVisible(true);
|
||||
m_stop_action->setEnabled(true);
|
||||
m_reset_action->setEnabled(true);
|
||||
m_fullscreen_action->setEnabled(true);
|
||||
m_frame_advance_action->setEnabled(true);
|
||||
m_screenshot_action->setEnabled(true);
|
||||
m_state_load_menu->setEnabled(true);
|
||||
m_state_save_menu->setEnabled(true);
|
||||
UpdateStateSlotMenu();
|
||||
}
|
||||
void MenuBar::EmulationPaused()
|
||||
{
|
||||
m_play_action->setEnabled(true);
|
||||
m_play_action->setVisible(true);
|
||||
m_pause_action->setEnabled(false);
|
||||
m_pause_action->setVisible(false);
|
||||
m_play_action->setEnabled(true);
|
||||
m_play_action->setVisible(true);
|
||||
m_pause_action->setEnabled(false);
|
||||
m_pause_action->setVisible(false);
|
||||
}
|
||||
void MenuBar::EmulationStopped()
|
||||
{
|
||||
// Emulation
|
||||
m_play_action->setEnabled(true);
|
||||
m_play_action->setVisible(true);
|
||||
m_pause_action->setEnabled(false);
|
||||
m_pause_action->setVisible(false);
|
||||
m_stop_action->setEnabled(false);
|
||||
m_reset_action->setEnabled(false);
|
||||
m_fullscreen_action->setEnabled(false);
|
||||
m_frame_advance_action->setEnabled(false);
|
||||
m_screenshot_action->setEnabled(false);
|
||||
m_state_load_menu->setEnabled(false);
|
||||
m_state_save_menu->setEnabled(false);
|
||||
UpdateStateSlotMenu();
|
||||
// Emulation
|
||||
m_play_action->setEnabled(true);
|
||||
m_play_action->setVisible(true);
|
||||
m_pause_action->setEnabled(false);
|
||||
m_pause_action->setVisible(false);
|
||||
m_stop_action->setEnabled(false);
|
||||
m_reset_action->setEnabled(false);
|
||||
m_fullscreen_action->setEnabled(false);
|
||||
m_frame_advance_action->setEnabled(false);
|
||||
m_screenshot_action->setEnabled(false);
|
||||
m_state_load_menu->setEnabled(false);
|
||||
m_state_save_menu->setEnabled(false);
|
||||
UpdateStateSlotMenu();
|
||||
}
|
||||
|
||||
void MenuBar::AddFileMenu()
|
||||
{
|
||||
QMenu* file_menu = addMenu(tr("File"));
|
||||
m_open_action = file_menu->addAction(tr("Open"), this, SIGNAL(Open()));
|
||||
m_exit_action = file_menu->addAction(tr("Exit"), this, SIGNAL(Exit()));
|
||||
QMenu* file_menu = addMenu(tr("File"));
|
||||
m_open_action = file_menu->addAction(tr("Open"), this, SIGNAL(Open()));
|
||||
m_exit_action = file_menu->addAction(tr("Exit"), this, SIGNAL(Exit()));
|
||||
}
|
||||
|
||||
void MenuBar::AddEmulationMenu()
|
||||
{
|
||||
QMenu* emu_menu = addMenu(tr("Emulation"));
|
||||
m_play_action = emu_menu->addAction(tr("Play"), this, SIGNAL(Play()));
|
||||
m_pause_action = emu_menu->addAction(tr("Pause"), this, SIGNAL(Pause()));
|
||||
m_stop_action = emu_menu->addAction(tr("Stop"), this, SIGNAL(Stop()));
|
||||
m_reset_action = emu_menu->addAction(tr("Reset"), this, SIGNAL(Reset()));
|
||||
m_fullscreen_action = emu_menu->addAction(tr("Fullscreen"), this, SIGNAL(Fullscreen()));
|
||||
m_frame_advance_action = emu_menu->addAction(tr("Frame Advance"), this, SIGNAL(FrameAdvance()));
|
||||
m_screenshot_action = emu_menu->addAction(tr("Take Screenshot"), this, SIGNAL(Screenshot()));
|
||||
AddStateLoadMenu(emu_menu);
|
||||
AddStateSaveMenu(emu_menu);
|
||||
AddStateSlotMenu(emu_menu);
|
||||
UpdateStateSlotMenu();
|
||||
QMenu* emu_menu = addMenu(tr("Emulation"));
|
||||
m_play_action = emu_menu->addAction(tr("Play"), this, SIGNAL(Play()));
|
||||
m_pause_action = emu_menu->addAction(tr("Pause"), this, SIGNAL(Pause()));
|
||||
m_stop_action = emu_menu->addAction(tr("Stop"), this, SIGNAL(Stop()));
|
||||
m_reset_action = emu_menu->addAction(tr("Reset"), this, SIGNAL(Reset()));
|
||||
m_fullscreen_action = emu_menu->addAction(tr("Fullscreen"), this, SIGNAL(Fullscreen()));
|
||||
m_frame_advance_action = emu_menu->addAction(tr("Frame Advance"), this, SIGNAL(FrameAdvance()));
|
||||
m_screenshot_action = emu_menu->addAction(tr("Take Screenshot"), this, SIGNAL(Screenshot()));
|
||||
AddStateLoadMenu(emu_menu);
|
||||
AddStateSaveMenu(emu_menu);
|
||||
AddStateSlotMenu(emu_menu);
|
||||
UpdateStateSlotMenu();
|
||||
}
|
||||
|
||||
void MenuBar::AddStateLoadMenu(QMenu* emu_menu)
|
||||
{
|
||||
m_state_load_menu = emu_menu->addMenu(tr("Load State"));
|
||||
m_state_load_menu->addAction(tr("Load State from File"), this, SIGNAL(StateLoad()));
|
||||
m_state_load_menu->addAction(tr("Load State from Selected Slot"), this, SIGNAL(StateLoadSlot()));
|
||||
m_state_load_slots_menu = m_state_load_menu->addMenu(tr("Load State from Slot"));
|
||||
m_state_load_menu->addAction(tr("Undo Load State"), this, SIGNAL(StateLoadUndo()));
|
||||
m_state_load_menu = emu_menu->addMenu(tr("Load State"));
|
||||
m_state_load_menu->addAction(tr("Load State from File"), this, SIGNAL(StateLoad()));
|
||||
m_state_load_menu->addAction(tr("Load State from Selected Slot"), this, SIGNAL(StateLoadSlot()));
|
||||
m_state_load_slots_menu = m_state_load_menu->addMenu(tr("Load State from Slot"));
|
||||
m_state_load_menu->addAction(tr("Undo Load State"), this, SIGNAL(StateLoadUndo()));
|
||||
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
QAction* action = m_state_load_slots_menu->addAction(QStringLiteral(""));
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
QAction* action = m_state_load_slots_menu->addAction(QStringLiteral(""));
|
||||
|
||||
connect(action, &QAction::triggered, this, [=]() {
|
||||
emit StateLoadSlotAt(i);
|
||||
});
|
||||
}
|
||||
connect(action, &QAction::triggered, this, [=]() { emit StateLoadSlotAt(i); });
|
||||
}
|
||||
}
|
||||
|
||||
void MenuBar::AddStateSaveMenu(QMenu* emu_menu)
|
||||
{
|
||||
m_state_save_menu = emu_menu->addMenu(tr("Save State"));
|
||||
m_state_save_menu->addAction(tr("Save State to File"), this, SIGNAL(StateSave()));
|
||||
m_state_save_menu->addAction(tr("Save State to Selected Slot"), this, SIGNAL(StateSaveSlot()));
|
||||
m_state_save_menu->addAction(tr("Save State to Oldest Slot"), this, SIGNAL(StateSaveOldest()));
|
||||
m_state_save_slots_menu = m_state_save_menu->addMenu(tr("Save State to Slot"));
|
||||
m_state_save_menu->addAction(tr("Undo Save State"), this, SIGNAL(StateSaveUndo()));
|
||||
m_state_save_menu = emu_menu->addMenu(tr("Save State"));
|
||||
m_state_save_menu->addAction(tr("Save State to File"), this, SIGNAL(StateSave()));
|
||||
m_state_save_menu->addAction(tr("Save State to Selected Slot"), this, SIGNAL(StateSaveSlot()));
|
||||
m_state_save_menu->addAction(tr("Save State to Oldest Slot"), this, SIGNAL(StateSaveOldest()));
|
||||
m_state_save_slots_menu = m_state_save_menu->addMenu(tr("Save State to Slot"));
|
||||
m_state_save_menu->addAction(tr("Undo Save State"), this, SIGNAL(StateSaveUndo()));
|
||||
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
QAction* action = m_state_save_slots_menu->addAction(QStringLiteral(""));
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
QAction* action = m_state_save_slots_menu->addAction(QStringLiteral(""));
|
||||
|
||||
connect(action, &QAction::triggered, this, [=]() {
|
||||
emit StateSaveSlotAt(i);
|
||||
});
|
||||
}
|
||||
connect(action, &QAction::triggered, this, [=]() { emit StateSaveSlotAt(i); });
|
||||
}
|
||||
}
|
||||
|
||||
void MenuBar::AddStateSlotMenu(QMenu* emu_menu)
|
||||
{
|
||||
m_state_slot_menu = emu_menu->addMenu(tr("Select State Slot"));
|
||||
m_state_slots = new QActionGroup(this);
|
||||
m_state_slot_menu = emu_menu->addMenu(tr("Select State Slot"));
|
||||
m_state_slots = new QActionGroup(this);
|
||||
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
QAction* action = m_state_slot_menu->addAction(QStringLiteral(""));
|
||||
action->setCheckable(true);
|
||||
action->setActionGroup(m_state_slots);
|
||||
if (Settings().GetStateSlot() == i)
|
||||
action->setChecked(true);
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
QAction* action = m_state_slot_menu->addAction(QStringLiteral(""));
|
||||
action->setCheckable(true);
|
||||
action->setActionGroup(m_state_slots);
|
||||
if (Settings().GetStateSlot() == i)
|
||||
action->setChecked(true);
|
||||
|
||||
connect(action, &QAction::triggered, this, [=]() {
|
||||
emit SetStateSlot(i);
|
||||
});
|
||||
}
|
||||
connect(action, &QAction::triggered, this, [=]() { emit SetStateSlot(i); });
|
||||
}
|
||||
}
|
||||
|
||||
void MenuBar::UpdateStateSlotMenu()
|
||||
{
|
||||
QList<QAction*> actions_slot = m_state_slots->actions();
|
||||
QList<QAction*> actions_load = m_state_load_slots_menu->actions();
|
||||
QList<QAction*> actions_save = m_state_save_slots_menu->actions();
|
||||
for (int i = 0; i < actions_slot.length(); i++)
|
||||
{
|
||||
int slot = i + 1;
|
||||
QString info = QString::fromStdString(State::GetInfoStringOfSlot(slot));
|
||||
QString action_string = tr(" Slot %1 - %2").arg(slot).arg(info);
|
||||
actions_load.at(i)->setText(tr("Load from") + action_string);
|
||||
actions_save.at(i)->setText(tr("Save to") + action_string);
|
||||
actions_slot.at(i)->setText(tr("Select") + action_string);
|
||||
}
|
||||
QList<QAction*> actions_slot = m_state_slots->actions();
|
||||
QList<QAction*> actions_load = m_state_load_slots_menu->actions();
|
||||
QList<QAction*> actions_save = m_state_save_slots_menu->actions();
|
||||
for (int i = 0; i < actions_slot.length(); i++)
|
||||
{
|
||||
int slot = i + 1;
|
||||
QString info = QString::fromStdString(State::GetInfoStringOfSlot(slot));
|
||||
QString action_string = tr(" Slot %1 - %2").arg(slot).arg(info);
|
||||
actions_load.at(i)->setText(tr("Load from") + action_string);
|
||||
actions_save.at(i)->setText(tr("Save to") + action_string);
|
||||
actions_slot.at(i)->setText(tr("Select") + action_string);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuBar::AddViewMenu()
|
||||
{
|
||||
QMenu* view_menu = addMenu(tr("View"));
|
||||
AddGameListTypeSection(view_menu);
|
||||
view_menu->addSeparator();
|
||||
AddTableColumnsMenu(view_menu);
|
||||
QMenu* view_menu = addMenu(tr("View"));
|
||||
AddGameListTypeSection(view_menu);
|
||||
view_menu->addSeparator();
|
||||
AddTableColumnsMenu(view_menu);
|
||||
}
|
||||
|
||||
void MenuBar::AddHelpMenu()
|
||||
{
|
||||
QMenu* help_menu = addMenu(tr("Help"));
|
||||
QAction* documentation = help_menu->addAction(tr("Online Documentation"));
|
||||
connect(documentation, &QAction::triggered, this, [=]() {
|
||||
QDesktopServices::openUrl(QUrl(QStringLiteral("https://dolphin-emu.org/docs/guides")));
|
||||
});
|
||||
help_menu->addAction(tr("About"), this, SIGNAL(ShowAboutDialog()));
|
||||
QMenu* help_menu = addMenu(tr("Help"));
|
||||
QAction* documentation = help_menu->addAction(tr("Online Documentation"));
|
||||
connect(documentation, &QAction::triggered, this, [=]() {
|
||||
QDesktopServices::openUrl(QUrl(QStringLiteral("https://dolphin-emu.org/docs/guides")));
|
||||
});
|
||||
help_menu->addAction(tr("About"), this, SIGNAL(ShowAboutDialog()));
|
||||
}
|
||||
|
||||
|
||||
void MenuBar::AddGameListTypeSection(QMenu* view_menu)
|
||||
{
|
||||
QAction* table_view = view_menu->addAction(tr("Table"));
|
||||
table_view->setCheckable(true);
|
||||
QAction* table_view = view_menu->addAction(tr("Table"));
|
||||
table_view->setCheckable(true);
|
||||
|
||||
QAction* list_view = view_menu->addAction(tr("List"));
|
||||
list_view->setCheckable(true);
|
||||
QAction* list_view = view_menu->addAction(tr("List"));
|
||||
list_view->setCheckable(true);
|
||||
|
||||
QActionGroup* list_group = new QActionGroup(this);
|
||||
list_group->addAction(table_view);
|
||||
list_group->addAction(list_view);
|
||||
QActionGroup* list_group = new QActionGroup(this);
|
||||
list_group->addAction(table_view);
|
||||
list_group->addAction(list_view);
|
||||
|
||||
bool prefer_table = Settings().GetPreferredView();
|
||||
table_view->setChecked(prefer_table);
|
||||
list_view->setChecked(!prefer_table);
|
||||
bool prefer_table = Settings().GetPreferredView();
|
||||
table_view->setChecked(prefer_table);
|
||||
list_view->setChecked(!prefer_table);
|
||||
|
||||
connect(table_view, &QAction::triggered, this, &MenuBar::ShowTable);
|
||||
connect(list_view, &QAction::triggered, this, &MenuBar::ShowList);
|
||||
connect(table_view, &QAction::triggered, this, &MenuBar::ShowTable);
|
||||
connect(list_view, &QAction::triggered, this, &MenuBar::ShowList);
|
||||
}
|
||||
|
||||
// TODO implement this
|
||||
void MenuBar::AddTableColumnsMenu(QMenu* view_menu)
|
||||
{
|
||||
QActionGroup* column_group = new QActionGroup(this);
|
||||
QMenu* cols_menu = view_menu->addMenu(tr("Table Columns"));
|
||||
column_group->setExclusive(false);
|
||||
QActionGroup* column_group = new QActionGroup(this);
|
||||
QMenu* cols_menu = view_menu->addMenu(tr("Table Columns"));
|
||||
column_group->setExclusive(false);
|
||||
|
||||
QStringList col_names{
|
||||
tr("Platform"),
|
||||
tr("ID"),
|
||||
tr("Banner"),
|
||||
tr("Title"),
|
||||
tr("Description"),
|
||||
tr("Maker"),
|
||||
tr("Size"),
|
||||
tr("Country"),
|
||||
tr("Quality")
|
||||
};
|
||||
for (int i = 0; i < col_names.count(); i++)
|
||||
{
|
||||
QAction* action = column_group->addAction(cols_menu->addAction(col_names[i]));
|
||||
action->setCheckable(true);
|
||||
}
|
||||
QStringList col_names{tr("Platform"), tr("ID"), tr("Banner"), tr("Title"), tr("Description"),
|
||||
tr("Maker"), tr("Size"), tr("Country"), tr("Quality")};
|
||||
for (int i = 0; i < col_names.count(); i++)
|
||||
{
|
||||
QAction* action = column_group->addAction(cols_menu->addAction(col_names[i]));
|
||||
action->setCheckable(true);
|
||||
}
|
||||
}
|
||||
|
@ -9,77 +9,77 @@
|
||||
|
||||
class MenuBar final : public QMenuBar
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MenuBar(QWidget* parent = nullptr);
|
||||
explicit MenuBar(QWidget* parent = nullptr);
|
||||
|
||||
signals:
|
||||
// File
|
||||
void Open();
|
||||
void Exit();
|
||||
// File
|
||||
void Open();
|
||||
void Exit();
|
||||
|
||||
// Emulation
|
||||
void Play();
|
||||
void Pause();
|
||||
void Stop();
|
||||
void Reset();
|
||||
void Fullscreen();
|
||||
void FrameAdvance();
|
||||
void Screenshot();
|
||||
void StateLoad();
|
||||
void StateSave();
|
||||
void StateLoadSlot();
|
||||
void StateSaveSlot();
|
||||
void StateLoadSlotAt(int slot);
|
||||
void StateSaveSlotAt(int slot);
|
||||
void StateLoadUndo();
|
||||
void StateSaveUndo();
|
||||
void StateSaveOldest();
|
||||
void SetStateSlot(int slot);
|
||||
// Emulation
|
||||
void Play();
|
||||
void Pause();
|
||||
void Stop();
|
||||
void Reset();
|
||||
void Fullscreen();
|
||||
void FrameAdvance();
|
||||
void Screenshot();
|
||||
void StateLoad();
|
||||
void StateSave();
|
||||
void StateLoadSlot();
|
||||
void StateSaveSlot();
|
||||
void StateLoadSlotAt(int slot);
|
||||
void StateSaveSlotAt(int slot);
|
||||
void StateLoadUndo();
|
||||
void StateSaveUndo();
|
||||
void StateSaveOldest();
|
||||
void SetStateSlot(int slot);
|
||||
|
||||
// View
|
||||
void ShowTable();
|
||||
void ShowList();
|
||||
// View
|
||||
void ShowTable();
|
||||
void ShowList();
|
||||
|
||||
void ShowAboutDialog();
|
||||
void ShowAboutDialog();
|
||||
|
||||
public slots:
|
||||
void EmulationStarted();
|
||||
void EmulationPaused();
|
||||
void EmulationStopped();
|
||||
void UpdateStateSlotMenu();
|
||||
void EmulationStarted();
|
||||
void EmulationPaused();
|
||||
void EmulationStopped();
|
||||
void UpdateStateSlotMenu();
|
||||
|
||||
private:
|
||||
void AddFileMenu();
|
||||
void AddFileMenu();
|
||||
|
||||
void AddEmulationMenu();
|
||||
void AddStateLoadMenu(QMenu* emu_menu);
|
||||
void AddStateSaveMenu(QMenu* emu_menu);
|
||||
void AddStateSlotMenu(QMenu* emu_menu);
|
||||
void AddEmulationMenu();
|
||||
void AddStateLoadMenu(QMenu* emu_menu);
|
||||
void AddStateSaveMenu(QMenu* emu_menu);
|
||||
void AddStateSlotMenu(QMenu* emu_menu);
|
||||
|
||||
void AddViewMenu();
|
||||
void AddGameListTypeSection(QMenu* view_menu);
|
||||
void AddTableColumnsMenu(QMenu* view_menu);
|
||||
void AddViewMenu();
|
||||
void AddGameListTypeSection(QMenu* view_menu);
|
||||
void AddTableColumnsMenu(QMenu* view_menu);
|
||||
|
||||
void AddHelpMenu();
|
||||
void AddHelpMenu();
|
||||
|
||||
// File
|
||||
QAction* m_open_action;
|
||||
QAction* m_exit_action;
|
||||
// File
|
||||
QAction* m_open_action;
|
||||
QAction* m_exit_action;
|
||||
|
||||
// Emulation
|
||||
QAction* m_play_action;
|
||||
QAction* m_pause_action;
|
||||
QAction* m_stop_action;
|
||||
QAction* m_reset_action;
|
||||
QAction* m_fullscreen_action;
|
||||
QAction* m_frame_advance_action;
|
||||
QAction* m_screenshot_action;
|
||||
QMenu* m_state_load_menu;
|
||||
QMenu* m_state_save_menu;
|
||||
QMenu* m_state_slot_menu;
|
||||
QActionGroup* m_state_slots;
|
||||
QMenu* m_state_load_slots_menu;
|
||||
QMenu* m_state_save_slots_menu;
|
||||
// Emulation
|
||||
QAction* m_play_action;
|
||||
QAction* m_pause_action;
|
||||
QAction* m_stop_action;
|
||||
QAction* m_reset_action;
|
||||
QAction* m_fullscreen_action;
|
||||
QAction* m_frame_advance_action;
|
||||
QAction* m_screenshot_action;
|
||||
QMenu* m_state_load_menu;
|
||||
QMenu* m_state_save_menu;
|
||||
QMenu* m_state_slot_menu;
|
||||
QActionGroup* m_state_slots;
|
||||
QMenu* m_state_load_slots_menu;
|
||||
QMenu* m_state_save_slots_menu;
|
||||
};
|
||||
|
@ -7,45 +7,44 @@
|
||||
#include "DolphinQt2/Host.h"
|
||||
#include "DolphinQt2/RenderWidget.h"
|
||||
|
||||
RenderWidget::RenderWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
|
||||
{
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
||||
|
||||
connect(Host::GetInstance(), &Host::RequestTitle, this, &RenderWidget::setWindowTitle);
|
||||
connect(this, &RenderWidget::FocusChanged, Host::GetInstance(), &Host::SetRenderFocus);
|
||||
connect(this, &RenderWidget::StateChanged, Host::GetInstance(), &Host::SetRenderFullscreen);
|
||||
connect(this, &RenderWidget::HandleChanged, Host::GetInstance(), &Host::SetRenderHandle);
|
||||
emit HandleChanged((void*) winId());
|
||||
connect(Host::GetInstance(), &Host::RequestTitle, this, &RenderWidget::setWindowTitle);
|
||||
connect(this, &RenderWidget::FocusChanged, Host::GetInstance(), &Host::SetRenderFocus);
|
||||
connect(this, &RenderWidget::StateChanged, Host::GetInstance(), &Host::SetRenderFullscreen);
|
||||
connect(this, &RenderWidget::HandleChanged, Host::GetInstance(), &Host::SetRenderHandle);
|
||||
emit HandleChanged((void*)winId());
|
||||
}
|
||||
|
||||
bool RenderWidget::event(QEvent* event)
|
||||
{
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::KeyPress:
|
||||
{
|
||||
QKeyEvent* ke = static_cast<QKeyEvent*>(event);
|
||||
if (ke->key() == Qt::Key_Escape)
|
||||
emit EscapePressed();
|
||||
break;
|
||||
}
|
||||
case QEvent::WinIdChange:
|
||||
emit HandleChanged((void*) winId());
|
||||
break;
|
||||
case QEvent::FocusIn:
|
||||
case QEvent::FocusOut:
|
||||
emit FocusChanged(hasFocus());
|
||||
break;
|
||||
case QEvent::WindowStateChange:
|
||||
emit StateChanged(isFullScreen());
|
||||
break;
|
||||
case QEvent::Close:
|
||||
emit Closed();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QWidget::event(event);
|
||||
switch (event->type())
|
||||
{
|
||||
case QEvent::KeyPress:
|
||||
{
|
||||
QKeyEvent* ke = static_cast<QKeyEvent*>(event);
|
||||
if (ke->key() == Qt::Key_Escape)
|
||||
emit EscapePressed();
|
||||
break;
|
||||
}
|
||||
case QEvent::WinIdChange:
|
||||
emit HandleChanged((void*)winId());
|
||||
break;
|
||||
case QEvent::FocusIn:
|
||||
case QEvent::FocusOut:
|
||||
emit FocusChanged(hasFocus());
|
||||
break;
|
||||
case QEvent::WindowStateChange:
|
||||
emit StateChanged(isFullScreen());
|
||||
break;
|
||||
case QEvent::Close:
|
||||
emit Closed();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
@ -9,17 +9,17 @@
|
||||
|
||||
class RenderWidget final : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RenderWidget(QWidget* parent = nullptr);
|
||||
explicit RenderWidget(QWidget* parent = nullptr);
|
||||
|
||||
bool event(QEvent* event);
|
||||
bool event(QEvent* event);
|
||||
|
||||
signals:
|
||||
void EscapePressed();
|
||||
void Closed();
|
||||
void HandleChanged(void* handle);
|
||||
void FocusChanged(bool focus);
|
||||
void StateChanged(bool fullscreen);
|
||||
void EscapePressed();
|
||||
void Closed();
|
||||
void HandleChanged(void* handle);
|
||||
void FocusChanged(bool focus);
|
||||
void StateChanged(bool fullscreen);
|
||||
};
|
||||
|
@ -15,68 +15,51 @@ QList<QPixmap> Resources::m_misc;
|
||||
|
||||
void Resources::Init()
|
||||
{
|
||||
QString sys_dir = QString::fromStdString(File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP);
|
||||
QString sys_dir = QString::fromStdString(File::GetSysDirectory() + RESOURCES_DIR + DIR_SEP);
|
||||
|
||||
QStringList platforms{
|
||||
QStringLiteral("Platform_Gamecube.png"),
|
||||
QStringLiteral("Platform_Wii.png"),
|
||||
QStringLiteral("Platform_Wad.png"),
|
||||
QStringLiteral("Platform_File.png")
|
||||
};
|
||||
for (QString platform : platforms)
|
||||
m_platforms.append(QPixmap(platform.prepend(sys_dir)));
|
||||
QStringList platforms{QStringLiteral("Platform_Gamecube.png"), QStringLiteral("Platform_Wii.png"),
|
||||
QStringLiteral("Platform_Wad.png"), QStringLiteral("Platform_File.png")};
|
||||
for (QString platform : platforms)
|
||||
m_platforms.append(QPixmap(platform.prepend(sys_dir)));
|
||||
|
||||
QStringList countries{
|
||||
QStringLiteral("Flag_Europe.png"),
|
||||
QStringLiteral("Flag_Japan.png"),
|
||||
QStringLiteral("Flag_USA.png"),
|
||||
QStringLiteral("Flag_Australia.png"),
|
||||
QStringLiteral("Flag_France.png"),
|
||||
QStringLiteral("Flag_Germany.png"),
|
||||
QStringLiteral("Flag_Italy.png"),
|
||||
QStringLiteral("Flag_Korea.png"),
|
||||
QStringLiteral("Flag_Netherlands.png"),
|
||||
QStringLiteral("Flag_Russia.png"),
|
||||
QStringLiteral("Flag_Spain.png"),
|
||||
QStringLiteral("Flag_Taiwan.png"),
|
||||
QStringLiteral("Flag_International.png"),
|
||||
QStringLiteral("Flag_Unknown.png")
|
||||
};
|
||||
for (QString country : countries)
|
||||
m_countries.append(QPixmap(country.prepend(sys_dir)));
|
||||
QStringList countries{
|
||||
QStringLiteral("Flag_Europe.png"), QStringLiteral("Flag_Japan.png"),
|
||||
QStringLiteral("Flag_USA.png"), QStringLiteral("Flag_Australia.png"),
|
||||
QStringLiteral("Flag_France.png"), QStringLiteral("Flag_Germany.png"),
|
||||
QStringLiteral("Flag_Italy.png"), QStringLiteral("Flag_Korea.png"),
|
||||
QStringLiteral("Flag_Netherlands.png"), QStringLiteral("Flag_Russia.png"),
|
||||
QStringLiteral("Flag_Spain.png"), QStringLiteral("Flag_Taiwan.png"),
|
||||
QStringLiteral("Flag_International.png"), QStringLiteral("Flag_Unknown.png")};
|
||||
for (QString country : countries)
|
||||
m_countries.append(QPixmap(country.prepend(sys_dir)));
|
||||
|
||||
QStringList ratings{
|
||||
QStringLiteral("rating0.png"),
|
||||
QStringLiteral("rating1.png"),
|
||||
QStringLiteral("rating2.png"),
|
||||
QStringLiteral("rating3.png"),
|
||||
QStringLiteral("rating4.png"),
|
||||
QStringLiteral("rating5.png")
|
||||
};
|
||||
for (QString rating : ratings)
|
||||
m_ratings.append(QPixmap(rating.prepend(sys_dir)));
|
||||
QStringList ratings{QStringLiteral("rating0.png"), QStringLiteral("rating1.png"),
|
||||
QStringLiteral("rating2.png"), QStringLiteral("rating3.png"),
|
||||
QStringLiteral("rating4.png"), QStringLiteral("rating5.png")};
|
||||
for (QString rating : ratings)
|
||||
m_ratings.append(QPixmap(rating.prepend(sys_dir)));
|
||||
|
||||
m_misc.append(QPixmap(QStringLiteral("nobanner.png").prepend(sys_dir)));
|
||||
m_misc.append(QPixmap(QStringLiteral("dolphin_logo.png").prepend(sys_dir)));
|
||||
m_misc.append(QPixmap(QStringLiteral("Dolphin.png").prepend(sys_dir)));
|
||||
m_misc.append(QPixmap(QStringLiteral("nobanner.png").prepend(sys_dir)));
|
||||
m_misc.append(QPixmap(QStringLiteral("dolphin_logo.png").prepend(sys_dir)));
|
||||
m_misc.append(QPixmap(QStringLiteral("Dolphin.png").prepend(sys_dir)));
|
||||
}
|
||||
|
||||
QPixmap Resources::GetPlatform(int platform)
|
||||
{
|
||||
return m_platforms[platform];
|
||||
return m_platforms[platform];
|
||||
}
|
||||
|
||||
QPixmap Resources::GetCountry(int country)
|
||||
{
|
||||
return m_countries[country];
|
||||
return m_countries[country];
|
||||
}
|
||||
|
||||
QPixmap Resources::GetRating(int rating)
|
||||
{
|
||||
return m_ratings[rating];
|
||||
return m_ratings[rating];
|
||||
}
|
||||
|
||||
QPixmap Resources::GetMisc(int id)
|
||||
{
|
||||
return m_misc[id];
|
||||
return m_misc[id];
|
||||
}
|
||||
|
@ -11,26 +11,25 @@
|
||||
class Resources final
|
||||
{
|
||||
public:
|
||||
static void Init();
|
||||
static void Init();
|
||||
|
||||
static QPixmap GetPlatform(int platform);
|
||||
static QPixmap GetCountry(int country);
|
||||
static QPixmap GetRating(int rating);
|
||||
static QPixmap GetPlatform(int platform);
|
||||
static QPixmap GetCountry(int country);
|
||||
static QPixmap GetRating(int rating);
|
||||
|
||||
static QPixmap GetMisc(int id);
|
||||
static QPixmap GetMisc(int id);
|
||||
|
||||
enum
|
||||
{
|
||||
BANNER_MISSING,
|
||||
LOGO_LARGE,
|
||||
LOGO_SMALL
|
||||
};
|
||||
enum
|
||||
{
|
||||
BANNER_MISSING,
|
||||
LOGO_LARGE,
|
||||
LOGO_SMALL
|
||||
};
|
||||
|
||||
private:
|
||||
Resources() {}
|
||||
|
||||
static QList<QPixmap> m_platforms;
|
||||
static QList<QPixmap> m_countries;
|
||||
static QList<QPixmap> m_ratings;
|
||||
static QList<QPixmap> m_misc;
|
||||
Resources() {}
|
||||
static QList<QPixmap> m_platforms;
|
||||
static QList<QPixmap> m_countries;
|
||||
static QList<QPixmap> m_ratings;
|
||||
static QList<QPixmap> m_misc;
|
||||
};
|
||||
|
@ -10,137 +10,136 @@
|
||||
|
||||
static QString GetSettingsPath()
|
||||
{
|
||||
return QString::fromStdString(File::GetUserPath(D_CONFIG_IDX)) + QStringLiteral("/UI.ini");
|
||||
return QString::fromStdString(File::GetUserPath(D_CONFIG_IDX)) + QStringLiteral("/UI.ini");
|
||||
}
|
||||
|
||||
Settings::Settings(QObject* parent)
|
||||
: QSettings(GetSettingsPath(), QSettings::IniFormat, parent)
|
||||
Settings::Settings(QObject* parent) : QSettings(GetSettingsPath(), QSettings::IniFormat, parent)
|
||||
{
|
||||
}
|
||||
|
||||
QString Settings::GetThemeDir() const
|
||||
{
|
||||
QString theme_name = value(QStringLiteral("Theme"), QStringLiteral("Clean")).toString();
|
||||
return QString::fromStdString(File::GetThemeDir(theme_name.toStdString()));
|
||||
QString theme_name = value(QStringLiteral("Theme"), QStringLiteral("Clean")).toString();
|
||||
return QString::fromStdString(File::GetThemeDir(theme_name.toStdString()));
|
||||
}
|
||||
|
||||
QString Settings::GetLastGame() const
|
||||
{
|
||||
return value(QStringLiteral("GameList/LastGame")).toString();
|
||||
return value(QStringLiteral("GameList/LastGame")).toString();
|
||||
}
|
||||
|
||||
void Settings::SetLastGame(const QString& path)
|
||||
{
|
||||
setValue(QStringLiteral("GameList/LastGame"), path);
|
||||
setValue(QStringLiteral("GameList/LastGame"), path);
|
||||
}
|
||||
|
||||
QStringList Settings::GetPaths() const
|
||||
{
|
||||
return value(QStringLiteral("GameList/Paths")).toStringList();
|
||||
return value(QStringLiteral("GameList/Paths")).toStringList();
|
||||
}
|
||||
|
||||
void Settings::SetPaths(const QStringList& paths)
|
||||
{
|
||||
setValue(QStringLiteral("GameList/Paths"), paths);
|
||||
setValue(QStringLiteral("GameList/Paths"), paths);
|
||||
}
|
||||
|
||||
void Settings::RemovePath(int i)
|
||||
{
|
||||
QStringList paths = GetPaths();
|
||||
paths.removeAt(i);
|
||||
SetPaths(paths);
|
||||
QStringList paths = GetPaths();
|
||||
paths.removeAt(i);
|
||||
SetPaths(paths);
|
||||
}
|
||||
|
||||
QString Settings::GetDefaultGame() const
|
||||
{
|
||||
return QString::fromStdString(SConfig::GetInstance().m_strDefaultISO);
|
||||
return QString::fromStdString(SConfig::GetInstance().m_strDefaultISO);
|
||||
}
|
||||
|
||||
void Settings::SetDefaultGame(const QString& path)
|
||||
{
|
||||
SConfig::GetInstance().m_strDefaultISO = path.toStdString();
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
SConfig::GetInstance().m_strDefaultISO = path.toStdString();
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
QString Settings::GetDVDRoot() const
|
||||
{
|
||||
return QString::fromStdString(SConfig::GetInstance().m_strDVDRoot);
|
||||
return QString::fromStdString(SConfig::GetInstance().m_strDVDRoot);
|
||||
}
|
||||
|
||||
void Settings::SetDVDRoot(const QString& path)
|
||||
{
|
||||
SConfig::GetInstance().m_strDVDRoot = path.toStdString();
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
SConfig::GetInstance().m_strDVDRoot = path.toStdString();
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
QString Settings::GetApploader() const
|
||||
{
|
||||
return QString::fromStdString(SConfig::GetInstance().m_strApploader);
|
||||
return QString::fromStdString(SConfig::GetInstance().m_strApploader);
|
||||
}
|
||||
|
||||
void Settings::SetApploader(const QString& path)
|
||||
{
|
||||
SConfig::GetInstance().m_strApploader = path.toStdString();
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
SConfig::GetInstance().m_strApploader = path.toStdString();
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
QString Settings::GetWiiNAND() const
|
||||
{
|
||||
return QString::fromStdString(SConfig::GetInstance().m_NANDPath);
|
||||
return QString::fromStdString(SConfig::GetInstance().m_NANDPath);
|
||||
}
|
||||
|
||||
void Settings::SetWiiNAND(const QString& path)
|
||||
{
|
||||
SConfig::GetInstance().m_NANDPath = path.toStdString();
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
SConfig::GetInstance().m_NANDPath = path.toStdString();
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
}
|
||||
|
||||
DiscIO::IVolume::ELanguage Settings::GetWiiSystemLanguage() const
|
||||
{
|
||||
return SConfig::GetInstance().GetCurrentLanguage(true);
|
||||
return SConfig::GetInstance().GetCurrentLanguage(true);
|
||||
}
|
||||
|
||||
DiscIO::IVolume::ELanguage Settings::GetGCSystemLanguage() const
|
||||
{
|
||||
return SConfig::GetInstance().GetCurrentLanguage(false);
|
||||
return SConfig::GetInstance().GetCurrentLanguage(false);
|
||||
}
|
||||
|
||||
bool Settings::GetPreferredView() const
|
||||
{
|
||||
return value(QStringLiteral("PreferredView"), true).toBool();
|
||||
return value(QStringLiteral("PreferredView"), true).toBool();
|
||||
}
|
||||
|
||||
void Settings::SetPreferredView(bool table)
|
||||
{
|
||||
setValue(QStringLiteral("PreferredView"), table);
|
||||
setValue(QStringLiteral("PreferredView"), table);
|
||||
}
|
||||
|
||||
bool Settings::GetConfirmStop() const
|
||||
{
|
||||
return value(QStringLiteral("Emulation/ConfirmStop"), true).toBool();
|
||||
return value(QStringLiteral("Emulation/ConfirmStop"), true).toBool();
|
||||
}
|
||||
|
||||
int Settings::GetStateSlot() const
|
||||
{
|
||||
return value(QStringLiteral("Emulation/StateSlot"), 1).toInt();
|
||||
return value(QStringLiteral("Emulation/StateSlot"), 1).toInt();
|
||||
}
|
||||
|
||||
void Settings::SetStateSlot(int slot)
|
||||
{
|
||||
setValue(QStringLiteral("Emulation/StateSlot"), slot);
|
||||
setValue(QStringLiteral("Emulation/StateSlot"), slot);
|
||||
}
|
||||
|
||||
bool Settings::GetRenderToMain() const
|
||||
{
|
||||
return value(QStringLiteral("Graphics/RenderToMain"), false).toBool();
|
||||
return value(QStringLiteral("Graphics/RenderToMain"), false).toBool();
|
||||
}
|
||||
|
||||
bool Settings::GetFullScreen() const
|
||||
{
|
||||
return value(QStringLiteral("Graphics/FullScreen"), false).toBool();
|
||||
return value(QStringLiteral("Graphics/FullScreen"), false).toBool();
|
||||
}
|
||||
|
||||
QSize Settings::GetRenderWindowSize() const
|
||||
{
|
||||
return value(QStringLiteral("Graphics/RenderWindowSize"), QSize(640, 480)).toSize();
|
||||
return value(QStringLiteral("Graphics/RenderWindowSize"), QSize(640, 480)).toSize();
|
||||
}
|
||||
|
@ -11,40 +11,40 @@
|
||||
// UI settings to be stored in the config directory.
|
||||
class Settings final : public QSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Settings(QObject* parent = nullptr);
|
||||
explicit Settings(QObject* parent = nullptr);
|
||||
|
||||
// UI
|
||||
QString GetThemeDir() const;
|
||||
// UI
|
||||
QString GetThemeDir() const;
|
||||
|
||||
// GameList
|
||||
QString GetLastGame() const;
|
||||
void SetLastGame(const QString& path);
|
||||
QStringList GetPaths() const;
|
||||
void SetPaths(const QStringList& paths);
|
||||
void RemovePath(int i);
|
||||
QString GetDefaultGame() const;
|
||||
void SetDefaultGame(const QString& path);
|
||||
QString GetDVDRoot() const;
|
||||
void SetDVDRoot(const QString& path);
|
||||
QString GetApploader() const;
|
||||
void SetApploader(const QString& path);
|
||||
QString GetWiiNAND() const;
|
||||
void SetWiiNAND(const QString& path);
|
||||
DiscIO::IVolume::ELanguage GetWiiSystemLanguage() const;
|
||||
DiscIO::IVolume::ELanguage GetGCSystemLanguage() const;
|
||||
bool GetPreferredView() const;
|
||||
void SetPreferredView(bool table);
|
||||
// GameList
|
||||
QString GetLastGame() const;
|
||||
void SetLastGame(const QString& path);
|
||||
QStringList GetPaths() const;
|
||||
void SetPaths(const QStringList& paths);
|
||||
void RemovePath(int i);
|
||||
QString GetDefaultGame() const;
|
||||
void SetDefaultGame(const QString& path);
|
||||
QString GetDVDRoot() const;
|
||||
void SetDVDRoot(const QString& path);
|
||||
QString GetApploader() const;
|
||||
void SetApploader(const QString& path);
|
||||
QString GetWiiNAND() const;
|
||||
void SetWiiNAND(const QString& path);
|
||||
DiscIO::IVolume::ELanguage GetWiiSystemLanguage() const;
|
||||
DiscIO::IVolume::ELanguage GetGCSystemLanguage() const;
|
||||
bool GetPreferredView() const;
|
||||
void SetPreferredView(bool table);
|
||||
|
||||
// Emulation
|
||||
bool GetConfirmStop() const;
|
||||
int GetStateSlot() const;
|
||||
void SetStateSlot(int);
|
||||
// Emulation
|
||||
bool GetConfirmStop() const;
|
||||
int GetStateSlot() const;
|
||||
void SetStateSlot(int);
|
||||
|
||||
// Graphics
|
||||
bool GetRenderToMain() const;
|
||||
bool GetFullScreen() const;
|
||||
QSize GetRenderWindowSize() const;
|
||||
// Graphics
|
||||
bool GetRenderToMain() const;
|
||||
bool GetFullScreen() const;
|
||||
QSize GetRenderWindowSize() const;
|
||||
};
|
||||
|
@ -9,78 +9,76 @@
|
||||
|
||||
static QSize ICON_SIZE(32, 32);
|
||||
|
||||
ToolBar::ToolBar(QWidget* parent)
|
||||
: QToolBar(parent)
|
||||
ToolBar::ToolBar(QWidget* parent) : QToolBar(parent)
|
||||
{
|
||||
setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
setMovable(false);
|
||||
setFloatable(false);
|
||||
setIconSize(ICON_SIZE);
|
||||
setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
setMovable(false);
|
||||
setFloatable(false);
|
||||
setIconSize(ICON_SIZE);
|
||||
|
||||
MakeActions();
|
||||
UpdateIcons();
|
||||
MakeActions();
|
||||
UpdateIcons();
|
||||
|
||||
EmulationStopped();
|
||||
EmulationStopped();
|
||||
}
|
||||
|
||||
void ToolBar::EmulationStarted()
|
||||
{
|
||||
m_play_action->setEnabled(false);
|
||||
m_play_action->setVisible(false);
|
||||
m_pause_action->setEnabled(true);
|
||||
m_pause_action->setVisible(true);
|
||||
m_fullscreen_action->setEnabled(true);
|
||||
m_screenshot_action->setEnabled(true);
|
||||
m_play_action->setEnabled(false);
|
||||
m_play_action->setVisible(false);
|
||||
m_pause_action->setEnabled(true);
|
||||
m_pause_action->setVisible(true);
|
||||
m_fullscreen_action->setEnabled(true);
|
||||
m_screenshot_action->setEnabled(true);
|
||||
}
|
||||
|
||||
void ToolBar::EmulationPaused()
|
||||
{
|
||||
m_play_action->setEnabled(true);
|
||||
m_play_action->setVisible(true);
|
||||
m_pause_action->setEnabled(false);
|
||||
m_pause_action->setVisible(false);
|
||||
m_play_action->setEnabled(true);
|
||||
m_play_action->setVisible(true);
|
||||
m_pause_action->setEnabled(false);
|
||||
m_pause_action->setVisible(false);
|
||||
}
|
||||
|
||||
void ToolBar::EmulationStopped()
|
||||
{
|
||||
m_play_action->setEnabled(true);
|
||||
m_play_action->setVisible(true);
|
||||
m_pause_action->setEnabled(false);
|
||||
m_pause_action->setVisible(false);
|
||||
m_stop_action->setEnabled(false);
|
||||
m_fullscreen_action->setEnabled(false);
|
||||
m_screenshot_action->setEnabled(false);
|
||||
m_play_action->setEnabled(true);
|
||||
m_play_action->setVisible(true);
|
||||
m_pause_action->setEnabled(false);
|
||||
m_pause_action->setVisible(false);
|
||||
m_stop_action->setEnabled(false);
|
||||
m_fullscreen_action->setEnabled(false);
|
||||
m_screenshot_action->setEnabled(false);
|
||||
}
|
||||
|
||||
void ToolBar::MakeActions()
|
||||
{
|
||||
m_open_action = addAction(tr("Open"), this, SIGNAL(OpenPressed()));
|
||||
m_play_action = addAction(tr("Play"), this, SIGNAL(PlayPressed()));
|
||||
m_pause_action = addAction(tr("Pause"), this, SIGNAL(PausePressed()));
|
||||
m_stop_action = addAction(tr("Stop"), this, SIGNAL(StopPressed()));
|
||||
m_fullscreen_action = addAction(tr("Full Screen"), this, SIGNAL(FullScreenPressed()));
|
||||
m_screenshot_action = addAction(tr("Screen Shot"), this, SIGNAL(ScreenShotPressed()));
|
||||
m_open_action = addAction(tr("Open"), this, SIGNAL(OpenPressed()));
|
||||
m_play_action = addAction(tr("Play"), this, SIGNAL(PlayPressed()));
|
||||
m_pause_action = addAction(tr("Pause"), this, SIGNAL(PausePressed()));
|
||||
m_stop_action = addAction(tr("Stop"), this, SIGNAL(StopPressed()));
|
||||
m_fullscreen_action = addAction(tr("Full Screen"), this, SIGNAL(FullScreenPressed()));
|
||||
m_screenshot_action = addAction(tr("Screen Shot"), this, SIGNAL(ScreenShotPressed()));
|
||||
|
||||
addSeparator();
|
||||
addSeparator();
|
||||
|
||||
m_paths_action = addAction(tr("Paths"), this, SIGNAL(PathsPressed()));
|
||||
m_config_action = addAction(tr("Settings"), this, SIGNAL(SettingsPressed()));
|
||||
m_controllers_action = addAction(tr("Controllers"));
|
||||
m_controllers_action->setEnabled(false);
|
||||
m_paths_action = addAction(tr("Paths"), this, SIGNAL(PathsPressed()));
|
||||
m_config_action = addAction(tr("Settings"), this, SIGNAL(SettingsPressed()));
|
||||
m_controllers_action = addAction(tr("Controllers"));
|
||||
m_controllers_action->setEnabled(false);
|
||||
}
|
||||
|
||||
void ToolBar::UpdateIcons()
|
||||
{
|
||||
QString dir = Settings().GetThemeDir();
|
||||
QString dir = Settings().GetThemeDir();
|
||||
|
||||
m_open_action->setIcon(QIcon(QStringLiteral("open.png").prepend(dir)));
|
||||
m_paths_action->setIcon(QIcon(QStringLiteral("browse.png").prepend(dir)));
|
||||
m_play_action->setIcon(QIcon(QStringLiteral("play.png").prepend(dir)));
|
||||
m_pause_action->setIcon(QIcon(QStringLiteral("pause.png").prepend(dir)));
|
||||
m_stop_action->setIcon(QIcon(QStringLiteral("stop.png").prepend(dir)));
|
||||
m_fullscreen_action->setIcon(QIcon(QStringLiteral("fullscreen.png").prepend(dir)));
|
||||
m_screenshot_action->setIcon(QIcon(QStringLiteral("screenshot.png").prepend(dir)));
|
||||
m_config_action->setIcon(QIcon(QStringLiteral("config.png").prepend(dir)));
|
||||
m_controllers_action->setIcon(QIcon(QStringLiteral("classic.png").prepend(dir)));
|
||||
m_open_action->setIcon(QIcon(QStringLiteral("open.png").prepend(dir)));
|
||||
m_paths_action->setIcon(QIcon(QStringLiteral("browse.png").prepend(dir)));
|
||||
m_play_action->setIcon(QIcon(QStringLiteral("play.png").prepend(dir)));
|
||||
m_pause_action->setIcon(QIcon(QStringLiteral("pause.png").prepend(dir)));
|
||||
m_stop_action->setIcon(QIcon(QStringLiteral("stop.png").prepend(dir)));
|
||||
m_fullscreen_action->setIcon(QIcon(QStringLiteral("fullscreen.png").prepend(dir)));
|
||||
m_screenshot_action->setIcon(QIcon(QStringLiteral("screenshot.png").prepend(dir)));
|
||||
m_config_action->setIcon(QIcon(QStringLiteral("config.png").prepend(dir)));
|
||||
m_controllers_action->setIcon(QIcon(QStringLiteral("classic.png").prepend(dir)));
|
||||
}
|
||||
|
||||
|
@ -10,37 +10,38 @@
|
||||
|
||||
class ToolBar final : public QToolBar
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ToolBar(QWidget* parent = nullptr);
|
||||
explicit ToolBar(QWidget* parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void EmulationStarted();
|
||||
void EmulationPaused();
|
||||
void EmulationStopped();
|
||||
void EmulationStarted();
|
||||
void EmulationPaused();
|
||||
void EmulationStopped();
|
||||
|
||||
signals:
|
||||
void OpenPressed();
|
||||
void PlayPressed();
|
||||
void PausePressed();
|
||||
void StopPressed();
|
||||
void FullScreenPressed();
|
||||
void ScreenShotPressed();
|
||||
void OpenPressed();
|
||||
void PlayPressed();
|
||||
void PausePressed();
|
||||
void StopPressed();
|
||||
void FullScreenPressed();
|
||||
void ScreenShotPressed();
|
||||
|
||||
void PathsPressed();
|
||||
void SettingsPressed();
|
||||
|
||||
void PathsPressed();
|
||||
void SettingsPressed();
|
||||
private:
|
||||
void MakeActions();
|
||||
void UpdateIcons();
|
||||
void MakeActions();
|
||||
void UpdateIcons();
|
||||
|
||||
QAction* m_open_action;
|
||||
QAction* m_play_action;
|
||||
QAction* m_pause_action;
|
||||
QAction* m_stop_action;
|
||||
QAction* m_fullscreen_action;
|
||||
QAction* m_screenshot_action;
|
||||
QAction* m_paths_action;
|
||||
QAction* m_config_action;
|
||||
QAction* m_controllers_action;
|
||||
QAction* m_open_action;
|
||||
QAction* m_play_action;
|
||||
QAction* m_pause_action;
|
||||
QAction* m_stop_action;
|
||||
QAction* m_fullscreen_action;
|
||||
QAction* m_screenshot_action;
|
||||
QAction* m_paths_action;
|
||||
QAction* m_config_action;
|
||||
QAction* m_controllers_action;
|
||||
};
|
||||
|
Reference in New Issue
Block a user