aboutsummaryrefslogtreecommitdiff
path: root/src/qt_common/util/content.cpp
diff options
context:
space:
mode:
authorcrueter <crueter@eden-emu.dev>2026-03-10 06:51:08 +0100
committercrueter <crueter@eden-emu.dev>2026-03-10 06:51:08 +0100
commit8678cb06eb28a6416a4c6911458fc04113ad8ed4 (patch)
tree3ec250a08b89730833cb9e44d33a5ef42e094a0c /src/qt_common/util/content.cpp
parent769edbfea31e0300137bb1214dd2822fceaa09ab (diff)
[meta] clang-format literally all of the Qt code (#3706)
I'm tired of dealing with this tbh Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3706 Reviewed-by: Lizzie <lizzie@eden-emu.dev>
Diffstat (limited to 'src/qt_common/util/content.cpp')
-rw-r--r--src/qt_common/util/content.cpp188
1 files changed, 79 insertions, 109 deletions
diff --git a/src/qt_common/util/content.cpp b/src/qt_common/util/content.cpp
index dd095a40a4..4d9b324608 100644
--- a/src/qt_common/util/content.cpp
+++ b/src/qt_common/util/content.cpp
@@ -15,17 +15,16 @@
#include "qt_common/abstract/progress.h"
#include "qt_common/qt_common.h"
+#include <JlCompress.h>
#include <QFuture>
#include <QFutureWatcher>
#include <QtConcurrentRun>
-#include <JlCompress.h>
namespace QtCommon::Content {
-bool CheckGameFirmware(u64 program_id)
-{
- if (FirmwareManager::GameRequiresFirmware(program_id)
- && !FirmwareManager::CheckFirmwarePresence(*system)) {
+bool CheckGameFirmware(u64 program_id) {
+ if (FirmwareManager::GameRequiresFirmware(program_id) &&
+ !FirmwareManager::CheckFirmwarePresence(*system)) {
auto result = QtCommon::Frontend::Warning(
tr("Game Requires Firmware"),
tr("The game you are trying to launch requires firmware to boot or to get past the "
@@ -39,11 +38,10 @@ bool CheckGameFirmware(u64 program_id)
return true;
}
-void InstallFirmware(const QString& location, bool recursive)
-{
+void InstallFirmware(const QString& location, bool recursive) {
// Initialize a progress dialog.
- auto progress = QtCommon::Frontend::newProgressDialog(tr("Installing Firmware..."),
- tr("Cancel"), 0, 100);
+ auto progress =
+ QtCommon::Frontend::newProgressDialog(tr("Installing Firmware..."), tr("Cancel"), 0, 100);
progress->show();
QGuiApplication::processEvents();
@@ -61,9 +59,7 @@ void InstallFirmware(const QString& location, bool recursive)
FirmwareInstallResult result;
const auto ShowMessage = [&]() {
- QtCommon::Frontend::ShowMessage(icon,
- failedTitle,
- GetFirmwareInstallResultString(result));
+ QtCommon::Frontend::ShowMessage(icon, failedTitle, GetFirmwareInstallResultString(result));
};
LOG_INFO(Frontend, "Installing firmware from {}", location.toStdString());
@@ -88,12 +84,10 @@ void InstallFirmware(const QString& location, bool recursive)
callback(100, 10);
if (recursive) {
- Common::FS::IterateDirEntriesRecursively(firmware_source_path,
- dir_callback,
+ Common::FS::IterateDirEntriesRecursively(firmware_source_path, dir_callback,
Common::FS::DirEntryFilter::File);
} else {
- Common::FS::IterateDirEntries(firmware_source_path,
- dir_callback,
+ Common::FS::IterateDirEntries(firmware_source_path, dir_callback,
Common::FS::DirEntryFilter::File);
}
@@ -106,8 +100,8 @@ void InstallFirmware(const QString& location, bool recursive)
// Locate and erase the content of nand/system/Content/registered/*.nca, if any.
auto sysnand_content_vdir = system->GetFileSystemController().GetSystemNANDContentDirectory();
- if (sysnand_content_vdir->IsWritable()
- && !sysnand_content_vdir->CleanSubdirectoryRecursive("registered")) {
+ if (sysnand_content_vdir->IsWritable() &&
+ !sysnand_content_vdir->CleanSubdirectoryRecursive("registered")) {
result = FirmwareInstallResult::FailedDelete;
icon = QtCommon::Frontend::Icon::Critical;
ShowMessage();
@@ -125,16 +119,14 @@ void InstallFirmware(const QString& location, bool recursive)
int i = 0;
for (const auto& firmware_src_path : out) {
i++;
- auto firmware_src_vfile = vfs->OpenFile(firmware_src_path.generic_string(),
- FileSys::OpenMode::Read);
- auto firmware_dst_vfile = firmware_vdir->CreateFileRelative(
- firmware_src_path.filename().string());
+ auto firmware_src_vfile =
+ vfs->OpenFile(firmware_src_path.generic_string(), FileSys::OpenMode::Read);
+ auto firmware_dst_vfile =
+ firmware_vdir->CreateFileRelative(firmware_src_path.filename().string());
if (!VfsRawCopy(firmware_src_vfile, firmware_dst_vfile)) {
- LOG_ERROR(Frontend,
- "Failed to copy firmware file {} to {} in registered folder!",
- firmware_src_path.generic_string(),
- firmware_src_path.filename().string());
+ LOG_ERROR(Frontend, "Failed to copy firmware file {} to {} in registered folder!",
+ firmware_src_path.generic_string(), firmware_src_path.filename().string());
success = false;
}
@@ -162,14 +154,12 @@ void InstallFirmware(const QString& location, bool recursive)
return progress->wasCanceled();
};
- auto results = ContentManager::VerifyInstalledContents(*QtCommon::system,
- *QtCommon::provider,
- VerifyFirmwareCallback,
- true);
+ auto results = ContentManager::VerifyInstalledContents(*QtCommon::system, *QtCommon::provider,
+ VerifyFirmwareCallback, true);
if (results.size() > 0) {
- const auto failed_names = QString::fromStdString(
- fmt::format("{}", fmt::join(results, "\n")));
+ const auto failed_names =
+ QString::fromStdString(fmt::format("{}", fmt::join(results, "\n")));
progress->close();
QtCommon::Frontend::Critical(
tr("Firmware integrity verification failed!"),
@@ -185,13 +175,11 @@ void InstallFirmware(const QString& location, bool recursive)
const std::string display_version(firmware_data.display_version.data());
result = FirmwareInstallResult::Success;
- QtCommon::Frontend::Information(successTitle,
- GetFirmwareInstallResultString(result).arg(
- QString::fromStdString(display_version)));
+ QtCommon::Frontend::Information(successTitle, GetFirmwareInstallResultString(result).arg(
+ QString::fromStdString(display_version)));
}
-QString UnzipFirmwareToTmp(const QString& location)
-{
+QString UnzipFirmwareToTmp(const QString& location) {
namespace fs = std::filesystem;
fs::path tmp{fs::temp_directory_path()};
@@ -216,8 +204,7 @@ QString UnzipFirmwareToTmp(const QString& location)
}
// Content //
-void VerifyGameContents(const std::string& game_path)
-{
+void VerifyGameContents(const std::string& game_path) {
auto progress =
QtCommon::Frontend::newProgressDialog(tr("Verifying integrity..."), tr("Cancel"), 0, 100);
progress->show();
@@ -234,34 +221,30 @@ void VerifyGameContents(const std::string& game_path)
switch (result) {
case ContentManager::GameVerificationResult::Success:
- QtCommon::Frontend::Information(rootObject,
- tr("Integrity verification succeeded!"),
+ QtCommon::Frontend::Information(rootObject, tr("Integrity verification succeeded!"),
tr("The operation completed successfully."));
break;
case ContentManager::GameVerificationResult::Failed:
- QtCommon::Frontend::Critical(rootObject,
- tr("Integrity verification failed!"),
+ QtCommon::Frontend::Critical(rootObject, tr("Integrity verification failed!"),
tr("File contents may be corrupt or missing."));
break;
case ContentManager::GameVerificationResult::NotImplemented:
QtCommon::Frontend::Warning(
- rootObject,
- tr("Integrity verification couldn't be performed"),
+ rootObject, tr("Integrity verification couldn't be performed"),
tr("Firmware installation cancelled, firmware may be in a bad state or corrupted. "
"File contents could not be checked for validity."));
}
}
-void InstallKeys()
-{
+void InstallKeys() {
const QString key_source_location = QtCommon::Frontend::GetOpenFileName(
tr("Select Dumped Keys Location"), {}, QStringLiteral("Decryption Keys (*.keys)"), {});
if (key_source_location.isEmpty())
return;
- FirmwareManager::KeyInstallResult result
- = FirmwareManager::InstallKeys(key_source_location.toStdString(), "keys");
+ FirmwareManager::KeyInstallResult result =
+ FirmwareManager::InstallKeys(key_source_location.toStdString(), "keys");
system->GetFileSystemController().CreateFactories(*QtCommon::vfs);
@@ -276,11 +259,10 @@ void InstallKeys()
}
}
-void VerifyInstalledContents()
-{
+void VerifyInstalledContents() {
// Initialize a progress dialog.
- auto progress = QtCommon::Frontend::newProgressDialog(tr("Verifying integrity..."),
- tr("Cancel"), 0, 100);
+ auto progress =
+ QtCommon::Frontend::newProgressDialog(tr("Verifying integrity..."), tr("Cancel"), 0, 100);
progress->show();
QGuiApplication::processEvents();
@@ -289,7 +271,8 @@ void VerifyInstalledContents()
auto QtProgressCallback = [&](size_t total_size, size_t processed_size) {
QGuiApplication::processEvents();
progress->setValue(static_cast<int>((processed_size * 100) / total_size));
- return progress->wasCanceled(); };
+ return progress->wasCanceled();
+ };
const std::vector<std::string> result = ContentManager::VerifyInstalledContents(
*QtCommon::system, *QtCommon::provider, QtProgressCallback);
@@ -300,17 +283,18 @@ void VerifyInstalledContents()
QtCommon::Frontend::Information(tr("Integrity verification succeeded!"),
tr("The operation completed successfully."));
} else {
- const auto failed_names = QString::fromStdString(fmt::format("{}", fmt::join(result, "\n")));
+ const auto failed_names =
+ QString::fromStdString(fmt::format("{}", fmt::join(result, "\n")));
QtCommon::Frontend::Critical(
tr("Integrity verification failed!"),
tr("Verification failed for the following files:\n\n%1").arg(failed_names));
}
}
-void FixProfiles()
-{
+void FixProfiles() {
// Reset user save files after config is initialized and migration is done.
- // Doing it at init time causes profiles to read from the wrong place entirely if NAND dir is not default
+ // Doing it at init time causes profiles to read from the wrong place entirely if NAND dir is
+ // not default
// TODO: better solution
system->GetProfileManager().ResetUserSaveFile();
std::vector<std::string> orphaned = system->GetProfileManager().FindOrphanedProfiles();
@@ -350,28 +334,27 @@ void FixProfiles()
"%2<br><br>"
"Click \"OK\" to open your save folder and fix up your profiles.<br>"
"Hint: copy the contents of the largest or last-modified folder elsewhere, "
- "delete all orphaned profiles, and move your copied contents to the good profile.<br><br>"
- "Still confused? See the <a href='https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/user/Orphaned.md'>help page</a>.<br>")
+ "delete all orphaned profiles, and move your copied contents to the good "
+ "profile.<br><br>"
+ "Still confused? See the <a "
+ "href='https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/user/"
+ "Orphaned.md'>help page</a>.<br>")
.arg(qorphaned, qgood));
QtCommon::Game::OpenSaveFolder();
}
-void ClearDataDir(FrontendCommon::DataManager::DataDir dir, const std::string& user_id)
-{
+void ClearDataDir(FrontendCommon::DataManager::DataDir dir, const std::string& user_id) {
using namespace QtCommon::Frontend;
- auto result = Warning(tr("Really clear data?"),
- tr("Important data may be lost!"),
- Yes | No);
+ auto result = Warning(tr("Really clear data?"), tr("Important data may be lost!"), Yes | No);
if (result != Yes)
return;
- result = Warning(
- tr("Are you REALLY sure?"),
- tr("Once deleted, your data will NOT come back!\n"
- "Only do this if you're 100% sure you want to delete this data."),
- Yes | No);
+ result = Warning(tr("Are you REALLY sure?"),
+ tr("Once deleted, your data will NOT come back!\n"
+ "Only do this if you're 100% sure you want to delete this data."),
+ Yes | No);
if (result != Yes)
return;
@@ -384,17 +367,13 @@ void ClearDataDir(FrontendCommon::DataManager::DataDir dir, const std::string& u
dialog->close();
}
-void ExportDataDir(FrontendCommon::DataManager::DataDir data_dir,
- const std::string& user_id,
- const QString& name,
- std::function<void()> callback)
-{
+void ExportDataDir(FrontendCommon::DataManager::DataDir data_dir, const std::string& user_id,
+ const QString& name, std::function<void()> callback) {
using namespace QtCommon::Frontend;
const std::string dir = FrontendCommon::DataManager::GetDataDirString(data_dir, user_id);
- const QString zip_dump_location = GetSaveFileName(tr("Select Export Location"),
- tr("%1.zip").arg(name),
- tr("Zipped Archives (*.zip)"));
+ const QString zip_dump_location = GetSaveFileName(
+ tr("Select Export Location"), tr("%1.zip").arg(name), tr("Zipped Archives (*.zip)"));
if (zip_dump_location.isEmpty())
return;
@@ -406,18 +385,15 @@ void ExportDataDir(FrontendCommon::DataManager::DataDir data_dir,
progress->show();
auto progress_callback = [=](size_t total_size, size_t processed_size) {
- QMetaObject::invokeMethod(progress,
- "setValue",
- Qt::DirectConnection,
- Q_ARG(int, static_cast<int>((processed_size * 100) / total_size)));
+ QMetaObject::invokeMethod(
+ progress, "setValue", Qt::DirectConnection,
+ Q_ARG(int, static_cast<int>((processed_size * 100) / total_size)));
return !progress->wasCanceled();
};
QFuture<bool> future = QtConcurrent::run([=]() {
- return QtCommon::Compress::compressDir(zip_dump_location,
- QString::fromStdString(dir),
- QtCommon::Compress::Options(),
- progress_callback);
+ return QtCommon::Compress::compressDir(zip_dump_location, QString::fromStdString(dir),
+ QtCommon::Compress::Options(), progress_callback);
});
QFutureWatcher<bool>* watcher = new QFutureWatcher<bool>(rootObject);
@@ -444,37 +420,34 @@ void ExportDataDir(FrontendCommon::DataManager::DataDir data_dir,
watcher->setFuture(future);
}
-void ImportDataDir(FrontendCommon::DataManager::DataDir data_dir,
- const std::string& user_id,
- std::function<void()> callback)
-{
+void ImportDataDir(FrontendCommon::DataManager::DataDir data_dir, const std::string& user_id,
+ std::function<void()> callback) {
const std::string dir = FrontendCommon::DataManager::GetDataDirString(data_dir, user_id);
using namespace QtCommon::Frontend;
- const QString zip_dump_location = GetOpenFileName(tr("Select Import Location"),
- {},
- tr("Zipped Archives (*.zip)"));
+ const QString zip_dump_location =
+ GetOpenFileName(tr("Select Import Location"), {}, tr("Zipped Archives (*.zip)"));
if (zip_dump_location.isEmpty())
return;
- StandardButton button = Warning(
- tr("Import Warning"),
- tr("All previous data in this directory will be deleted. Are you sure you wish to "
- "proceed?"),
- StandardButton::Yes | StandardButton::No);
+ StandardButton button =
+ Warning(tr("Import Warning"),
+ tr("All previous data in this directory will be deleted. Are you sure you wish to "
+ "proceed?"),
+ StandardButton::Yes | StandardButton::No);
if (button != QtCommon::Frontend::Yes)
return;
- QtProgressDialog* progress = newProgressDialogPtr(
- tr("Importing data. This may take a while..."), tr("Cancel"), 0, 100);
+ QtProgressDialog* progress =
+ newProgressDialogPtr(tr("Importing data. This may take a while..."), tr("Cancel"), 0, 100);
progress->setTitle(tr("Importing"));
progress->show();
- // to prevent GUI mangling we have to run this in a thread as well
+ // to prevent GUI mangling we have to run this in a thread as well
QFuture<bool> delete_future = QtConcurrent::run([=]() {
FrontendCommon::DataManager::ClearDir(data_dir, user_id);
return !progress->wasCanceled();
@@ -485,17 +458,14 @@ void ImportDataDir(FrontendCommon::DataManager::DataDir data_dir,
QObject::connect(delete_watcher, &QFutureWatcher<bool>::finished, rootObject, [=]() {
auto progress_callback = [=](size_t total_size, size_t processed_size) {
- QMetaObject::invokeMethod(progress,
- "setValue",
- Qt::DirectConnection,
- Q_ARG(int,
- static_cast<int>((processed_size * 100) / total_size)));
+ QMetaObject::invokeMethod(
+ progress, "setValue", Qt::DirectConnection,
+ Q_ARG(int, static_cast<int>((processed_size * 100) / total_size)));
return !progress->wasCanceled();
};
QFuture<bool> future = QtConcurrent::run([=]() {
- return !QtCommon::Compress::extractDir(zip_dump_location,
- QString::fromStdString(dir),
+ return !QtCommon::Compress::extractDir(zip_dump_location, QString::fromStdString(dir),
progress_callback)
.empty();
});
@@ -505,7 +475,7 @@ void ImportDataDir(FrontendCommon::DataManager::DataDir data_dir,
QObject::connect(watcher, &QFutureWatcher<bool>::finished, rootObject, [=]() {
progress->close();
- // this sucks
+ // this sucks
if (watcher->result()) {
Information(tr("Imported Successfully"), tr("Data was imported successfully."));
} else if (progress->wasCanceled()) {