Skip to content
Merged
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
36 changes: 27 additions & 9 deletions app/appsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@ AppSettings::AppSettings( QObject *parent ): QObject( parent )
{
QSettings settings;
settings.beginGroup( CoreUtils::QSETTINGS_APP_GROUP_NAME );
const QString path = settings.value( "defaultProject", "" ).toString();
const QString layer = settings.value( "defaultLayer/" + path, "" ).toString();
const double gpsTolerance = settings.value( "gpsTolerance", 10 ).toDouble();
const int lineRecordingInterval = settings.value( "lineRecordingInterval", 3 ).toInt();
int streamingIntervalType = settings.value( "intervalType", 0 ).toInt();
const QString path = settings.value( QStringLiteral( "defaultProject" ), "" ).toString();
const QString layer = settings.value( QStringLiteral( "defaultLayer/" ) + path, "" ).toString();
const double gpsTolerance = settings.value( QStringLiteral( "gpsTolerance" ), 10 ).toDouble();
const int lineRecordingInterval = settings.value( QStringLiteral( "lineRecordingInterval" ), 3 ).toInt();
int streamingIntervalType = settings.value( QStringLiteral( "intervalType" ), 0 ).toInt();
const StreamingIntervalType::IntervalType intervalType = static_cast<StreamingIntervalType::IntervalType>( streamingIntervalType );
const bool reuseLastEnteredValues = settings.value( "reuseLastEnteredValues", false ).toBool();
const bool reuseLastEnteredValues = settings.value( QStringLiteral( "reuseLastEnteredValues" ), false ).toBool();
const QString savedAppVersion = settings.value( QStringLiteral( "appVersion" ), QString() ).toString();
const QString activeProviderId = settings.value( QStringLiteral( "activePositionProviderId" ) ).toString();
const bool autosync = settings.value( QStringLiteral( "autosyncAllowed" ), false ).toBool();
const double gpsHeight = settings.value( "gpsHeight", 0 ).toDouble();
const double gpsHeight = settings.value( QStringLiteral( "gpsHeight" ), 0 ).toDouble();
const QString ignoreMigrateVersion = settings.value( QStringLiteral( "ignoreMigrateVersion" ) ).toString();
const bool autolockPosition = settings.value( QStringLiteral( "autolockPosition" ), true ).toBool();
int hapticsTypeInt = settings.value( "hapticsType", 0 ).toInt();
int hapticsTypeInt = settings.value( QStringLiteral( "hapticsType" ), 0 ).toInt();
const HapticsType hapticsType = static_cast<HapticsType>( hapticsTypeInt );
int startupBehaviorInt = settings.value( QStringLiteral( "startupBehavior" ), 0 ).toInt();
const StartupBehavior startupBehavior = static_cast<StartupBehavior>( startupBehaviorInt );

settings.endGroup();

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

QString AppSettings::defaultLayer() const
Expand All @@ -62,7 +65,7 @@ void AppSettings::setDefaultLayer( const QString &value )
{
if ( defaultLayer() != value )
{
setValue( "defaultLayer/" + mActiveProject, value );
setValue( QStringLiteral( "defaultLayer/" ) + mActiveProject, value );
mDefaultLayers.insert( mActiveProject, value );
emit defaultLayerChanged();
}
Expand Down Expand Up @@ -316,6 +319,21 @@ void AppSettings::setHapticsType( const HapticsType hapticsType )
emit hapticsTypeChanged( hapticsType );
}

AppSettings::StartupBehavior AppSettings::startupBehavior() const
{
return mStartupBehavior;
}

void AppSettings::setStartupBehavior( const StartupBehavior startupBehavior )
{
if ( mStartupBehavior == startupBehavior )
return;

setValue( QStringLiteral( "startupBehavior" ), startupBehavior );
mStartupBehavior = startupBehavior;
emit startupBehaviorChanged( startupBehavior );
}

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( StartupBehavior startupBehavior READ startupBehavior WRITE setStartupBehavior NOTIFY startupBehaviorChanged )

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 StartupBehavior
{
StartupRecentProject = 0,
StartupProjectHome
};
Q_ENUM( StartupBehavior )

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 );

StartupBehavior startupBehavior() const;
void setStartupBehavior( StartupBehavior startupBehavior );

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 startupBehaviorChanged( StartupBehavior startupBehavior );

void ignoreMigrateVersionChanged();

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

HapticsType mHapticsType;
StartupBehavior mStartupBehavior;
};

#endif // APPSETTINGS_H
8 changes: 4 additions & 4 deletions 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.startupBehavior === AppSettings.StartupProjectHome || !AppSettings.defaultProject ) {
stateManager.state = "projects"
}
else {
let path = AppSettings.defaultProject

if ( __localProjectsManager.projectIsValid( path ) && __activeProject.load( path ) ) {
Expand All @@ -131,9 +134,6 @@ ApplicationWindow {
stateManager.state = "projects"
}
}
else {
stateManager.state = "projects"
}

// Catch back button click (if no other component catched it so far)
// to prevent QT from quitting the APP immediately
Expand Down
24 changes: 24 additions & 0 deletions app/qml/settings/MMSettingsPage.qml
Comment thread
xkello marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import QtQuick
import QtQuick.Controls
import QtQml.Models

import mm 1.0 as MM
import MMInput
Expand Down Expand Up @@ -37,6 +38,13 @@ MMPage {
}
}

ListModel {
id: startupBehaviorModel

ListElement { text: qsTr("Recent project"); description: qsTr("Jump back into your last project") } // AppSettings.StartupRecentProject
ListElement { text: qsTr("Project home"); description: qsTr("See all your downloaded projects") } // AppSettings.StartupProjectHome
}

pageBottomMarginPolicy: MMPage.BottomMarginPolicy.PaintBehindSystemBar

pageContent: MMScrollView {
Expand Down Expand Up @@ -216,6 +224,22 @@ MMPage {

Item { width: 1; height: 1 }

MMSettingsComponents.MMSettingsDropdown {
width: parent.width

title: qsTr("Startup behaviour")
description: qsTr("Choose what opens when you launch the app")

currentIndex: AppSettings.startupBehavior

model: startupBehaviorModel
value: model.get(currentIndex).text

onCurrentIndexChanged: AppSettings.startupBehavior = 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: 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