Skip to content
Draft
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
2 changes: 2 additions & 0 deletions app/androidutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ void AndroidUtils::handleActivityResult( const int receiverRequestCode, const in
QJniObject::fromString( mTargetPath ).object<jstring>() )
.toString();
emit imageSelected( newUri, mLastCode );
emit photoFromGallery();
}
else if ( receiverRequestCode == CAMERA_CODE && resultCode == RESULT_OK )
{
Expand All @@ -394,6 +395,7 @@ void AndroidUtils::handleActivityResult( const int receiverRequestCode, const in
const QString absolutePath = absolutePathJNI.toString();

emit imageSelected( absolutePath, mLastCode );
emit photoCaptured();
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions app/androidutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class AndroidUtils: public QObject

signals:
void imageSelected( QString imagePath, QString code );
void photoCaptured();
void photoFromGallery();
void bluetoothEnabled( bool state );
void notifyInfo( const QString &msg );
void notifyError( const QString &msg );
Expand Down
51 changes: 50 additions & 1 deletion app/appsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ const QString AppSettings::POSITION_PROVIDERS_GROUP = QStringLiteral( "inputApp/

AppSettings::AppSettings( QObject *parent ): QObject( parent )
{
// Usage report settings live outside the app group
{
QSettings settings;
mUsageReportEnabled = settings.value( QStringLiteral( "usage_report/enabled" ), true ).toBool();
}

QSettings settings;
settings.beginGroup( CoreUtils::QSETTINGS_APP_GROUP_NAME );
const QString path = settings.value( QStringLiteral( "defaultProject" ), "" ).toString();
Expand Down Expand Up @@ -391,4 +397,47 @@ void AppSettings::setWindowPosition( const QList<QVariant> &newWindowPosition )
setValue( QStringLiteral( "windowPosition" ), QVariant::fromValue( newWindowPosition ) );

emit windowPositionChanged();
}
}

bool AppSettings::usageReportEnabled() const
{
return mUsageReportEnabled;
}

void AppSettings::setUsageReportEnabled( bool enabled )
{
if ( mUsageReportEnabled == enabled )
return;

mUsageReportEnabled = enabled;

QSettings settings;
if ( !mUsageReportEnabled )
{
// Opt-out: clear all accumulated data but keep the enabled flag
settings.beginGroup( QStringLiteral( "usage_report" ) );
settings.remove( QString() );
settings.endGroup();
settings.setValue( QStringLiteral( "usage_report/enabled" ), false );
}
else
{
settings.setValue( QStringLiteral( "usage_report/enabled" ), true );
}

emit usageReportEnabledChanged( mUsageReportEnabled );
}

void AppSettings::trackUsageFeature( const QString &key )
{
if ( !mUsageReportEnabled ) return;
QSettings().setValue( QStringLiteral( "usage_report/data/" ) + key, true );
}

void AppSettings::incrementUsageCounter( const QString &key )
{
if ( !mUsageReportEnabled ) return;
QSettings s;
const QString fullKey = QStringLiteral( "usage_report/data/" ) + key;
s.setValue( fullKey, s.value( fullKey, 0 ).toInt() + 1 );
}
10 changes: 10 additions & 0 deletions app/appsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class AppSettings: public QObject
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 )
Q_PROPERTY( bool usageReportEnabled READ usageReportEnabled WRITE setUsageReportEnabled NOTIFY usageReportEnabledChanged )

public:
// enum of haptic modes we support
Expand Down Expand Up @@ -122,6 +123,12 @@ class AppSettings: public QObject
StartupBehavior startupBehavior() const;
void setStartupBehavior( StartupBehavior startupBehavior );

bool usageReportEnabled() const;
void setUsageReportEnabled( bool enabled );

Q_INVOKABLE void trackUsageFeature( const QString &key );
Q_INVOKABLE void incrementUsageCounter( const QString &key );

public slots:
void setReuseLastEnteredValues( bool reuseLastEnteredValues );

Expand All @@ -147,6 +154,8 @@ class AppSettings: public QObject

void windowPositionChanged();

void usageReportEnabledChanged( bool enabled );

private:
// Projects path
QString mDefaultProject;
Expand Down Expand Up @@ -183,6 +192,7 @@ class AppSettings: public QObject

HapticsType mHapticsType;
StartupBehavior mStartupBehavior;
bool mUsageReportEnabled = true;
};

#endif // APPSETTINGS_H
8 changes: 8 additions & 0 deletions app/ios/iosutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ IosUtils::IosUtils( QObject *parent ): QObject( parent )
QObject::connect( mImagePicker, &IOSImagePicker::imageCaptured, this, [this]( const QString & absoluteImagePath )
{
emit imageSelected( absoluteImagePath, mLastCode );
if ( mLastCode.isEmpty() )
return;
if ( mLastSourceWasCamera )
emit photoCaptured();
else
emit photoFromGallery();
} );
QObject::connect( mImagePicker, &IOSImagePicker::notifyError, this, &IosUtils::notifyError );
}
Expand All @@ -34,12 +40,14 @@ bool IosUtils::isIos() const
void IosUtils::callImagePicker( const QString &targetPath, const QString &code )
{
mLastCode = code;
mLastSourceWasCamera = false;
mImagePicker->showImagePicker( targetPath );
}

void IosUtils::callCamera( const QString &targetPath, const QString &code )
{
mLastCode = code;
mLastSourceWasCamera = true;
mImagePicker->callCamera( targetPath, mPositionKit, mCompass );
}

Expand Down
3 changes: 3 additions & 0 deletions app/ios/iosutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class IosUtils: public QObject

signals:
void imageSelected( const QString &imagePath, const QString &code );
void photoCaptured();
void photoFromGallery();
void notifyError( const QString &message );
void positionKitChanged();
void compassChanged();
Expand All @@ -61,6 +63,7 @@ class IosUtils: public QObject
Compass *mCompass = nullptr;

QString mLastCode;
bool mLastSourceWasCamera = false;
/**
* Calls the objective-c function to disable idle timer to prevent screen from sleeping.
*/
Expand Down
Loading
Loading