@@ -37,28 +37,48 @@ bool DockTabBar::event(QEvent* event)
3737 doubleClicked (mouseEvent->pos ());
3838 return true ;
3939 }
40- case QEvent::MouseButtonPress: {
41- QQuickItem* tabBar = tabBarQmlItem ();
42- if (tabBar) {
43- QMouseEvent* mouseEvent = static_cast <QMouseEvent*>(event);
44- QPoint localPos = mouseEvent->pos ();
40+ case QEvent::MouseButtonPress:
41+ case QEvent::MouseButtonRelease: {
42+ QMouseEvent* mouseEvent = static_cast <QMouseEvent*>(event);
43+ onMousePressRelease (mouseEvent);
44+ return true ;
45+ }
46+ default :
47+ break ;
48+ }
4549
46- int tabIndex = tabAt (localPos);
47- if (tabIndex < 0 ) {
48- return true ;
49- }
50+ return KDDockWidgets::TabBarQuick::event (event);
51+ }
5052
51- tabBar->setProperty (" currentIndex" , tabIndex);
52- TabBar::onMousePress (localPos);
53- }
53+ void DockTabBar::onMousePressRelease (const QMouseEvent* mouseEvent)
54+ {
55+ QQuickItem* tabBar = tabBarQmlItem ();
56+ if (!mouseEvent || !tabBar) {
57+ return ;
58+ }
59+
60+ const QPoint localPos = mouseEvent->pos ();
61+
62+ int tabIndex = tabAt (localPos);
63+ if (tabIndex < 0 ) {
64+ return ;
65+ }
5466
67+ switch (mouseEvent->type ()) {
68+ case QEvent::MouseButtonPress: {
69+ m_indexOfPressedTab = tabIndex;
70+ TabBar::onMousePress (localPos);
5571 break ;
5672 }
57- default :
73+ case QEvent::MouseButtonRelease: {
74+ if (tabIndex == m_indexOfPressedTab) {
75+ tabBar->setProperty (" currentIndex" , tabIndex);
76+ }
77+ m_indexOfPressedTab = -1 ;
5878 break ;
5979 }
60-
61- return KDDockWidgets::TabBarQuick::event (event);
80+ default : UNREACHABLE ;
81+ }
6282}
6383
6484void DockTabBar::doubleClicked (const QPoint& pos) const
0 commit comments