From ebdfec8604b7cf308475c8907d9e70e6b13aeed9 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 26 Sep 2017 14:03:24 -0400 Subject: Fix up the close event handling in lumina-textedit. Now it will actually close when there are no changes to be saved. --- src-qt5/desktop-utils/lumina-textedit/MainUI.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp b/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp index 4c2ce0bd..9e4ce499 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp @@ -496,11 +496,14 @@ void MainUI::closeEvent(QCloseEvent *ev){ unsaved << tmp->currentFile(); } } - bool savenow = unsaved.isEmpty(); + if(unsaved.isEmpty()){ QMainWindow::closeEvent(ev); return; } + bool savenow = false; if(!savenow && !ui->actionShow_Popups->isChecked()){ savenow = true; } if(!savenow){ - savenow = (QMessageBox::Yes == QMessageBox::question(this, tr("Save Changes before closing?"), QString(tr("There are unsaved changes.\nDo you want save them before you close the editor?\n\n%1")).arg(unsaved.join("\n")), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ); + QMessageBox::StandardButton but = QMessageBox::question(this, tr("Save Changes before closing?"), QString(tr("There are unsaved changes.\nDo you want save them before you close the editor?\n\n%1")).arg(unsaved.join("\n")), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::No); + savenow = (but == QMessageBox::Yes); + if(but == QMessageBox::Cancel){ ev->ignore(); return; } } - if(!savenow){ QMainWindow::closeEvent(ev); } - else{ ev->ignore(); SaveFile(); } + if(savenow){ SaveFile(); } + QMainWindow::closeEvent(ev); } -- cgit