Signed-off-by: crueter <swurl@swurl.xyz>
This commit is contained in:
crueter 2025-06-16 20:46:40 -04:00 committed by crueter
parent 2f6b686859
commit a1db66cf7a
Signed by: crueter
GPG key ID: 425ACD2D4830EBC6
28 changed files with 153 additions and 36 deletions

2
.gitignore vendored
View file

@ -53,3 +53,5 @@ eden-windows-msvc
artifacts
*.AppImage*
/install*
/*.patch
/.cache

View file

@ -131,7 +131,6 @@ else()
add_compile_options(
-Werror=all
-Werror=extra
-Werror=missing-declarations
-Werror=shadow
-Werror=unused

View file

@ -21,6 +21,7 @@ set(PLUGINS
edenConfigplugin
edenInterfaceplugin
edenConstantsplugin
edenUtilplugin
)
if (ENABLE_SDL2)

View file

@ -9,5 +9,6 @@ qt_add_qml_module(edenInterface
shared_translation.h shared_translation.cpp
QMLSetting.h QMLSetting.cpp
MetaObjectHelper.h
SOURCES QMLConfig.h
)

View file

@ -0,0 +1,26 @@
#ifndef QMLCONFIG_H
#define QMLCONFIG_H
#include "eden/interface/qt_config.h"
#include <QObject>
class QMLConfig : public QObject {
Q_OBJECT
QtConfig *m_config;
public:
QMLConfig()
: m_config{new QtConfig}
{}
Q_INVOKABLE inline void reload() {
m_config->ReloadAllValues();
}
Q_INVOKABLE inline void save() {
m_config->SaveAllValues();
}
};
#endif // QMLCONFIG_H

View file

@ -6,7 +6,7 @@
#include "QMLSetting.h"
#include "shared_translation.h"
#include "yuzu/models/SettingsModel.h"
#include "eden/models/SettingsModel.h"
namespace SettingsCategories {
Q_NAMESPACE

View file

@ -534,6 +534,9 @@ void QtConfig::SaveMultiplayerValues() {
std::vector<Settings::BasicSetting*>& QtConfig::FindRelevantList(Settings::Category category) {
auto& map = Settings::values.linkage.by_category;
// if (!map[category].empty()) {
// return map[category];
// }
if (map.contains(category)) {
return Settings::values.linkage.by_category[category];
}

View file

@ -1,10 +1,10 @@
#include "core/core.h"
#include "interface/SettingsInterface.h"
#include "interface/qt_config.h"
#include "models/GameListModel.h"
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "core/core.h"
#include "interface/QMLConfig.h"
#include "models/GameListModel.h"
#include "interface/SettingsInterface.h"
#include <QQuickStyle>
@ -14,18 +14,18 @@ int main(int argc, char *argv[])
QQuickStyle::setStyle(QObject::tr("Material"));
QCoreApplication::setOrganizationName(QStringLiteral("yuzu"));
QCoreApplication::setOrganizationName(QStringLiteral("eden-emu"));
QCoreApplication::setApplicationName(QStringLiteral("eden"));
QApplication::setDesktopFileName(QStringLiteral("org.eden-emu.eden"));
/// Settings, etc
Settings::SetConfiguringGlobal(true);
QtConfig *config = new QtConfig;
config->SaveAllValues();
QMLConfig *config = new QMLConfig;
// TODO: Save all values on launch and per game etc
app.connect(&app, &QCoreApplication::aboutToQuit, &app, [config]() {
config->SaveAllValues();
});
// // TODO: Save all values on launch and per game etc
// app.connect(&app, &QCoreApplication::aboutToQuit, &app, [config]() {
// config->save();
// });
/// Expose Enums
@ -34,13 +34,16 @@ int main(int argc, char *argv[])
/// CONTEXT
QQmlApplicationEngine engine;
auto ctx = engine.rootContext();
ctx->setContextProperty(QStringLiteral("QtConfig"), QVariant::fromValue(config));
// Enums
qmlRegisterUncreatableMetaObject(SettingsCategories::staticMetaObject, "org.eden_emu.interface", 1, 0, "SettingsCategories", QString());
// Directory List
GameListModel *gameListModel = new GameListModel(&app);
engine.rootContext()->setContextProperty(QStringLiteral("EdenGameList"), gameListModel);
ctx->setContextProperty(QStringLiteral("EdenGameList"), gameListModel);
/// LOAD
QObject::connect(

View file

@ -47,7 +47,9 @@ bool SettingsModel::setData(const QModelIndex &index, const QVariant &value, int
switch (role) {
case VALUE:
qDebug() << "Before" << s->value();
s->setValue(value);
qDebug() << "After" << s->value();
break;
}

View file

@ -2,7 +2,7 @@
#define SETTINGSMODEL_H
#include <QAbstractListModel>
#include "yuzu/interface/QMLSetting.h"
#include "eden/interface/QMLSetting.h"
class SettingsModel : public QAbstractListModel {
Q_OBJECT

View file

@ -1,5 +1,6 @@
add_subdirectory(config)
add_subdirectory(constants)
add_subdirectory(items)
add_subdirectory(util)
add_subdirectory(main)

View file

@ -5,21 +5,28 @@ import QtQuick.Layouts
import org.eden_emu.constants
import org.eden_emu.items
import org.eden_emu.interface
import org.eden_emu.util
AnimatedDialog {
property list<var> configs
Dialog {
preferredWidth: 1280
title: "Configuration"
standardButtons: Dialog.Ok | Dialog.Cancel
onOpened: {
for (var tab in tabBar.children) {
console.log(tab)
}
}
Component.onCompleted: configs = Util.searchItem(swipe, "BaseField")
onAccepted: {
configs.forEach(config => {
config.apply()
// console.log(config.setting.label)
})
QtConfig.save()
}
onRejected: {
configs.forEach(config => config.sync())
QtConfig.reload()
}
VerticalTabBar {

View file

@ -14,11 +14,19 @@ Item {
property alias enable: enable.checked
property Item contentItem
readonly property string typeName: "BaseField"
clip: true
height: content.height + (helpText.height + helpText.anchors.topMargin)
Component.onCompleted: sync()
function apply() {
setting.value = value
if (setting.value !== value) {
console.log(setting.label, "previous value:", setting.value,
"new value:", value)
setting.value = value
}
}
function sync() {

View file

@ -20,7 +20,7 @@ BaseField {
text: setting.label
checked: setting.value
onClicked: setting.value = checked
onClicked: value = checked
checkable: true
}

View file

@ -18,9 +18,9 @@ BaseField {
font.pixelSize: 15 * Constants.scalar
text: Number(setting.value).toString(16)
text: Number(value).toString(16)
suffix: setting.suffix
onTextEdited: setting.value = Number("0x" + text)
onTextEdited: value = Number("0x" + text)
}
}

View file

@ -20,9 +20,9 @@ BaseField {
font.pixelSize: 15 * Constants.scalar
text: setting.value
text: value
suffix: setting.suffix
onTextEdited: setting.value = parseInt(text)
onTextEdited: value = parseInt(text)
}
}

View file

@ -8,6 +8,7 @@ import org.eden_emu.constants
// Lots of cancer but idrc
BaseField {
id: field
contentItem: RowLayout {
Layout.fillWidth: true
@ -18,9 +19,9 @@ BaseField {
to: setting.max
stepSize: 1
value: setting.value
value: field.value
onMoved: setting.value = value
onMoved: field.value = value
Layout.rightMargin: 10 * Constants.scalar
@ -31,7 +32,7 @@ BaseField {
font.pixelSize: 14 * Constants.scalar
color: Constants.text
text: setting.value + setting.suffix
text: field.value + setting.suffix
Layout.rightMargin: 10 * Constants.scalar
}

View file

@ -6,6 +6,7 @@ import org.eden_emu.config
import org.eden_emu.constants
BaseField {
id: field
contentItem: BetterSpinBox {
enabled: enable
@ -17,9 +18,9 @@ BaseField {
font.pixelSize: 15 * Constants.scalar
value: setting.value
value: field.value
label: setting.suffix
onValueModified: setting.value = value
onValueModified: field.value = value
}
}

View file

@ -14,9 +14,9 @@ BaseField {
font.pixelSize: 15 * Constants.scalar
text: setting.value
text: value
suffix: setting.suffix
onTextEdited: setting.value = text
onTextEdited: value = text
}
}

View file

@ -21,7 +21,7 @@ BaseField {
font.pixelSize: 15 * Constants.scalar
text: setting.value
text: value
suffix: setting.suffix
}
}

View file

@ -3,6 +3,8 @@ import QtQuick
import org.eden_emu.config
GlobalTab {
property alias swipe: swipe
tabs: ["Audio"]
GlobalTabSwipeView {

View file

@ -3,6 +3,7 @@ import QtQuick
import org.eden_emu.config
GlobalTab {
property alias swipe: swipe
tabs: ["CPU"]
GlobalTabSwipeView {

View file

@ -3,6 +3,7 @@ import QtQuick
import org.eden_emu.config
GlobalTab {
property alias swipe: swipe
tabs: ["General", "Graphics", "Advanced", "CPU"]
GlobalTabSwipeView {

View file

@ -3,6 +3,7 @@ import QtQuick
import org.eden_emu.config
GlobalTab {
property alias swipe: swipe
tabs: ["General", "Hotkeys", "Game List"]
GlobalTabSwipeView {

View file

@ -3,6 +3,7 @@ import QtQuick
import org.eden_emu.config
GlobalTab {
property alias swipe: swipe
tabs: ["Graphics", "Advanced", "Extensions"]
GlobalTabSwipeView {

View file

@ -3,6 +3,7 @@ import QtQuick
import org.eden_emu.config
GlobalTab {
property alias swipe: swipe
tabs: ["System", "Core", "Profiles", "Filesystem", "Applets"]
GlobalTabSwipeView {

View file

@ -0,0 +1,23 @@
set(CMAKE_AUTOMOC ON)
find_package(Qt6 REQUIRED COMPONENTS Quick)
set_source_files_properties(Util.qml
PROPERTIES
QT_QML_SINGLETON_TYPE true
)
qt_add_library(edenUtil STATIC)
qt_add_qml_module(edenUtil
URI org.eden_emu.util
OUTPUT_DIRECTORY EdenUtil
VERSION 1.0
QML_FILES
Util.qml
)
target_link_libraries(edenUtil
PRIVATE
Qt6::Quick
)

View file

@ -0,0 +1,32 @@
pragma Singleton
import QtQuick
QtObject {
/**
* Recursively search an Item for children matching the specified type.
* @return A list of found items.
*/
function searchItem(parent, typeName) {
let results = []
// Search contentChildren too for views/layouts/etc
let children = parent.children
if (parent.contentChildren) {
children = parent.contentChildren
}
for (var i = 0; i < children.length; ++i) {
let child = children[i]
if (child.typeName === typeName) {
results.push(child)
}
let childResults = searchItem(child, typeName)
results = results.concat(childResults)
}
return results
}
}