From 3e2a91d7b15d995ed0e6777a77e144e665459119 Mon Sep 17 00:00:00 2001 From: crueter Date: Thu, 13 Nov 2025 02:20:25 -0500 Subject: [PATCH] ui fixes, tab inline, auto reload Signed-off-by: crueter --- src/Eden/Config/GlobalConfigureDialog.qml | 23 +++- src/Eden/Config/fields/BaseField.qml | 1 + src/Eden/Config/fields/ConfigComboBox.qml | 1 + src/Eden/Config/fields/ConfigHexEdit.qml | 3 +- src/Eden/Config/fields/ConfigIntLine.qml | 3 +- src/Eden/Config/fields/ConfigIntSlider.qml | 2 + src/Eden/Config/fields/ConfigIntSpin.qml | 3 +- src/Eden/Config/fields/ConfigStringEdit.qml | 4 +- src/Eden/Config/fields/ConfigTimeEdit.qml | 3 +- .../Config/pages/general/UiGeneralPage.qml | 4 + src/Eden/Config/pages/global/GlobalTab.qml | 2 + src/Eden/Native/CMakeLists.txt | 1 + src/Eden/Native/EdenApplication.cpp | 116 ++++++++++++++++++ src/Eden/Native/EdenApplication.h | 22 ++++ src/Eden/Native/main.cpp | 83 +------------ src/qt_common/config/shared_translation.cpp | 3 + src/qt_common/externals/cpmfile.json | 4 +- 17 files changed, 187 insertions(+), 91 deletions(-) create mode 100644 src/Eden/Native/EdenApplication.cpp create mode 100644 src/Eden/Native/EdenApplication.h diff --git a/src/Eden/Config/GlobalConfigureDialog.qml b/src/Eden/Config/GlobalConfigureDialog.qml index f1421eb4d2..0ea94ceb12 100644 --- a/src/Eden/Config/GlobalConfigureDialog.qml +++ b/src/Eden/Config/GlobalConfigureDialog.qml @@ -22,10 +22,11 @@ Dialog { padding: 5 title: qsTr("Configuration") - standardButtons: Dialog.Ok | Dialog.Cancel + standardButtons: Dialog.Ok | Dialog.Apply | Dialog.Cancel Component.onCompleted: configs = Util.searchItem(swipe, "PageScrollView") - onAccepted: { + + function applyConfigs() { configs.forEach(config => { config.apply() }) @@ -33,8 +34,22 @@ Dialog { // console.log("Saving") QtConfig.save() } + + onAccepted: { + applyConfigs() + + if (EdenApplication.shouldReload) { + EdenApplication.shouldReload = false + EdenApplication.reload() + } + } + + onApplied: { + applyConfigs() + } + onRejected: { - console.log("Rejected") + // TODO // configs.forEach(config => config.sync()) // QtConfig.reload() @@ -75,7 +90,7 @@ Dialog { CarboxylTabButton { text: modelData coloredIcon: true - inlineIcon: false // TODO: fix inlineIcon + inlineIcon: true icon.source: "qrc:/icons/" + modelData.toLowerCase() + ".svg" icon.width: 20 diff --git a/src/Eden/Config/fields/BaseField.qml b/src/Eden/Config/fields/BaseField.qml index e326900d97..a5cb7b0fb6 100644 --- a/src/Eden/Config/fields/BaseField.qml +++ b/src/Eden/Config/fields/BaseField.qml @@ -14,6 +14,7 @@ Item { property alias enable: enable.checked property Item contentItem + property bool unsaved: value !== setting.value readonly property string typeName: "BaseField" diff --git a/src/Eden/Config/fields/ConfigComboBox.qml b/src/Eden/Config/fields/ConfigComboBox.qml index 6f97d24e53..b554508041 100644 --- a/src/Eden/Config/fields/ConfigComboBox.qml +++ b/src/Eden/Config/fields/ConfigComboBox.qml @@ -16,6 +16,7 @@ BaseField { Layout.fillWidth: true Layout.rightMargin: 10 + Layout.maximumHeight: 30 font.pixelSize: 14 model: runtimeModel !== null ? runtimeModel : setting.combo diff --git a/src/Eden/Config/fields/ConfigHexEdit.qml b/src/Eden/Config/fields/ConfigHexEdit.qml index 62d70881fb..43b713eb59 100644 --- a/src/Eden/Config/fields/ConfigHexEdit.qml +++ b/src/Eden/Config/fields/ConfigHexEdit.qml @@ -12,12 +12,13 @@ BaseField { Layout.fillWidth: true Layout.rightMargin: 10 + Layout.maximumHeight: 30 validator: RegularExpressionValidator { regularExpression: /[0-9a-fA-F]{0,8}/ } - font.pixelSize: 15 + font.pixelSize: 14 text: Number(value).toString(16) diff --git a/src/Eden/Config/fields/ConfigIntLine.qml b/src/Eden/Config/fields/ConfigIntLine.qml index 0e8e50624e..fa9755ac27 100644 --- a/src/Eden/Config/fields/ConfigIntLine.qml +++ b/src/Eden/Config/fields/ConfigIntLine.qml @@ -12,6 +12,7 @@ BaseField { Layout.fillWidth: true Layout.rightMargin: 10 + Layout.maximumHeight: 30 inputMethodHints: Qt.ImhDigitsOnly validator: IntValidator { @@ -19,7 +20,7 @@ BaseField { top: setting.max } - font.pixelSize: 15 + font.pixelSize: 14 text: value diff --git a/src/Eden/Config/fields/ConfigIntSlider.qml b/src/Eden/Config/fields/ConfigIntSlider.qml index d56e23c837..31130c08c4 100644 --- a/src/Eden/Config/fields/ConfigIntSlider.qml +++ b/src/Eden/Config/fields/ConfigIntSlider.qml @@ -24,6 +24,7 @@ BaseField { onMoved: field.value = value Layout.rightMargin: 10 + Layout.maximumHeight: 30 snapMode: Slider.SnapAlways } @@ -34,6 +35,7 @@ BaseField { text: field.value + setting.suffix Layout.rightMargin: 10 + Layout.maximumHeight: 30 } } } diff --git a/src/Eden/Config/fields/ConfigIntSpin.qml b/src/Eden/Config/fields/ConfigIntSpin.qml index 77dcaf972d..a1a22467bd 100644 --- a/src/Eden/Config/fields/ConfigIntSpin.qml +++ b/src/Eden/Config/fields/ConfigIntSpin.qml @@ -13,11 +13,12 @@ BaseField { Layout.fillWidth: true Layout.rightMargin: 10 + Layout.maximumHeight: 30 from: setting.min to: setting.max - font.pixelSize: 15 + font.pixelSize: 14 value: field.value diff --git a/src/Eden/Config/fields/ConfigStringEdit.qml b/src/Eden/Config/fields/ConfigStringEdit.qml index 9278992644..ff5e48ae01 100644 --- a/src/Eden/Config/fields/ConfigStringEdit.qml +++ b/src/Eden/Config/fields/ConfigStringEdit.qml @@ -10,10 +10,12 @@ BaseField { contentItem: TextField { enabled: enable + Layout.maximumHeight: 30 + Layout.fillWidth: true Layout.rightMargin: 10 - font.pixelSize: 15 + font.pixelSize: 14 text: value diff --git a/src/Eden/Config/fields/ConfigTimeEdit.qml b/src/Eden/Config/fields/ConfigTimeEdit.qml index 24374053c3..49cf3b1ee1 100644 --- a/src/Eden/Config/fields/ConfigTimeEdit.qml +++ b/src/Eden/Config/fields/ConfigTimeEdit.qml @@ -13,6 +13,7 @@ BaseField { Layout.fillWidth: true Layout.rightMargin: 10 + Layout.maximumHeight: 30 inputMethodHints: Qt.ImhDigitsOnly validator: IntValidator { @@ -20,7 +21,7 @@ BaseField { top: setting.max } - font.pixelSize: 15 + font.pixelSize: 14 text: value // suffix: setting.suffix diff --git a/src/Eden/Config/pages/general/UiGeneralPage.qml b/src/Eden/Config/pages/general/UiGeneralPage.qml index 3587ab5c0e..badf5a77a5 100644 --- a/src/Eden/Config/pages/general/UiGeneralPage.qml +++ b/src/Eden/Config/pages/general/UiGeneralPage.qml @@ -10,6 +10,10 @@ import Carboxyl.Base PageScrollView { id: scroll function apply() { + if (style.unsaved) { + EdenApplication.shouldReload = true + } + ui.apply() style.apply() theme.apply() diff --git a/src/Eden/Config/pages/global/GlobalTab.qml b/src/Eden/Config/pages/global/GlobalTab.qml index 16ac2da7aa..0fe8c3bee4 100644 --- a/src/Eden/Config/pages/global/GlobalTab.qml +++ b/src/Eden/Config/pages/global/GlobalTab.qml @@ -13,6 +13,8 @@ Item { id: tabBar currentIndex: swipe.currentIndex + contentHeight: 35 + anchors { top: parent.top left: parent.left diff --git a/src/Eden/Native/CMakeLists.txt b/src/Eden/Native/CMakeLists.txt index 7181d6b82b..e245824193 100644 --- a/src/Eden/Native/CMakeLists.txt +++ b/src/Eden/Native/CMakeLists.txt @@ -7,6 +7,7 @@ qt_add_executable(eden main.cpp icons.qrc + EdenApplication.h EdenApplication.cpp ) set(MODULES diff --git a/src/Eden/Native/EdenApplication.cpp b/src/Eden/Native/EdenApplication.cpp new file mode 100644 index 0000000000..a7614d2e16 --- /dev/null +++ b/src/Eden/Native/EdenApplication.cpp @@ -0,0 +1,116 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "EdenApplication.h" + +#include +#include +#include "CarboxylApplication.h" + +#include "Eden/Interface/QMLConfig.h" +#include "Eden/Interface/SettingsInterface.h" +#include "Eden/Interface/TitleManager.h" +#include "Eden/Models/GameListModel.h" + +#include "common/settings_enums.h" +#include "qt_common/config/uisettings.h" +#include "qt_common/qt_common.h" + +#include +#include + +static constexpr const int EXIT_RELOAD = -2; + +EdenApplication::EdenApplication(int &argc, char *argv[]) + : QApplication(argc, argv) +{ + QCoreApplication::setOrganizationName(QStringLiteral("eden-emu")); + QCoreApplication::setApplicationName(QStringLiteral("eden")); + QApplication::setDesktopFileName(QStringLiteral("dev.eden-emu.eden")); + QGuiApplication::setWindowIcon(QIcon(QStringLiteral(":/icons/eden.svg"))); + + /// QtCommon + QtCommon::Init(new QWidget); + + /// Settings, etc + Settings::SetConfiguringGlobal(true); + config = new QMLConfig; + + // TODO: Save all values on launch and per game etc + connect(this, &QCoreApplication::aboutToQuit, this, [this]() { config->save(); }); + } + +void EdenApplication::reload() +{ + exit(EXIT_RELOAD); +} + +int EdenApplication::run() { + int ret = EXIT_SUCCESS; + do { + if (ret == EXIT_RELOAD) + qmlClearTypeRegistrations(); + + QQmlApplicationEngine engine; + + // carboxyl setup + auto translations = ConfigurationShared::ComboboxEnumeration(this); + + const auto enumeration = &translations->at(Settings::EnumMetadata::Index()); + QString style; + for (const auto &[idx, name] : *enumeration) { + if (idx == (u32) UISettings::values.carboxyl_style.GetValue()) { + style = name; + } + } + + CarboxylApplication *carboxylApp = new CarboxylApplication(*this, + &engine, + style, + QStringLiteral("Trioxide")); + carboxylApp->setParent(this); + + /// CONTEXT + auto ctx = engine.rootContext(); + + ctx->setContextProperty(QStringLiteral("QtConfig"), QVariant::fromValue(config)); + + // Enums + qmlRegisterUncreatableMetaObject(SettingsCategories::staticMetaObject, + "Eden.Interface", + 1, + 0, + "SettingsCategories", + QString()); + + // Directory List + GameListModel *gameListModel = new GameListModel(this, &engine); + ctx->setContextProperty(QStringLiteral("EdenGameList"), gameListModel); + + // Settings Interface + SettingsInterface *interface = new SettingsInterface(&engine); + ctx->setContextProperty(QStringLiteral("SettingsInterface"), interface); + + // Title Manager + TitleManager *title = new TitleManager(&engine); + ctx->setContextProperty(QStringLiteral("TitleManager"), title); + + // :) + ctx->setContextProperty(QStringLiteral("EdenApplication"), this); + + /// LOAD + QObject::connect( + &engine, + &QQmlApplicationEngine::objectCreationFailed, + this, + []() { QCoreApplication::exit(-1); }, + Qt::QueuedConnection); + + engine.loadFromModule("Eden.Main", "Main"); + + ret = exec(); + + } while (ret == EXIT_RELOAD); + + return ret; +} diff --git a/src/Eden/Native/EdenApplication.h b/src/Eden/Native/EdenApplication.h new file mode 100644 index 0000000000..960d3e9df9 --- /dev/null +++ b/src/Eden/Native/EdenApplication.h @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later +#pragma once + +#include +#include "Eden/Interface/QMLConfig.h" + +class EdenApplication : public QApplication +{ + Q_OBJECT + Q_PROPERTY(bool shouldReload MEMBER m_shouldReload) +public: + EdenApplication(int &argc, char *argv[]); + +public slots: + void reload(); + int run(); + +private: + QMLConfig *config; + bool m_shouldReload = false; +}; diff --git a/src/Eden/Native/main.cpp b/src/Eden/Native/main.cpp index 6d720f8579..3ad8fabbae 100644 --- a/src/Eden/Native/main.cpp +++ b/src/Eden/Native/main.cpp @@ -6,90 +6,13 @@ #undef VMA_IMPLEMENTATION #endif -#include -#include -#include -#include "CarboxylApplication.h" - -#include "Eden/Interface/QMLConfig.h" -#include "Eden/Interface/SettingsInterface.h" -#include "Eden/Interface/TitleManager.h" -#include "Eden/Models/GameListModel.h" - -#include "common/settings_enums.h" -#include "qt_common/config/uisettings.h" -#include "qt_common/qt_common.h" - -#include -#include +#include "EdenApplication.h" int main(int argc, char *argv[]) { - QApplication app(argc, argv); - QQmlApplicationEngine engine; - - QCoreApplication::setOrganizationName(QStringLiteral("eden-emu")); - QCoreApplication::setApplicationName(QStringLiteral("eden")); - QApplication::setDesktopFileName(QStringLiteral("dev.eden-emu.eden")); - QGuiApplication::setWindowIcon(QIcon(QStringLiteral(":/icons/eden.svg"))); - - /// QtCommon - QtCommon::Init(new QWidget); - - /// Settings, etc - Settings::SetConfiguringGlobal(true); - QMLConfig *config = new QMLConfig; - - // TODO: Save all values on launch and per game etc - app.connect(&app, &QCoreApplication::aboutToQuit, &app, [config]() { - config->save(); - }); - - // carboxyl setup - auto translations = ConfigurationShared::ComboboxEnumeration(&app); - - const auto enumeration = &translations->at(Settings::EnumMetadata::Index()); - QString style; - for (const auto &[idx, name] : *enumeration) { - if (idx == (u32) UISettings::values.carboxyl_style.GetValue()) { - style = name; - } - } - - CarboxylApplication *carboxylApp = new CarboxylApplication(app, &engine, style, QStringLiteral("Trioxide")); - carboxylApp->setParent(&app); - - /// CONTEXT - auto ctx = engine.rootContext(); - - ctx->setContextProperty(QStringLiteral("QtConfig"), QVariant::fromValue(config)); - - // Enums - qmlRegisterUncreatableMetaObject(SettingsCategories::staticMetaObject, "Eden.Interface", 1, 0, "SettingsCategories", QString()); - - // Directory List - GameListModel *gameListModel = new GameListModel(&app, &engine); - ctx->setContextProperty(QStringLiteral("EdenGameList"), gameListModel); - - // Settings Interface - SettingsInterface *interface = new SettingsInterface(&engine); - ctx->setContextProperty(QStringLiteral("SettingsInterface"), interface); - - // Title Manager - TitleManager *title = new TitleManager(&engine); - ctx->setContextProperty(QStringLiteral("TitleManager"), title); - - /// LOAD - QObject::connect( - &engine, - &QQmlApplicationEngine::objectCreationFailed, - &app, - []() { QCoreApplication::exit(-1); }, - Qt::QueuedConnection); - - engine.loadFromModule("Eden.Main", "Main"); + EdenApplication app(argc, argv); - return app.exec(); + return app.run(); } #if !defined(QT_STATICPLUGIN) || defined(__APPLE__) diff --git a/src/qt_common/config/shared_translation.cpp b/src/qt_common/config/shared_translation.cpp index 22235829c7..212f76f476 100644 --- a/src/qt_common/config/shared_translation.cpp +++ b/src/qt_common/config/shared_translation.cpp @@ -403,11 +403,14 @@ std::unique_ptr InitializeTranslations(QObject* parent) // Web Service // Ui + +#ifdef YUZU_QT_QML INSERT(UISettings, carboxyl_accent, tr("Accent"), tr("What accent color to use throughout the application.")); INSERT(UISettings, carboxyl_theme, tr("Theme"), tr("The palette to use throughout the application.")); // TODO: brief explanations, link to Carboxyl? INSERT(UISettings, carboxyl_style, tr("Style"), tr("The control style to use throughout the application.")); +#endif // Ui General INSERT(UISettings, diff --git a/src/qt_common/externals/cpmfile.json b/src/qt_common/externals/cpmfile.json index 29adb3fcaf..e9ea6c98fb 100644 --- a/src/qt_common/externals/cpmfile.json +++ b/src/qt_common/externals/cpmfile.json @@ -19,8 +19,8 @@ "package": "Carboxyl", "repo": "crueter/Carboxyl", "git_host": "git.crueter.xyz", - "sha": "7bb3818c24", - "hash": "57f61145a1bbb976537af1ef9f3b99d4c442ca47f2dd5d86e65e1a612ecf879d3e7f383bef565bd52606e2b3a68264d8d0c8f53375cd0fe4bdd5175bd3f06ec9", + "sha": "6789e1b2c9", + "hash": "e067c5a5ddb4ef77fee58afd4fb47ef4058b68213a33bc52a349b597aa25b8eb9cbb695c580ae59b82373531d0c96c24f192ada11dc7e198c9c33364a213b90d", "bundled": "true", "options": [ "CARBOXYL_DEMO OFF"