mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-28 20:32:40 -06:00
cdb240f3d4
[REUSE] is a specification that aims at making file copyright
information consistent, so that it can be both human and machine
readable. It basically requires that all files have a header containing
copyright and licensing information. When this isn't possible, like
when dealing with binary assets, generated files or embedded third-party
dependencies, it is permitted to insert copyright information in the
`.reuse/dep5` file.
Oh, and it also requires that all the licenses used in the project are
present in the `LICENSES` folder, that's why the diff is so huge.
This can be done automatically with `reuse download --all`.
The `reuse` tool also contains a handy subcommand that analyzes the
project and tells whether or not the project is (still) compliant,
`reuse lint`.
Following REUSE has a few advantages over the current approach:
- Copyright information is easy to access for users / downstream
- Files like `dist/license.md` do not need to exist anymore, as
`.reuse/dep5` is used instead
- `reuse lint` makes it easy to ensure that copyright information of
files like binary assets / images is always accurate and up to date
To add copyright information of files that didn't have it I looked up
who committed what and when, for each file. As yuzu contributors do not
have to sign a CLA or similar I couldn't assume that copyright ownership
was of the "yuzu Emulator Project", so I used the name and/or email of
the commit author instead.
[REUSE]: https://reuse.software
Follow-up to 01cf05bc75
145 lines
4.9 KiB
C++
145 lines
4.9 KiB
C++
// SPDX-FileCopyrightText: 2016 Citra Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include <algorithm>
|
|
#include <memory>
|
|
#include <utility>
|
|
|
|
#include <QHeaderView>
|
|
#include <QMenu>
|
|
#include <QStandardItemModel>
|
|
#include <QString>
|
|
#include <QTimer>
|
|
#include <QTreeView>
|
|
|
|
#include "common/fs/fs.h"
|
|
#include "common/fs/path_util.h"
|
|
#include "core/core.h"
|
|
#include "core/file_sys/patch_manager.h"
|
|
#include "core/file_sys/xts_archive.h"
|
|
#include "core/loader/loader.h"
|
|
#include "ui_configure_per_game_addons.h"
|
|
#include "yuzu/configuration/config.h"
|
|
#include "yuzu/configuration/configure_input.h"
|
|
#include "yuzu/configuration/configure_per_game_addons.h"
|
|
#include "yuzu/uisettings.h"
|
|
|
|
ConfigurePerGameAddons::ConfigurePerGameAddons(Core::System& system_, QWidget* parent)
|
|
: QWidget(parent), ui{std::make_unique<Ui::ConfigurePerGameAddons>()}, system{system_} {
|
|
ui->setupUi(this);
|
|
|
|
layout = new QVBoxLayout;
|
|
tree_view = new QTreeView;
|
|
item_model = new QStandardItemModel(tree_view);
|
|
tree_view->setModel(item_model);
|
|
tree_view->setAlternatingRowColors(true);
|
|
tree_view->setSelectionMode(QHeaderView::SingleSelection);
|
|
tree_view->setSelectionBehavior(QHeaderView::SelectRows);
|
|
tree_view->setVerticalScrollMode(QHeaderView::ScrollPerPixel);
|
|
tree_view->setHorizontalScrollMode(QHeaderView::ScrollPerPixel);
|
|
tree_view->setSortingEnabled(true);
|
|
tree_view->setEditTriggers(QHeaderView::NoEditTriggers);
|
|
tree_view->setUniformRowHeights(true);
|
|
tree_view->setContextMenuPolicy(Qt::NoContextMenu);
|
|
|
|
item_model->insertColumns(0, 2);
|
|
item_model->setHeaderData(0, Qt::Horizontal, tr("Patch Name"));
|
|
item_model->setHeaderData(1, Qt::Horizontal, tr("Version"));
|
|
|
|
tree_view->header()->setStretchLastSection(false);
|
|
tree_view->header()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch);
|
|
tree_view->header()->setMinimumSectionSize(150);
|
|
|
|
// We must register all custom types with the Qt Automoc system so that we are able to use it
|
|
// with signals/slots. In this case, QList falls under the umbrella of custom types.
|
|
qRegisterMetaType<QList<QStandardItem*>>("QList<QStandardItem*>");
|
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
layout->setSpacing(0);
|
|
layout->addWidget(tree_view);
|
|
|
|
ui->scrollArea->setLayout(layout);
|
|
|
|
ui->scrollArea->setEnabled(!system.IsPoweredOn());
|
|
|
|
connect(item_model, &QStandardItemModel::itemChanged,
|
|
[] { UISettings::values.is_game_list_reload_pending.exchange(true); });
|
|
}
|
|
|
|
ConfigurePerGameAddons::~ConfigurePerGameAddons() = default;
|
|
|
|
void ConfigurePerGameAddons::ApplyConfiguration() {
|
|
std::vector<std::string> disabled_addons;
|
|
|
|
for (const auto& item : list_items) {
|
|
const auto disabled = item.front()->checkState() == Qt::Unchecked;
|
|
if (disabled)
|
|
disabled_addons.push_back(item.front()->text().toStdString());
|
|
}
|
|
|
|
auto current = Settings::values.disabled_addons[title_id];
|
|
std::sort(disabled_addons.begin(), disabled_addons.end());
|
|
std::sort(current.begin(), current.end());
|
|
if (disabled_addons != current) {
|
|
Common::FS::RemoveFile(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) /
|
|
"game_list" / fmt::format("{:016X}.pv.txt", title_id));
|
|
}
|
|
|
|
Settings::values.disabled_addons[title_id] = disabled_addons;
|
|
}
|
|
|
|
void ConfigurePerGameAddons::LoadFromFile(FileSys::VirtualFile file_) {
|
|
file = std::move(file_);
|
|
LoadConfiguration();
|
|
}
|
|
|
|
void ConfigurePerGameAddons::SetTitleId(u64 id) {
|
|
this->title_id = id;
|
|
}
|
|
|
|
void ConfigurePerGameAddons::changeEvent(QEvent* event) {
|
|
if (event->type() == QEvent::LanguageChange) {
|
|
RetranslateUI();
|
|
}
|
|
|
|
QWidget::changeEvent(event);
|
|
}
|
|
|
|
void ConfigurePerGameAddons::RetranslateUI() {
|
|
ui->retranslateUi(this);
|
|
}
|
|
|
|
void ConfigurePerGameAddons::LoadConfiguration() {
|
|
if (file == nullptr) {
|
|
return;
|
|
}
|
|
|
|
const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
|
|
system.GetContentProvider()};
|
|
const auto loader = Loader::GetLoader(system, file);
|
|
|
|
FileSys::VirtualFile update_raw;
|
|
loader->ReadUpdateRaw(update_raw);
|
|
|
|
const auto& disabled = Settings::values.disabled_addons[title_id];
|
|
|
|
for (const auto& patch : pm.GetPatchVersionNames(update_raw)) {
|
|
const auto name =
|
|
QString::fromStdString(patch.first).replace(QStringLiteral("[D] "), QString{});
|
|
|
|
auto* const first_item = new QStandardItem;
|
|
first_item->setText(name);
|
|
first_item->setCheckable(true);
|
|
|
|
const auto patch_disabled =
|
|
std::find(disabled.begin(), disabled.end(), name.toStdString()) != disabled.end();
|
|
|
|
first_item->setCheckState(patch_disabled ? Qt::Unchecked : Qt::Checked);
|
|
|
|
list_items.push_back(QList<QStandardItem*>{
|
|
first_item, new QStandardItem{QString::fromStdString(patch.second)}});
|
|
item_model->appendRow(list_items.back());
|
|
}
|
|
|
|
tree_view->resizeColumnToContents(1);
|
|
}
|