diff options
| author | Kai Uwe Broulik <[email protected]> | 2017-02-13 13:20:07 +0100 |
|---|---|---|
| committer | Kai Uwe Broulik <[email protected]> | 2017-02-13 13:20:07 +0100 |
| commit | f7770c60b17108fde8d4b15006a4e8347e85de7b (patch) | |
| tree | 2136521ee7349de681d4130f1eb2275f991a12d3 /src/dolphintabbar.cpp | |
| parent | d75b1de7bfeba76c540f6772e997aed4aacada88 (diff) | |
Close tab on mouse release rather than on mouse press
Differential Revision: https://phabricator.kde.org/D4501
Diffstat (limited to 'src/dolphintabbar.cpp')
| -rw-r--r-- | src/dolphintabbar.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/dolphintabbar.cpp b/src/dolphintabbar.cpp index e909c36ae..484a9f3a0 100644 --- a/src/dolphintabbar.cpp +++ b/src/dolphintabbar.cpp @@ -29,7 +29,8 @@ DolphinTabBar::DolphinTabBar(QWidget* parent) : QTabBar(parent), - m_autoActivationIndex(-1) + m_autoActivationIndex(-1), + m_tabToBeClosedOnMiddleMouseButtonRelease(-1) { setAcceptDrops(true); setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); @@ -95,12 +96,25 @@ void DolphinTabBar::mousePressEvent(QMouseEvent* event) const int index = tabAt(event->pos()); if (index >= 0 && event->button() == Qt::MiddleButton) { + m_tabToBeClosedOnMiddleMouseButtonRelease = index; + return; + } + + QTabBar::mousePressEvent(event); +} + +void DolphinTabBar::mouseReleaseEvent(QMouseEvent *event) +{ + const int index = tabAt(event->pos()); + + if (index >= 0 && index == m_tabToBeClosedOnMiddleMouseButtonRelease + && event->button() == Qt::MiddleButton) { // Mouse middle click on a tab closes this tab. emit tabCloseRequested(index); return; } - QTabBar::mousePressEvent(event); + QTabBar::mouseReleaseEvent(event); } void DolphinTabBar::mouseDoubleClickEvent(QMouseEvent* event) |
