dbhub: Show a warning when trying to push unsaved changes

When clicking the Upload Database button when there are unsaved changes
show a warning to the user.
This commit is contained in:
Martin Kleusberg
2020-07-14 15:41:34 +02:00
parent 0942fad612
commit e285de6dc9
+12
View File
@@ -1,5 +1,6 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QFileInfo> #include <QFileInfo>
#include <QMessageBox>
#include <QUrl> #include <QUrl>
#include <QUrlQuery> #include <QUrlQuery>
@@ -152,6 +153,17 @@ void RemoteDock::pushDatabase()
return; return;
} }
// Show a warning when trying to push a database with unsaved changes
if(mainWindow->getDb().getDirty())
{
if(QMessageBox::warning(this,
QApplication::applicationName(),
tr("The database has unsaved changes. Are you sure you want to push it before saving?"),
QMessageBox::Yes | QMessageBox::Cancel,
QMessageBox::Cancel) == QMessageBox::Cancel)
return;
}
// The default suggestion for a database name is the local file name. If it is a remote file (like when it initially was fetched using DB4S), // The default suggestion for a database name is the local file name. If it is a remote file (like when it initially was fetched using DB4S),
// the extra bit of information at the end of the name gets removed first. // the extra bit of information at the end of the name gets removed first.
QString name = QFileInfo(mainWindow->getDb().currentFile()).fileName(); QString name = QFileInfo(mainWindow->getDb().currentFile()).fileName();