core: fix qPrefCloudStorage to derive git_url

remove set_git_url and git_url_changed, because it is not possible
to set git_url, this is done inderectly through set_base_url

Update disk_base_url to generated git_url for both load/sync

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2018-07-26 18:26:17 +02:00 committed by Dirk Hohndel
parent 67a875ef81
commit 037ee9994d
2 changed files with 7 additions and 20 deletions

View file

@ -17,7 +17,6 @@ qPrefCloudStorage *qPrefCloudStorage::instance()
void qPrefCloudStorage::loadSync(bool doSync) void qPrefCloudStorage::loadSync(bool doSync)
{ {
disk_cloud_base_url(doSync); disk_cloud_base_url(doSync);
disk_cloud_git_url(doSync);
disk_cloud_storage_email(doSync); disk_cloud_storage_email(doSync);
disk_cloud_storage_email_encoded(doSync); disk_cloud_storage_email_encoded(doSync);
disk_cloud_storage_password(doSync); disk_cloud_storage_password(doSync);
@ -41,28 +40,19 @@ void qPrefCloudStorage::set_cloud_base_url(const QString &value)
} }
disk_cloud_base_url(true); disk_cloud_base_url(true);
disk_cloud_git_url(true);
emit cloud_base_url_changed(value); emit cloud_base_url_changed(value);
emit cloud_git_url_changed(valueGit);
} }
} }
void qPrefCloudStorage::disk_cloud_base_url(bool doSync)
DISK_LOADSYNC_TXT(CloudStorage, "/cloud_base_url", cloud_base_url);
void qPrefCloudStorage::set_cloud_git_url(const QString &value)
{ {
if (value != prefs.cloud_git_url) { if (doSync) {
// only free and set if not default qPrefPrivate::instance()->setting.setValue(group + "/cloud_base_url", prefs.cloud_base_url);
if (prefs.cloud_git_url != default_prefs.cloud_git_url) { } else {
qPrefPrivate::copy_txt(&prefs.cloud_git_url, value); prefs.cloud_base_url = copy_qstring(qPrefPrivate::instance()->setting.value(group + "/cloud_base_url", default_prefs.cloud_base_url).toString());
} qPrefPrivate::copy_txt(&prefs.cloud_git_url, QString(prefs.cloud_base_url) + "/git");
disk_cloud_git_url(true);
emit cloud_git_url_changed(value);
} }
} }
DISK_LOADSYNC_TXT(CloudStorage, "/cloud_git_url", cloud_git_url);
HANDLE_PREFERENCE_TXT(CloudStorage, "/email", cloud_storage_email); HANDLE_PREFERENCE_TXT(CloudStorage, "/email", cloud_storage_email);
HANDLE_PREFERENCE_TXT(CloudStorage, "/email_encoded", cloud_storage_email_encoded); HANDLE_PREFERENCE_TXT(CloudStorage, "/email_encoded", cloud_storage_email_encoded);

View file

@ -8,7 +8,7 @@
class qPrefCloudStorage : public QObject { class qPrefCloudStorage : public QObject {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString cloud_base_url READ cloud_base_url WRITE set_cloud_base_url NOTIFY cloud_base_url_changed); Q_PROPERTY(QString cloud_base_url READ cloud_base_url WRITE set_cloud_base_url NOTIFY cloud_base_url_changed);
Q_PROPERTY(QString cloud_git_url READ cloud_git_url WRITE set_cloud_git_url NOTIFY cloud_git_url_changed); Q_PROPERTY(QString cloud_git_url READ cloud_git_url);
Q_PROPERTY(QString cloud_storage_email READ cloud_storage_email WRITE set_cloud_storage_email NOTIFY cloud_storage_email_changed); Q_PROPERTY(QString cloud_storage_email READ cloud_storage_email WRITE set_cloud_storage_email NOTIFY cloud_storage_email_changed);
Q_PROPERTY(QString cloud_storage_email_encoded READ cloud_storage_email_encoded WRITE set_cloud_storage_email_encoded NOTIFY cloud_storage_email_encoded_changed); Q_PROPERTY(QString cloud_storage_email_encoded READ cloud_storage_email_encoded WRITE set_cloud_storage_email_encoded NOTIFY cloud_storage_email_encoded_changed);
Q_PROPERTY(QString cloud_storage_newpassword READ cloud_storage_newpassword WRITE set_cloud_storage_newpassword NOTIFY cloud_storage_newpassword_changed); Q_PROPERTY(QString cloud_storage_newpassword READ cloud_storage_newpassword WRITE set_cloud_storage_newpassword NOTIFY cloud_storage_newpassword_changed);
@ -47,7 +47,6 @@ public:
public slots: public slots:
void set_cloud_base_url(const QString &value); void set_cloud_base_url(const QString &value);
void set_cloud_git_url(const QString &value);
void set_cloud_storage_email(const QString &value); void set_cloud_storage_email(const QString &value);
void set_cloud_storage_email_encoded(const QString &value); void set_cloud_storage_email_encoded(const QString &value);
void set_cloud_storage_newpassword(const QString &value); void set_cloud_storage_newpassword(const QString &value);
@ -62,7 +61,6 @@ public slots:
signals: signals:
void cloud_base_url_changed(const QString &value); void cloud_base_url_changed(const QString &value);
void cloud_git_url_changed(const QString &value);
void cloud_storage_email_changed(const QString &value); void cloud_storage_email_changed(const QString &value);
void cloud_storage_email_encoded_changed(const QString &value); void cloud_storage_email_encoded_changed(const QString &value);
void cloud_storage_newpassword_changed(const QString &value); void cloud_storage_newpassword_changed(const QString &value);
@ -78,7 +76,6 @@ signals:
private: private:
// functions to load/sync variable with disk // functions to load/sync variable with disk
void disk_cloud_base_url(bool doSync); void disk_cloud_base_url(bool doSync);
void disk_cloud_git_url(bool doSync);
void disk_cloud_storage_email(bool doSync); void disk_cloud_storage_email(bool doSync);
void disk_cloud_storage_email_encoded(bool doSync); void disk_cloud_storage_email_encoded(bool doSync);
void disk_cloud_storage_newpassword(bool doSync); void disk_cloud_storage_newpassword(bool doSync);