diff --git a/CLEANUP_NOTES.md b/CLEANUP_NOTES.md new file mode 100644 index 0000000..01b752b --- /dev/null +++ b/CLEANUP_NOTES.md @@ -0,0 +1,58 @@ +# Cleanup Notes + +## 2026-01-25 + +This file tracks cleanup/refactor steps taken during a “deep cleanup” pass, with the goal of reducing dead/duplicate code **without changing application functionality**. + +### Applied changes + +#### 1) Remove duplicate QML type registration in `src/main.cpp` + +- **What changed** + - Removed manual `qmlRegisterSingletonType` / `qmlRegisterType` / `qmlRegisterUncreatableType` calls for types already marked with `QML_ELEMENT` / `QML_SINGLETON`. +- **Why** + - The project uses `ecm_add_qml_module(...)` and the generated QML type registration (based on `QML_ELEMENT` / `QML_SINGLETON`) already registers these types. + - Keeping both mechanisms is redundant and risks divergence. +- **Files** + - `src/main.cpp` + +#### 2) Remove dead QML state in `src/qml/SettingsPage.qml` + +- **What changed** + - Removed unused `pendingDisableImportDelegate` state. + - Simplified `requestDisableImport(...)` to no longer accept an unused `delegate` parameter. +- **Why** + - The variable was assigned/cleared but never read. +- **Files** + - `src/qml/SettingsPage.qml` + +#### 3) Stop shipping `FocusableCard.qml` in the QML module (but keep the file) + +- **What changed** + - Removed `qml/components/FocusableCard.qml` from the `QML_FILES` list in `ecm_add_qml_module(...)`. +- **Why** + - The component is not referenced anywhere in QML currently. + - We want to keep the implementation around because it may be useful later (e.g. Desktop/Couch mode), but avoid shipping unused module contents. +- **Files** + - `src/CMakeLists.txt` + - Note: `src/qml/components/FocusableCard.qml` still exists in the repository. + +### Verification performed + +- Built successfully: + - `cmake --build build-debug` +- Quick run smoke test: + - Launches without QML type registration errors. + - Only the existing Kirigami `StackView has detected conflicting anchors` warning was observed. + +### Intentional non-changes (paused items) + +- Do **not** delete `src/qml/components/FocusableCard.qml` yet. +- Do **not** remove or migrate any persisted `Config` settings or public QML API fields yet. + +### How to revert / resume later + +- To re-ship `FocusableCard.qml`: + - Add it back to `ecm_add_qml_module(... QML_FILES ...)` in `src/CMakeLists.txt`. +- To fully remove it: + - `git rm src/qml/components/FocusableCard.qml` (only after confirming it is not needed for future UI modes). diff --git a/src/main.cpp b/src/main.cpp index f50b271..82a72c3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,13 +15,6 @@ #include #include "alakarte-version.h" -#include "app.h" -#include "config.h" -#include "game.h" -#include "gamepadmanager.h" -#include "gamelauncher.h" -#include "gamemodel.h" -#include "gamesortfiltermodel.h" int main(int argc, char *argv[]) { @@ -63,19 +56,6 @@ int main(int argc, char *argv[]) QQmlApplicationEngine engine; - qmlRegisterSingletonType("org.kde.alakarte", 1, 0, "App", [](QQmlEngine *engine, QJSEngine *) -> QObject * { - Q_UNUSED(engine) - return App::instance(); - }); - - qmlRegisterSingletonType("org.kde.alakarte", 1, 0, "GamepadManager", &GamepadManager::create); - - qmlRegisterType("org.kde.alakarte", 1, 0, "GameModel"); - qmlRegisterType("org.kde.alakarte", 1, 0, "GameSortFilterModel"); - qmlRegisterUncreatableType("org.kde.alakarte", 1, 0, "Game", QStringLiteral("Game objects are created by GameModel")); - qmlRegisterType("org.kde.alakarte", 1, 0, "GameLauncher"); - qmlRegisterType("org.kde.alakarte", 1, 0, "Config"); - engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); engine.loadFromModule("org.kde.alakarte", "Main"); diff --git a/src/qml/SettingsPage.qml b/src/qml/SettingsPage.qml index 8bdae0b..cba46d2 100644 --- a/src/qml/SettingsPage.qml +++ b/src/qml/SettingsPage.qml @@ -18,11 +18,9 @@ ColumnLayout { } property var pendingDisableImportApply: null - property var pendingDisableImportDelegate: null property string pendingDisableImportName: "" - function requestDisableImport(delegate, sourceName, applyFn) { - pendingDisableImportDelegate = delegate + function requestDisableImport(sourceName, applyFn) { pendingDisableImportName = sourceName pendingDisableImportApply = applyFn disableImportConfirmDialog.open() @@ -110,7 +108,7 @@ FormCard.FormHeader { restoring = true checked = Qt.binding(function() { return App.config.importSteam }) restoring = false - settingsPage.requestDisableImport(this, i18n("Steam"), function() { App.config.importSteam = false }) + settingsPage.requestDisableImport(i18n("Steam"), function() { App.config.importSteam = false }) return } @@ -141,7 +139,7 @@ FormCard.FormHeader { restoring = true checked = Qt.binding(function() { return App.config.importLutris }) restoring = false - settingsPage.requestDisableImport(this, i18n("Lutris"), function() { App.config.importLutris = false }) + settingsPage.requestDisableImport(i18n("Lutris"), function() { App.config.importLutris = false }) return } @@ -173,7 +171,7 @@ FormCard.FormHeader { restoring = true checked = Qt.binding(function() { return App.config.importHeroic }) restoring = false - settingsPage.requestDisableImport(this, i18n("Heroic Games Launcher"), function() { App.config.importHeroic = false }) + settingsPage.requestDisableImport(i18n("Heroic Games Launcher"), function() { App.config.importHeroic = false }) return } @@ -205,7 +203,7 @@ FormCard.FormHeader { restoring = true checked = Qt.binding(function() { return App.config.importDesktop }) restoring = false - settingsPage.requestDisableImport(this, i18n("Desktop Entries"), function() { App.config.importDesktop = false }) + settingsPage.requestDisableImport(i18n("Desktop Entries"), function() { App.config.importDesktop = false }) return } @@ -237,7 +235,7 @@ FormCard.FormHeader { restoring = true checked = Qt.binding(function() { return App.config.importBottles }) restoring = false - settingsPage.requestDisableImport(this, i18n("Bottles"), function() { App.config.importBottles = false }) + settingsPage.requestDisableImport(i18n("Bottles"), function() { App.config.importBottles = false }) return } @@ -269,7 +267,7 @@ FormCard.FormHeader { restoring = true checked = Qt.binding(function() { return App.config.importFlatpak }) restoring = false - settingsPage.requestDisableImport(this, i18n("Flatpak"), function() { App.config.importFlatpak = false }) + settingsPage.requestDisableImport(i18n("Flatpak"), function() { App.config.importFlatpak = false }) return } @@ -302,7 +300,7 @@ FormCard.FormHeader { restoring = true checked = Qt.binding(function() { return App.config.importItch }) restoring = false - settingsPage.requestDisableImport(this, i18n("itch.io"), function() { App.config.importItch = false }) + settingsPage.requestDisableImport(i18n("itch.io"), function() { App.config.importItch = false }) return } @@ -334,7 +332,7 @@ FormCard.FormHeader { restoring = true checked = Qt.binding(function() { return App.config.importLegendary }) restoring = false - settingsPage.requestDisableImport(this, i18n("Legendary"), function() { App.config.importLegendary = false }) + settingsPage.requestDisableImport(i18n("Legendary"), function() { App.config.importLegendary = false }) return } @@ -367,7 +365,7 @@ FormCard.FormHeader { restoring = true checked = Qt.binding(function() { return App.config.importRetroArch }) restoring = false - settingsPage.requestDisableImport(this, i18n("RetroArch"), function() { App.config.importRetroArch = false }) + settingsPage.requestDisableImport(i18n("RetroArch"), function() { App.config.importRetroArch = false }) return } @@ -560,12 +558,10 @@ FormCard.FormHeader { settingsPage.pendingDisableImportApply() } settingsPage.pendingDisableImportApply = null - settingsPage.pendingDisableImportDelegate = null settingsPage.pendingDisableImportName = "" } onRejected: { settingsPage.pendingDisableImportApply = null - settingsPage.pendingDisableImportDelegate = null settingsPage.pendingDisableImportName = "" } }