From a1db66cf7ae546797de3b588e51ff179559532d9 Mon Sep 17 00:00:00 2001 From: crueter Date: Mon, 16 Jun 2025 20:46:40 -0400 Subject: [PATCH] tmp Signed-off-by: crueter --- .gitignore | 2 ++ src/CMakeLists.txt | 1 - src/eden/CMakeLists.txt | 1 + src/eden/interface/CMakeLists.txt | 1 + src/eden/interface/QMLConfig.h | 26 +++++++++++++++ src/eden/interface/SettingsInterface.h | 2 +- src/eden/interface/qt_config.cpp | 3 ++ src/eden/main.cpp | 27 +++++++++------- src/eden/models/SettingsModel.cpp | 2 ++ src/eden/models/SettingsModel.h | 2 +- src/eden/qml/CMakeLists.txt | 1 + src/eden/qml/config/GlobalConfigureDialog.qml | 21 ++++++++---- src/eden/qml/config/fields/BaseField.qml | 10 +++++- src/eden/qml/config/fields/ConfigCheckbox.qml | 2 +- src/eden/qml/config/fields/ConfigHexEdit.qml | 4 +-- src/eden/qml/config/fields/ConfigIntLine.qml | 4 +-- .../qml/config/fields/ConfigIntSlider.qml | 7 ++-- src/eden/qml/config/fields/ConfigIntSpin.qml | 5 +-- .../qml/config/fields/ConfigStringEdit.qml | 4 +-- src/eden/qml/config/fields/ConfigTimeEdit.qml | 2 +- .../config/pages/global/GlobalAudioPage.qml | 2 ++ .../qml/config/pages/global/GlobalCpuPage.qml | 1 + .../config/pages/global/GlobalDebugPage.qml | 1 + .../config/pages/global/GlobalGeneralPage.qml | 1 + .../pages/global/GlobalGraphicsPage.qml | 1 + .../config/pages/global/GlobalSystemPage.qml | 1 + src/eden/qml/util/CMakeLists.txt | 23 +++++++++++++ src/eden/qml/util/Util.qml | 32 +++++++++++++++++++ 28 files changed, 153 insertions(+), 36 deletions(-) create mode 100644 src/eden/interface/QMLConfig.h create mode 100644 src/eden/qml/util/CMakeLists.txt create mode 100644 src/eden/qml/util/Util.qml diff --git a/.gitignore b/.gitignore index 2b342e5145..b263cb6a42 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,5 @@ eden-windows-msvc artifacts *.AppImage* /install* +/*.patch +/.cache diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5f12646c71..f3d45bbfe2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -131,7 +131,6 @@ else() add_compile_options( -Werror=all -Werror=extra - -Werror=missing-declarations -Werror=shadow -Werror=unused diff --git a/src/eden/CMakeLists.txt b/src/eden/CMakeLists.txt index 702ccd3adf..50d9b30db7 100644 --- a/src/eden/CMakeLists.txt +++ b/src/eden/CMakeLists.txt @@ -21,6 +21,7 @@ set(PLUGINS edenConfigplugin edenInterfaceplugin edenConstantsplugin + edenUtilplugin ) if (ENABLE_SDL2) diff --git a/src/eden/interface/CMakeLists.txt b/src/eden/interface/CMakeLists.txt index 374b4ec70d..290dec22b9 100644 --- a/src/eden/interface/CMakeLists.txt +++ b/src/eden/interface/CMakeLists.txt @@ -9,5 +9,6 @@ qt_add_qml_module(edenInterface shared_translation.h shared_translation.cpp QMLSetting.h QMLSetting.cpp MetaObjectHelper.h + SOURCES QMLConfig.h ) diff --git a/src/eden/interface/QMLConfig.h b/src/eden/interface/QMLConfig.h new file mode 100644 index 0000000000..83b7f174cb --- /dev/null +++ b/src/eden/interface/QMLConfig.h @@ -0,0 +1,26 @@ +#ifndef QMLCONFIG_H +#define QMLCONFIG_H + +#include "eden/interface/qt_config.h" + +#include + +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 diff --git a/src/eden/interface/SettingsInterface.h b/src/eden/interface/SettingsInterface.h index 4c132c3ce6..c5a0617f26 100644 --- a/src/eden/interface/SettingsInterface.h +++ b/src/eden/interface/SettingsInterface.h @@ -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 diff --git a/src/eden/interface/qt_config.cpp b/src/eden/interface/qt_config.cpp index f4390065c4..9cd8f58c3d 100644 --- a/src/eden/interface/qt_config.cpp +++ b/src/eden/interface/qt_config.cpp @@ -534,6 +534,9 @@ void QtConfig::SaveMultiplayerValues() { std::vector& 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]; } diff --git a/src/eden/main.cpp b/src/eden/main.cpp index 6e4126d466..810d293c36 100644 --- a/src/eden/main.cpp +++ b/src/eden/main.cpp @@ -1,10 +1,10 @@ -#include "core/core.h" -#include "interface/SettingsInterface.h" -#include "interface/qt_config.h" -#include "models/GameListModel.h" #include #include #include +#include "core/core.h" +#include "interface/QMLConfig.h" +#include "models/GameListModel.h" +#include "interface/SettingsInterface.h" #include @@ -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( diff --git a/src/eden/models/SettingsModel.cpp b/src/eden/models/SettingsModel.cpp index a6a9d1bb62..6627ef2c72 100644 --- a/src/eden/models/SettingsModel.cpp +++ b/src/eden/models/SettingsModel.cpp @@ -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; } diff --git a/src/eden/models/SettingsModel.h b/src/eden/models/SettingsModel.h index 0edaab7982..4f7ff9860e 100644 --- a/src/eden/models/SettingsModel.h +++ b/src/eden/models/SettingsModel.h @@ -2,7 +2,7 @@ #define SETTINGSMODEL_H #include -#include "yuzu/interface/QMLSetting.h" +#include "eden/interface/QMLSetting.h" class SettingsModel : public QAbstractListModel { Q_OBJECT diff --git a/src/eden/qml/CMakeLists.txt b/src/eden/qml/CMakeLists.txt index 958f84c3dd..293061b88f 100644 --- a/src/eden/qml/CMakeLists.txt +++ b/src/eden/qml/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(config) add_subdirectory(constants) add_subdirectory(items) +add_subdirectory(util) add_subdirectory(main) diff --git a/src/eden/qml/config/GlobalConfigureDialog.qml b/src/eden/qml/config/GlobalConfigureDialog.qml index 869a682858..50d81a5469 100644 --- a/src/eden/qml/config/GlobalConfigureDialog.qml +++ b/src/eden/qml/config/GlobalConfigureDialog.qml @@ -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 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 { diff --git a/src/eden/qml/config/fields/BaseField.qml b/src/eden/qml/config/fields/BaseField.qml index 092f69f3eb..3d045a3b7b 100644 --- a/src/eden/qml/config/fields/BaseField.qml +++ b/src/eden/qml/config/fields/BaseField.qml @@ -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() { diff --git a/src/eden/qml/config/fields/ConfigCheckbox.qml b/src/eden/qml/config/fields/ConfigCheckbox.qml index 43c84e2248..846be6147d 100644 --- a/src/eden/qml/config/fields/ConfigCheckbox.qml +++ b/src/eden/qml/config/fields/ConfigCheckbox.qml @@ -20,7 +20,7 @@ BaseField { text: setting.label checked: setting.value - onClicked: setting.value = checked + onClicked: value = checked checkable: true } diff --git a/src/eden/qml/config/fields/ConfigHexEdit.qml b/src/eden/qml/config/fields/ConfigHexEdit.qml index 983b0e94c7..0e4a3c1974 100644 --- a/src/eden/qml/config/fields/ConfigHexEdit.qml +++ b/src/eden/qml/config/fields/ConfigHexEdit.qml @@ -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) } } diff --git a/src/eden/qml/config/fields/ConfigIntLine.qml b/src/eden/qml/config/fields/ConfigIntLine.qml index 7f1653207c..6f48b72492 100644 --- a/src/eden/qml/config/fields/ConfigIntLine.qml +++ b/src/eden/qml/config/fields/ConfigIntLine.qml @@ -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) } } diff --git a/src/eden/qml/config/fields/ConfigIntSlider.qml b/src/eden/qml/config/fields/ConfigIntSlider.qml index eac6f66993..9428a0c791 100644 --- a/src/eden/qml/config/fields/ConfigIntSlider.qml +++ b/src/eden/qml/config/fields/ConfigIntSlider.qml @@ -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 } diff --git a/src/eden/qml/config/fields/ConfigIntSpin.qml b/src/eden/qml/config/fields/ConfigIntSpin.qml index 7d65e90663..3fe0a82183 100644 --- a/src/eden/qml/config/fields/ConfigIntSpin.qml +++ b/src/eden/qml/config/fields/ConfigIntSpin.qml @@ -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 } } diff --git a/src/eden/qml/config/fields/ConfigStringEdit.qml b/src/eden/qml/config/fields/ConfigStringEdit.qml index 32873c96b2..11c58ac7a3 100644 --- a/src/eden/qml/config/fields/ConfigStringEdit.qml +++ b/src/eden/qml/config/fields/ConfigStringEdit.qml @@ -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 } } diff --git a/src/eden/qml/config/fields/ConfigTimeEdit.qml b/src/eden/qml/config/fields/ConfigTimeEdit.qml index e070102ca3..66c731c7ed 100644 --- a/src/eden/qml/config/fields/ConfigTimeEdit.qml +++ b/src/eden/qml/config/fields/ConfigTimeEdit.qml @@ -21,7 +21,7 @@ BaseField { font.pixelSize: 15 * Constants.scalar - text: setting.value + text: value suffix: setting.suffix } } diff --git a/src/eden/qml/config/pages/global/GlobalAudioPage.qml b/src/eden/qml/config/pages/global/GlobalAudioPage.qml index ddfdef51f8..73ed7f20fe 100644 --- a/src/eden/qml/config/pages/global/GlobalAudioPage.qml +++ b/src/eden/qml/config/pages/global/GlobalAudioPage.qml @@ -3,6 +3,8 @@ import QtQuick import org.eden_emu.config GlobalTab { + property alias swipe: swipe + tabs: ["Audio"] GlobalTabSwipeView { diff --git a/src/eden/qml/config/pages/global/GlobalCpuPage.qml b/src/eden/qml/config/pages/global/GlobalCpuPage.qml index bcca4f17ae..457565ede7 100644 --- a/src/eden/qml/config/pages/global/GlobalCpuPage.qml +++ b/src/eden/qml/config/pages/global/GlobalCpuPage.qml @@ -3,6 +3,7 @@ import QtQuick import org.eden_emu.config GlobalTab { + property alias swipe: swipe tabs: ["CPU"] GlobalTabSwipeView { diff --git a/src/eden/qml/config/pages/global/GlobalDebugPage.qml b/src/eden/qml/config/pages/global/GlobalDebugPage.qml index 85df6bd1e4..bbbbfbf29f 100644 --- a/src/eden/qml/config/pages/global/GlobalDebugPage.qml +++ b/src/eden/qml/config/pages/global/GlobalDebugPage.qml @@ -3,6 +3,7 @@ import QtQuick import org.eden_emu.config GlobalTab { + property alias swipe: swipe tabs: ["General", "Graphics", "Advanced", "CPU"] GlobalTabSwipeView { diff --git a/src/eden/qml/config/pages/global/GlobalGeneralPage.qml b/src/eden/qml/config/pages/global/GlobalGeneralPage.qml index 30a782d5a8..feae9cd482 100644 --- a/src/eden/qml/config/pages/global/GlobalGeneralPage.qml +++ b/src/eden/qml/config/pages/global/GlobalGeneralPage.qml @@ -3,6 +3,7 @@ import QtQuick import org.eden_emu.config GlobalTab { + property alias swipe: swipe tabs: ["General", "Hotkeys", "Game List"] GlobalTabSwipeView { diff --git a/src/eden/qml/config/pages/global/GlobalGraphicsPage.qml b/src/eden/qml/config/pages/global/GlobalGraphicsPage.qml index af42494591..67380be9e4 100644 --- a/src/eden/qml/config/pages/global/GlobalGraphicsPage.qml +++ b/src/eden/qml/config/pages/global/GlobalGraphicsPage.qml @@ -3,6 +3,7 @@ import QtQuick import org.eden_emu.config GlobalTab { + property alias swipe: swipe tabs: ["Graphics", "Advanced", "Extensions"] GlobalTabSwipeView { diff --git a/src/eden/qml/config/pages/global/GlobalSystemPage.qml b/src/eden/qml/config/pages/global/GlobalSystemPage.qml index 20f0780c97..1fa34e0d26 100644 --- a/src/eden/qml/config/pages/global/GlobalSystemPage.qml +++ b/src/eden/qml/config/pages/global/GlobalSystemPage.qml @@ -3,6 +3,7 @@ import QtQuick import org.eden_emu.config GlobalTab { + property alias swipe: swipe tabs: ["System", "Core", "Profiles", "Filesystem", "Applets"] GlobalTabSwipeView { diff --git a/src/eden/qml/util/CMakeLists.txt b/src/eden/qml/util/CMakeLists.txt new file mode 100644 index 0000000000..a2243aa611 --- /dev/null +++ b/src/eden/qml/util/CMakeLists.txt @@ -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 +) diff --git a/src/eden/qml/util/Util.qml b/src/eden/qml/util/Util.qml new file mode 100644 index 0000000000..03d2a09beb --- /dev/null +++ b/src/eden/qml/util/Util.qml @@ -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 + } +}