aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qdeduper/mingui.cpp11
-rw-r--r--qdeduper/mingui.hpp2
2 files changed, 8 insertions, 5 deletions
diff --git a/qdeduper/mingui.cpp b/qdeduper/mingui.cpp
index c9ca2f8..8d5d10a 100644
--- a/qdeduper/mingui.cpp
+++ b/qdeduper/mingui.cpp
@@ -233,6 +233,7 @@ void DeduperMainWindow::setup_menu()
QAction *load_db = file->addAction("Load Database...");
load_db->setIcon(this->style()->standardIcon(QStyle::StandardPixmap::SP_DialogOpenButton));
QObject::connect(load_db, &QAction::triggered, [this] {
+ if (!modified_check(false)) return;
QString dbpath = QFileDialog::getOpenFileName(this, "Load Database", QString(), "Signature database (*.sigdb)");
if (!dbpath.isNull())
{
@@ -303,7 +304,7 @@ void DeduperMainWindow::setup_menu()
menuact["preferences"] = pref;
QAction *exita = file->addAction("Exit");
QObject::connect(exita, &QAction::triggered, [this] {
- if (this->quit_check()) qApp->quit();
+ if (this->modified_check()) qApp->quit();
});
menuact["exit"] = exita;
@@ -649,6 +650,7 @@ void DeduperMainWindow::load_list()
void DeduperMainWindow::create_new()
{
+ if (!modified_check(false)) return;
PathChooser *pc = new PathChooser(this);
pc->setModal(true);
if (pc->exec() == QDialog::DialogCode::Accepted)
@@ -899,12 +901,13 @@ fs::path::string_type DeduperMainWindow::common_prefix(const std::vector<fs::pat
return ret;
}
-bool DeduperMainWindow::quit_check()
+bool DeduperMainWindow::modified_check(bool quitting)
{
if (!this->sdb || !this->sdb->valid()) return true;
if (this->markschanged || this->sdb->is_dirty())
return QMessageBox::StandardButton::Yes ==
- QMessageBox::question(this, "Confirmation", "You have unsaved files list or database. Really quit?",
+ QMessageBox::question(this, "Confirmation", quitting ? "You have unsaved files list or database. Really quit?"
+ : "You have unsaved files list or database. Proceed?",
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No,
QMessageBox::StandardButton::No);
return true;
@@ -912,7 +915,7 @@ bool DeduperMainWindow::quit_check()
void DeduperMainWindow::closeEvent(QCloseEvent *e)
{
- if (quit_check())
+ if (modified_check())
e->accept();
else
e->ignore();
diff --git a/qdeduper/mingui.hpp b/qdeduper/mingui.hpp
index d675d47..a4b2089 100644
--- a/qdeduper/mingui.hpp
+++ b/qdeduper/mingui.hpp
@@ -74,7 +74,7 @@ private:
void mark_none(bool msg = true);
void marked_update(bool update_msg = true);
fs::path::string_type common_prefix(const std::vector<fs::path> &fns);
- bool quit_check();
+ bool modified_check(bool quitting = true);
protected:
void closeEvent(QCloseEvent *e) override;
bool eventFilter(QObject *obj, QEvent *ev) override;