aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-06-01 16:40:36 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-06-01 16:40:36 +0200
commit13ff604e5bd84fbfd63e666c6dacd149fd50d9a9 (patch)
tree66177209eb193f6dda32289c7a53872e9df4c49b
parentAdd ProfileManagerDialog (diff)
downloadsmolbote-13ff604e5bd84fbfd63e666c6dacd149fd50d9a9.tar.xz
Middle mouse button closes tab
-rw-r--r--src/mainwindow/widgets/tabwidget.cpp14
-rw-r--r--src/mainwindow/widgets/tabwidget.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/src/mainwindow/widgets/tabwidget.cpp b/src/mainwindow/widgets/tabwidget.cpp
index 48a1cfb..2858fb0 100644
--- a/src/mainwindow/widgets/tabwidget.cpp
+++ b/src/mainwindow/widgets/tabwidget.cpp
@@ -123,3 +123,17 @@ void TabWidget::contextMenuEvent(QContextMenuEvent *event)
tabContextMenu->exec(event->globalPos());
}
+
+void TabWidget::mousePressEvent(QMouseEvent *event)
+{
+ if(event->button() == Qt::MiddleButton) {
+ int index = tabBar()->tabAt(event->pos());
+ if(index >= 0) {
+ deleteTab(index);
+ }
+ event->accept();
+ return;
+ }
+
+ QTabWidget::mousePressEvent(event);
+}
diff --git a/src/mainwindow/widgets/tabwidget.h b/src/mainwindow/widgets/tabwidget.h
index 06fa79b..793e041 100644
--- a/src/mainwindow/widgets/tabwidget.h
+++ b/src/mainwindow/widgets/tabwidget.h
@@ -28,6 +28,7 @@ public slots:
protected:
void contextMenuEvent(QContextMenuEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
private:
QMenu *tabContextMenu;