diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-11-27 18:04:58 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-11-27 18:04:58 +0100 |
commit | 71314570d03631f50ab2c262011aba6a572d0ced (patch) | |
tree | 6d0c663ad313af89efff8e7b0fdafe6a28b19505 /src | |
parent | 3704a616dfabb71ebd3ffc64f8efe32931c82a8b (diff) | |
parent | ea099e341b5f8845be56f81b22e44a8b6cb227a2 (diff) | |
download | qtquickcontrols-71314570d03631f50ab2c262011aba6a572d0ced.tar.gz |
Merge remote-tracking branch 'origin/5.4.0' into 5.4
Change-Id: I4c81a7852e7041328b7cfa320e907cc3cb863f04
Diffstat (limited to 'src')
21 files changed, 151 insertions, 20 deletions
diff --git a/src/controls/Private/ScrollBar.qml b/src/controls/Private/ScrollBar.qml index 82750412..3bd0a164 100644 --- a/src/controls/Private/ScrollBar.qml +++ b/src/controls/Private/ScrollBar.qml @@ -102,7 +102,7 @@ Item { onExited: if (!pressed) __panel.activeControl = "none" onMouseXChanged: if (!pressed) __panel.activeControl = __panel.hitTest(mouseX, mouseY) hoverEnabled: !Settings.hasTouchScreen - enabled: !Settings.hasTouchScreen // TODO: touch on desktop? + enabled: !Settings.isMobile || !Settings.hasTouchScreen // ### Not ideal, but will usually behave as expected... preventStealing: true property var pressedX property var pressedY diff --git a/src/controls/Private/TextInputWithHandles.qml b/src/controls/Private/TextInputWithHandles.qml index 726b6863..75ca947f 100644 --- a/src/controls/Private/TextInputWithHandles.qml +++ b/src/controls/Private/TextInputWithHandles.qml @@ -54,7 +54,7 @@ TextInput { property alias editMenu: editMenu cursorDelegate: __style && __style.__cursorDelegate ? __style.__cursorDelegate : null - selectByMouse: control.selectByMouse && (!cursorHandle.delegate || !selectionHandle.delegate) + selectByMouse: control.selectByMouse && (!Settings.isMobile || !cursorHandle.delegate || !selectionHandle.delegate) // force re-evaluation when selection moves: // - cursorRectangle changes => content scrolled @@ -137,7 +137,7 @@ TextInput { editor: input parent: control control: input.control - active: control.selectByMouse + active: control.selectByMouse && Settings.isMobile maximum: cursorHandle.position - 1 property var mappedPos: parent.mapFromItem(editor, editor.selectionRectangle.x, editor.selectionRectangle.y) @@ -163,7 +163,7 @@ TextInput { editor: input parent: control control: input.control - active: control.selectByMouse + active: control.selectByMouse && Settings.isMobile minimum: input.hasSelection ? selectionHandle.position + 1 : -1 property var mappedPos: parent.mapFromItem(editor, editor.cursorRectangle.x, editor.cursorRectangle.y) diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index 89c1e723..d0644b4c 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -167,6 +167,8 @@ Control { \l stepSize property. The default value is \c false. + + \note This property may be ignored on some platforms when using the native style (e.g. Android). */ property bool tickmarksEnabled: false diff --git a/src/controls/Styles/Android/SwitchStyle.qml b/src/controls/Styles/Android/SwitchStyle.qml index 4c36c918..6e9260c3 100644 --- a/src/controls/Styles/Android/SwitchStyle.qml +++ b/src/controls/Styles/Android/SwitchStyle.qml @@ -79,18 +79,26 @@ SwitchStyle { Item { id: thumb + readonly property bool hideText: AndroidStyle.styleDef.switchStyle.Switch_showText === false + x: control.checked ? max : min - FontMetrics { - id: metrics + TextMetrics { + id: onMetrics + font: label.font + text: panel.styleDef.Switch_textOn + } + + TextMetrics { + id: offMetrics font: label.font + text: panel.styleDef.Switch_textOff } - readonly property real maxTextWidth: Math.max(metrics.boundingRect(panel.styleDef.Switch_textOn).width, - metrics.boundingRect(panel.styleDef.Switch_textOff).width) + readonly property real maxTextWidth: Math.max(onMetrics.width, offMetrics.width) implicitWidth: Math.max(loader.implicitWidth, maxTextWidth + 2 * panel.styleDef.Switch_thumbTextPadding) - implicitHeight: Math.max(loader.implicitHeight, metrics.height) + implicitHeight: Math.max(loader.implicitHeight, onMetrics.height, offMetrics.height) anchors.top: parent.top anchors.bottom: parent.bottom @@ -120,6 +128,7 @@ SwitchStyle { LabelStyle { id: label + visible: !thumb.hideText text: control.checked ? panel.styleDef.Switch_textOn : panel.styleDef.Switch_textOff pressed: control.pressed diff --git a/src/controls/Styles/Android/drawables/AnimationDrawable.qml b/src/controls/Styles/Android/drawables/AnimationDrawable.qml index a522bfa7..12d576ff 100644 --- a/src/controls/Styles/Android/drawables/AnimationDrawable.qml +++ b/src/controls/Styles/Android/drawables/AnimationDrawable.qml @@ -49,14 +49,17 @@ Drawable { property int currentFrame: 0 readonly property int frameCount: styleDef.frames ? styleDef.frames.length : 0 readonly property var frameDef: styleDef.frames ? styleDef.frames[currentFrame] : undefined + readonly property alias running: timer.running + property bool oneshot: styleDef.oneshot Timer { + id: timer repeat: true running: root.frameCount && root.visible && Qt.application.active interval: root.frameDef ? root.frameDef.duration : 0 onTriggered: { var frame = root.currentFrame + 1 - repeat = !root.styleDef.oneshot || frame < root.frameCount - 1 + repeat = !root.oneshot || frame < root.frameCount - 1 root.currentFrame = frame % root.frameCount } } diff --git a/src/controls/Styles/Android/drawables/ImageDrawable.qml b/src/controls/Styles/Android/drawables/ImageDrawable.qml index 1e71a389..4b41b2f2 100644 --- a/src/controls/Styles/Android/drawables/ImageDrawable.qml +++ b/src/controls/Styles/Android/drawables/ImageDrawable.qml @@ -52,5 +52,33 @@ Drawable { anchors.fill: parent fillMode: Image.TileHorizontally source: AndroidStyle.filePath(styleDef.path) + + layer.enabled: !!styleDef && !!styleDef.tintList + layer.effect: ShaderEffect { + property variant source: image + property color color: AndroidStyle.colorValue(styleDef.tintList[state]) + state: { + var states = [] + if (pressed) states.push("PRESSED") + if (enabled) states.push("ENABLED") + if (focused) states.push("FOCUSED") + if (selected) states.push("SELECTED") + if (window_focused) states.push("WINDOW_FOCUSED") + if (!states.length) + states.push("EMPTY") + return states.join("_") + "_STATE_SET" + } + // QtGraphicalEffects/ColorOverlay: + fragmentShader: " + varying mediump vec2 qt_TexCoord0; + uniform highp float qt_Opacity; + uniform lowp sampler2D source; + uniform highp vec4 color; + void main() { + highp vec4 pixelColor = texture2D(source, qt_TexCoord0); + gl_FragColor = vec4(mix(pixelColor.rgb/max(pixelColor.a, 0.00390625), color.rgb/max(color.a, 0.00390625), color.a) * pixelColor.a, pixelColor.a) * qt_Opacity; + } + " + } } } diff --git a/src/controls/Styles/Android/drawables/StateDrawable.qml b/src/controls/Styles/Android/drawables/StateDrawable.qml index d446542d..862ab9ae 100644 --- a/src/controls/Styles/Android/drawables/StateDrawable.qml +++ b/src/controls/Styles/Android/drawables/StateDrawable.qml @@ -46,10 +46,12 @@ Drawable { implicitWidth: Math.max(loader.implicitWidth, styleDef.width || 0) implicitHeight: Math.max(loader.implicitHeight, styleDef.height || 0) + property int prevMatch: 0 + DrawableLoader { id: loader anchors.fill: parent - styleDef: bestStateMatch() + visible: !animation.active focused: root.focused pressed: root.pressed checked: root.checked @@ -65,17 +67,70 @@ Drawable { clippables: root.clippables } - function bestStateMatch () { + Loader { + id: animation + property var animDef + active: false + anchors.fill: parent + sourceComponent: AnimationDrawable { + anchors.fill: parent + styleDef: animDef + focused: root.focused + pressed: root.pressed + checked: root.checked + selected: root.selected + accelerated: root.accelerated + window_focused: root.window_focused + index: root.index + level: root.level + levelId: root.levelId + orientations: root.orientations + duration: root.duration + excludes: root.excludes + clippables: root.clippables + + oneshot: true + onRunningChanged: if (!running) animation.active = false + } + } + + onStyleDefChanged: resolveState() + Component.onCompleted: resolveState() + + // In order to be able to find appropriate transition paths between + // various states, the following states must be allowed to change in + // batches. For example, button-like controls could have a transition + // path from pressed+checked to unpressed+unchecked. We must let both + // properties change before we try to find the transition path. + onEnabledChanged: resolver.start() + onFocusedChanged: resolver.start() + onPressedChanged: resolver.start() + onCheckedChanged: resolver.start() + onSelectedChanged: resolver.start() + onAcceleratedChanged: resolver.start() + onWindow_focusedChanged: resolver.start() + + Timer { + id: resolver + interval: 15 + onTriggered: resolveState() + } + + function resolveState () { if (styleDef && styleDef.stateslist) { var bestMatch = 0 var highestScore = -1 var stateslist = styleDef.stateslist + var transitions = [] for (var i = 0; i < stateslist.length; ++i) { var score = 0 var state = stateslist[i] + if (state.transition) + transitions.push(i) + for (var s in state.states) { if (s === "pressed") score += (pressed === state.states[s]) ? 1 : -10 @@ -98,8 +153,21 @@ Drawable { highestScore = score } } - return stateslist[bestMatch].drawable + + if (prevMatch != bestMatch) { + for (var t = 0; t < transitions.length; ++t) { + var transition = stateslist[transitions[t]].transition + if ((transition.from == prevMatch && transition.to == bestMatch) || + (transition.reverse && transition.from == bestMatch && transition.to == prevMatch)) { + animation.animDef = stateslist[transitions[t]].drawable + animation.active = true + break + } + } + prevMatch = bestMatch + } + + loader.styleDef = stateslist[bestMatch].drawable } - return undefined } } diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml index 691bf13e..1c19a300 100644 --- a/src/controls/TextArea.qml +++ b/src/controls/TextArea.qml @@ -770,7 +770,7 @@ ScrollView { wrapMode: TextEdit.WordWrap textMargin: __style && __style.textMargin !== undefined ? __style.textMargin : 4 - selectByMouse: area.selectByMouse && (!cursorHandle.delegate || !selectionHandle.delegate) + selectByMouse: area.selectByMouse && (!Settings.isMobile || !cursorHandle.delegate || !selectionHandle.delegate) readOnly: false Keys.forwardTo: area @@ -885,7 +885,7 @@ ScrollView { control: area z: 1 // above scrollbars parent: Qt.platform.os === "ios" ? editor : __scroller // no clip - active: area.selectByMouse + active: area.selectByMouse && Settings.isMobile delegate: __style.__selectionHandle maximum: cursorHandle.position - 1 @@ -921,7 +921,7 @@ ScrollView { control: area z: 1 // above scrollbars parent: Qt.platform.os === "ios" ? editor : __scroller // no clip - active: area.selectByMouse + active: area.selectByMouse && Settings.isMobile delegate: __style.__cursorHandle minimum: edit.hasSelection ? selectionHandle.position + 1 : -1 diff --git a/src/controls/doc/images/qtquickcontrols-android.png b/src/controls/doc/images/qtquickcontrols-android.png Binary files differdeleted file mode 100644 index 8877c09c..00000000 --- a/src/controls/doc/images/qtquickcontrols-android.png +++ /dev/null diff --git a/src/controls/doc/images/qtquickcontrols-example-gallery-android.png b/src/controls/doc/images/qtquickcontrols-example-gallery-android.png Binary files differnew file mode 100644 index 00000000..11ba2cc0 --- /dev/null +++ b/src/controls/doc/images/qtquickcontrols-example-gallery-android.png diff --git a/src/controls/doc/images/qtquickcontrols-example-gallery-osx.png b/src/controls/doc/images/qtquickcontrols-example-gallery-osx.png Binary files differnew file mode 100644 index 00000000..492dc36e --- /dev/null +++ b/src/controls/doc/images/qtquickcontrols-example-gallery-osx.png diff --git a/src/controls/doc/images/qtquickcontrols-example-gallery.png b/src/controls/doc/images/qtquickcontrols-example-gallery.png Binary files differdeleted file mode 100644 index a88eab79..00000000 --- a/src/controls/doc/images/qtquickcontrols-example-gallery.png +++ /dev/null diff --git a/src/controls/doc/src/applicationwindow.qdoc b/src/controls/doc/src/applicationwindow.qdoc index f9e2d97f..45b66e30 100644 --- a/src/controls/doc/src/applicationwindow.qdoc +++ b/src/controls/doc/src/applicationwindow.qdoc @@ -27,5 +27,6 @@ /*! \group applicationwindow + \brief A window adding convenience for positioning items. \title Application Window */ diff --git a/src/controls/doc/src/controls.qdoc b/src/controls/doc/src/controls.qdoc index d1e4d052..fa2a800c 100644 --- a/src/controls/doc/src/controls.qdoc +++ b/src/controls/doc/src/controls.qdoc @@ -27,5 +27,6 @@ /*! \group controls + \brief Buttons and UI Controls. \title Buttons and Controls */ diff --git a/src/controls/doc/src/menus.qdoc b/src/controls/doc/src/menus.qdoc index 75f5ba2c..8a6a8032 100644 --- a/src/controls/doc/src/menus.qdoc +++ b/src/controls/doc/src/menus.qdoc @@ -27,5 +27,6 @@ /*! \group menus + \brief How to create a menu bar. \title Menus */ diff --git a/src/controls/doc/src/qtquickcontrols-examples.qdoc b/src/controls/doc/src/qtquickcontrols-examples.qdoc index 4e6fccb0..29c8d2b5 100644 --- a/src/controls/doc/src/qtquickcontrols-examples.qdoc +++ b/src/controls/doc/src/qtquickcontrols-examples.qdoc @@ -40,7 +40,22 @@ \title Qt Quick Controls - Gallery \ingroup qtquickcontrols_examples \brief A collection of components for a classic desktop-style UI. - \image qtquickcontrols-example-gallery.png + + \raw HTML + <div class="table"><table style="background:transparent; border:0px"> + <tr><td style="border:0px"> + \endraw + \image qtquickcontrols-example-gallery-osx.png + \caption OS X + \raw HTML + </td><td style="border:0px"> + \endraw + \image qtquickcontrols-example-gallery-android.png + \caption Android - Nexus 5 + \raw HTML + </td></tr> + </table></div> + \endraw This example project demonstrates the various UI components provided by \l{Qt Quick Controls}. diff --git a/src/controls/doc/src/qtquickcontrols-overview.qdoc b/src/controls/doc/src/qtquickcontrols-overview.qdoc index 09f5318d..651edc66 100644 --- a/src/controls/doc/src/qtquickcontrols-overview.qdoc +++ b/src/controls/doc/src/qtquickcontrols-overview.qdoc @@ -61,7 +61,7 @@ For an overview of the controls provided by \l{Qt Quick Controls}, you can look at the \l{Qt Quick Controls - Gallery}{Gallery} example. - \image qtquickcontrols-example-gallery.png + \image qtquickcontrols-example-gallery-osx.png \section1 Setting Up Controls from C++ diff --git a/src/controls/doc/src/qtquickcontrols-platformnotes.qdoc b/src/controls/doc/src/qtquickcontrols-platformnotes.qdoc index fdf64cf5..2d852445 100644 --- a/src/controls/doc/src/qtquickcontrols-platformnotes.qdoc +++ b/src/controls/doc/src/qtquickcontrols-platformnotes.qdoc @@ -37,7 +37,7 @@ Qt 5.4 introduced a native Android style for Qt Quick Controls. - \image qtquickcontrols-android.png + \image qtquickcontrols-example-gallery-android.png \note The Android style requires Android 3.0 (API level 11) or later. diff --git a/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc b/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc index 74c750a5..7548d742 100644 --- a/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc +++ b/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc @@ -40,6 +40,7 @@ /*! \group controlsstyling + \brief Provides custom styling for Buttons and UI Controls. \title Styling Controls */ diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp index c2e7bc30..1a125135 100644 --- a/src/controls/qquickmenu.cpp +++ b/src/controls/qquickmenu.cpp @@ -414,6 +414,7 @@ void QQuickMenu::__popup(const QRectF &targetRect, int atItemIndex, MenuType men } globalTargetRect = visualItem()->mapRectToScene(globalTargetRect); } + globalTargetRect.translate(renderOffset); m_platformMenu->setMenuType(QPlatformMenu::MenuType(menuType)); m_platformMenu->showPopup(parentWindow, globalTargetRect.toRect(), atItem ? atItem->platformItem() : 0); } else { diff --git a/src/dialogs/doc/src/qtquickdialogs-index.qdoc b/src/dialogs/doc/src/qtquickdialogs-index.qdoc index 5a1223b0..ab0bc31a 100644 --- a/src/dialogs/doc/src/qtquickdialogs-index.qdoc +++ b/src/dialogs/doc/src/qtquickdialogs-index.qdoc @@ -27,6 +27,7 @@ /*! \group dialogs + \brief Dialog components \title Dialogs */ |