diff options
author | Liang Qi <liang.qi@qt.io> | 2018-02-06 12:38:51 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-02-10 15:55:52 +0100 |
commit | 32b506d1db1f8cee748a27b548ba8208f2928058 (patch) | |
tree | 2d5b23baafe22ccc3518719f8f5d19bb846b2b61 /src/widgets/widgets | |
parent | 2cb1db64370989fffeec313c196fe573c479e6aa (diff) | |
parent | c0948d508e7179e2e23c893ba6152c40400de060 (diff) |
Merge remote-tracking branch 'origin/dev' into 5.11
Conflicts:
src/corelib/tools/qvarlengtharray.qdoc
src/corelib/tools/qvector.qdoc
Resolved documentation changes in favor of 017569f702b6dd0,
which keeps the move overloads along with its const-ref sibling.
Change-Id: I0835b0b3211a418e5e50defc4cf315f0964fab79
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qlineedit.cpp | 14 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit_p.cpp | 8 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit_p.h | 4 | ||||
-rw-r--r-- | src/widgets/widgets/qmenubar.cpp | 4 |
4 files changed, 28 insertions, 2 deletions
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 156b0e331c..e3b348f0ef 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1466,6 +1466,8 @@ bool QLineEdit::event(QEvent * e) #endif } else if (e->type() == QEvent::Resize) { d->positionSideWidgets(); + } else if (e->type() == QEvent::StyleChange) { + d->initMouseYThreshold(); } #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) { @@ -1546,7 +1548,17 @@ void QLineEdit::mouseMoveEvent(QMouseEvent * e) const bool select = (d->imHints & Qt::ImhNoPredictiveText); #endif #ifndef QT_NO_IM - if (d->control->composeMode() && select) { + if (d->mouseYThreshold > 0 && e->pos().y() > d->mousePressPos.y() + d->mouseYThreshold) { + if (layoutDirection() == Qt::RightToLeft) + d->control->home(select); + else + d->control->end(select); + } else if (d->mouseYThreshold > 0 && e->pos().y() + d->mouseYThreshold < d->mousePressPos.y()) { + if (layoutDirection() == Qt::RightToLeft) + d->control->end(select); + else + d->control->home(select); + } else if (d->control->composeMode() && select) { int startPos = d->xToPos(d->mousePressPos.x()); int currentPos = d->xToPos(e->pos().x()); if (startPos != currentPos) diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index c66b842223..6a8af53c97 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -56,6 +56,7 @@ #endif #include <qpainter.h> #include <qpropertyanimation.h> +#include <qstylehints.h> #include <qvalidator.h> QT_BEGIN_NAMESPACE @@ -232,6 +233,13 @@ void QLineEditPrivate::init(const QString& txt) q->setAcceptDrops(true); q->setAttribute(Qt::WA_MacShowFocusRect); + + initMouseYThreshold(); +} + +void QLineEditPrivate::initMouseYThreshold() +{ + mouseYThreshold = QGuiApplication::styleHints()->mouseQuickSelectionThreshold(); } QRect QLineEditPrivate::adjustedContentsRect() const diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index a3f549ad31..39f670b0b0 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -141,7 +141,7 @@ public: dragEnabled(0), clickCausedFocus(0), hscroll(0), vscroll(0), alignment(Qt::AlignLeading | Qt::AlignVCenter), leftTextMargin(0), topTextMargin(0), rightTextMargin(0), bottomTextMargin(0), - lastTextSize(0) + lastTextSize(0), mouseYThreshold(0) { } @@ -155,6 +155,7 @@ public: QPointer<QAction> selectAllAction; #endif void init(const QString&); + void initMouseYThreshold(); QRect adjustedControlRect(const QRect &) const; @@ -253,6 +254,7 @@ private: SideWidgetEntryList leadingSideWidgets; SideWidgetEntryList trailingSideWidgets; int lastTextSize; + int mouseYThreshold; }; Q_DECLARE_TYPEINFO(QLineEditPrivate::SideWidgetEntry, Q_PRIMITIVE_TYPE); Q_DECLARE_TYPEINFO(QLineEditPrivate::SideWidgetLocation, Q_PRIMITIVE_TYPE); diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 0c11afdc61..b0a75288e8 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -1080,6 +1080,10 @@ void QMenuBar::mouseReleaseEvent(QMouseEvent *e) d->mouseDown = false; QAction *action = d->actionAt(e->pos()); + + // do noting if the action is hidden + if (!d->isVisible(action)) + return; if((d->closePopupMode && action == d->currentAction) || !action || !action->menu()) { //we set the current action before activating //so that we let the leave event set the current back to 0 |