QML UI: add preference for webservice user id

This handles the user id for the Subsurface webservice for GPS location
tracking.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-11-13 17:14:22 -08:00
parent 6124842b0c
commit d65b756c4f
3 changed files with 43 additions and 0 deletions

View file

@ -72,6 +72,24 @@ Item {
id: savePassword id: savePassword
} }
Label {
text: "Subsurface GPS data webservice"
Layout.bottomMargin: units.largeSpacing
font.pointSize: units.titlePointSize
Layout.columnSpan: 2
}
Label {
text: "ID"
Layout.alignment: Qt.AlignRight
}
TextField {
id: userid
text: manager.ssrfGpsWebUserid
Layout.fillWidth: true
}
Item { width: units.gridUnit; height: width } Item { width: units.gridUnit; height: width }
Item { Item {
height: saveButton.height height: saveButton.height

View file

@ -25,6 +25,7 @@ QMLManager::QMLManager() :
setCloudUserName(prefs.cloud_storage_email); setCloudUserName(prefs.cloud_storage_email);
setCloudPassword(prefs.cloud_storage_password); setCloudPassword(prefs.cloud_storage_password);
setSaveCloudPassword(prefs.save_password_local); setSaveCloudPassword(prefs.save_password_local);
setSsrfGpsWebUserid(prefs.userid);
if (!same_string(prefs.cloud_storage_email, "") && !same_string(prefs.cloud_storage_password, "")) if (!same_string(prefs.cloud_storage_email, "") && !same_string(prefs.cloud_storage_password, ""))
loadDives(); loadDives();
} }
@ -39,6 +40,7 @@ void QMLManager::savePreferences()
s.beginGroup("CloudStorage"); s.beginGroup("CloudStorage");
s.setValue("email", cloudUserName()); s.setValue("email", cloudUserName());
s.setValue("save_password_local", saveCloudPassword()); s.setValue("save_password_local", saveCloudPassword());
s.setValue("subsurface_webservice_uid", ssrfGpsWebUserid());
if (saveCloudPassword()) if (saveCloudPassword())
s.setValue("password", cloudPassword()); s.setValue("password", cloudPassword());
s.sync(); s.sync();
@ -55,6 +57,10 @@ void QMLManager::savePreferences()
prefs.cloud_storage_password = strdup(qPrintable(cloudPassword())); prefs.cloud_storage_password = strdup(qPrintable(cloudPassword()));
} }
} }
if (!same_string(prefs.userid, qPrintable(ssrfGpsWebUserid()))) {
free(prefs.userid);
prefs.userid = strdup(qPrintable(ssrfGpsWebUserid()));
}
} }
void QMLManager::loadDives() void QMLManager::loadDives()
@ -213,3 +219,14 @@ void QMLManager::setCloudUserName(const QString &cloudUserName)
m_cloudUserName = cloudUserName; m_cloudUserName = cloudUserName;
emit cloudUserNameChanged(); emit cloudUserNameChanged();
} }
QString QMLManager::ssrfGpsWebUserid() const
{
return m_ssrfGpsWebUserid;
}
void QMLManager::setSsrfGpsWebUserid(const QString &userid)
{
m_ssrfGpsWebUserid = userid;
emit ssrfGpsWebUseridChanged();
}

View file

@ -16,6 +16,7 @@ class QMLManager : public QObject
Q_PROPERTY(bool saveCloudPassword READ saveCloudPassword WRITE setSaveCloudPassword NOTIFY saveCloudPasswordChanged) Q_PROPERTY(bool saveCloudPassword READ saveCloudPassword WRITE setSaveCloudPassword NOTIFY saveCloudPasswordChanged)
Q_PROPERTY(QString logText READ logText WRITE setLogText NOTIFY logTextChanged) Q_PROPERTY(QString logText READ logText WRITE setLogText NOTIFY logTextChanged)
Q_PROPERTY(bool locationServiceEnabled READ locationServiceEnabled WRITE setLocationServiceEnabled NOTIFY locationServiceEnabledChanged) Q_PROPERTY(bool locationServiceEnabled READ locationServiceEnabled WRITE setLocationServiceEnabled NOTIFY locationServiceEnabledChanged)
Q_PROPERTY(QString ssrfGpsWebUserid READ ssrfGpsWebUserid WRITE setSsrfGpsWebUserid NOTIFY ssrfGpsWebUseridChanged)
public: public:
QMLManager(); QMLManager();
~QMLManager(); ~QMLManager();
@ -26,6 +27,9 @@ public:
QString cloudPassword() const; QString cloudPassword() const;
void setCloudPassword(const QString &cloudPassword); void setCloudPassword(const QString &cloudPassword);
QString ssrfGpsWebUserid() const;
void setSsrfGpsWebUserid(const QString &userid);
bool saveCloudPassword() const; bool saveCloudPassword() const;
void setSaveCloudPassword(bool saveCloudPassword); void setSaveCloudPassword(bool saveCloudPassword);
@ -43,10 +47,13 @@ public slots:
void saveChanges(); void saveChanges();
void addDive(); void addDive();
void applyGpsData(); void applyGpsData();
void sendGpsData();
void clearGpsData();
private: private:
QString m_cloudUserName; QString m_cloudUserName;
QString m_cloudPassword; QString m_cloudPassword;
QString m_ssrfGpsWebUserid;
bool m_saveCloudPassword; bool m_saveCloudPassword;
QString m_logText; QString m_logText;
bool m_locationServiceEnabled; bool m_locationServiceEnabled;
@ -55,6 +62,7 @@ private:
signals: signals:
void cloudUserNameChanged(); void cloudUserNameChanged();
void cloudPasswordChanged(); void cloudPasswordChanged();
void ssrfGpsWebUseridChanged();
void saveCloudPasswordChanged(); void saveCloudPasswordChanged();
void locationServiceEnabledChanged(); void locationServiceEnabledChanged();
void logTextChanged(); void logTextChanged();