diff options
Diffstat (limited to 'src')
23 files changed, 66 insertions, 24 deletions
diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index 2baa4c73..2f50dc0e 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -345,7 +345,7 @@ Control { property bool overridePressed: false readonly property bool effectivePressed: (pressed || overridePressed) && containsMouse anchors.fill: parent - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled onPressed: { if (comboBox.activeFocusOnPress) forceActiveFocus() diff --git a/src/controls/Menu.qml b/src/controls/Menu.qml index 7d90e19e..2ab229ab 100644 --- a/src/controls/Menu.qml +++ b/src/controls/Menu.qml @@ -44,8 +44,8 @@ import QtQuick.Controls.Private 1.0 \inqmlmodule QtQuick.Controls \since 5.1 \ingroup menus - \brief Provides a menu component for use in menu bars, as context menu, - and other popup menus. + \brief Provides a menu component for use as a context menu, popup menu, or + as part of a menu bar. \image menu.png diff --git a/src/controls/MenuBar.qml b/src/controls/MenuBar.qml index d453e227..5f444dac 100644 --- a/src/controls/MenuBar.qml +++ b/src/controls/MenuBar.qml @@ -286,7 +286,7 @@ MenuBarPrivate { MouseArea { id: menuMouseArea anchors.fill: parent - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled onPositionChanged: updateCurrentItem(mouse, false) onPressed: { diff --git a/src/controls/Private/AbstractCheckable.qml b/src/controls/Private/AbstractCheckable.qml index 0e685dea..42abebe5 100644 --- a/src/controls/Private/AbstractCheckable.qml +++ b/src/controls/Private/AbstractCheckable.qml @@ -36,6 +36,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 +import QtQuick.Controls.Private 1.0 /*! \qmltype AbstractCheckable @@ -109,7 +110,7 @@ Control { id: mouseArea focus: true anchors.fill: parent - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled enabled: !keyPressed property bool keyPressed: false diff --git a/src/controls/Private/BasicButton.qml b/src/controls/Private/BasicButton.qml index dc503dc5..5de95aa9 100644 --- a/src/controls/Private/BasicButton.qml +++ b/src/controls/Private/BasicButton.qml @@ -182,7 +182,7 @@ Control { property bool effectivePressed: pressed && containsMouse || keyPressed anchors.fill: parent - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled enabled: !keyPressed function toggle() { diff --git a/src/controls/Private/BasicTableView.qml b/src/controls/Private/BasicTableView.qml index cac673eb..bc8ebdb0 100644 --- a/src/controls/Private/BasicTableView.qml +++ b/src/controls/Private/BasicTableView.qml @@ -682,7 +682,7 @@ ScrollView { MouseArea{ id: headerClickArea drag.axis: Qt.YAxis - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled anchors.fill: parent onClicked: { if (sortIndicatorColumn === index) diff --git a/src/controls/Private/ColumnMenuContent.qml b/src/controls/Private/ColumnMenuContent.qml index a5fa3dc8..8de3fcea 100644 --- a/src/controls/Private/ColumnMenuContent.qml +++ b/src/controls/Private/ColumnMenuContent.qml @@ -36,6 +36,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 +import QtQuick.Controls.Private 1.0 Item { id: content @@ -189,7 +190,7 @@ Item { width: scrollView.width - scrollView.__verticalScrollBar.width height: parent.height - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled acceptedButtons: Qt.AllButtons onPositionChanged: updateCurrentItem({ "x": mouse.x, "y": mouse.y }) diff --git a/src/controls/Private/HoverButton.qml b/src/controls/Private/HoverButton.qml index 6825ff98..c5b39d56 100644 --- a/src/controls/Private/HoverButton.qml +++ b/src/controls/Private/HoverButton.qml @@ -35,6 +35,8 @@ ****************************************************************************/ import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Private 1.0 Item { id: button @@ -69,6 +71,6 @@ Item { id: mouse anchors.fill: parent onClicked: button.clicked() - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled } } diff --git a/src/controls/Private/MenuContentScroller.qml b/src/controls/Private/MenuContentScroller.qml index 44c0eaa1..3efbd5ad 100644 --- a/src/controls/Private/MenuContentScroller.qml +++ b/src/controls/Private/MenuContentScroller.qml @@ -36,6 +36,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 +import QtQuick.Controls.Private 1.0 MouseArea { id: scrollIndicator @@ -46,7 +47,7 @@ MouseArea { bottom: direction === Qt.DownArrow ? parent.bottom : undefined } - hoverEnabled: visible + hoverEnabled: visible && Settings.hoverEnabled height: scrollerLoader.height width: parent.width diff --git a/src/controls/Private/ScrollBar.qml b/src/controls/Private/ScrollBar.qml index 481d766a..f6f5e26d 100644 --- a/src/controls/Private/ScrollBar.qml +++ b/src/controls/Private/ScrollBar.qml @@ -97,7 +97,7 @@ Item { onEntered: if (!pressed) __panel.activeControl = __panel.hitTest(mouseX, mouseY) onExited: if (!pressed) __panel.activeControl = "none" onMouseXChanged: if (!pressed) __panel.activeControl = __panel.hitTest(mouseX, mouseY) - hoverEnabled: !Settings.hasTouchScreen + hoverEnabled: Settings.hoverEnabled enabled: !Settings.isMobile || !Settings.hasTouchScreen // ### Not ideal, but will usually behave as expected... preventStealing: true property var pressedX diff --git a/src/controls/Private/TabBar.qml b/src/controls/Private/TabBar.qml index e7382aa4..183d006b 100644 --- a/src/controls/Private/TabBar.qml +++ b/src/controls/Private/TabBar.qml @@ -36,6 +36,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 +import QtQuick.Controls.Private 1.0 /*! \qmltype TabBar @@ -161,7 +162,7 @@ FocusScope { delegate: MouseArea { id: tabitem objectName: "mousearea" - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled focus: true enabled: modelData.enabled diff --git a/src/controls/Private/TextInputWithHandles.qml b/src/controls/Private/TextInputWithHandles.qml index 9ed4468d..f931986f 100644 --- a/src/controls/Private/TextInputWithHandles.qml +++ b/src/controls/Private/TextInputWithHandles.qml @@ -99,7 +99,7 @@ TextInput { MouseArea { id: mouseArea anchors.fill: parent - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled cursorShape: Qt.IBeamCursor acceptedButtons: (input.selectByMouse ? Qt.NoButton : Qt.LeftButton) | (control.menu ? Qt.RightButton : Qt.NoButton) onClicked: { diff --git a/src/controls/Private/ToolMenuButton.qml b/src/controls/Private/ToolMenuButton.qml index c93c3b14..f2c8c3e1 100644 --- a/src/controls/Private/ToolMenuButton.qml +++ b/src/controls/Private/ToolMenuButton.qml @@ -87,7 +87,7 @@ FocusScope { anchors.fill: parent enabled: !keyPressed - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled onReleased: { if (Settings.hasTouchScreen && containsMouse && menu) diff --git a/src/controls/Private/qquickcontrolsettings.cpp b/src/controls/Private/qquickcontrolsettings.cpp index d1c5b82e..017a0714 100644 --- a/src/controls/Private/qquickcontrolsettings.cpp +++ b/src/controls/Private/qquickcontrolsettings.cpp @@ -101,6 +101,11 @@ bool QQuickControlSettings::isMobile() const #endif } +bool QQuickControlSettings::hoverEnabled() const +{ + return !isMobile() || !hasTouchScreen(); +} + static QString styleImportPath(QQmlEngine *engine, const QString &styleName) { QString path = qgetenv("QT_QUICK_CONTROLS_STYLE"); diff --git a/src/controls/Private/qquickcontrolsettings_p.h b/src/controls/Private/qquickcontrolsettings_p.h index f7234670..ed21101d 100644 --- a/src/controls/Private/qquickcontrolsettings_p.h +++ b/src/controls/Private/qquickcontrolsettings_p.h @@ -54,6 +54,7 @@ class QQuickControlSettings : public QObject Q_PROPERTY(qreal dragThreshold READ dragThreshold CONSTANT) Q_PROPERTY(bool hasTouchScreen READ hasTouchScreen CONSTANT) Q_PROPERTY(bool isMobile READ isMobile CONSTANT) + Q_PROPERTY(bool hoverEnabled READ hoverEnabled CONSTANT) public: QQuickControlSettings(QQmlEngine *engine); @@ -71,6 +72,7 @@ public: bool hasTouchScreen() const; bool isMobile() const; + bool hoverEnabled() const; signals: void styleChanged(); diff --git a/src/controls/ProgressBar.qml b/src/controls/ProgressBar.qml index e988874e..7bc3bec5 100644 --- a/src/controls/ProgressBar.qml +++ b/src/controls/ProgressBar.qml @@ -141,7 +141,7 @@ Control { MouseArea { id: hoverArea anchors.fill: parent - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled } /*! \internal */ diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index 3f1169a2..8bce7e8f 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -171,8 +171,11 @@ Control { /*! \internal */ property bool __horizontal: orientation === Qt.Horizontal - /*! \internal */ - property real __handlePos: range.valueForPosition(__horizontal ? fakeHandle.x : fakeHandle.y) + /*! \internal + The extra arguments positionAtMinimum and positionAtMaximum are there to force + re-evaluation of the handle position when the constraints change (QTBUG-41255). + */ + property real __handlePos: range.valueForPosition(__horizontal ? fakeHandle.x : fakeHandle.y, range.positionAtMinimum, range.positionAtMaximum) activeFocusOnTab: true @@ -225,7 +228,7 @@ Control { id: mouseArea anchors.fill: parent - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled property int clickOffset: 0 property real pressX: 0 property real pressY: 0 diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index 39caae50..95ce2b47 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -267,7 +267,7 @@ Control { MouseArea { id: mouseArea anchors.fill: parent - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled onPressed: if (activeFocusOnPress) input.forceActiveFocus() onWheel: { if (wheel.angleDelta.y > 0) @@ -330,7 +330,7 @@ Control { MouseArea { id: mouseUp objectName: "mouseUp" - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled property var upRect: __panel ? __panel.upRect : null @@ -357,7 +357,7 @@ Control { MouseArea { id: mouseDown objectName: "mouseDown" - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled onClicked: __decrement() onPressed: if (!Settings.hasTouchScreen && activeFocusOnPress) input.forceActiveFocus() diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml index 15db7350..38b7f839 100644 --- a/src/controls/SplitView.qml +++ b/src/controls/SplitView.qml @@ -449,7 +449,7 @@ Item { anchors.rightMargin: (parent.width <= 1) ? -defaultMargin : 0 anchors.topMargin: (parent.height <= 1) ? -defaultMargin : 0 anchors.bottomMargin: (parent.height <= 1) ? -defaultMargin : 0 - hoverEnabled: true + hoverEnabled: Private.Settings.hoverEnabled drag.threshold: 0 drag.target: parent drag.axis: root.orientation === Qt.Horizontal ? Drag.XAxis : Drag.YAxis diff --git a/src/controls/Styles/Base/CalendarStyle.qml b/src/controls/Styles/Base/CalendarStyle.qml index d8af6ab1..590f67db 100644 --- a/src/controls/Styles/Base/CalendarStyle.qml +++ b/src/controls/Styles/Base/CalendarStyle.qml @@ -526,7 +526,7 @@ Style { id: mouseArea anchors.fill: parent - hoverEnabled: true + hoverEnabled: Settings.hoverEnabled function cellIndexAt(mouseX, mouseY) { var viewContainerPos = viewContainer.mapFromItem(mouseArea, mouseX, mouseY); diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp index 1c5f8d0b..52063979 100644 --- a/src/controls/qquickmenupopupwindow.cpp +++ b/src/controls/qquickmenupopupwindow.cpp @@ -96,7 +96,7 @@ void QQuickMenuPopupWindow::setGeometry(int posx, int posy, int w, int h) pw = parentItem()->window(); if (!pw) pw = this; - QRect g = pw->screen()->availableVirtualGeometry(); + QRect g = pw->screen()->virtualGeometry(); if (posx + w > g.right()) { if (qobject_cast<QQuickMenuPopupWindow *>(transientParent())) { diff --git a/src/layouts/qquicklinearlayout.cpp b/src/layouts/qquicklinearlayout.cpp index e22951ac..0b9c6f54 100644 --- a/src/layouts/qquicklinearlayout.cpp +++ b/src/layouts/qquicklinearlayout.cpp @@ -393,6 +393,11 @@ void QQuickGridLayoutBase::invalidate(QQuickItem *childItem) Q_D(QQuickGridLayoutBase); if (!isReady()) return; + if (d->m_rearranging) { + d->m_invalidateAfterRearrange << childItem; + return; + } + quickLayoutDebug() << "QQuickGridLayoutBase::invalidate()"; if (childItem) { @@ -432,6 +437,11 @@ void QQuickGridLayoutBase::updateLayoutItems() Q_D(QQuickGridLayoutBase); if (!isReady()) return; + if (d->m_rearranging) { + d->m_updateAfterRearrange = true; + return; + } + quickLayoutDebug() << "QQuickGridLayoutBase::updateLayoutItems"; d->engine.deleteItems(); insertLayoutItems(); @@ -540,6 +550,7 @@ void QQuickGridLayoutBase::rearrange(const QSizeF &size) if (!isReady()) return; + d->m_rearranging = true; quickLayoutDebug() << objectName() << "QQuickGridLayoutBase::rearrange()" << size; Qt::LayoutDirection visualDir = effectiveLayoutDirection(); d->engine.setVisualDirection(visualDir); @@ -555,6 +566,16 @@ void QQuickGridLayoutBase::rearrange(const QSizeF &size) // This could happen if there is a binding like implicitWidth: height QQuickLayout::rearrange(size); d->engine.setGeometries(QRectF(QPointF(0,0), size), d->styleInfo); + d->m_rearranging = false; + + foreach (QQuickItem *invalid, d->m_invalidateAfterRearrange) + invalidate(invalid); + d->m_invalidateAfterRearrange.clear(); + + if (d->m_updateAfterRearrange) { + updateLayoutItems(); + d->m_updateAfterRearrange = false; + } } bool QQuickGridLayoutBase::shouldIgnoreItem(QQuickItem *child, QQuickLayoutAttached *&info, QSizeF *sizeHints) diff --git a/src/layouts/qquicklinearlayout_p.h b/src/layouts/qquicklinearlayout_p.h index 322ae93e..0f43badd 100644 --- a/src/layouts/qquicklinearlayout_p.h +++ b/src/layouts/qquicklinearlayout_p.h @@ -109,6 +109,8 @@ class QQuickGridLayoutBasePrivate : public QQuickLayoutPrivate public: QQuickGridLayoutBasePrivate() : m_disableRearrange(true) , m_isReady(false) + , m_rearranging(false) + , m_updateAfterRearrange(false) , m_layoutDirection(Qt::LeftToRight) {} @@ -122,6 +124,9 @@ public: Qt::Orientation orientation; unsigned m_disableRearrange : 1; unsigned m_isReady : 1; + unsigned m_rearranging : 1; + unsigned m_updateAfterRearrange : 1; + QVector<QQuickItem *> m_invalidateAfterRearrange; Qt::LayoutDirection m_layoutDirection : 2; QSet<QQuickItem *> m_ignoredItems; |