diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/preferences.cpp | 11 | ||||
-rw-r--r-- | qt-ui/preferences.ui | 27 | ||||
-rw-r--r-- | qt-ui/subsurfacewebservices.cpp | 39 | ||||
-rw-r--r-- | qt-ui/subsurfacewebservices.h | 11 | ||||
-rw-r--r-- | qt-ui/webservices.ui | 9 |
5 files changed, 94 insertions, 3 deletions
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 1e87662a1..b22991c5b 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -100,6 +100,10 @@ void PreferencesDialog::setUiFromPrefs() connect(ui.languageFilter, SIGNAL(textChanged(QString)), filterModel, SLOT(setFilterFixedString(QString))); QSettings s; + + ui.save_uid_local->setChecked(s.value("save_uid_local").toBool()); + ui.default_uid->setText(s.value("subsurface_webservice_uid").toString().toUpper()); + s.beginGroup("Language"); ui.languageSystemDefault->setChecked(s.value("UseSystemLanguage", true).toBool()); QAbstractItemModel *m = ui.languageView->model(); @@ -170,6 +174,9 @@ void PreferencesDialog::syncSettings() { QSettings s; + s.setValue("subsurface_webservice_uid", ui.default_uid->text().toUpper()); + set_save_userid_local(ui.save_uid_local->checkState()); + // Graph s.beginGroup("TecDetails"); @@ -235,6 +242,10 @@ void PreferencesDialog::loadSettings() QSettings s; QVariant v; + + ui.save_uid_local->setChecked(s.value("save_uid_local").toBool()); + ui.default_uid->setText(s.value("subsurface_webservice_uid").toString().toUpper()); + s.beginGroup("Units"); if (s.value("unit_system").toString() == "metric") { prefs.unit_system = METRIC; diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui index 502cc2915..485577d33 100644 --- a/qt-ui/preferences.ui +++ b/qt-ui/preferences.ui @@ -265,6 +265,33 @@ </widget> </item> <item> + <widget class="QGroupBox" name="groupBox_8"> + <property name="title"> + <string>Subsurface Webservice</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <item> + <widget class="QLabel" name="label_16"> + <property name="text"> + <string>Default User ID</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="default_uid"> + </widget> + </item> + <item> + <widget class="QCheckBox" name="save_uid_local"> + <property name="text"> + <string>Save User ID locally?</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> <spacer name="verticalSpacer_2"> <property name="orientation"> <enum>Qt::Vertical</enum> diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index d6d0debee..1b8eab129 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -312,12 +312,16 @@ void WebServices::resetState() SubsurfaceWebServices::SubsurfaceWebServices(QWidget *parent, Qt::WindowFlags f) : WebServices(parent, f) { QSettings s; - ui.userID->setText(s.value("subsurface_webservice_uid").toString().toUpper()); + if (!save_userid_local || !*userid) + ui.userID->setText(s.value("subsurface_webservice_uid").toString().toUpper()); + else + ui.userID->setText(userid); hidePassword(); hideUpload(); ui.progressBar->setFormat("Enter User ID and click Download"); ui.progressBar->setRange(0, 1); ui.progressBar->setValue(-1); + ui.saveUidLocal->setChecked(save_userid_local); } void SubsurfaceWebServices::buttonClicked(QAbstractButton *button) @@ -339,7 +343,20 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button) /* store last entered uid in config */ QSettings s; - s.setValue("subsurface_webservice_uid", ui.userID->text().toUpper()); + QString qDialogUid = ui.userID->text().toUpper(); + bool qSaveUid = ui.saveUidLocal->checkState(); + set_save_userid_local(qSaveUid); + if (qSaveUid) { + QString qSettingUid = s.value("subsurface_webservice_uid").toString(); + QString qFileUid = QString::fromStdString(userid); + bool s_eq_d = (qSettingUid == qDialogUid); + bool d_eq_f = (qDialogUid == qFileUid); + if (!d_eq_f || s_eq_d) + s.setValue("subsurface_webservice_uid", qDialogUid); + set_userid(qDialogUid.toLocal8Bit().data()); + } else { + s.setValue("subsurface_webservice_uid", qDialogUid); + } s.sync(); hide(); close(); @@ -626,6 +643,7 @@ DivelogsDeWebServices::DivelogsDeWebServices(QWidget *parent, Qt::WindowFlags f) QSettings s; ui.userID->setText(s.value("divelogde_user").toString()); ui.password->setText(s.value("divelogde_pass").toString()); + ui.saveUidLocal->hide(); hideUpload(); } @@ -883,3 +901,20 @@ void DivelogsDeWebServices::buttonClicked(QAbstractButton *button) break; } } + +#define MAX_USERID_SIZE 32 +short save_userid_local = false; +char *userid = NULL; +void set_save_userid_local(short value) +{ + QSettings s; + s.setValue("save_uid_local", value); + save_userid_local = value; +} + +void set_userid(char *rUserId) +{ + userid = (char *) malloc(MAX_USERID_SIZE); + if (userid && rUserId) + strcpy(userid, rUserId); +} diff --git a/qt-ui/subsurfacewebservices.h b/qt-ui/subsurfacewebservices.h index 175c99109..f3fbb5b63 100644 --- a/qt-ui/subsurfacewebservices.h +++ b/qt-ui/subsurfacewebservices.h @@ -98,4 +98,15 @@ private: bool uploadMode; }; +#ifdef __cplusplus +extern "C" { +#endif +extern short save_userid_local; +extern char *userid; +extern void set_save_userid_local(short value); +extern void set_userid(char *user_id); +#ifdef __cplusplus +} +#endif + #endif // SUBSURFACEWEBSERVICES_H diff --git a/qt-ui/webservices.ui b/qt-ui/webservices.ui index 295c25218..a55b9175d 100644 --- a/qt-ui/webservices.ui +++ b/qt-ui/webservices.ui @@ -45,7 +45,7 @@ </property> </widget> </item> - <item row="4" column="0" colspan="3"> + <item row="5" column="0" colspan="3"> <widget class="QDialogButtonBox" name="buttonBox"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -79,6 +79,13 @@ </property> </widget> </item> + <item row="4" column="0" colspan="4"> + <widget class="QCheckBox" name="saveUidLocal"> + <property name="text"> + <string>Save User ID locally?</string> + </property> + </widget> + </item> <item row="1" column="0"> <widget class="QLabel" name="passLabel"> <property name="text"> |