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 artifacts
*.AppImage* *.AppImage*
/install* /install*
/*.patch
/.cache

View file

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

View file

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

View file

@ -9,5 +9,6 @@ qt_add_qml_module(edenInterface
shared_translation.h shared_translation.cpp shared_translation.h shared_translation.cpp
QMLSetting.h QMLSetting.cpp QMLSetting.h QMLSetting.cpp
MetaObjectHelper.h 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 "QMLSetting.h"
#include "shared_translation.h" #include "shared_translation.h"
#include "yuzu/models/SettingsModel.h" #include "eden/models/SettingsModel.h"
namespace SettingsCategories { namespace SettingsCategories {
Q_NAMESPACE Q_NAMESPACE

View file

@ -534,6 +534,9 @@ void QtConfig::SaveMultiplayerValues() {
std::vector<Settings::BasicSetting*>& QtConfig::FindRelevantList(Settings::Category category) { std::vector<Settings::BasicSetting*>& QtConfig::FindRelevantList(Settings::Category category) {
auto& map = Settings::values.linkage.by_category; auto& map = Settings::values.linkage.by_category;
// if (!map[category].empty()) {
// return map[category];
// }
if (map.contains(category)) { if (map.contains(category)) {
return Settings::values.linkage.by_category[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 <QApplication>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QQmlContext> #include <QQmlContext>
#include "core/core.h"
#include "interface/QMLConfig.h"
#include "models/GameListModel.h"
#include "interface/SettingsInterface.h"
#include <QQuickStyle> #include <QQuickStyle>
@ -14,18 +14,18 @@ int main(int argc, char *argv[])
QQuickStyle::setStyle(QObject::tr("Material")); QQuickStyle::setStyle(QObject::tr("Material"));
QCoreApplication::setOrganizationName(QStringLiteral("yuzu")); QCoreApplication::setOrganizationName(QStringLiteral("eden-emu"));
QCoreApplication::setApplicationName(QStringLiteral("eden")); QCoreApplication::setApplicationName(QStringLiteral("eden"));
QApplication::setDesktopFileName(QStringLiteral("org.eden-emu.eden"));
/// Settings, etc /// Settings, etc
Settings::SetConfiguringGlobal(true); Settings::SetConfiguringGlobal(true);
QtConfig *config = new QtConfig; QMLConfig *config = new QMLConfig;
config->SaveAllValues();
// TODO: Save all values on launch and per game etc // // TODO: Save all values on launch and per game etc
app.connect(&app, &QCoreApplication::aboutToQuit, &app, [config]() { // app.connect(&app, &QCoreApplication::aboutToQuit, &app, [config]() {
config->SaveAllValues(); // config->save();
}); // });
/// Expose Enums /// Expose Enums
@ -34,13 +34,16 @@ int main(int argc, char *argv[])
/// CONTEXT /// CONTEXT
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
auto ctx = engine.rootContext();
ctx->setContextProperty(QStringLiteral("QtConfig"), QVariant::fromValue(config));
// Enums // Enums
qmlRegisterUncreatableMetaObject(SettingsCategories::staticMetaObject, "org.eden_emu.interface", 1, 0, "SettingsCategories", QString()); qmlRegisterUncreatableMetaObject(SettingsCategories::staticMetaObject, "org.eden_emu.interface", 1, 0, "SettingsCategories", QString());
// Directory List // Directory List
GameListModel *gameListModel = new GameListModel(&app); GameListModel *gameListModel = new GameListModel(&app);
engine.rootContext()->setContextProperty(QStringLiteral("EdenGameList"), gameListModel); ctx->setContextProperty(QStringLiteral("EdenGameList"), gameListModel);
/// LOAD /// LOAD
QObject::connect( QObject::connect(

View file

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

View file

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

View file

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

View file

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

View file

@ -14,11 +14,19 @@ Item {
property alias enable: enable.checked property alias enable: enable.checked
property Item contentItem property Item contentItem
readonly property string typeName: "BaseField"
clip: true clip: true
height: content.height + (helpText.height + helpText.anchors.topMargin) height: content.height + (helpText.height + helpText.anchors.topMargin)
Component.onCompleted: sync()
function apply() { 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() { function sync() {

View file

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

View file

@ -18,9 +18,9 @@ BaseField {
font.pixelSize: 15 * Constants.scalar font.pixelSize: 15 * Constants.scalar
text: Number(setting.value).toString(16) text: Number(value).toString(16)
suffix: setting.suffix 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 font.pixelSize: 15 * Constants.scalar
text: setting.value text: value
suffix: setting.suffix 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 // Lots of cancer but idrc
BaseField { BaseField {
id: field
contentItem: RowLayout { contentItem: RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
@ -18,9 +19,9 @@ BaseField {
to: setting.max to: setting.max
stepSize: 1 stepSize: 1
value: setting.value value: field.value
onMoved: setting.value = value onMoved: field.value = value
Layout.rightMargin: 10 * Constants.scalar Layout.rightMargin: 10 * Constants.scalar
@ -31,7 +32,7 @@ BaseField {
font.pixelSize: 14 * Constants.scalar font.pixelSize: 14 * Constants.scalar
color: Constants.text color: Constants.text
text: setting.value + setting.suffix text: field.value + setting.suffix
Layout.rightMargin: 10 * Constants.scalar Layout.rightMargin: 10 * Constants.scalar
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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