QSplitter: Don't move handle in non-pressed state
Fixes: QTBUG-102249 Pick-to: 6.2 6.3 Change-Id: Ib1d74447e346760d1fc9960e11486e8dc7ea3bc0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
cd1ac8666c
commit
99f22e3fc8
@ -289,10 +289,11 @@ bool QSplitterHandle::event(QEvent *event)
|
|||||||
void QSplitterHandle::mouseMoveEvent(QMouseEvent *e)
|
void QSplitterHandle::mouseMoveEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
Q_D(QSplitterHandle);
|
Q_D(QSplitterHandle);
|
||||||
if (!(e->buttons() & Qt::LeftButton))
|
if (!d->pressed)
|
||||||
return;
|
return;
|
||||||
int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPosition().toPoint()))
|
|
||||||
- d->mouseOffset;
|
const int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPosition().toPoint()))
|
||||||
|
- d->mouseOffset;
|
||||||
if (opaqueResize()) {
|
if (opaqueResize()) {
|
||||||
moveSplitter(pos);
|
moveSplitter(pos);
|
||||||
} else {
|
} else {
|
||||||
@ -319,16 +320,18 @@ void QSplitterHandle::mousePressEvent(QMouseEvent *e)
|
|||||||
void QSplitterHandle::mouseReleaseEvent(QMouseEvent *e)
|
void QSplitterHandle::mouseReleaseEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
Q_D(QSplitterHandle);
|
Q_D(QSplitterHandle);
|
||||||
if (!opaqueResize() && e->button() == Qt::LeftButton) {
|
if (!d->pressed)
|
||||||
int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPosition().toPoint()))
|
return;
|
||||||
- d->mouseOffset;
|
|
||||||
|
if (!opaqueResize()) {
|
||||||
|
const int pos = d->pick(parentWidget()->mapFromGlobal(e->globalPosition().toPoint()))
|
||||||
|
- d->mouseOffset;
|
||||||
d->s->setRubberBand(-1);
|
d->s->setRubberBand(-1);
|
||||||
moveSplitter(pos);
|
moveSplitter(pos);
|
||||||
}
|
}
|
||||||
if (e->button() == Qt::LeftButton) {
|
|
||||||
d->pressed = false;
|
d->pressed = false;
|
||||||
update();
|
update();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
|
#include <QSignalSpy>
|
||||||
|
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qsplitter.h>
|
#include <qsplitter.h>
|
||||||
#include <qstyle.h>
|
#include <qstyle.h>
|
||||||
@ -89,6 +91,7 @@ private slots:
|
|||||||
void task169702_sizes();
|
void task169702_sizes();
|
||||||
void taskQTBUG_4101_ensureOneNonCollapsedWidget_data();
|
void taskQTBUG_4101_ensureOneNonCollapsedWidget_data();
|
||||||
void taskQTBUG_4101_ensureOneNonCollapsedWidget();
|
void taskQTBUG_4101_ensureOneNonCollapsedWidget();
|
||||||
|
void taskQTBUG_102249_moveNonPressed();
|
||||||
void setLayout();
|
void setLayout();
|
||||||
void autoAdd();
|
void autoAdd();
|
||||||
|
|
||||||
@ -1026,6 +1029,24 @@ void tst_QSplitter::taskQTBUG_4101_ensureOneNonCollapsedWidget()
|
|||||||
QTRY_VERIFY(s.sizes().at(0) > 0);
|
QTRY_VERIFY(s.sizes().at(0) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QSplitter::taskQTBUG_102249_moveNonPressed()
|
||||||
|
{
|
||||||
|
QSplitter s;
|
||||||
|
s.setOpaqueResize(true);
|
||||||
|
s.addWidget(new QWidget());
|
||||||
|
s.addWidget(new QWidget());
|
||||||
|
s.show();
|
||||||
|
|
||||||
|
QSignalSpy spyMove(&s, &QSplitter::splitterMoved);
|
||||||
|
QPointF posOutOfWidget = QPointF(30, 30);
|
||||||
|
QMouseEvent me(QEvent::MouseMove,
|
||||||
|
posOutOfWidget, s.mapToGlobal(posOutOfWidget),
|
||||||
|
Qt::NoButton, Qt::MouseButtons(Qt::LeftButton),
|
||||||
|
Qt::NoModifier);
|
||||||
|
qApp->sendEvent(s.handle(0), &me);
|
||||||
|
QCOMPARE(spyMove.count(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QSplitter::setLayout()
|
void tst_QSplitter::setLayout()
|
||||||
{
|
{
|
||||||
QSplitter splitter;
|
QSplitter splitter;
|
||||||
|
Loading…
Reference in New Issue
Block a user