summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop-widgets/mainwindow.cpp35
-rw-r--r--desktop-widgets/mainwindow.h2
2 files changed, 23 insertions, 14 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 25e1a0cd6..4aa4aa1b6 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -441,8 +441,6 @@ void MainWindow::enableDisableCloudActions()
{
ui.actionCloudstorageopen->setEnabled(prefs.cloud_verification_status == CS_VERIFIED);
ui.actionCloudstoragesave->setEnabled(prefs.cloud_verification_status == CS_VERIFIED);
- ui.actionCloudOnline->setEnabled(prefs.cloud_verification_status == CS_VERIFIED);
- ui.actionCloudOnline->setChecked(prefs.cloud_verification_status == CS_VERIFIED && !prefs.git_local_only);
}
PlannerDetails *MainWindow::plannerDetails() const {
@@ -611,10 +609,8 @@ void MainWindow::on_actionCloudstorageopen_triggered()
showProgressBar();
QByteArray fileNamePtr = QFile::encodeName(filename);
- if (!parse_file(fileNamePtr.data())) {
- set_filename(fileNamePtr.data());
- setTitle();
- }
+ if (!parse_file(fileNamePtr.data()))
+ setCurrentFile(fileNamePtr.data());
process_dives(false, false);
hideProgressBar();
refreshDisplay();
@@ -641,8 +637,7 @@ void MainWindow::on_actionCloudstoragesave_triggered()
if (error)
return;
- set_filename(filename.toUtf8().data());
- setTitle();
+ setCurrentFile(filename.toUtf8().data());
mark_divelist_changed(false);
}
@@ -684,7 +679,7 @@ void MainWindow::on_actionCloudOnline_triggered()
}
setTitle();
- ui.actionCloudOnline->setChecked(!prefs.git_local_only);
+ updateCloudOnlineStatus();
}
void learnImageDirs(QStringList dirnames)
@@ -759,6 +754,21 @@ void MainWindow::closeCurrentFile()
dcList.dcMap.clear();
}
+void MainWindow::updateCloudOnlineStatus()
+{
+ bool is_cloud = existing_filename && prefs.cloud_git_url && prefs.cloud_verification_status == CS_VERIFIED &&
+ strstr(existing_filename, prefs.cloud_git_url);
+ ui.actionCloudOnline->setEnabled(is_cloud);
+ ui.actionCloudOnline->setChecked(is_cloud && !prefs.git_local_only);
+}
+
+void MainWindow::setCurrentFile(const char *f)
+{
+ set_filename(f);
+ setTitle();
+ updateCloudOnlineStatus();
+}
+
void MainWindow::on_actionClose_triggered()
{
if (okToClose(tr("Please save or cancel the current dive edit before closing the file."))) {
@@ -1685,8 +1695,7 @@ int MainWindow::file_save_as(void)
if (save_dives(filename.toUtf8().data()))
return -1;
- set_filename(filename.toUtf8().data());
- setTitle();
+ setCurrentFile(filename.toUtf8().data());
mark_divelist_changed(false);
addRecentFile(filename, true);
return 0;
@@ -1740,7 +1749,6 @@ QString MainWindow::displayedFilename(QString fullFilename)
if (fullFilename.contains(prefs.cloud_git_url)) {
QString email = fileName.left(fileName.indexOf('['));
- ui.actionCloudOnline->setChecked(!prefs.git_local_only);
if (prefs.git_local_only)
return tr("[local cache for] %1").arg(email);
else
@@ -1824,9 +1832,8 @@ void MainWindow::loadFiles(const QStringList fileNames)
for (int i = 0; i < fileNames.size(); ++i) {
fileNamePtr = QFile::encodeName(fileNames.at(i));
if (!parse_file(fileNamePtr.data())) {
- set_filename(fileNamePtr.data());
+ setCurrentFile(fileNamePtr.data());
addRecentFile(fileNamePtr, false);
- setTitle();
}
}
hideProgressBar();
diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h
index 7e5ebbebe..18b03cb61 100644
--- a/desktop-widgets/mainwindow.h
+++ b/desktop-widgets/mainwindow.h
@@ -198,6 +198,8 @@ private:
bool askSaveChanges();
bool okToClose(QString message);
void closeCurrentFile();
+ void setCurrentFile(const char *f);
+ void updateCloudOnlineStatus();
void showProgressBar();
void hideProgressBar();
void writeSettings();