added confirmation dialog when closing a tab
This commit is contained in:
@@ -324,15 +324,25 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
this->mouseDown = false;
|
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 (event->button() == Qt::MiddleButton) {
|
||||||
if (this->rect().contains(event->pos())) {
|
if (this->rect().contains(event->pos())) {
|
||||||
this->notebook->removePage(this->page);
|
removeThisPage();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this->hasXButton() && this->mouseDownX && this->getXRect().contains(event->pos())) {
|
if (this->hasXButton() && this->mouseDownX && this->getXRect().contains(event->pos())) {
|
||||||
this->mouseDownX = false;
|
this->mouseDownX = false;
|
||||||
|
|
||||||
this->notebook->removePage(this->page);
|
removeThisPage();
|
||||||
} else {
|
} else {
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user