From c718ccab2b3a7d821509c299016c60af2b244d98 Mon Sep 17 00:00:00 2001 From: Richard Kello Date: Fri, 7 Aug 2026 18:38:16 +0200 Subject: [PATCH] Add option to start app in Home/Last project --- app/appsettings.cpp | 18 +++++++++++++ app/appsettings.h | 14 ++++++++++ app/qml/main.qml | 5 +++- app/qml/settings/MMSettingsPage.qml | 26 +++++++++++++++++++ .../components/MMSettingsDropdown.qml | 4 ++- 5 files changed, 65 insertions(+), 2 deletions(-) diff --git a/app/appsettings.cpp b/app/appsettings.cpp index 34c12d008..148a280bd 100644 --- a/app/appsettings.cpp +++ b/app/appsettings.cpp @@ -34,6 +34,8 @@ AppSettings::AppSettings( QObject *parent ): QObject( parent ) const bool autolockPosition = settings.value( QStringLiteral( "autolockPosition" ), true ).toBool(); int hapticsTypeInt = settings.value( "hapticsType", 0 ).toInt(); const HapticsType hapticsType = static_cast( hapticsTypeInt ); + int startupBehaviourInt = settings.value( "startupBehaviour", 0 ).toInt(); + const StartupBehaviour startupBehaviour = static_cast( startupBehaviourInt ); settings.endGroup(); @@ -51,6 +53,7 @@ AppSettings::AppSettings( QObject *parent ): QObject( parent ) setIgnoreMigrateVersion( ignoreMigrateVersion ); setAutolockPosition( autolockPosition ); setHapticsType( hapticsType ); + setStartupBehaviour( startupBehaviour ); } QString AppSettings::defaultLayer() const @@ -316,6 +319,21 @@ void AppSettings::setHapticsType( const HapticsType hapticsType ) emit hapticsTypeChanged( hapticsType ); } +AppSettings::StartupBehaviour AppSettings::startupBehaviour() const +{ + return mStartupBehaviour; +} + +void AppSettings::setStartupBehaviour( const StartupBehaviour startupBehaviour ) +{ + if ( mStartupBehaviour == startupBehaviour ) + return; + + setValue( QStringLiteral( "startupBehaviour" ), startupBehaviour ); + mStartupBehaviour = startupBehaviour; + emit startupBehaviourChanged( startupBehaviour ); +} + double AppSettings::gpsAntennaHeight() const { return std::round( mGpsAntennaHeight / 0.001 ) * 0.001; diff --git a/app/appsettings.h b/app/appsettings.h index a684e416c..9cc0dda7f 100644 --- a/app/appsettings.h +++ b/app/appsettings.h @@ -38,6 +38,7 @@ class AppSettings: public QObject Q_PROPERTY( bool autolockPosition READ autolockPosition WRITE setAutolockPosition NOTIFY autolockPositionChanged ) Q_PROPERTY( QList windowPosition READ windowPosition WRITE setWindowPosition NOTIFY windowPositionChanged ) Q_PROPERTY( HapticsType hapticsType READ hapticsType WRITE setHapticsType NOTIFY hapticsTypeChanged ) + Q_PROPERTY( StartupBehaviour startupBehaviour READ startupBehaviour WRITE setStartupBehaviour NOTIFY startupBehaviourChanged ) public: // enum of haptic modes we support @@ -55,6 +56,14 @@ class AppSettings: public QObject }; Q_ENUM( HapticsType ) + // enum of options for what should open when the app starts + enum StartupBehaviour + { + StartupRecentProject = 0, + StartupProjectHome + }; + Q_ENUM( StartupBehaviour ) + explicit AppSettings( QObject *parent = nullptr ); QString defaultProject() const; @@ -110,6 +119,9 @@ class AppSettings: public QObject HapticsType hapticsType() const; void setHapticsType( HapticsType hapticsType ); + StartupBehaviour startupBehaviour() const; + void setStartupBehaviour( StartupBehaviour startupBehaviour ); + public slots: void setReuseLastEnteredValues( bool reuseLastEnteredValues ); @@ -129,6 +141,7 @@ class AppSettings: public QObject void autosyncAllowedChanged( bool autosyncAllowed ); void autolockPositionChanged( bool autolockPosition ); void hapticsTypeChanged( HapticsType hapticsType ); + void startupBehaviourChanged( StartupBehaviour startupBehaviour ); void ignoreMigrateVersionChanged(); @@ -169,6 +182,7 @@ class AppSettings: public QObject QString mIgnoreMigrateVersion; HapticsType mHapticsType; + StartupBehaviour mStartupBehaviour; }; #endif // APPSETTINGS_H diff --git a/app/qml/main.qml b/app/qml/main.qml index f1f75837a..5dfaa7933 100644 --- a/app/qml/main.qml +++ b/app/qml/main.qml @@ -119,7 +119,10 @@ ApplicationWindow { Component.onCompleted: { // load default project - if ( AppSettings.defaultProject ) { + if ( AppSettings.startupBehaviour === AppSettings.StartupProjectHome ) { + stateManager.state = "projects" + } + else if ( AppSettings.defaultProject ) { let path = AppSettings.defaultProject if ( __localProjectsManager.projectIsValid( path ) && __activeProject.load( path ) ) { diff --git a/app/qml/settings/MMSettingsPage.qml b/app/qml/settings/MMSettingsPage.qml index 26435fddc..790b8e1c8 100644 --- a/app/qml/settings/MMSettingsPage.qml +++ b/app/qml/settings/MMSettingsPage.qml @@ -37,6 +37,15 @@ MMPage { } } + ListModel { + id: startupBehaviourModel + + Component.onCompleted: { + startupBehaviourModel.append({ value: AppSettings.StartupRecentProject, text: qsTr("Recent project"), description: qsTr("Jump back into your last project") }); + startupBehaviourModel.append({ value: AppSettings.StartupProjectHome, text: qsTr("Project home"), description: qsTr("See all your downloaded projects") }); + } + } + pageBottomMarginPolicy: MMPage.BottomMarginPolicy.PaintBehindSystemBar pageContent: MMScrollView { @@ -216,6 +225,23 @@ MMPage { Item { width: 1; height: 1 } + MMSettingsComponents.MMSettingsDropdown { + width: parent.width + + title: qsTr("On app startup") + description: qsTr("Choose what opens when you launch the app") + drawerTitle: qsTr("Open on startup") + + value: AppSettings.startupBehaviour === AppSettings.StartupProjectHome ? qsTr("Project home") : qsTr("Recent project") + currentIndex: AppSettings.startupBehaviour + + model: startupBehaviourModel + + onCurrentIndexChanged: AppSettings.startupBehaviour = currentIndex + } + + MMLine {} + MMSettingsComponents.MMSettingsItem { width: parent.width title: qsTr("About") diff --git a/app/qml/settings/components/MMSettingsDropdown.qml b/app/qml/settings/components/MMSettingsDropdown.qml index d5030515c..20f368685 100644 --- a/app/qml/settings/components/MMSettingsDropdown.qml +++ b/app/qml/settings/components/MMSettingsDropdown.qml @@ -17,6 +17,7 @@ MMSettingsItem { property var model property int currentIndex: -1 + property string drawerTitle: root.title onClicked: { if(root.model?.count > 0) { @@ -37,12 +38,13 @@ MMSettingsItem { MMComponents.MMListDrawer { - drawerHeader.title: root.title + drawerHeader.title: root.drawerTitle list.model: root.model list.delegate: MMComponents.MMListDelegate { text: model.text + secondaryText: model.description ?? "" rightContent: MMComponents.MMIcon { source: __style.doneCircleIcon