From 32f6c5e920085f3bf5baa2e248db260cfeb325d5 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 23 Jan 2017 12:27:42 -0500 Subject: Add a checkable menu option for showing/skipping the unsaved changes dialogs in lumina-textedit. --- src-qt5/desktop-utils/lumina-textedit/MainUI.cpp | 10 +++++++++- src-qt5/desktop-utils/lumina-textedit/MainUI.h | 1 + src-qt5/desktop-utils/lumina-textedit/MainUI.ui | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'src-qt5') diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp b/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp index 88f7bf00..b5790cc5 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.cpp @@ -50,6 +50,8 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ } ui->actionLine_Numbers->setChecked( settings->value("showLineNumbers",true).toBool() ); ui->actionWrap_Lines->setChecked( settings->value("wrapLines",true).toBool() ); + ui->actionShow_Popups->setChecked( settings->value("showPopupWarnings",true).toBool() ); + //Setup any connections connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(close()) ); connect(ui->actionNew_File, SIGNAL(triggered()), this, SLOT(NewFile()) ); @@ -62,6 +64,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabClosed(int)) ); connect(ui->actionLine_Numbers, SIGNAL(toggled(bool)), this, SLOT(showLineNumbers(bool)) ); connect(ui->actionWrap_Lines, SIGNAL(toggled(bool)), this, SLOT(wrapLines(bool)) ); + connect(ui->actionShow_Popups, SIGNAL(toggled(bool)), this, SLOT(showPopupWarnings(bool)) ); connect(ui->actionCustomize_Colors, SIGNAL(triggered()), this, SLOT(ModifyColors()) ); connect(ui->actionFind, SIGNAL(triggered()), this, SLOT(openFind()) ); connect(ui->actionReplace, SIGNAL(triggered()), this, SLOT(openReplace()) ); @@ -250,6 +253,10 @@ void MainUI::ModifyColors(){ colorDLG->showNormal(); } +void MainUI::showPopupWarnings(bool show){ + settings->setValue("showPopupWarnings",show); +} + void MainUI::updateTab(QString file){ PlainTextEditor *cur = 0; int index = -1; @@ -284,7 +291,7 @@ void MainUI::tabChanged(){ void MainUI::tabClosed(int tab){ PlainTextEditor *edit = static_cast(ui->tabWidget->widget(tab)); if(edit==0){ return; } //should never happen - if(edit->hasChange()){ + if(edit->hasChange() && ui->actionShow_Popups->isChecked() ){ //Verify if the user wants to lose any unsaved changes if(QMessageBox::Yes != QMessageBox::question(this, tr("Lose Unsaved Changes?"), QString(tr("This file has unsaved changes.\nDo you want to close it anyway?\n\n%1")).arg(edit->currentFile()), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){ return; } } @@ -382,6 +389,7 @@ void MainUI::closeEvent(QCloseEvent *ev){ } } bool quitnow = unsaved.isEmpty(); + if(!quitnow && !ui->actionShow_Popups->isChecked()){ quitnow = true; } if(!quitnow){ quitnow = (QMessageBox::Yes == QMessageBox::question(this, tr("Lose Unsaved Changes?"), QString(tr("There are unsaved changes.\nDo you want to close the editor anyway?\n\n%1")).arg(unsaved.join("\n")), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ); } diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.h b/src-qt5/desktop-utils/lumina-textedit/MainUI.h index d80793b0..097b747e 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.h +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.h @@ -57,6 +57,7 @@ private slots: void showLineNumbers(bool); void wrapLines(bool); void ModifyColors(); + void showPopupWarnings(bool); //Tab Interactions void updateTab(QString); diff --git a/src-qt5/desktop-utils/lumina-textedit/MainUI.ui b/src-qt5/desktop-utils/lumina-textedit/MainUI.ui index f58644db..eb70184c 100644 --- a/src-qt5/desktop-utils/lumina-textedit/MainUI.ui +++ b/src-qt5/desktop-utils/lumina-textedit/MainUI.ui @@ -236,6 +236,7 @@ + @@ -388,6 +389,23 @@ Qt::ApplicationShortcut + + + true + + + true + + + Show Popup Warnings + + + Show warnings about unsaved changes + + + Show warnings about unsaved changes + + -- cgit