mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 18:23:23 +00:00
Enable cloud-online menu entry only if connected to cloud
Enable the menu item cloud-online only if the current file is the cloud storage. Since this has to be checked every time the current file is set, factor this out into the new MainWindow::setCurrentFile() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
bb64c6bda8
commit
b3901aa8f9
2 changed files with 23 additions and 14 deletions
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue