diff options
author | Jani Heikkinen <jani.heikkinen@theqtcompany.com> | 2014-11-11 17:38:39 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-11-11 17:38:39 +0100 |
commit | 0bcb10542727e6f84459ba2779139a71effd965d (patch) | |
tree | 37320542f855e3e976cc7722a2ce24212a39a7b0 /src | |
parent | 313ae1c3b581a3e3a44f86793e158ba9e8eae9ab (diff) | |
parent | d162d3b03cf5fb5c359c87ac841dd74a9909a548 (diff) | |
download | qtquickcontrols-0bcb10542727e6f84459ba2779139a71effd965d.tar.gz |
Merge "Merge remote-tracking branch 'origin/5.4' into 5.4.0" into refs/staging/5.4.0
Diffstat (limited to 'src')
-rw-r--r-- | src/controls/Private/TextHandle.qml | 2 | ||||
-rw-r--r-- | src/controls/Private/TextInputWithHandles.qml | 2 | ||||
-rw-r--r-- | src/controls/Private/qquickstyleitem.cpp | 2 | ||||
-rw-r--r-- | src/controls/Slider.qml | 11 | ||||
-rw-r--r-- | src/controls/Styles/Android/ComboBoxStyle.qml | 9 | ||||
-rw-r--r-- | src/controls/Styles/Android/CursorHandleStyle.qml | 75 | ||||
-rw-r--r-- | src/controls/Styles/Android/SpinBoxStyle.qml | 9 | ||||
-rw-r--r-- | src/controls/Styles/Android/TextFieldStyle.qml | 11 | ||||
-rw-r--r-- | src/controls/Styles/Desktop/ComboBoxStyle.qml | 4 | ||||
-rw-r--r-- | src/controls/Styles/iOS/CursorHandleStyle.qml | 1 | ||||
-rw-r--r-- | src/controls/TextArea.qml | 2 | ||||
-rw-r--r-- | src/controls/doc/images/qtquickcontrols-example-splitview.png | bin | 398 -> 0 bytes | |||
-rw-r--r-- | src/controls/doc/images/qtquickcontrols-example-tableview.png | bin | 38463 -> 36290 bytes | |||
-rw-r--r-- | src/controls/doc/src/qtquickcontrols-examples.qdoc | 46 | ||||
-rw-r--r-- | src/controls/doc/src/qtquickcontrols-platformnotes.qdoc | 11 |
15 files changed, 99 insertions, 86 deletions
diff --git a/src/controls/Private/TextHandle.qml b/src/controls/Private/TextHandle.qml index 19fc19a6..8656dcfd 100644 --- a/src/controls/Private/TextHandle.qml +++ b/src/controls/Private/TextHandle.qml @@ -75,7 +75,7 @@ Loader { MouseArea { id: mouse anchors.fill: item - enabled: handle.active + enabled: item && item.visible preventStealing: true property real pressX property point offset diff --git a/src/controls/Private/TextInputWithHandles.qml b/src/controls/Private/TextInputWithHandles.qml index d19dda31..75ca947f 100644 --- a/src/controls/Private/TextInputWithHandles.qml +++ b/src/controls/Private/TextInputWithHandles.qml @@ -170,7 +170,7 @@ TextInput { x: mappedPos.x y: mappedPos.y - visible: pressed || (input.hasSelection && handleX + handleWidth >= -1 && handleX <= control.width + 1) + visible: pressed || ((input.cursorVisible || input.hasSelection) && handleX + handleWidth >= -1 && handleX <= control.width + 1) onPositionChanged: { if (!input.blockRecursion) { diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp index edb33212..fb49e6e3 100644 --- a/src/controls/Private/qquickstyleitem.cpp +++ b/src/controls/Private/qquickstyleitem.cpp @@ -354,6 +354,8 @@ void QQuickStyleItem::initStyleOption() opt->features = QStyleOptionViewItem::HasDisplay; opt->text = text(); opt->textElideMode = Qt::ElideRight; + opt->displayAlignment = Qt::AlignLeft | Qt::AlignVCenter; + opt->decorationAlignment = Qt::AlignCenter; resolvePalette(); needsResolvePalette = false; QPalette pal = m_styleoption->palette; diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index 459fe54c..d0644b4c 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -239,28 +239,28 @@ Control { return Math.max(range.positionAtMinimum, Math.min(range.positionAtMaximum, val)) } - function updateHandlePosition(mouse) { + function updateHandlePosition(mouse, force) { var pos, overThreshold if (__horizontal) { pos = clamp (mouse.x + clickOffset - fakeHandle.width/2) overThreshold = Math.abs(mouse.x - pressX) >= Settings.dragThreshold if (overThreshold) preventStealing = true - if (overThreshold || !Settings.hasTouchScreen) + if (overThreshold || force) fakeHandle.x = pos } else if (!__horizontal) { pos = clamp (mouse.y + clickOffset- fakeHandle.height/2) overThreshold = Math.abs(mouse.y - pressY) >= Settings.dragThreshold if (overThreshold) preventStealing = true - if (overThreshold || !Settings.hasTouchScreen) + if (overThreshold || force) fakeHandle.y = pos } } onPositionChanged: { if (pressed) - updateHandlePosition(mouse) + updateHandlePosition(mouse, preventStealing) var point = mouseArea.mapToItem(fakeHandle, mouse.x, mouse.y) handleHovered = fakeHandle.contains(Qt.point(point.x, point.y)) @@ -276,10 +276,11 @@ Control { } pressX = mouse.x pressY = mouse.y - updateHandlePosition(mouse) + updateHandlePosition(mouse, !Settings.hasTouchScreen) } onReleased: { + updateHandlePosition(mouse, Settings.hasTouchScreen) // If we don't update while dragging, this is the only // moment that the range is updated. if (!slider.updateValueWhileDragging) diff --git a/src/controls/Styles/Android/ComboBoxStyle.qml b/src/controls/Styles/Android/ComboBoxStyle.qml index b6ff1c30..366deed5 100644 --- a/src/controls/Styles/Android/ComboBoxStyle.qml +++ b/src/controls/Styles/Android/ComboBoxStyle.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.2 +import QtQuick 2.4 import QtQuick.Window 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Private 1.0 @@ -70,7 +70,7 @@ Style { readonly property real minWidth: styleDef.View_minWidth || 0 readonly property real minHeight: styleDef.View_minHeight || 0 - readonly property real labelWidth: label.implicitWidth + paddingStart + paddingEnd + readonly property real labelWidth: Math.max(label.implicitWidth, metrics.width) + paddingStart + paddingEnd readonly property real labelHeight: label.implicitHeight + bg.padding.top + bg.padding.bottom implicitWidth: Math.max(minWidth, Math.max(bg.implicitWidth, labelWidth)) @@ -85,6 +85,11 @@ Style { styleDef: panel.styleDef.View_background } + TextMetrics { + id: metrics + text: "12345678901234567890" + } + LabelStyle { id: label text: control.currentText diff --git a/src/controls/Styles/Android/CursorHandleStyle.qml b/src/controls/Styles/Android/CursorHandleStyle.qml index 97b9fe85..e9d08f8e 100644 --- a/src/controls/Styles/Android/CursorHandleStyle.qml +++ b/src/controls/Styles/Android/CursorHandleStyle.qml @@ -45,66 +45,51 @@ import "drawables" DrawableLoader { id: delegate - property bool active: false + + property bool hasText: !!editor.text || !!editor.displayText + styleDef: styleData.hasSelection ? AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandleRight : AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandle x: styleData.hasSelection ? -width / 4 : -width / 2 y: styleData.lineHeight - opacity: 1.0 pressed: styleData.pressed focused: control.activeFocus window_focused: focused && control.Window.active - Connections { - target: editor - ignoreUnknownSignals: true - onDisplayTextChanged: { - delegate.state = "hidden" - } + opacity: hasText && (styleData.hasSelection || styleData.pressed || idle.running) ? 1.0 : 0.0 + + Timer { + id: idle + repeat: false + interval: 4000 } Connections { target: styleData - onActivated: { - if (editor.text) { - delegate.active = true - delegate.opacity = 1.0 - delegate.state = "" - if (!styleData.hasSelection) - delegate.state = "idle" - } + onActivated: idle.restart() + onPressedChanged: { + if (!styleData.pressed) + idle.restart() } } - state: "hidden" - - states: [ - State { - name: "hidden" - when: editor.inputMethodComposing && !delegate.active && !editor.text - }, - State { - name: "idle" - when: !styleData.hasSelection && !styleData.pressed - } - ] + // Hide the cursor handle on textual changes, unless the signals are + // indirectly triggered by activating/tapping/moving the handle. When + // text prediction is enabled, the textual content may change when the + // cursor moves and the predicted text is committed. + Connections { + target: editor + ignoreUnknownSignals: true + onTextChanged: if (!ignore.running) idle.stop() + onDisplayTextChanged: if (!ignore.running) idle.stop() + onInputMethodComposing: if (!ignore.running) idle.stop() + } - transitions: [ - Transition { - to: "hidden" - SequentialAnimation { - PauseAnimation { duration: 100 } - PropertyAction { target: delegate; property: "opacity"; value: 0.0 } - } - }, - Transition { - to: "idle" - SequentialAnimation { - PauseAnimation { duration: 4000 } - NumberAnimation { target: delegate; property: "opacity"; to: 0.0 } - PropertyAction { target: delegate; property: "active"; value: false } - } - } - ] + Timer { + id: ignore + repeat: false + interval: 250 + running: idle.running + } } diff --git a/src/controls/Styles/Android/SpinBoxStyle.qml b/src/controls/Styles/Android/SpinBoxStyle.qml index 5c05774f..0e5df3fd 100644 --- a/src/controls/Styles/Android/SpinBoxStyle.qml +++ b/src/controls/Styles/Android/SpinBoxStyle.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.2 +import QtQuick 2.4 import QtQuick.Window 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Private 1.0 @@ -58,7 +58,7 @@ Style { readonly property real contentWidth: Math.max(styleDef.View_minWidth || 0, styleData.contentWidth) readonly property real contentHeight: Math.max(styleDef.View_minHeight || 0, styleData.contentHeight) - readonly property real labelWidth: label.implicitWidth + bg.padding.left + bg.padding.right + readonly property real labelWidth: Math.max(label.implicitWidth, metrics.width) + bg.padding.left + bg.padding.right readonly property real labelHeight: label.implicitHeight + bg.padding.top + bg.padding.bottom implicitWidth: Math.max(contentWidth, Math.max(bg.implicitWidth, labelWidth)) @@ -88,6 +88,11 @@ Style { readonly property int horizontalAlignment: Qt.AlignLeft readonly property int verticalAlignment: Qt.AlignVCenter + TextMetrics { + id: metrics + text: "12345678901234567890" + } + LabelStyle { id: label visible: false diff --git a/src/controls/Styles/Android/TextFieldStyle.qml b/src/controls/Styles/Android/TextFieldStyle.qml index 67cd3b78..0edc5c90 100644 --- a/src/controls/Styles/Android/TextFieldStyle.qml +++ b/src/controls/Styles/Android/TextFieldStyle.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.2 +import QtQuick 2.4 import QtQuick.Window 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Private 1.0 @@ -56,7 +56,7 @@ Style { readonly property real minWidth: styleDef.View_minWidth || 0 readonly property real minHeight: styleDef.View_minHeight || 0 - readonly property real labelWidth: label.implicitWidth + bg.padding.left + bg.padding.right + readonly property real labelWidth: Math.max(label.implicitWidth, metrics.width) + bg.padding.left + bg.padding.right readonly property real labelHeight: label.implicitHeight + bg.padding.top + bg.padding.bottom implicitWidth: Math.max(minWidth, Math.max(bg.implicitWidth, labelWidth)) @@ -81,10 +81,15 @@ Style { readonly property alias selectionColor: label.selectionColor readonly property color selectedTextColor: label.selectedTextColor + TextMetrics { + id: metrics + text: "12345678901234567890" + } + LabelStyle { id: label visible: false - text: control.text + text: control.text || control.placeholderText focused: control.activeFocus window_focused: focused && control.Window.active styleDef: panel.styleDef diff --git a/src/controls/Styles/Desktop/ComboBoxStyle.qml b/src/controls/Styles/Desktop/ComboBoxStyle.qml index d897a2a4..758518ed 100644 --- a/src/controls/Styles/Desktop/ComboBoxStyle.qml +++ b/src/controls/Styles/Desktop/ComboBoxStyle.qml @@ -109,8 +109,8 @@ Style { elementType: "itemrow" selected: styleData.selected - implicitWidth: textItem.contentWidth - implicitHeight: textItem.contentHeight + implicitWidth: textItem.implicitWidth + implicitHeight: textItem.implicitHeight StyleItem { id: textItem diff --git a/src/controls/Styles/iOS/CursorHandleStyle.qml b/src/controls/Styles/iOS/CursorHandleStyle.qml index 26ab9728..408a7bf4 100644 --- a/src/controls/Styles/iOS/CursorHandleStyle.qml +++ b/src/controls/Styles/iOS/CursorHandleStyle.qml @@ -45,6 +45,7 @@ Item { y: -20 width: 80 height: knob.height + knobLine.height + 60 + visible: styleData.hasSelection Rectangle { id: knob diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml index b8ed0ba2..1c19a300 100644 --- a/src/controls/TextArea.qml +++ b/src/controls/TextArea.qml @@ -933,7 +933,7 @@ ScrollView { property var posInViewport: flickableItem.contentX !== flickableItem.contentY !== Number.MAX_VALUE ? parent.mapToItem(viewport, handleX, handleY) : -1 - visible: pressed || (edit.hasSelection + visible: pressed || ((edit.cursorVisible || edit.hasSelection) && posInViewport.y + handleHeight >= -1 && posInViewport.y <= viewport.height + 1 && posInViewport.x + handleWidth >= -1 diff --git a/src/controls/doc/images/qtquickcontrols-example-splitview.png b/src/controls/doc/images/qtquickcontrols-example-splitview.png Binary files differdeleted file mode 100644 index a82017b4..00000000 --- a/src/controls/doc/images/qtquickcontrols-example-splitview.png +++ /dev/null diff --git a/src/controls/doc/images/qtquickcontrols-example-tableview.png b/src/controls/doc/images/qtquickcontrols-example-tableview.png Binary files differindex b9dc67c3..c4ab8d99 100644 --- a/src/controls/doc/images/qtquickcontrols-example-tableview.png +++ b/src/controls/doc/images/qtquickcontrols-example-tableview.png diff --git a/src/controls/doc/src/qtquickcontrols-examples.qdoc b/src/controls/doc/src/qtquickcontrols-examples.qdoc index 5ff2b27b..29c8d2b5 100644 --- a/src/controls/doc/src/qtquickcontrols-examples.qdoc +++ b/src/controls/doc/src/qtquickcontrols-examples.qdoc @@ -78,30 +78,40 @@ */ /*! - \example splitview - \title Qt Quick Controls - Split View Example - \ingroup qtquickcontrols_examples - \brief An example for the SplitView UI control. - \image qtquickcontrols-example-splitview.png - - This example project demonstrates the usage of \l {SplitView} from - \l{Qt Quick Controls} - a control that lays out items horizontally or - vertically with a draggable splitter between each item. - - \include examples-run.qdocinc -*/ - -/*! \example tableview \title Qt Quick Controls - Table View Example \ingroup qtquickcontrols_examples \brief An example for the TableView control. \image qtquickcontrols-example-tableview.png - This example shows how a \l{TableView} from \l{Qt Quick Controls} - can be used together with different types of data models to display - lists of information with support for scroll bars, selections and - resizable header sections. + This example project demonstrates the usage of \l {TableView} from + \l{Qt Quick Controls} - a control to display one or more columns of + information from a data list model. The example includes a model + that supports sorting and filtering. + + The C++ class, SortFilterProxyModel, is registered as a QML type + under the namespace, "\c{org.qtproject.example 1.0}". + + The following snippets show how the type is registered under + a namespace and later imported by \e main.qml. + + QML type registration: + + \code + #include <QtQml/qqml.h> + ... + qmlRegisterType<SortFilterProxyModel>("org.qtproject.example", 1, 0, "SortFilterProxyModel"); + ... + \endcode + + QML namespace import: + + \qml + import org.qtproject.example 1.0 + \endqml + + For more information about registering C++ classses as QML types, see + \l {Defining QML Types from C++}. \include examples-run.qdocinc */ diff --git a/src/controls/doc/src/qtquickcontrols-platformnotes.qdoc b/src/controls/doc/src/qtquickcontrols-platformnotes.qdoc index 092dc45d..2d852445 100644 --- a/src/controls/doc/src/qtquickcontrols-platformnotes.qdoc +++ b/src/controls/doc/src/qtquickcontrols-platformnotes.qdoc @@ -33,7 +33,7 @@ This page contains platform specific notes for creating applications that use \l{Qt Quick Controls}. - \section1 Android + \section1 Android Style Qt 5.4 introduced a native Android style for Qt Quick Controls. @@ -41,8 +41,7 @@ \note The Android style requires Android 3.0 (API level 11) or later. - No special actions are required to use the Android style. It is - automatically selected and deployed on Android. See \l{Getting Started + It is automatically selected and deployed on Android. See \l{Getting Started with Qt for Android} and \l{Deploying an Application on Android} for more details on the Android essentials. @@ -62,8 +61,8 @@ items declared in QML. Just to name a few possibilities: \list \li ToolButton actions, - \li A TextField as a search field, - \li A ComboBox for navigation, and - \li A ProgressBar for displaying progress. + \li a TextField as a search field, + \li a ComboBox for navigation, and + \li a ProgressBar for displaying progress. \endlist */ |