forked from eden-emu/eden
This is part of a series of PRs made in preparation for the QML rewrite. this PR specifically moves a bunch of utility functions from main.cpp into qt_common, with the biggest benefit being that QML can reuse the exact same code through ctx passthrough. Also, QtCommon::Frontend is an abstraction layer over several previously Widgets-specific stuff like QMessageBox that gets used everywhere. The idea is that once QML is implemented, these functions can have a Quick version implemented for systems that don't work well with Widgets (sun) or for those on Plasma 6+ (reduces memory usage w/o Widgets linkage) although Quick from C++ is actually anal, but whatever. Other than that this should also just kinda reduce the size of main.cpp which is a 6000-line behemoth rn, and clangd straight up gives up with it for me (likely caused by the massive amount of headers, which this DOES reduce). In the future, I probably want to create a common strings lookup table that both Qt and QML can reference--though I'm not sure how much linguist likes that--which should give us a way to keep language consistent (use frozen-map). TODO: Docs for Qt stuff Co-authored-by: MaranBr <maranbr@outlook.com> Reviewed-on: eden-emu/eden#94 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev>
84 lines
2.5 KiB
C++
84 lines
2.5 KiB
C++
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include <QFileDialog>
|
|
#include <QMessageBox>
|
|
#include "common/fs/fs.h"
|
|
#include "common/fs/path_util.h"
|
|
#include "common/settings.h"
|
|
#include "ui_configure_tas.h"
|
|
#include "yuzu/configuration/configure_tas.h"
|
|
#include "qt_common/uisettings.h"
|
|
|
|
ConfigureTasDialog::ConfigureTasDialog(QWidget* parent)
|
|
: QDialog(parent), ui(std::make_unique<Ui::ConfigureTas>()) {
|
|
|
|
ui->setupUi(this);
|
|
|
|
setFocusPolicy(Qt::ClickFocus);
|
|
setWindowTitle(tr("TAS Configuration"));
|
|
|
|
connect(ui->tas_path_button, &QToolButton::pressed, this,
|
|
[this] { SetDirectory(DirectoryTarget::TAS, ui->tas_path_edit); });
|
|
|
|
LoadConfiguration();
|
|
}
|
|
|
|
ConfigureTasDialog::~ConfigureTasDialog() = default;
|
|
|
|
void ConfigureTasDialog::LoadConfiguration() {
|
|
ui->tas_path_edit->setText(
|
|
QString::fromStdString(Common::FS::GetEdenPathString(Common::FS::EdenPath::TASDir)));
|
|
ui->tas_enable->setChecked(Settings::values.tas_enable.GetValue());
|
|
ui->tas_loop_script->setChecked(Settings::values.tas_loop.GetValue());
|
|
ui->tas_pause_on_load->setChecked(Settings::values.pause_tas_on_load.GetValue());
|
|
}
|
|
|
|
void ConfigureTasDialog::ApplyConfiguration() {
|
|
Common::FS::SetEdenPath(Common::FS::EdenPath::TASDir, ui->tas_path_edit->text().toStdString());
|
|
Settings::values.tas_enable.SetValue(ui->tas_enable->isChecked());
|
|
Settings::values.tas_loop.SetValue(ui->tas_loop_script->isChecked());
|
|
Settings::values.pause_tas_on_load.SetValue(ui->tas_pause_on_load->isChecked());
|
|
}
|
|
|
|
void ConfigureTasDialog::SetDirectory(DirectoryTarget target, QLineEdit* edit) {
|
|
QString caption;
|
|
|
|
switch (target) {
|
|
case DirectoryTarget::TAS:
|
|
caption = tr("Select TAS Load Directory...");
|
|
break;
|
|
}
|
|
|
|
QString str = QFileDialog::getExistingDirectory(this, caption, edit->text());
|
|
|
|
if (str.isEmpty()) {
|
|
return;
|
|
}
|
|
|
|
if (str.back() != QChar::fromLatin1('/')) {
|
|
str.append(QChar::fromLatin1('/'));
|
|
}
|
|
|
|
edit->setText(str);
|
|
}
|
|
|
|
void ConfigureTasDialog::changeEvent(QEvent* event) {
|
|
if (event->type() == QEvent::LanguageChange) {
|
|
RetranslateUI();
|
|
}
|
|
|
|
QDialog::changeEvent(event);
|
|
}
|
|
|
|
void ConfigureTasDialog::RetranslateUI() {
|
|
ui->retranslateUi(this);
|
|
}
|
|
|
|
void ConfigureTasDialog::HandleApplyButtonClicked() {
|
|
UISettings::values.configuration_applied = true;
|
|
ApplyConfiguration();
|
|
}
|