mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
qt: Add Properties menu to game list right-click
This commit is contained in:
parent
60e27252a5
commit
f6f6503578
|
@ -669,7 +669,7 @@ void Config::SaveValues() {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const auto& elem : Settings::values.disabled_addons) {
|
for (const auto& elem : Settings::values.disabled_addons) {
|
||||||
qt_config->setArrayIndex(i);
|
qt_config->setArrayIndex(i);
|
||||||
qt_config->setValue("title_id", elem.first);
|
qt_config->setValue("title_id", QVariant::fromValue<u64>(elem.first));
|
||||||
qt_config->beginWriteArray("disabled");
|
qt_config->beginWriteArray("disabled");
|
||||||
for (std::size_t j = 0; j < elem.second.size(); ++j) {
|
for (std::size_t j = 0; j < elem.second.size(); ++j) {
|
||||||
qt_config->setArrayIndex(j);
|
qt_config->setArrayIndex(j);
|
||||||
|
|
|
@ -5,24 +5,27 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include <QHeaderView>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include "common/param_package.h"
|
|
||||||
#include "core/file_sys/control_metadata.h"
|
#include "core/file_sys/control_metadata.h"
|
||||||
#include "core/file_sys/patch_manager.h"
|
#include "core/file_sys/patch_manager.h"
|
||||||
#include "core/file_sys/xts_archive.h"
|
#include "core/file_sys/xts_archive.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
#include "input_common/main.h"
|
#include "ui_configure_per_general.h"
|
||||||
#include "yuzu/configuration/config.h"
|
#include "yuzu/configuration/config.h"
|
||||||
#include "yuzu/configuration/configure_input.h"
|
#include "yuzu/configuration/configure_input.h"
|
||||||
#include "yuzu/configuration/configure_per_general.h"
|
#include "yuzu/configuration/configure_per_general.h"
|
||||||
#include "yuzu/ui_settings.h"
|
#include "yuzu/ui_settings.h"
|
||||||
|
#include "yuzu/util/util.h"
|
||||||
|
|
||||||
ConfigurePerGameGeneral::ConfigurePerGameGeneral(u64 title_id, QWidget* parent)
|
ConfigurePerGameGeneral::ConfigurePerGameGeneral(QWidget* parent, u64 title_id)
|
||||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGameGeneral>()), title_id(title_id) {
|
: QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGameGeneral>()), title_id(title_id) {
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
@ -61,11 +64,13 @@ ConfigurePerGameGeneral::ConfigurePerGameGeneral(u64 title_id, QWidget* parent)
|
||||||
ui->icon_view->setScene(scene);
|
ui->icon_view->setScene(scene);
|
||||||
|
|
||||||
connect(item_model, &QStandardItemModel::itemChanged,
|
connect(item_model, &QStandardItemModel::itemChanged,
|
||||||
[&]() { UISettings::values.is_game_list_reload_pending.exchange(true); });
|
[] { UISettings::values.is_game_list_reload_pending.exchange(true); });
|
||||||
|
|
||||||
this->loadConfiguration();
|
this->loadConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigurePerGameGeneral::~ConfigurePerGameGeneral() = default;
|
||||||
|
|
||||||
void ConfigurePerGameGeneral::applyConfiguration() {
|
void ConfigurePerGameGeneral::applyConfiguration() {
|
||||||
std::vector<std::string> disabled_addons;
|
std::vector<std::string> disabled_addons;
|
||||||
|
|
||||||
|
@ -107,7 +112,7 @@ void ConfigurePerGameGeneral::loadConfiguration() {
|
||||||
if (loader->ReadDeveloper(developer) == Loader::ResultStatus::Success)
|
if (loader->ReadDeveloper(developer) == Loader::ResultStatus::Success)
|
||||||
ui->display_developer->setText(QString::fromStdString(developer));
|
ui->display_developer->setText(QString::fromStdString(developer));
|
||||||
|
|
||||||
ui->display_version->setText("1.0.0");
|
ui->display_version->setText(QStringLiteral("1.0.0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (control.second != nullptr) {
|
if (control.second != nullptr) {
|
||||||
|
@ -160,7 +165,6 @@ void ConfigurePerGameGeneral::loadConfiguration() {
|
||||||
ui->display_format->setText(
|
ui->display_format->setText(
|
||||||
QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())));
|
QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())));
|
||||||
|
|
||||||
QLocale locale = this->locale();
|
const auto valueText = ReadableByteSize(file->GetSize());
|
||||||
QString valueText = locale.formattedDataSize(file->GetSize());
|
|
||||||
ui->display_size->setText(valueText);
|
ui->display_size->setText(valueText);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,21 +4,14 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <vector>
|
||||||
#include <unordered_map>
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <boost/optional.hpp>
|
|
||||||
#include "common/param_package.h"
|
#include "core/file_sys/vfs_types.h"
|
||||||
#include "core/file_sys/vfs.h"
|
|
||||||
#include "core/settings.h"
|
|
||||||
#include "input_common/main.h"
|
|
||||||
#include "ui_configure_per_general.h"
|
|
||||||
#include "yuzu/configuration/config.h"
|
|
||||||
|
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
class QGraphicsScene;
|
class QGraphicsScene;
|
||||||
|
@ -33,7 +26,8 @@ class ConfigurePerGameGeneral : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConfigurePerGameGeneral(u64 title_id, QWidget* parent = nullptr);
|
explicit ConfigurePerGameGeneral(QWidget* parent, u64 title_id);
|
||||||
|
~ConfigurePerGameGeneral() override;
|
||||||
|
|
||||||
/// Save all button configurations to settings file
|
/// Save all button configurations to settings file
|
||||||
void applyConfiguration();
|
void applyConfiguration();
|
||||||
|
|
|
@ -333,6 +333,8 @@ void GameList::PopupContextMenu(const QPoint& menu_location) {
|
||||||
QAction* dump_romfs = context_menu.addAction(tr("Dump RomFS"));
|
QAction* dump_romfs = context_menu.addAction(tr("Dump RomFS"));
|
||||||
QAction* copy_tid = context_menu.addAction(tr("Copy Title ID to Clipboard"));
|
QAction* copy_tid = context_menu.addAction(tr("Copy Title ID to Clipboard"));
|
||||||
QAction* navigate_to_gamedb_entry = context_menu.addAction(tr("Navigate to GameDB entry"));
|
QAction* navigate_to_gamedb_entry = context_menu.addAction(tr("Navigate to GameDB entry"));
|
||||||
|
context_menu.addSeparator();
|
||||||
|
QAction* properties = context_menu.addAction(tr("Properties"));
|
||||||
|
|
||||||
open_save_location->setEnabled(program_id != 0);
|
open_save_location->setEnabled(program_id != 0);
|
||||||
auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id);
|
auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id);
|
||||||
|
@ -346,6 +348,7 @@ void GameList::PopupContextMenu(const QPoint& menu_location) {
|
||||||
connect(copy_tid, &QAction::triggered, [&]() { emit CopyTIDRequested(program_id); });
|
connect(copy_tid, &QAction::triggered, [&]() { emit CopyTIDRequested(program_id); });
|
||||||
connect(navigate_to_gamedb_entry, &QAction::triggered,
|
connect(navigate_to_gamedb_entry, &QAction::triggered,
|
||||||
[&]() { emit NavigateToGamedbEntryRequested(program_id, compatibility_list); });
|
[&]() { emit NavigateToGamedbEntryRequested(program_id, compatibility_list); });
|
||||||
|
connect(properties, &QAction::triggered, [&]() { emit OpenPerGameGeneralRequested(path); });
|
||||||
|
|
||||||
context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location));
|
context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location));
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ signals:
|
||||||
void CopyTIDRequested(u64 program_id);
|
void CopyTIDRequested(u64 program_id);
|
||||||
void NavigateToGamedbEntryRequested(u64 program_id,
|
void NavigateToGamedbEntryRequested(u64 program_id,
|
||||||
const CompatibilityList& compatibility_list);
|
const CompatibilityList& compatibility_list);
|
||||||
|
void OpenPerGameGeneralRequested(const std::string& file);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onTextChanged(const QString& newText);
|
void onTextChanged(const QString& newText);
|
||||||
|
|
|
@ -62,7 +62,7 @@ QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager,
|
||||||
FileSys::VirtualFile update_raw;
|
FileSys::VirtualFile update_raw;
|
||||||
loader.ReadUpdateRaw(update_raw);
|
loader.ReadUpdateRaw(update_raw);
|
||||||
for (const auto& kv : patch_manager.GetPatchVersionNames(update_raw)) {
|
for (const auto& kv : patch_manager.GetPatchVersionNames(update_raw)) {
|
||||||
const bool is_update = kv.first == "Update";
|
const bool is_update = kv.first == "Update" || kv.first == "[D] Update";
|
||||||
if (!updatable && is_update) {
|
if (!updatable && is_update) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
// VFS includes must be before glad as they will conflict with Windows file api, which uses defines.
|
// VFS includes must be before glad as they will conflict with Windows file api, which uses defines.
|
||||||
#include "applets/software_keyboard.h"
|
#include "applets/software_keyboard.h"
|
||||||
|
#include "configuration/configure_per_general.h"
|
||||||
#include "core/file_sys/vfs.h"
|
#include "core/file_sys/vfs.h"
|
||||||
#include "core/file_sys/vfs_real.h"
|
#include "core/file_sys/vfs_real.h"
|
||||||
#include "core/hle/service/acc/profile_manager.h"
|
#include "core/hle/service/acc/profile_manager.h"
|
||||||
|
@ -441,6 +442,8 @@ void GMainWindow::ConnectWidgetEvents() {
|
||||||
connect(game_list, &GameList::CopyTIDRequested, this, &GMainWindow::OnGameListCopyTID);
|
connect(game_list, &GameList::CopyTIDRequested, this, &GMainWindow::OnGameListCopyTID);
|
||||||
connect(game_list, &GameList::NavigateToGamedbEntryRequested, this,
|
connect(game_list, &GameList::NavigateToGamedbEntryRequested, this,
|
||||||
&GMainWindow::OnGameListNavigateToGamedbEntry);
|
&GMainWindow::OnGameListNavigateToGamedbEntry);
|
||||||
|
connect(game_list, &GameList::OpenPerGameGeneralRequested, this,
|
||||||
|
&GMainWindow::OnGameListOpenPerGameProperties);
|
||||||
|
|
||||||
connect(this, &GMainWindow::EmulationStarting, render_window,
|
connect(this, &GMainWindow::EmulationStarting, render_window,
|
||||||
&GRenderWindow::OnEmulationStarting);
|
&GRenderWindow::OnEmulationStarting);
|
||||||
|
@ -988,6 +991,32 @@ void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id,
|
||||||
QDesktopServices::openUrl(QUrl("https://yuzu-emu.org/game/" + directory));
|
QDesktopServices::openUrl(QUrl("https://yuzu-emu.org/game/" + directory));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GMainWindow::OnGameListOpenPerGameProperties(const std::string& file) {
|
||||||
|
u64 title_id{};
|
||||||
|
const auto v_file = Core::GetGameFileFromPath(vfs, file);
|
||||||
|
const auto loader = Loader::GetLoader(v_file);
|
||||||
|
if (loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success) {
|
||||||
|
QMessageBox::information(this, tr("Properties"),
|
||||||
|
tr("The game properties could not be loaded."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigurePerGameGeneral dialog(this, title_id);
|
||||||
|
dialog.loadFromFile(v_file);
|
||||||
|
auto result = dialog.exec();
|
||||||
|
if (result == QDialog::Accepted) {
|
||||||
|
dialog.applyConfiguration();
|
||||||
|
|
||||||
|
const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false);
|
||||||
|
if (reload) {
|
||||||
|
game_list->PopulateAsync(UISettings::values.gamedir,
|
||||||
|
UISettings::values.gamedir_deepscan);
|
||||||
|
}
|
||||||
|
|
||||||
|
config->Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GMainWindow::OnMenuLoadFile() {
|
void GMainWindow::OnMenuLoadFile() {
|
||||||
const QString extensions =
|
const QString extensions =
|
||||||
QString("*.").append(GameList::supported_file_extensions.join(" *.")).append(" main");
|
QString("*.").append(GameList::supported_file_extensions.join(" *.")).append(" main");
|
||||||
|
|
|
@ -168,6 +168,7 @@ private slots:
|
||||||
void OnGameListCopyTID(u64 program_id);
|
void OnGameListCopyTID(u64 program_id);
|
||||||
void OnGameListNavigateToGamedbEntry(u64 program_id,
|
void OnGameListNavigateToGamedbEntry(u64 program_id,
|
||||||
const CompatibilityList& compatibility_list);
|
const CompatibilityList& compatibility_list);
|
||||||
|
void OnGameListOpenPerGameProperties(const std::string& file);
|
||||||
void OnMenuLoadFile();
|
void OnMenuLoadFile();
|
||||||
void OnMenuLoadFolder();
|
void OnMenuLoadFolder();
|
||||||
void OnMenuInstallToNAND();
|
void OnMenuInstallToNAND();
|
||||||
|
|
Loading…
Reference in a new issue