aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-31 22:11:27 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-31 22:35:50 -0700
commit5bbcc7f16ddb1315dbd4a7a43034cddf8c9f2a36 (patch)
treee445d47e14b8fbfeb3902b12d165db117bbe9f52 /qt-ui
parenta6b667478034cee6efde4b0828ad4a263345355f (diff)
downloadsubsurface-5bbcc7f16ddb1315dbd4a7a43034cddf8c9f2a36.tar.gz
Cloud storage: first stab at implementing cloud storage
So far there is no mechanism to actually create a repository on the server, so this only works with the two test repositories. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/mainwindow.cpp64
-rw-r--r--qt-ui/mainwindow.h2
-rw-r--r--qt-ui/mainwindow.ui16
3 files changed, 80 insertions, 2 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 2848e26b7..b039af9bb 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -305,6 +305,70 @@ void MainWindow::on_actionSaveAs_triggered()
file_save_as();
}
+static int getCloudURL(QString &filename)
+{
+ QString email = QString(prefs.cloud_storage_email);
+ email.replace("@", "_at_");
+ email.replace(QRegularExpression("[^a-zA-Z0-9._+-]"), "");
+ if (email.isEmpty() || same_string(prefs.cloud_storage_password, ""))
+ return report_error("Please configure Cloud storage email and password in the preferences");
+ if (email != prefs.cloud_storage_email_encoded) {
+ free(prefs.cloud_storage_email_encoded);
+ prefs.cloud_storage_email_encoded = strdup(qPrintable(email));
+ }
+ filename = QString("https://cloud.subsurface-divelog.org/git/%1[%1]").arg(email);
+ return 0;
+}
+
+void MainWindow::on_actionCloudstorageopen_triggered()
+{
+ if (!okToClose(tr("Please save or cancel the current dive edit before opening a new file.")))
+ return;
+
+ QString filename;
+ if (getCloudURL(filename)) {
+ getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
+ return;
+ }
+ qDebug() << filename;
+
+ closeCurrentFile();
+
+ int error;
+
+ QByteArray fileNamePtr = QFile::encodeName(filename);
+ error = parse_file(fileNamePtr.data());
+ if (!error) {
+ set_filename(fileNamePtr.data(), true);
+ setTitle(MWTF_FILENAME);
+ }
+ getNotificationWidget()->hideNotification();
+ process_dives(false, false);
+ refreshDisplay();
+ ui.actionAutoGroup->setChecked(autogroup);
+}
+
+void MainWindow::on_actionCloudstoragesave_triggered()
+{
+ QString filename;
+ if (getCloudURL(filename)) {
+ getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
+ return;
+ }
+ qDebug() << filename;
+ if (information()->isEditing())
+ information()->acceptChanges();
+
+ if (save_dives(filename.toUtf8().data())) {
+ getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
+ return;
+ }
+ getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
+ set_filename(filename.toUtf8().data(), true);
+ setTitle(MWTF_FILENAME);
+ mark_divelist_changed(false);
+}
+
void learnImageDirs(QStringList dirnames)
{
QList<QFuture<void> > futures;
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index f963330cc..a9686dcd9 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -103,6 +103,8 @@ slots:
void on_actionSave_triggered();
void on_actionSaveAs_triggered();
void on_actionClose_triggered();
+ void on_actionCloudstorageopen_triggered();
+ void on_actionCloudstoragesave_triggered();
void on_actionPrint_triggered();
void on_actionPreferences_triggered();
void on_actionQuit_triggered();
diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui
index c7367bc66..e097b6bb9 100644
--- a/qt-ui/mainwindow.ui
+++ b/qt-ui/mainwindow.ui
@@ -62,7 +62,7 @@
<x>0</x>
<y>0</y>
<width>861</width>
- <height>22</height>
+ <height>29</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -74,6 +74,9 @@
<addaction name="actionSave"/>
<addaction name="actionSaveAs"/>
<addaction name="separator"/>
+ <addaction name="actionCloudstorageopen"/>
+ <addaction name="actionCloudstoragesave"/>
+ <addaction name="separator"/>
<addaction name="actionClose"/>
<addaction name="actionExport"/>
<addaction name="actionPrint"/>
@@ -81,7 +84,6 @@
<addaction name="separator"/>
<addaction name="actionHash_images"/>
<addaction name="actionConfigure_Dive_Computer"/>
- <addaction name="separator"/>
<addaction name="actionRecent1"/>
<addaction name="actionRecent2"/>
<addaction name="actionRecent3"/>
@@ -714,6 +716,16 @@
<string>&amp;Find moved images</string>
</property>
</action>
+ <action name="actionCloudstorageopen">
+ <property name="text">
+ <string>Cloud storage open</string>
+ </property>
+ </action>
+ <action name="actionCloudstoragesave">
+ <property name="text">
+ <string>Cloud storage save</string>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>