Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/appsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<HapticsType>( hapticsTypeInt );
int startupBehaviourInt = settings.value( "startupBehaviour", 0 ).toInt();
const StartupBehaviour startupBehaviour = static_cast<StartupBehaviour>( startupBehaviourInt );

settings.endGroup();

Expand All @@ -51,6 +53,7 @@ AppSettings::AppSettings( QObject *parent ): QObject( parent )
setIgnoreMigrateVersion( ignoreMigrateVersion );
setAutolockPosition( autolockPosition );
setHapticsType( hapticsType );
setStartupBehaviour( startupBehaviour );
}

QString AppSettings::defaultLayer() const
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions app/appsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class AppSettings: public QObject
Q_PROPERTY( bool autolockPosition READ autolockPosition WRITE setAutolockPosition NOTIFY autolockPositionChanged )
Q_PROPERTY( QList<QVariant> 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
Expand All @@ -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;
Expand Down Expand Up @@ -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 );

Expand All @@ -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();

Expand Down Expand Up @@ -169,6 +182,7 @@ class AppSettings: public QObject
QString mIgnoreMigrateVersion;

HapticsType mHapticsType;
StartupBehaviour mStartupBehaviour;
};

#endif // APPSETTINGS_H
5 changes: 4 additions & 1 deletion app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down
26 changes: 26 additions & 0 deletions app/qml/settings/MMSettingsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion app/qml/settings/components/MMSettingsDropdown.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ MMSettingsItem {

property var model
property int currentIndex: -1
property string drawerTitle: root.title

onClicked: {
if(root.model?.count > 0) {
Expand All @@ -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
Expand Down
Loading