From fb750d6d85796b2f64f4093d315307a0cf9dadee Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 23 May 2018 20:02:12 +0200 Subject: [PATCH] added confirmation dialog when closing a tab --- src/widgets/helper/notebooktab.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/widgets/helper/notebooktab.cpp b/src/widgets/helper/notebooktab.cpp index 6fcb6747e..621a37fc2 100644 --- a/src/widgets/helper/notebooktab.cpp +++ b/src/widgets/helper/notebooktab.cpp @@ -324,15 +324,25 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event) { this->mouseDown = false; + auto removeThisPage = [this] { + auto reply = QMessageBox::question(this, "Remove this tab", + "Are you sure that you want to remove this tab?", + QMessageBox::Yes | QMessageBox::Cancel); + + if (reply == QMessageBox::Yes) { + this->notebook->removePage(this->page); + } + }; + if (event->button() == Qt::MiddleButton) { if (this->rect().contains(event->pos())) { - this->notebook->removePage(this->page); + removeThisPage(); } } else { if (this->hasXButton() && this->mouseDownX && this->getXRect().contains(event->pos())) { this->mouseDownX = false; - this->notebook->removePage(this->page); + removeThisPage(); } else { this->update(); }