Keep track of mouse button state in QTabBar
Get rid of call to QGuiApplication::mouseButtons Task-number: QTBUG-73829 Change-Id: I7cc706b5e037c68ecf3c778b824ae8c93e5cfe38 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
01d30f8399
commit
dd34ac5c34
@ -861,7 +861,7 @@ void QTabBarPrivate::refresh()
|
||||
// be safe in case a subclass is also handling move with the tabs
|
||||
if (pressedIndex != -1
|
||||
&& movable
|
||||
&& QGuiApplication::mouseButtons() == Qt::NoButton) {
|
||||
&& mouseButtons == Qt::NoButton) {
|
||||
moveTabFinished(pressedIndex);
|
||||
if (!validIndex(pressedIndex))
|
||||
pressedIndex = -1;
|
||||
@ -1782,6 +1782,11 @@ bool QTabBar::event(QEvent *event)
|
||||
event->ignore();
|
||||
break;
|
||||
#endif
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::MouseMove:
|
||||
d->mouseButtons = static_cast<QMouseEvent *>(event)->buttons();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -88,14 +88,17 @@ class Q_WIDGETS_EXPORT QTabBarPrivate : public QWidgetPrivate
|
||||
Q_DECLARE_PUBLIC(QTabBar)
|
||||
public:
|
||||
QTabBarPrivate()
|
||||
:currentIndex(-1), pressedIndex(-1), firstVisible(0), lastVisible(-1), shape(QTabBar::RoundedNorth), layoutDirty(false),
|
||||
drawBase(true), scrollOffset(0), hoverIndex(-1), elideModeSetByUser(false), useScrollButtonsSetByUser(false), expanding(true), closeButtonOnTabs(false),
|
||||
selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false),
|
||||
dragInProgress(false), documentMode(false), autoHide(false), changeCurrentOnDrag(false),
|
||||
switchTabCurrentIndex(-1), switchTabTimerId(0), movingTab(nullptr)
|
||||
: currentIndex(-1), mouseButtons(Qt::NoButton), pressedIndex(-1), firstVisible(0), lastVisible(-1),
|
||||
shape(QTabBar::RoundedNorth), layoutDirty(false), drawBase(true), scrollOffset(0),
|
||||
hoverIndex(-1), elideModeSetByUser(false), useScrollButtonsSetByUser(false), expanding(true),
|
||||
closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab),
|
||||
paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false),
|
||||
autoHide(false), changeCurrentOnDrag(false), switchTabCurrentIndex(-1), switchTabTimerId(0),
|
||||
movingTab(nullptr)
|
||||
{}
|
||||
|
||||
int currentIndex;
|
||||
Qt::MouseButtons mouseButtons;
|
||||
int pressedIndex;
|
||||
int firstVisible;
|
||||
int lastVisible;
|
||||
|
Loading…
Reference in New Issue
Block a user