diff options
author | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-11-08 18:16:24 +0100 |
---|---|---|
committer | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-11-08 18:16:24 +0100 |
commit | 80a5e0fffcf5c064ac4fea1ed8dc7e0a390a2d45 (patch) | |
tree | d3f8c8a8c43d43b312fb60189bbea4dd71f70179 | |
parent | 10e5b4fff66c56ee8ac77db9ab4d4df5e9e7bd62 (diff) | |
parent | 69b567b66ef9e90bb3c2179bded54961d3051039 (diff) | |
download | qtquickcontrols-80a5e0fffcf5c064ac4fea1ed8dc7e0a390a2d45.tar.gz |
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I678a00ebdf769eaa87d43214c2a32c303d3877ca
53 files changed, 1624 insertions, 363 deletions
diff --git a/dist/changes-5.2.0 b/dist/changes-5.2.0 index 53f408e4..ca477c04 100644 --- a/dist/changes-5.2.0 +++ b/dist/changes-5.2.0 @@ -21,6 +21,43 @@ information about a particular change. - Improve support for Right To Left layout (RTL) - Add support for StandardKeys in Actions and MenuItem::shortcut + - Add text alignment property to SpinBox and SpinBoxStyle + - QML Base style: support transient scrollbars + - Enable TableView multi-row selection + +New Controls +--------------- + - Add a BusyIndicator control + - Add a Switch control + +**************************************************************************** +* Styles * +**************************************************************************** + + - Add styles: BusyIndicatorStyle, SwitchStyle and TextAreaStyle + - Expose styles: SpinBoxStyle, StatusBarStyle, ToolBarStyle + - More styling improvements for Base Style: + - Better scalability + - Retina support + - Added focus rects + +**************************************************************************** +* Layouts * +**************************************************************************** + + - Add baseline support for Qt Quick Layouts + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + + - Remove widgets dependency on touch platforms + - Enable flicking on touch based devices for ScrollView and TableView + +**************************************************************************** +* Plugins * +**************************************************************************** + - [QTBUG-31565] Make the deployment of Qt Quick Controls applications easier The QtQuickControls plugin now embeds its qml files and the Styles and Private submodules files using the resource system. While the qml and diff --git a/examples/quick/controls/gallery/content/Controls.qml b/examples/quick/controls/gallery/content/Controls.qml index f13b9fda..6817d9b7 100644 --- a/examples/quick/controls/gallery/content/Controls.qml +++ b/examples/quick/controls/gallery/content/Controls.qml @@ -61,12 +61,10 @@ Item { spacing: 16 ColumnLayout { id: firstColumn - spacing: 7 Layout.minimumWidth: implicitWidth Layout.fillWidth: false RowLayout { id: buttonrow - spacing:8 Button { id: button1 text: "Button 1" @@ -109,7 +107,6 @@ Item { } } RowLayout { - spacing: 8 SpinBox { id: t1 Layout.fillWidth: true @@ -157,7 +154,6 @@ Item { } ColumnLayout { id: rightcol - spacing: 12 Layout.fillWidth: true anchors { top: parent.top @@ -169,20 +165,24 @@ Item { title: "CheckBox" Layout.fillWidth: true RowLayout { + Layout.fillWidth: true CheckBox { id: frameCheckbox text: "Text frame" checked: true + Layout.minimumWidth: 100 } CheckBox { id: tickmarkCheck text: "Tickmarks" checked: false + Layout.minimumWidth: 100 } CheckBox { id: wrapCheck text: "Word wrap" checked: true + Layout.minimumWidth: 100 } } } @@ -197,11 +197,13 @@ Item { text: "Top" checked: true exclusiveGroup: tabPositionGroup + Layout.minimumWidth: 100 } RadioButton { id: r2 text: "Bottom" exclusiveGroup: tabPositionGroup + Layout.minimumWidth: 100 } } } diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index 43bc9889..564e8d2a 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -145,7 +145,8 @@ Window { anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right - height: childrenRect.height + implicitHeight: childrenRect.height + height: visibleChildren.length > 0 ? implicitHeight: 0 } Item { @@ -153,7 +154,8 @@ Window { anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right - height: childrenRect.height + implicitHeight: childrenRect.height + height: visibleChildren.length > 0 ? implicitHeight: 0 } onVisibleChanged: if (visible && menuBar) menuBar.__parentWindow = root diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index 4ada75e7..db39f579 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -107,14 +107,20 @@ Control { id: comboBox /*! \qmlproperty model ComboBox::model - The model to populate the ComboBox from. */ + The model to populate the ComboBox from. + + Changing the model after initialization will reset \l currentIndex to \c 0. + */ property alias model: popupItems.model /*! The model role used for populating the ComboBox. */ property string textRole: "" /*! \qmlproperty int ComboBox::currentIndex - The index of the currently selected item in the ComboBox. */ + The index of the currently selected item in the ComboBox. + + \sa model + */ property alias currentIndex: popup.__selectedIndex /*! \qmlproperty string ComboBox::currentText @@ -311,7 +317,8 @@ Control { anchors.fill: parent anchors.leftMargin: 8 - anchors.rightMargin: 24 + anchors.rightMargin: __style.drowDownButtonWidth + verticalAlignment: Text.AlignVCenter renderType: Text.NativeRendering @@ -412,7 +419,8 @@ Control { property string currentText: selectedText onSelectedTextChanged: if (selectedText) popup.currentText = selectedText - readonly property string selectedText: items[__selectedIndex] ? items[__selectedIndex].text : "" + property string selectedText + on__SelectedIndexChanged: updateSelectedText() property string textRole: "" property bool ready: false @@ -429,6 +437,20 @@ Control { Instantiator { id: popupItems active: false + + property bool updatingModel: false + onModelChanged: { + if (active) { + if (updatingModel && popup.__selectedIndex === 0) { + // We still want to update the currentText + popup.updateSelectedText() + } else { + updatingModel = true + popup.__selectedIndex = 0 + } + } + } + MenuItem { text: popup.textRole === '' ? modelData : @@ -441,7 +463,11 @@ Control { checkable: true exclusiveGroup: eg } - onObjectAdded: popup.insertItem(index, object) + onObjectAdded: { + popup.insertItem(index, object) + if (!updatingModel && index === popup.__selectedIndex) + popup.selectedText = object["text"] + } onObjectRemoved: popup.removeItem(object) } @@ -483,8 +509,13 @@ Control { textRole = roleName } } - popupItems.active = true + + if (!popupItems.active) + popupItems.active = true + else + updateSelectedText() } + function show() { if (items[__selectedIndex]) items[__selectedIndex].checked = true @@ -494,6 +525,12 @@ Control { else __popup(0, y, isPopup ? __selectedIndex : 0) } + + function updateSelectedText() { + var selectedItem; + if (__selectedIndex !== -1 && (selectedItem = items[__selectedIndex])) + selectedText = selectedItem.text + } } // The key bindings below will only be in use when popup is diff --git a/src/controls/Private/BasicButton.qml b/src/controls/Private/BasicButton.qml index 188e35ff..4c1eeb04 100644 --- a/src/controls/Private/BasicButton.qml +++ b/src/controls/Private/BasicButton.qml @@ -166,10 +166,13 @@ Control { behavior.keyPressed = true; } + onFocusChanged: if (!focus) behavior.keyPressed = false + Keys.onReleased: { if (event.key === Qt.Key_Space && !event.isAutoRepeat && behavior.keyPressed) { behavior.keyPressed = false; __action.trigger(button) + behavior.toggle() } } @@ -182,10 +185,14 @@ Control { hoverEnabled: true enabled: !keyPressed + function toggle() { + if (button.checkable && !button.action && !(button.checked && button.exclusiveGroup)) + button.checked = !button.checked + } + onReleased: { if (containsMouse) { - if (button.checkable && !button.action && !(button.checked && button.exclusiveGroup)) - button.checked = !button.checked + toggle() __action.trigger(button) } } diff --git a/src/controls/Private/FastGlow.qml b/src/controls/Private/FastGlow.qml new file mode 100644 index 00000000..f4bd2c74 --- /dev/null +++ b/src/controls/Private/FastGlow.qml @@ -0,0 +1,393 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Graphical Effects module. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: rootItem + property variant source + property real spread: 0.0 + property real blur: 0.0 + property color color: "white" + property bool transparentBorder: false + property bool cached: false + + SourceProxy { + id: sourceProxy + input: rootItem.source + } + + ShaderEffectSource { + id: cacheItem + anchors.fill: shaderItem + visible: rootItem.cached + smooth: true + sourceItem: shaderItem + live: true + hideSource: visible + } + + property string __internalBlurVertexShader: " + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + uniform highp mat4 qt_Matrix; + uniform highp float yStep; + uniform highp float xStep; + varying highp vec2 qt_TexCoord0; + varying highp vec2 qt_TexCoord1; + varying highp vec2 qt_TexCoord2; + varying highp vec2 qt_TexCoord3; + + void main() { + qt_TexCoord0 = vec2(qt_MultiTexCoord0.x + xStep, qt_MultiTexCoord0.y + yStep * 0.36); + qt_TexCoord1 = vec2(qt_MultiTexCoord0.x + xStep * 0.36, qt_MultiTexCoord0.y - yStep); + qt_TexCoord2 = vec2(qt_MultiTexCoord0.x - xStep * 0.36, qt_MultiTexCoord0.y + yStep); + qt_TexCoord3 = vec2(qt_MultiTexCoord0.x - xStep, qt_MultiTexCoord0.y - yStep * 0.36); + gl_Position = qt_Matrix * qt_Vertex; + } + " + + property string __internalBlurFragmentShader: " + uniform lowp sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + varying highp vec2 qt_TexCoord1; + varying highp vec2 qt_TexCoord2; + varying highp vec2 qt_TexCoord3; + + void main() { + highp vec4 sourceColor = (texture2D(source, qt_TexCoord0) + + texture2D(source, qt_TexCoord1) + + texture2D(source, qt_TexCoord2) + + texture2D(source, qt_TexCoord3)) * 0.25; + gl_FragColor = sourceColor * qt_Opacity; + } + " + + ShaderEffect { + id: level0 + property variant source: sourceProxy.output + anchors.fill: parent + visible: false + smooth: true + } + + ShaderEffectSource { + id: level1 + width: Math.ceil(shaderItem.width / 32) * 32 + height: Math.ceil(shaderItem.height / 32) * 32 + sourceItem: level0 + hideSource: rootItem.visible + sourceRect: transparentBorder ? Qt.rect(-64, -64, shaderItem.width, shaderItem.height) : Qt.rect(0,0,0,0) + smooth: true + visible: false + } + + ShaderEffect { + id: effect1 + property variant source: level1 + property real yStep: 1/height + property real xStep: 1/width + anchors.fill: level2 + visible: false + smooth: true + vertexShader: __internalBlurVertexShader + fragmentShader: __internalBlurFragmentShader + } + + ShaderEffectSource { + id: level2 + width: level1.width / 2 + height: level1.height / 2 + sourceItem: effect1 + hideSource: rootItem.visible + visible: false + smooth: true + } + + ShaderEffect { + id: effect2 + property variant source: level2 + property real yStep: 1/height + property real xStep: 1/width + anchors.fill: level3 + visible: false + smooth: true + vertexShader: __internalBlurVertexShader + fragmentShader: __internalBlurFragmentShader + } + + ShaderEffectSource { + id: level3 + width: level2.width / 2 + height: level2.height / 2 + sourceItem: effect2 + hideSource: rootItem.visible + visible: false + smooth: true + } + + ShaderEffect { + id: effect3 + property variant source: level3 + property real yStep: 1/height + property real xStep: 1/width + anchors.fill: level4 + visible: false + smooth: true + vertexShader: __internalBlurVertexShader + fragmentShader: __internalBlurFragmentShader + } + + ShaderEffectSource { + id: level4 + width: level3.width / 2 + height: level3.height / 2 + sourceItem: effect3 + hideSource: rootItem.visible + visible: false + smooth: true + } + + ShaderEffect { + id: effect4 + property variant source: level4 + property real yStep: 1/height + property real xStep: 1/width + anchors.fill: level5 + visible: false + smooth: true + vertexShader: __internalBlurVertexShader + fragmentShader: __internalBlurFragmentShader + } + + ShaderEffectSource { + id: level5 + width: level4.width / 2 + height: level4.height / 2 + sourceItem: effect4 + hideSource: rootItem.visible + visible: false + smooth: true + } + + ShaderEffect { + id: effect5 + property variant source: level5 + property real yStep: 1/height + property real xStep: 1/width + anchors.fill: level6 + visible: false + smooth: true + vertexShader: __internalBlurVertexShader + fragmentShader: __internalBlurFragmentShader + } + + ShaderEffectSource { + id: level6 + width: level5.width / 2 + height: level5.height / 2 + sourceItem: effect5 + hideSource: rootItem.visible + visible: false + smooth: true + } + + Item { + id: dummysource + width: 1 + height: 1 + visible: false + } + + ShaderEffectSource { + id: dummy + width: 1 + height: 1 + sourceItem: dummysource + visible: false + smooth: false + live: false + } + + ShaderEffect { + id: shaderItem + x: transparentBorder ? -64 : 0 + y: transparentBorder ? -64 : 0 + width: transparentBorder ? parent.width + 128 : parent.width + height: transparentBorder ? parent.height + 128 : parent.height + + property variant source1: level1 + property variant source2: level2 + property variant source3: level3 + property variant source4: level4 + property variant source5: level5 + property variant source6: level6 + property real lod: rootItem.blur + + property real weight1; + property real weight2; + property real weight3; + property real weight4; + property real weight5; + property real weight6; + + property real spread: 1.0 - (rootItem.spread * 0.98) + property alias color: rootItem.color + + function weight(v) { + if (v <= 0.0) + return 1 + if (v >= 0.5) + return 0 + + return 1.0 - v / 0.5 + } + + function calculateWeights() { + + var w1 = weight(Math.abs(lod - 0.100)) + var w2 = weight(Math.abs(lod - 0.300)) + var w3 = weight(Math.abs(lod - 0.500)) + var w4 = weight(Math.abs(lod - 0.700)) + var w5 = weight(Math.abs(lod - 0.900)) + var w6 = weight(Math.abs(lod - 1.100)) + + var sum = w1 + w2 + w3 + w4 + w5 + w6; + weight1 = w1 / sum; + weight2 = w2 / sum; + weight3 = w3 / sum; + weight4 = w4 / sum; + weight5 = w5 / sum; + weight6 = w6 / sum; + + upateSources() + } + + function upateSources() { + var sources = new Array(); + var weights = new Array(); + + if (weight1 > 0) { + sources.push(level1) + weights.push(weight1) + } + + if (weight2 > 0) { + sources.push(level2) + weights.push(weight2) + } + + if (weight3 > 0) { + sources.push(level3) + weights.push(weight3) + } + + if (weight4 > 0) { + sources.push(level4) + weights.push(weight4) + } + + if (weight5 > 0) { + sources.push(level5) + weights.push(weight5) + } + + if (weight6 > 0) { + sources.push(level6) + weights.push(weight6) + } + + for (var j = sources.length; j < 6; j++) { + sources.push(dummy) + weights.push(0.0) + } + + source1 = sources[0] + source2 = sources[1] + source3 = sources[2] + source4 = sources[3] + source5 = sources[4] + source6 = sources[5] + + weight1 = weights[0] + weight2 = weights[1] + weight3 = weights[2] + weight4 = weights[3] + weight5 = weights[4] + weight6 = weights[5] + } + + Component.onCompleted: calculateWeights() + + onLodChanged: calculateWeights() + + fragmentShader: " + uniform lowp sampler2D source1; + uniform lowp sampler2D source2; + uniform lowp sampler2D source3; + uniform lowp sampler2D source4; + uniform lowp sampler2D source5; + uniform mediump float weight1; + uniform mediump float weight2; + uniform mediump float weight3; + uniform mediump float weight4; + uniform mediump float weight5; + uniform highp vec4 color; + uniform highp float spread; + uniform lowp float qt_Opacity; + varying mediump vec2 qt_TexCoord0; + + highp float linearstep(highp float e0, highp float e1, highp float x) { + return clamp((x - e0) / (e1 - e0), 0.0, 1.0); + } + + void main() { + lowp vec4 sourceColor = texture2D(source1, qt_TexCoord0) * weight1; + sourceColor += texture2D(source2, qt_TexCoord0) * weight2; + sourceColor += texture2D(source3, qt_TexCoord0) * weight3; + sourceColor += texture2D(source4, qt_TexCoord0) * weight4; + sourceColor += texture2D(source5, qt_TexCoord0) * weight5; + sourceColor = mix(vec4(0), color, linearstep(0.0, spread, sourceColor.a)); + gl_FragColor = sourceColor * qt_Opacity; + } + " + } +} diff --git a/src/controls/Private/MenuContentItem.qml b/src/controls/Private/MenuContentItem.qml index a7b7233d..7056b4e1 100644 --- a/src/controls/Private/MenuContentItem.qml +++ b/src/controls/Private/MenuContentItem.qml @@ -226,7 +226,8 @@ Loader { Binding { target: menuItemLoader.item property: "width" - value: Math.max(menu.__minimumWidth, content.width) + property alias menuItem: menuItemLoader.item + value: menuItem ? Math.max(menu.__minimumWidth, content.width) - 2 * menuItem.x : 0 } } } diff --git a/src/controls/Private/SourceProxy.qml b/src/controls/Private/SourceProxy.qml new file mode 100644 index 00000000..1cf03f31 --- /dev/null +++ b/src/controls/Private/SourceProxy.qml @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Graphical Effects module. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Item { + id: rootItem + property variant input + property variant output + property variant sourceRect + visible: false + + Component.onCompleted: evaluateInput() + + onInputChanged: evaluateInput() + + onSourceRectChanged: evaluateInput() + + function evaluateInput() { + if (input == undefined) { + output = input + } + else if (sourceRect != undefined && sourceRect != Qt.rect(0, 0, 0, 0) && !isQQuickShaderEffectSource(input)) { + proxySource.sourceItem = input + output = proxySource + proxySource.sourceRect = sourceRect + } + else if (isQQuickItemLayerEnabled(input)) { + output = input + } + else if ((isQQuickImage(input) && !hasTileMode(input) && !hasChildren(input))) { + output = input + } + else if (isQQuickShaderEffectSource(input)) { + output = input + } + else { + proxySource.sourceItem = input + output = proxySource + proxySource.sourceRect = Qt.rect(0, 0, 0, 0) + } + } + + function isQQuickItemLayerEnabled(item) { + if (item.hasOwnProperty("layer")) { + var l = item["layer"] + if (l.hasOwnProperty("enabled") && l["enabled"].toString() == "true") + return true + } + return false + } + + function isQQuickImage(item) { + var imageProperties = [ "fillMode", "progress", "asynchronous", "sourceSize", "status", "smooth" ] + return hasProperties(item, imageProperties) + } + + function isQQuickShaderEffectSource(item) { + var shaderEffectSourceProperties = [ "hideSource", "format", "sourceItem", "mipmap", "wrapMode", "live", "recursive", "sourceRect" ] + return hasProperties(item, shaderEffectSourceProperties) + } + + function hasProperties(item, properties) { + var counter = 0 + for (var j = 0; j < properties.length; j++) { + if (item.hasOwnProperty(properties [j])) + counter++ + } + return properties.length == counter + } + + function hasChildren(item) { + if (item.hasOwnProperty("childrenRect")) { + if (item["childrenRect"].toString() != "QRectF(0, 0, 0, 0)") + return true + else + return false + } + return false + } + + function hasTileMode(item) { + if (item.hasOwnProperty("fillMode")) { + if (item["fillMode"].toString() != "0") + return true + else + return false + } + return false + } + + ShaderEffectSource { + id: proxySource + live: rootItem.input != rootItem.output + hideSource: false + smooth: true + visible: false + } +} + diff --git a/src/controls/Private/private.pri b/src/controls/Private/private.pri index f51223cd..30464974 100644 --- a/src/controls/Private/private.pri +++ b/src/controls/Private/private.pri @@ -30,6 +30,8 @@ PRIVATE_QML_FILES += \ $$PWD/TabBar.qml \ $$PWD/BasicButton.qml \ $$PWD/Control.qml \ + $$PWD/FastGlow.qml \ + $$PWD/SourceProxy.qml\ $$PWD/Style.qml \ $$PWD/style.js \ $$PWD/ModalPopupBehavior.qml \ diff --git a/src/controls/Private/qmldir b/src/controls/Private/qmldir index 05d52b19..35138780 100644 --- a/src/controls/Private/qmldir +++ b/src/controls/Private/qmldir @@ -12,12 +12,11 @@ StackViewSlideDelegate 1.0 StackViewSlideDelegate.qml StyleHelpers 1.0 style.js JSArray 1.0 StackView.js TableViewSelection 1.0 TableViewSelection.qml +FastGlow 1.0 FastGlow.qml +SourceProxy 1.0 SourceProxy.qml GroupBoxStyle 1.0 ../Styles/Base/GroupBoxStyle.qml -ToolBarStyle 1.0 ../Styles/Base/ToolBarStyle.qml -StatusBarStyle 1.0 ../Styles/Base/StatusBarStyle.qml ToolButtonStyle 1.0 ../Styles/Base/ToolButtonStyle.qml MenuContentItem 1.0 MenuContentItem.qml MenuContentScroller 1.0 MenuContentScroller.qml ColumnMenuContent 1.0 ColumnMenuContent.qml singleton TextSingleton 1.0 TextSingleton.qml - diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp index 68f86d36..a14a22d1 100644 --- a/src/controls/Private/qquickstyleitem.cpp +++ b/src/controls/Private/qquickstyleitem.cpp @@ -1684,4 +1684,45 @@ void QQuickStyleItem::updatePolish() } } +QPixmap QQuickTableRowImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) +{ + Q_UNUSED (requestedSize); + int width = 16; + int height = 16; + if (size) + *size = QSize(width, height); + + QPixmap pixmap(width, height); + + QStyleOptionViewItem opt; + opt.state |= QStyle::State_Enabled; + opt.rect = QRect(0, 0, width, height); + QString style = qApp->style()->metaObject()->className(); + opt.features = 0; + + if (id.contains("selected")) + opt.state |= QStyle::State_Selected; + + if (id.contains("active")) { + opt.state |= QStyle::State_Active; + opt.palette.setCurrentColorGroup(QPalette::Active); + } else + opt.palette.setCurrentColorGroup(QPalette::Inactive); + + if (id.contains("alternate")) + opt.features |= QStyleOptionViewItem::Alternate; + + QPalette pal = QApplication::palette("QAbstractItemView"); + if (opt.state & QStyle::State_Selected && (style.contains("Mac") || + !qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected))) { + pal.setCurrentColorGroup(opt.palette.currentColorGroup()); + pixmap.fill(pal.highlight().color()); + } else { + pixmap.fill(pal.base().color()); + QPainter pixpainter(&pixmap); + qApp->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, &pixpainter); + } + return pixmap; +} + QT_END_NAMESPACE diff --git a/src/controls/Private/qquickstyleitem_p.h b/src/controls/Private/qquickstyleitem_p.h index 7ab37a52..a13cd4cc 100644 --- a/src/controls/Private/qquickstyleitem_p.h +++ b/src/controls/Private/qquickstyleitem_p.h @@ -44,6 +44,7 @@ #include <QtGui/qimage.h> #include <QtQuick/qquickitem.h> +#include <QtQuick/qquickimageprovider.h> #include "qquickpadding_p.h" QT_BEGIN_NAMESPACE @@ -51,6 +52,14 @@ QT_BEGIN_NAMESPACE class QWidget; class QStyleOption; +class QQuickTableRowImageProvider : public QQuickImageProvider +{ +public: + QQuickTableRowImageProvider() + : QQuickImageProvider(QQuickImageProvider::Pixmap) {} + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize); +}; + class QQuickStyleItem: public QQuickItem { Q_OBJECT diff --git a/src/controls/Styles/Base/ButtonStyle.qml b/src/controls/Styles/Base/ButtonStyle.qml index d6a87540..ad14095c 100644 --- a/src/controls/Styles/Base/ButtonStyle.qml +++ b/src/controls/Styles/Base/ButtonStyle.qml @@ -89,38 +89,34 @@ Style { padding { top: 4 left: 4 - right: control.menu !== null ? 16 : 4 + right: control.menu !== null ? Math.round(TextSingleton.implicitHeight * 0.5) : 4 bottom: 4 } /*! This defines the background of the button. */ property Component background: Item { - implicitWidth: 100 - implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.1)) - BorderImage { + implicitWidth: Math.round(TextSingleton.implicitHeight * 4.5) + implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2)) + Rectangle { anchors.fill: parent - anchors.margins: -1 - source: control.pressed || (control.checkable && control.checked) ? "images/button_down.png" : "images/button.png" - border.top: 6 - border.bottom: 6 - border.left: 6 - border.right: 6 - anchors.bottomMargin: -1 - BorderImage { - anchors.fill: parent - source: "images/focusframe.png" - opacity: control.activeFocus ? 1 : 0 - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 + anchors.bottomMargin: control.pressed ? 0 : -1 + color: "#10000000" + radius: baserect.radius + } + Rectangle { + id: baserect + gradient: Gradient { + GradientStop {color: control.pressed ? "#aaa" : "#fefefe" ; position: 0} + GradientStop {color: control.pressed ? "#ccc" : "#e3e3e3" ; position: control.pressed ? 0.1: 1} } + radius: TextSingleton.implicitHeight * 0.16 + anchors.fill: parent + border.color: control.activeFocus ? "#47b" : "#999" Rectangle { anchors.fill: parent - anchors.margins: 2 - radius: 2 - color: "white" - opacity: control.hovered || control.activeFocus ? 0.2 : 0 + radius: parent.radius + color: control.activeFocus ? "#47b" : "white" + opacity: control.hovered || control.activeFocus ? 0.1 : 0 Behavior on opacity {NumberAnimation{ duration: 100 }} } } @@ -130,8 +126,8 @@ Style { source: "images/arrow-down.png" anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right - anchors.rightMargin: 8 - opacity: control.enabled ? 0.7 : 0.5 + anchors.rightMargin: padding.right + opacity: control.enabled ? 0.6 : 0.5 } } diff --git a/src/controls/Styles/Base/CheckBoxStyle.qml b/src/controls/Styles/Base/CheckBoxStyle.qml index ddb0a857..8fb58207 100644 --- a/src/controls/Styles/Base/CheckBoxStyle.qml +++ b/src/controls/Styles/Base/CheckBoxStyle.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.1 import QtQuick.Controls 1.1 +import QtQuick.Window 2.1 import QtQuick.Controls.Private 1.0 /*! @@ -84,68 +85,79 @@ Style { } /*! This defines the text label. */ - property Component label: Text { - text: control.text - color: __syspal.text - renderType: Text.NativeRendering + property Component label: Item { + implicitWidth: text.implicitWidth + 2 + implicitHeight: text.implicitHeight + Rectangle { + anchors.fill: text + anchors.margins: -1 + anchors.leftMargin: -3 + anchors.rightMargin: -3 + visible: control.activeFocus + height: 6 + radius: 3 + color: "#224f9fef" + border.color: "#47b" + opacity: 0.6 + } + Text { + id: text + text: control.text + anchors.centerIn: parent + color: __syspal.text + renderType: Text.NativeRendering + } } /*! The background under indicator and label. */ - property Component background: Item { - implicitWidth: 100 - } - - /*! The content padding. */ - padding { - top: 0 - left: 0 - right: 4 - bottom: 0 - } + property Component background /*! The spacing between indicator and label. */ - property int spacing: 4 + property int spacing: Math.round(TextSingleton.implicitHeight/4) /*! This defines the indicator button. */ property Component indicator: Item { - implicitWidth: 16 - implicitHeight: 18 - BorderImage { + implicitWidth: Math.round(TextSingleton.implicitHeight) + height: width + Rectangle { anchors.fill: parent - source: "images/editbox.png" - anchors.margins: -1 - border.top: 6 - border.bottom: 6 - border.left: 6 - border.right: 6 - anchors.bottomMargin: 1 - BorderImage { - anchors.fill: parent - source: "images/focusframe.png" - visible: control.activeFocus - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 + anchors.bottomMargin: -1 + color: "#44ffffff" + radius: baserect.radius + } + Rectangle { + id: baserect + gradient: Gradient { + GradientStop {color: "#eee" ; position: 0} + GradientStop {color: control.pressed ? "#eee" : "#fff" ; position: 0.1} + GradientStop {color: "#fff" ; position: 1} } + radius: TextSingleton.implicitHeight * 0.16 + anchors.fill: parent + border.color: control.activeFocus ? "#47b" : "#999" } + + Image { + source: "images/check.png" + opacity: control.checkedState === Qt.Checked ? control.enabled ? 1 : 0.5 : 0 + anchors.centerIn: parent + anchors.verticalCenterOffset: 1 + Behavior on opacity {NumberAnimation {duration: 80}} + } + Rectangle { - height: 16 - width: 16 - antialiasing: true - visible: control.checked - color: "#666" - radius: 1 - anchors.margins: 3 - anchors.bottomMargin: 5 anchors.fill: parent - border.color: "#222" - opacity: control.enabled ? 1 : 0.5 - Rectangle { - anchors.fill: parent - anchors.margins: 1 - color: "transparent" - border.color: "#33ffffff" + anchors.margins: Math.round(baserect.radius) + antialiasing: true + gradient: Gradient { + GradientStop {color: control.pressed ? "#555" : "#999" ; position: 0} + GradientStop {color: "#555" ; position: 1} } + radius: baserect.radius - 1 + anchors.centerIn: parent + anchors.alignWhenCentered: true + border.color: "#222" + Behavior on opacity {NumberAnimation {duration: 80}} + opacity: control.checkedState === Qt.PartiallyChecked ? control.enabled ? 1 : 0.5 : 0 } } diff --git a/src/controls/Styles/Base/ComboBoxStyle.qml b/src/controls/Styles/Base/ComboBoxStyle.qml index 14a0ff47..2b4b237d 100644 --- a/src/controls/Styles/Base/ComboBoxStyle.qml +++ b/src/controls/Styles/Base/ComboBoxStyle.qml @@ -64,79 +64,78 @@ Style { /*! The padding between the background and the label components. */ padding { top: 4 ; left: 6 ; right: 6 ; bottom:4 } + /*! The size of the drop down button when the combobox is editable. */ + property int drowDownButtonWidth: Math.round(TextSingleton.implicitHeight) + /*! This defines the background of the button. */ property Component background: Item { - implicitWidth: 125 - implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.1)) - BorderImage { + implicitWidth: Math.round(TextSingleton.implicitHeight * 4.5) + implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2)) + Rectangle { anchors.fill: parent - anchors.margins: -1 - source: control.pressed ? "images/button_down.png" : "images/button.png" - border.top: 6 - border.bottom: 6 - border.left: 6 - border.right: 6 - anchors.bottomMargin: -1 - BorderImage { - anchors.fill: parent - source: "images/focusframe.png" - opacity: control.activeFocus ? 1 : 0 - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 + anchors.bottomMargin: control.pressed ? 0 : -1 + color: "#10000000" + radius: baserect.radius + } + Rectangle { + id: baserect + gradient: Gradient { + GradientStop {color: control.pressed ? "#bababa" : "#fefefe" ; position: 0} + GradientStop {color: control.pressed ? "#ccc" : "#e3e3e3" ; position: 1} } + radius: TextSingleton.implicitHeight * 0.16 + anchors.fill: parent + border.color: control.activeFocus ? "#47b" : "#999" Rectangle { anchors.fill: parent - anchors.margins: 2 - radius: 2 - color: "white" - opacity: control.hovered || control.activeFocus ? 0.2 : 0 + radius: parent.radius + color: control.activeFocus ? "#47b" : "white" + opacity: control.hovered || control.activeFocus ? 0.1 : 0 Behavior on opacity {NumberAnimation{ duration: 100 }} } - Image { - id: imageItem - source: "images/arrow-down.png" - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: 8 - opacity: control.enabled ? 0.7 : 0.5 - } + } + Image { + id: imageItem + visible: control.menu !== null + source: "images/arrow-down.png" + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: drowDownButtonWidth / 2 + opacity: control.enabled ? 0.6 : 0.3 } } /*! \internal */ property Component __editor: Item { - implicitWidth: 125 - implicitHeight: 25 + implicitWidth: 100 + implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2)) clip: true - BorderImage { + Rectangle { anchors.fill: parent - anchors.margins: -1 anchors.bottomMargin: 0 - anchors.rightMargin: -2 - source: "images/editbox.png" - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 - BorderImage { - anchors.fill: parent - source: "images/focusframe.png" - visible: control.activeFocus - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 + color: "#44ffffff" + radius: baserect.radius + } + Rectangle { + id: baserect + anchors.rightMargin: -radius + anchors.bottomMargin: 1 + gradient: Gradient { + GradientStop {color: "#e0e0e0" ; position: 0} + GradientStop {color: "#fff" ; position: 0.1} + GradientStop {color: "#fff" ; position: 1} } + radius: TextSingleton.implicitHeight * 0.16 + anchors.fill: parent + border.color: control.activeFocus ? "#47b" : "#999" } Rectangle { color: "#aaa" + anchors.bottomMargin: 2 + anchors.topMargin: 1 anchors.right: parent.right anchors.top: parent.top anchors.bottom: parent.bottom - anchors.bottomMargin: 2 - anchors.topMargin: 1 width: 1 } } @@ -176,7 +175,7 @@ Style { Loader { id: editorLoader anchors.fill: parent - anchors.rightMargin: 20 + anchors.rightMargin: drowDownButtonWidth + padding.right anchors.bottomMargin: -1 sourceComponent: control.editable ? __editor : null } diff --git a/src/controls/Styles/Base/ProgressBarStyle.qml b/src/controls/Styles/Base/ProgressBarStyle.qml index fe76f300..d8ff8140 100644 --- a/src/controls/Styles/Base/ProgressBarStyle.qml +++ b/src/controls/Styles/Base/ProgressBarStyle.qml @@ -98,57 +98,99 @@ Style { /*! \qmlproperty Component ProgressBarStyle::progress The progress component for this style. */ - property Component progress: Rectangle { + property Component progress: Item { property color progressColor: "#49d" anchors.fill: parent - radius: 2 - antialiasing: true - gradient: Gradient { - GradientStop {color: Qt.lighter(progressColor, 1.3) ; position: 0} - GradientStop {color: progressColor ; position: 1.4} - } - border.width: 1 - border.color: Qt.darker(progressColor, 1.2) + clip: true Rectangle { - color: "transparent" - radius: 1.5 - clip: true + id: base + width: control.width + height: control.height + radius: TextSingleton.implicitHeight * 0.16 antialiasing: true - anchors.fill: parent - anchors.margins: 1 - border.color: Qt.rgba(1,1,1,0.1) - Image { - visible: control.indeterminate - height: parent.height - NumberAnimation on x { - from: -39 - to: 0 - running: control.indeterminate - duration: 800 - loops: Animation.Infinite + gradient: Gradient { + GradientStop {color: Qt.lighter(progressColor, 1.3) ; position: 0} + GradientStop {color: progressColor ; position: 1.4} + } + border.width: 1 + border.color: Qt.darker(progressColor, 1.2) + Rectangle { + color: "transparent" + radius: 1.5 + clip: true + antialiasing: true + anchors.fill: parent + anchors.margins: 1 + border.color: Qt.rgba(1,1,1,0.1) + Image { + visible: control.indeterminate + height: parent.height + NumberAnimation on x { + from: -39 + to: 0 + running: control.indeterminate + duration: 800 + loops: Animation.Infinite + } + fillMode: Image.Tile + width: parent.width + 25 + source: "images/progress-indeterminate.png" } - fillMode: Image.Tile - width: parent.width + 25 - source: "images/progress-indeterminate.png" } } + Rectangle { + height: parent.height - 2 + width: 1 + y: 1 + anchors.right: parent.right + anchors.rightMargin: 1 + color: Qt.rgba(1,1,1,0.1) + visible: splitter.visible + } + Rectangle { + id: splitter + height: parent.height - 2 + width: 1 + y: 1 + anchors.right: parent.right + color: Qt.darker(progressColor, 1.2) + property int offset: currentProgress * control.width + visible: offset > base.radius && offset < control.width - base.radius + 1 + } } /*! \qmlproperty Component ProgressBarStyle::background The background component for this style. + + \note The implicitWidth and implicitHeight of the background component + must be set. */ property Component background: Item { implicitWidth: 200 implicitHeight: Math.max(17, Math.round(TextSingleton.implicitHeight * 0.7)) - BorderImage { + Rectangle { + anchors.fill: parent + anchors.bottomMargin: control.pressed ? 0 : -1 + color: "#44ffffff" + radius: baserect.radius + } + Rectangle { + id: baserect + gradient: Gradient { + GradientStop {color: "#eee" ; position: 0} + GradientStop {color: "#fff" ; position: 0.1} + GradientStop {color: "#fff" ; position: 1} + } + radius: TextSingleton.implicitHeight * 0.16 anchors.fill: parent - anchors.topMargin: -1 - anchors.bottomMargin: -1 - source: "images/editbox.png" - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 + border.color: control.activeFocus ? "#47b" : "#999" + Rectangle { + anchors.fill: parent + radius: parent.radius + color: control.activeFocus ? "#47b" : "white" + opacity: control.hovered || control.activeFocus ? 0.1 : 0 + Behavior on opacity {NumberAnimation{ duration: 100 }} + } } } diff --git a/src/controls/Styles/Base/RadioButtonStyle.qml b/src/controls/Styles/Base/RadioButtonStyle.qml index c2cfbe00..78f423ac 100644 --- a/src/controls/Styles/Base/RadioButtonStyle.qml +++ b/src/controls/Styles/Base/RadioButtonStyle.qml @@ -84,43 +84,61 @@ Style { readonly property RadioButton control: __control /*! This defines the text label. */ - property Component label: Text { - text: control.text - renderType: Text.NativeRendering - verticalAlignment: Text.AlignVCenter - color: __syspal.text + property Component label: Item { + implicitWidth: text.implicitWidth + 2 + implicitHeight: text.implicitHeight + Rectangle { + anchors.fill: text + anchors.margins: -1 + anchors.leftMargin: -3 + anchors.rightMargin: -3 + visible: control.activeFocus + height: 6 + radius: 3 + color: "#224f9fef" + border.color: "#47b" + opacity: 0.6 + } + Text { + id: text + text: control.text + anchors.centerIn: parent + color: __syspal.text + renderType: Text.NativeRendering + } } /*! The background under indicator and label. */ - property Component background: Item { - implicitWidth: 100 - } - - /*! The content padding. */ - padding { top: 0 ; left: 0 ; right: 4 ; bottom: 0 } + property Component background /*! The spacing between indicator and label. */ - property int spacing: 4 + property int spacing: Math.round(TextSingleton.implicitHeight/4) /*! This defines the indicator button. */ property Component indicator: Rectangle { - width: 17 - height: 17 - color: "white" + width: Math.round(TextSingleton.implicitHeight) + height: width + gradient: Gradient { + GradientStop {color: "#eee" ; position: 0} + GradientStop {color: control.pressed ? "#eee" : "#fff" ; position: 0.4} + GradientStop {color: "#fff" ; position: 1} + } border.color: control.activeFocus ? "#16c" : "gray" antialiasing: true radius: height/2 - Rectangle { anchors.centerIn: parent - visible: control.checked - width: 9 - height: 9 - color: "#666" + width: Math.round(parent.width * 0.5) + height: width + gradient: Gradient { + GradientStop {color: "#999" ; position: 0} + GradientStop {color: "#555" ; position: 1} + } border.color: "#222" antialiasing: true radius: height/2 - opacity: control.enabled ? 1 : 0.5 + Behavior on opacity {NumberAnimation {duration: 80}} + opacity: control.checked ? control.enabled ? 1 : 0.5 : 0 } } diff --git a/src/controls/Styles/Base/ScrollViewStyle.qml b/src/controls/Styles/Base/ScrollViewStyle.qml index 2a0aa137..a7dbcc52 100644 --- a/src/controls/Styles/Base/ScrollViewStyle.qml +++ b/src/controls/Styles/Base/ScrollViewStyle.qml @@ -113,8 +113,8 @@ Style { property Component scrollBarBackground: Item { property bool sticky: false property bool hovered: styleData.hovered - implicitWidth: 16 - implicitHeight: 16 + implicitWidth: Math.round(TextSingleton.implicitHeight) + implicitHeight: Math.round(TextSingleton.implicitHeight) clip: true opacity: transientScrollBars ? 0.5 : 1.0 visible: !transientScrollBars || sticky @@ -146,8 +146,8 @@ Style { property Component handle: Item { property bool sticky: false property bool hovered: __activeControl !== "none" - implicitWidth: img.implicitWidth - implicitHeight: img.implicitHeight + implicitWidth: Math.round(TextSingleton.implicitHeight) + 1 + implicitHeight: Math.round(TextSingleton.implicitHeight) + 1 BorderImage { id: img opacity: styleData.pressed && !transientScrollBars ? 0.5 : styleData.hovered ? 1 : 0.8 @@ -161,8 +161,8 @@ Style { anchors.bottom: parent.bottom anchors.right: parent.right anchors.left: styleData.horizontal ? parent.left : undefined - width: !styleData.horizontal && transientScrollBars ? sticky ? 13 : 10 : img.implicitWidth - height: styleData.horizontal && transientScrollBars ? sticky ? 13 : 10 : img.implicitHeight + width: !styleData.horizontal && transientScrollBars ? sticky ? 13 : 10 : parent.width + height: styleData.horizontal && transientScrollBars ? sticky ? 13 : 10 : parent.height Behavior on width { enabled: !styleData.horizontal && transientScrollBars; NumberAnimation { duration: 100 } } Behavior on height { enabled: styleData.horizontal && transientScrollBars; NumberAnimation { duration: 100 } } } @@ -183,8 +183,8 @@ Style { */ property Component incrementControl: Rectangle { visible: !transientScrollBars - implicitWidth: transientScrollBars ? 0 : 16 - implicitHeight: transientScrollBars ? 0 : 16 + implicitWidth: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight) + implicitHeight: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight) Rectangle { anchors.fill: parent anchors.bottomMargin: -1 @@ -199,7 +199,7 @@ Style { Image { source: styleData.horizontal ? "images/arrow-right.png" : "images/arrow-down.png" anchors.centerIn: parent - opacity: control.enabled ? 0.7 : 0.5 + opacity: control.enabled ? 0.6 : 0.5 } gradient: Gradient { GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0} @@ -221,8 +221,8 @@ Style { */ property Component decrementControl: Rectangle { visible: !transientScrollBars - implicitWidth: transientScrollBars ? 0 : 16 - implicitHeight: transientScrollBars ? 0 : 16 + implicitWidth: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight) + implicitHeight: transientScrollBars ? 0 : Math.round(TextSingleton.implicitHeight) Rectangle { anchors.fill: parent anchors.topMargin: styleData.horizontal ? 0 : -1 @@ -241,7 +241,7 @@ Style { anchors.centerIn: parent anchors.verticalCenterOffset: styleData.horizontal ? 0 : -1 anchors.horizontalCenterOffset: styleData.horizontal ? -1 : 0 - opacity: control.enabled ? 0.7 : 0.5 + opacity: control.enabled ? 0.6 : 0.5 } gradient: Gradient { GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0} diff --git a/src/controls/Styles/Base/SliderStyle.qml b/src/controls/Styles/Base/SliderStyle.qml index 661f70c0..a62230bc 100644 --- a/src/controls/Styles/Base/SliderStyle.qml +++ b/src/controls/Styles/Base/SliderStyle.qml @@ -95,54 +95,75 @@ Style { /*! This property holds the item for the slider handle. You can access the slider through the \c control property */ - property Component handle: Item { - implicitWidth: Math.round(implicitHeight * 1.1) - implicitHeight: TextSingleton.implicitHeight + property Component handle: Item{ + implicitWidth: implicitHeight + implicitHeight: TextSingleton.implicitHeight * 1.2 - BorderImage { - anchors.fill: parent - anchors.margins: -1 - source: "images/slider-handle.png" - border.top: 4 - border.bottom: 4 - border.left: 4 - border.right: 4 - Rectangle { + FastGlow { + source: handle anchors.fill: parent - anchors.margins: 2 - radius: 2 - color: "white" - opacity: control.hovered || control.activeFocus ? 0.2 : 0 - Behavior on opacity {NumberAnimation{ duration: 100 }} + anchors.bottomMargin: -1 + anchors.topMargin: 1 + smooth: true + color: "#11000000" + spread: 0.8 + transparentBorder: true + blur: 0.1 + } - BorderImage { + Rectangle { + id: handle anchors.fill: parent - source: "images/focusframe.png" - opacity: control.activeFocus ? 1 : 0 - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 + + radius: width/2 + gradient: Gradient { + GradientStop { color: control.pressed ? "#e0e0e0" : "#fff" ; position: 1 } + GradientStop { color: "#eee" ; position: 0 } + } + Rectangle { + anchors.fill: parent + anchors.margins: 1 + radius: width/2 + border.color: "#99ffffff" + color: control.activeFocus ? "#224f7fbf" : "transparent" + } + border.color: control.activeFocus ? "#47b" : "#777" } - } - } + } /*! This property holds the background groove of the slider. You can access the handle position through the \c styleData.handlePosition property. */ property Component groove: Item { + property color fillColor: "#49d" anchors.verticalCenter: parent.verticalCenter - implicitWidth: 100 - implicitHeight: 8 - BorderImage { + implicitWidth: Math.round(TextSingleton.implicitHeight * 4.5) + implicitHeight: Math.max(6, Math.round(TextSingleton.implicitHeight * 0.3)) + Rectangle { + radius: height/2 anchors.fill: parent - source: "images/slider-groove.png" - opacity: 0.8 - border.top: 3 - border.bottom: 3 - border.left: 6 - border.right: 6 + border.width: 1 + border.color: "#888" + gradient: Gradient { + GradientStop { color: "#bbb" ; position: 0 } + GradientStop { color: "#ccc" ; position: 0.6 } + GradientStop { color: "#ccc" ; position: 1 } + } + } + Item { + clip: true + width: styleData.handlePosition + height: parent.height + Rectangle { + anchors.fill: parent + border.color: Qt.darker(fillColor, 1.2) + radius: height/2 + gradient: Gradient { + GradientStop {color: Qt.lighter(fillColor, 1.3) ; position: 0} + GradientStop {color: fillColor ; position: 1.4} + } + } } } @@ -194,7 +215,7 @@ Style { x: padding.left sourceComponent: groove width: (horizontal ? parent.width : parent.height) - padding.left - padding.right - y: padding.top + (Math.round(horizontal ? parent.height : parent.width - padding.top - padding.bottom) - grooveLoader.item.height)/2 + y: Math.round(padding.top + (Math.round(horizontal ? parent.height : parent.width - padding.top - padding.bottom) - grooveLoader.item.height)/2) } Loader { id: tickMarkLoader diff --git a/src/controls/Styles/Base/SpinBoxStyle.qml b/src/controls/Styles/Base/SpinBoxStyle.qml index 5c04fd32..9f1b565d 100644 --- a/src/controls/Styles/Base/SpinBoxStyle.qml +++ b/src/controls/Styles/Base/SpinBoxStyle.qml @@ -76,7 +76,7 @@ Style { } /*! The content margins of the text field. */ - padding { top: 1 ; left: 5 ; right: 18 ; bottom: 0 } + padding { top: 1 ; left: Math.round(TextSingleton.implicitHeight/2) ; right: Math.round(TextSingleton.implicitHeight) ; bottom: 0 } /*! \qmlproperty enumeration horizontalAlignment @@ -119,49 +119,46 @@ Style { /*! The button used to increment the value. */ property Component incrementControl: Item { - implicitWidth: 18 + implicitWidth: padding.right Image { source: "images/arrow-up.png" anchors.centerIn: parent anchors.verticalCenterOffset: 1 - opacity: control.enabled ? 0.7 : 0.5 + opacity: control.enabled ? (styleData.upPressed ? 1 : 0.6) : 0.5 } } /*! The button used to decrement the value. */ property Component decrementControl: Item { - implicitWidth: 18 + implicitWidth: padding.right Image { source: "images/arrow-down.png" anchors.centerIn: parent anchors.verticalCenterOffset: -2 - opacity: control.enabled ? 0.7 : 0.5 + opacity: control.enabled ? (styleData.downPressed ? 1 : 0.6) : 0.5 } } /*! The background of the SpinBox. */ property Component background: Item { - implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.1)) + implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2)) implicitWidth: styleData.contentWidth + 26 - BorderImage { - id: image + Rectangle { anchors.fill: parent - anchors.margins: -1 - source: "images/editbox.png" - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 anchors.bottomMargin: -1 - BorderImage { - anchors.fill: parent - source: "images/focusframe.png" - visible: control.activeFocus - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 + color: "#44ffffff" + radius: baserect.radius + } + Rectangle { + id: baserect + gradient: Gradient { + GradientStop {color: "#eee" ; position: 0} + GradientStop {color: "#fff" ; position: 0.1} + GradientStop {color: "#fff" ; position: 1} } + radius: TextSingleton.implicitHeight * 0.16 + anchors.fill: parent + border.color: control.activeFocus ? "#47b" : "#999" } } diff --git a/src/controls/Styles/Base/StatusBarStyle.qml b/src/controls/Styles/Base/StatusBarStyle.qml index a210650f..aa8f6d6e 100644 --- a/src/controls/Styles/Base/StatusBarStyle.qml +++ b/src/controls/Styles/Base/StatusBarStyle.qml @@ -43,19 +43,55 @@ import QtQuick.Controls.Private 1.0 /*! \qmltype StatusBarStyle - \internal - \ingroup applicationwindowstyling \inqmlmodule QtQuick.Controls.Styles - \since 5.1 + \ingroup controlsstyling + \since 5.2 + \brief Provides custom styling for StatusBar + + The status bar can be defined by overriding the background component and + setting the content padding. + + Example: + \qml + StatusBar { + style: StatusBarStyle { + padding { + left: 8 + right: 8 + top: 3 + bottom: 3 + } + background: Rectangle { + implicitHeight: 16 + implicitWidth: 200 + gradient: Gradient{ + GradientStop{color: "#eee" ; position: 0} + GradientStop{color: "#ccc" ; position: 1} + } + Rectangle { + anchors.top: parent.top + width: parent.width + height: 1 + color: "#999" + } + } + } + } + \endqml */ + Style { - padding.left: 3 - padding.right: 3 - padding.top: 3 - padding.bottom: 2 + /*! The content padding inside the status bar. */ + padding { + left: 3 + right: 3 + top: 3 + bottom: 2 + } - property Component panel: Rectangle { + /*! This defines the background of the tool bar. */ + property Component background: Rectangle { implicitHeight: 16 implicitWidth: 200 @@ -71,4 +107,8 @@ Style { color: "#999" } } + + property Component panel: Loader { + sourceComponent: background + } } diff --git a/src/controls/Styles/Base/SwitchStyle.qml b/src/controls/Styles/Base/SwitchStyle.qml index 9154e4ec..68796645 100644 --- a/src/controls/Styles/Base/SwitchStyle.qml +++ b/src/controls/Styles/Base/SwitchStyle.qml @@ -76,8 +76,9 @@ Style { /*! This defines the switch handle. */ property Component handle: Rectangle { - implicitWidth: 32 - implicitHeight: 18 + opacity: control.enabled ? 1.0 : 0.5 + implicitWidth: Math.round((parent.parent.width - padding.left - padding.right)/2) + implicitHeight: control.height - padding.top - padding.bottom border.color: control.activeFocus ? Qt.darker(__syspal.highlight, 2) : Qt.darker(__syspal.button, 2) property color bg: control.activeFocus ? Qt.darker(__syspal.highlight, 1.2) : __syspal.button @@ -94,8 +95,8 @@ Style { property color shadow: control.checked ? Qt.darker(__syspal.highlight, 1.2): "#999" property color bg: control.checked ? __syspal.highlight:"#bbb" - implicitWidth: 60 - implicitHeight: 18 + implicitWidth: Math.round(implicitHeight * 3) + implicitHeight: Math.max(16, Math.round(TextSingleton.implicitHeight)) border.color: "gray" color: "red" diff --git a/src/controls/Styles/Base/TabViewStyle.qml b/src/controls/Styles/Base/TabViewStyle.qml index e4d9c010..430dd02f 100644 --- a/src/controls/Styles/Base/TabViewStyle.qml +++ b/src/controls/Styles/Base/TabViewStyle.qml @@ -156,20 +156,22 @@ Style { border.right: 6 anchors.topMargin: styleData.selected ? 0 : 1 } - BorderImage { - anchors.fill: parent - anchors.margins: -1 - source: "images/focusframe.png" - visible: styleData.activeFocus && styleData.selected - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 - } + } + Rectangle { + anchors.fill: textitem + anchors.margins: -1 + anchors.leftMargin: -3 + anchors.rightMargin: -3 + visible: (styleData.activeFocus && styleData.selected) + height: 6 + radius: 3 + color: "#224f9fef" + border.color: "#47b" } Text { id: textitem anchors.centerIn: parent + anchors.alignWhenCentered: true text: styleData.title renderType: Text.NativeRendering scale: control.tabPosition === Qt.TopEdge ? 1 : -1 diff --git a/src/controls/Styles/Base/TableViewStyle.qml b/src/controls/Styles/Base/TableViewStyle.qml index 3397a81a..512b0cfe 100644 --- a/src/controls/Styles/Base/TableViewStyle.qml +++ b/src/controls/Styles/Base/TableViewStyle.qml @@ -99,6 +99,7 @@ ScrollViewStyle { anchors.top: parent.top anchors.bottom: parent.bottom anchors.bottomMargin: 1 + anchors.topMargin: 1 width: 1 color: "#ccc" } diff --git a/src/controls/Styles/Base/TextFieldStyle.qml b/src/controls/Styles/Base/TextFieldStyle.qml index e05ae82c..8b4494d1 100644 --- a/src/controls/Styles/Base/TextFieldStyle.qml +++ b/src/controls/Styles/Base/TextFieldStyle.qml @@ -77,7 +77,7 @@ Style { readonly property TextField control: __control /*! The content margins of the text field. */ - padding { top: 4 ; left: 6 ; right: 6 ; bottom:4 } + padding { top: 4 ; left: TextSingleton.implicitHeight/3 ; right: TextSingleton.implicitHeight/3 ; bottom:4 } /*! The current font. */ property font font @@ -113,25 +113,24 @@ Style { /*! The background of the text field. */ property Component background: Item { - implicitWidth: 100 - implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.1)) - BorderImage { + implicitWidth: Math.round(TextSingleton.implicitHeight * 8) + implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2)) + Rectangle { anchors.fill: parent - anchors.margins: -1 - source: "images/editbox.png" - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 - BorderImage { - anchors.fill: parent - source: "images/focusframe.png" - visible: control.activeFocus - border.left: 4 - border.right: 4 - border.top: 4 - border.bottom: 4 + anchors.bottomMargin: -1 + color: "#44ffffff" + radius: baserect.radius + } + Rectangle { + id: baserect + gradient: Gradient { + GradientStop {color: "#e0e0e0" ; position: 0} + GradientStop {color: "#fff" ; position: 0.1} + GradientStop {color: "#fff" ; position: 1} } + radius: TextSingleton.implicitHeight * 0.16 + anchors.fill: parent + border.color: control.activeFocus ? "#47b" : "#999" } } diff --git a/src/controls/Styles/Base/ToolBarStyle.qml b/src/controls/Styles/Base/ToolBarStyle.qml index 51fe8ca7..ca5d93fb 100644 --- a/src/controls/Styles/Base/ToolBarStyle.qml +++ b/src/controls/Styles/Base/ToolBarStyle.qml @@ -43,18 +43,50 @@ import QtQuick.Controls.Private 1.0 /*! \qmltype ToolBarStyle - \internal - \ingroup applicationwindowstyling \inqmlmodule QtQuick.Controls.Styles + \ingroup controlsstyling + \since 5.2 + \brief Provides custom styling for ToolBar + + The tool bar can be defined by overriding the background component and + setting the content padding. + + Example: + \qml + ToolBar { + style: ToolBarStyle { + padding { + left: 8 + right: 8 + top: 3 + bottom: 3 + } + background: Rectangle { + implicitWidth: 100 + implicitHeight: 40 + border.color: "#999" + gradient: Gradient { + GradientStop { position: 0 ; color: "#fff" } + GradientStop { position: 1 ; color: "#eee" } + } + } + } + } + \endqml */ + Style { - padding.left: 6 - padding.right: 6 - padding.top: 3 - padding.bottom: 3 + /*! The content padding inside the tool bar. */ + padding { + left: 6 + right: 6 + top: 3 + bottom: 3 + } - property Component panel: Item { + /*! This defines the background of the tool bar. */ + property Component background: Item { implicitHeight: 40 implicitWidth: 200 Rectangle { @@ -71,4 +103,8 @@ Style { } } } + + property Component panel: Loader { + sourceComponent: background + } } diff --git a/src/controls/Styles/Base/images/check.png b/src/controls/Styles/Base/images/check.png Binary files differnew file mode 100644 index 00000000..1774880a --- /dev/null +++ b/src/controls/Styles/Base/images/check.png diff --git a/src/controls/Styles/Base/images/check@2x.png b/src/controls/Styles/Base/images/check@2x.png Binary files differnew file mode 100644 index 00000000..65727caa --- /dev/null +++ b/src/controls/Styles/Base/images/check@2x.png diff --git a/src/controls/Styles/Desktop/ComboBoxStyle.qml b/src/controls/Styles/Desktop/ComboBoxStyle.qml index fd4b6cfe..b36b4c1d 100644 --- a/src/controls/Styles/Desktop/ComboBoxStyle.qml +++ b/src/controls/Styles/Desktop/ComboBoxStyle.qml @@ -46,6 +46,7 @@ import "." as Desktop Style { readonly property ComboBox control: __control + property int drowDownButtonWidth: 24 property Component panel: Item { property bool popup: !!styleItem.styleHint("comboboxpopup") diff --git a/src/controls/Styles/Desktop/MenuStyle.qml b/src/controls/Styles/Desktop/MenuStyle.qml index a3f3e8fa..ad04281d 100644 --- a/src/controls/Styles/Desktop/MenuStyle.qml +++ b/src/controls/Styles/Desktop/MenuStyle.qml @@ -53,10 +53,10 @@ Style { contentWidth: parent ? parent.contentWidth : 0 contentHeight: parent ? parent.contentHeight : 0 - width: implicitWidth + 2 * (pixelMetric("menuhmargin") + pixelMetric("menupanelwidth")) - height: implicitHeight + 2 * (pixelMetric("menuvmargin") + pixelMetric("menupanelwidth")) + width: implicitWidth + height: implicitHeight - property int subMenuOverlap: pixelMetric("submenuoverlap") + property int subMenuOverlap: -2 * pixelMetric("menupanelwidth") property real maxHeight: Screen.desktopAvailableHeight * 0.99 property int margin: pixelMetric("menuvmargin") + pixelMetric("menupanelwidth") @@ -75,7 +75,7 @@ Style { property Component menuItem: StyleItem { elementType: __menuItemType x: pixelMetric("menuhmargin") + pixelMetric("menupanelwidth") - y: pixelMetric("menuvmargin") + pixelMetric("menupanelwidth") + y: pixelMetric("menuvmargin") text: !!parent && parent.text property string textAndShorcut: text + (properties.shortcut ? "\t" + properties.shortcut : "") diff --git a/src/controls/Styles/Desktop/RowItemSingleton.qml b/src/controls/Styles/Desktop/RowItemSingleton.qml new file mode 100644 index 00000000..b78fc043 --- /dev/null +++ b/src/controls/Styles/Desktop/RowItemSingleton.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +pragma Singleton +import QtQuick.Controls.Private 1.0 +StyleItem { + elementType: "itemrow" +} diff --git a/src/controls/Styles/Desktop/TableViewStyle.qml b/src/controls/Styles/Desktop/TableViewStyle.qml index d636b1b8..88611ab5 100644 --- a/src/controls/Styles/Desktop/TableViewStyle.qml +++ b/src/controls/Styles/Desktop/TableViewStyle.qml @@ -40,6 +40,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.1 import QtQuick.Controls.Private 1.0 +import "." ScrollViewStyle { id: root @@ -81,17 +82,13 @@ ScrollViewStyle { styleData.column === 0 ? "beginning" : "" } - property Component rowDelegate: StyleItem { - id: rowstyle - elementType: "itemrow" - activeControl: styleData.alternate ? "alternate" : "" - selected: styleData.selected ? true : false - height: Math.max(16, rowstyle.implicitHeight) - active: styleData.hasActiveFocus - border.left: 4 - border.right: 4 - textureWidth: 16 - textureHeight: 16 + property Component rowDelegate: BorderImage { + visible: styleData.selected || styleData.alternate + source: "image://__tablerow/" + (styleData.alternate ? "alternate_" : "") + + (styleData.selected ? "selected_" : "") + + (styleData.hasActiveFocus ? "active" : "") + height: Math.max(16, RowItemSingleton.implicitHeight) + border.left: 4 ; border.right: 4 } property Component itemDelegate: Item { diff --git a/src/controls/Styles/Desktop/qmldir b/src/controls/Styles/Desktop/qmldir new file mode 100644 index 00000000..ac80635c --- /dev/null +++ b/src/controls/Styles/Desktop/qmldir @@ -0,0 +1,2 @@ +singleton RowItemSingleton 1.0 RowItemSingleton.qml + diff --git a/src/controls/Styles/qmldir b/src/controls/Styles/qmldir index 8e53b6ba..5cd368ac 100644 --- a/src/controls/Styles/qmldir +++ b/src/controls/Styles/qmldir @@ -13,3 +13,5 @@ TabViewStyle 1.0 Base/TabViewStyle.qml TableViewStyle 1.0 Base/TableViewStyle.qml TextAreaStyle 1.1 Base/TextAreaStyle.qml TextFieldStyle 1.0 Base/TextFieldStyle.qml +ToolBarStyle 1.0 Base/ToolBarStyle.qml +StatusBarStyle 1.0 Base/StatusBarStyle.qml diff --git a/src/controls/Styles/styles.pri b/src/controls/Styles/styles.pri index 4c57944c..5a36767e 100644 --- a/src/controls/Styles/styles.pri +++ b/src/controls/Styles/styles.pri @@ -25,6 +25,8 @@ STYLES_QML_FILES = \ # Desktop STYLES_QML_FILES += \ + $$PWD/Desktop/qmldir \ + $$PWD/Desktop/RowItemSingleton.qml \ $$PWD/Desktop/ButtonStyle.qml \ $$PWD/Desktop/BusyIndicatorStyle.qml \ $$PWD/Desktop/CheckBoxStyle.qml \ @@ -70,9 +72,10 @@ STYLES_QML_FILES += \ $$PWD/Base/images/arrow-left.png \ $$PWD/Base/images/arrow-left@2x.png \ $$PWD/Base/images/arrow-right.png \ - $$PWD/Base/images/arrow-right@2x.png + $$PWD/Base/images/arrow-right@2x.png \ + $$PWD/Base/images/check.png \ + $$PWD/Base/images/check@2x.png STYLES_QML_FILES += $$PWD/qmldir QML_FILES += $$STYLES_QML_FILES - diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index 9aa5cf2c..586f1211 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -476,7 +476,7 @@ ScrollView { implicitHeight: 150 frameVisible: true - __scrollBarTopMargin: Qt.platform.os === "osx" ? headerrow.height : 0 + __scrollBarTopMargin: (__style && __style.transientScrollBars || Qt.platform.os === "osx") ? headerrow.height : 0 __viewTopMargin: headerrow.height /*! \internal */ diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index 006ab7dc..c1e3ddab 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -586,6 +586,10 @@ Control { renderType: __style ? __style.renderType : Text.NativeRendering - onAccepted: textfield.accepted() + onAccepted: { + Qt.inputMethod.commit() + Qt.inputMethod.hide() + textfield.accepted() + } } } diff --git a/src/controls/controls.pro b/src/controls/controls.pro index 3de8aece..e31f8683 100644 --- a/src/controls/controls.pro +++ b/src/controls/controls.pro @@ -45,7 +45,7 @@ include(plugin.pri) include(Private/private.pri) include(Styles/styles.pri) -osx: LIBS += -framework Carbon +osx: LIBS_PRIVATE += -framework Carbon # Create the resource file GENERATED_RESOURCE_FILE = $$OUT_PWD/controls.qrc diff --git a/src/controls/doc/qtquickcontrols.qdocconf b/src/controls/doc/qtquickcontrols.qdocconf index 440cbff3..4c97d5c8 100644 --- a/src/controls/doc/qtquickcontrols.qdocconf +++ b/src/controls/doc/qtquickcontrols.qdocconf @@ -2,7 +2,7 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) project = QtQuickControls description = Qt Quick Controls Reference Documentation -url = http://qt-project.org/doc/qt-$QT_VER/qtquickcontrols/ +url = http://qt-project.org/doc/qt-$QT_VER version = $QT_VERSION qhp.projects = QtQuickControls diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp index 52e7cb0d..2a676e48 100644 --- a/src/controls/plugin.cpp +++ b/src/controls/plugin.cpp @@ -57,6 +57,7 @@ #include "Private/qquickcontrolsprivate_p.h" #ifdef QT_WIDGETS_LIB +#include <QtQuick/qquickimageprovider.h> #include "Private/qquickstyleitem_p.h" #endif @@ -134,8 +135,8 @@ void QtQuickControlsPlugin::initializeEngine(QQmlEngine *engine, const char *uri #ifdef QT_WIDGETS_LIB qmlRegisterType<QQuickStyleItem>(private_uri, 1, 0, "StyleItem"); + engine->addImageProvider("__tablerow", new QQuickTableRowImageProvider); #endif - engine->addImageProvider("desktoptheme", new QQuickDesktopIconProvider); if (isLoadedFromResource()) engine->addImportPath(QStringLiteral("qrc:/")); diff --git a/src/controls/plugins.qmltypes b/src/controls/plugins.qmltypes index 7c8f1e80..e82b58a5 100644 --- a/src/controls/plugins.qmltypes +++ b/src/controls/plugins.qmltypes @@ -446,7 +446,203 @@ Module { Signal { name: "horizontalWheelMoved" } } Component { - prototype: "QQuickWindowQmlImpl" + name: "QQuickWindow" + defaultProperty: "data" + prototype: "QWindow" + exports: ["QtQuick.Window/Window 2.0", "QtQuick.Window/Window 2.1"] + exportMetaObjectRevisions: [0, 1] + Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "color"; type: "QColor" } + Property { name: "contentItem"; type: "QQuickItem"; isReadonly: true; isPointer: true } + Property { + name: "activeFocusItem" + revision: 1 + type: "QQuickItem" + isReadonly: true + isPointer: true + } + Signal { name: "frameSwapped" } + Signal { name: "sceneGraphInitialized" } + Signal { name: "sceneGraphInvalidated" } + Signal { name: "beforeSynchronizing" } + Signal { name: "beforeRendering" } + Signal { name: "afterRendering" } + Signal { + name: "closing" + revision: 1 + Parameter { name: "close"; type: "QQuickCloseEvent"; isPointer: true } + } + Signal { + name: "colorChanged" + Parameter { type: "QColor" } + } + Signal { name: "activeFocusItemChanged"; revision: 1 } + Method { name: "update" } + Method { name: "releaseResources" } + } + Component { + name: "QWindow" + prototype: "QObject" + Enum { + name: "Visibility" + values: { + "Hidden": 0, + "AutomaticVisibility": 1, + "Windowed": 2, + "Minimized": 3, + "Maximized": 4, + "FullScreen": 5 + } + } + Property { name: "title"; type: "string" } + Property { name: "modality"; type: "Qt::WindowModality" } + Property { name: "flags"; type: "Qt::WindowFlags" } + Property { name: "x"; type: "int" } + Property { name: "y"; type: "int" } + Property { name: "width"; type: "int" } + Property { name: "height"; type: "int" } + Property { name: "minimumWidth"; revision: 1; type: "int" } + Property { name: "minimumHeight"; revision: 1; type: "int" } + Property { name: "maximumWidth"; revision: 1; type: "int" } + Property { name: "maximumHeight"; revision: 1; type: "int" } + Property { name: "visible"; type: "bool" } + Property { name: "active"; revision: 1; type: "bool"; isReadonly: true } + Property { name: "visibility"; revision: 1; type: "Visibility" } + Property { name: "contentOrientation"; revision: 1; type: "Qt::ScreenOrientation" } + Property { name: "opacity"; revision: 1; type: "double" } + Signal { + name: "screenChanged" + Parameter { name: "screen"; type: "QScreen"; isPointer: true } + } + Signal { + name: "modalityChanged" + Parameter { name: "modality"; type: "Qt::WindowModality" } + } + Signal { + name: "windowStateChanged" + Parameter { name: "windowState"; type: "Qt::WindowState" } + } + Signal { + name: "xChanged" + Parameter { name: "arg"; type: "int" } + } + Signal { + name: "yChanged" + Parameter { name: "arg"; type: "int" } + } + Signal { + name: "widthChanged" + Parameter { name: "arg"; type: "int" } + } + Signal { + name: "heightChanged" + Parameter { name: "arg"; type: "int" } + } + Signal { + name: "minimumWidthChanged" + revision: 1 + Parameter { name: "arg"; type: "int" } + } + Signal { + name: "minimumHeightChanged" + revision: 1 + Parameter { name: "arg"; type: "int" } + } + Signal { + name: "maximumWidthChanged" + revision: 1 + Parameter { name: "arg"; type: "int" } + } + Signal { + name: "maximumHeightChanged" + revision: 1 + Parameter { name: "arg"; type: "int" } + } + Signal { + name: "visibleChanged" + Parameter { name: "arg"; type: "bool" } + } + Signal { + name: "visibilityChanged" + revision: 1 + Parameter { name: "visibility"; type: "QWindow::Visibility" } + } + Signal { name: "activeChanged"; revision: 1 } + Signal { + name: "contentOrientationChanged" + revision: 1 + Parameter { name: "orientation"; type: "Qt::ScreenOrientation" } + } + Signal { + name: "focusObjectChanged" + Parameter { name: "object"; type: "QObject"; isPointer: true } + } + Signal { + name: "opacityChanged" + revision: 1 + Parameter { name: "opacity"; type: "double" } + } + Method { name: "requestActivate"; revision: 1 } + Method { + name: "setVisible" + Parameter { name: "visible"; type: "bool" } + } + Method { name: "show" } + Method { name: "hide" } + Method { name: "showMinimized" } + Method { name: "showMaximized" } + Method { name: "showFullScreen" } + Method { name: "showNormal" } + Method { name: "close"; type: "bool" } + Method { name: "raise" } + Method { name: "lower" } + Method { + name: "setTitle" + Parameter { type: "string" } + } + Method { + name: "setX" + Parameter { name: "arg"; type: "int" } + } + Method { + name: "setY" + Parameter { name: "arg"; type: "int" } + } + Method { + name: "setWidth" + Parameter { name: "arg"; type: "int" } + } + Method { + name: "setHeight" + Parameter { name: "arg"; type: "int" } + } + Method { + name: "setMinimumWidth" + revision: 1 + Parameter { name: "w"; type: "int" } + } + Method { + name: "setMinimumHeight" + revision: 1 + Parameter { name: "h"; type: "int" } + } + Method { + name: "setMaximumWidth" + revision: 1 + Parameter { name: "w"; type: "int" } + } + Method { + name: "setMaximumHeight" + revision: 1 + Parameter { name: "h"; type: "int" } + } + Method { + name: "alert" + Parameter { name: "msec"; type: "int" } + } + } + Component { + prototype: "QQuickWindow" name: "QtQuick.Controls/ApplicationWindow" exports: ["QtQuick.Controls/ApplicationWindow 1.0"] exportMetaObjectRevisions: [0] diff --git a/src/controls/qmldir b/src/controls/qmldir index d5083cce..f51b0553 100644 --- a/src/controls/qmldir +++ b/src/controls/qmldir @@ -1,3 +1,4 @@ module QtQuick.Controls plugin qtquickcontrolsplugin +classname QtQuickControlsPlugin typeinfo plugins.qmltypes diff --git a/src/layouts/doc/qtquicklayouts.qdocconf b/src/layouts/doc/qtquicklayouts.qdocconf index 1356fd40..41fcc6a1 100644 --- a/src/layouts/doc/qtquicklayouts.qdocconf +++ b/src/layouts/doc/qtquicklayouts.qdocconf @@ -2,7 +2,7 @@ include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) project = QtQuickLayouts description = Qt Quick Layouts Reference Documentation -url = http://qt-project.org/doc/qt-$QT_VER/qtquicklayouts/ +url = http://qt-project.org/doc/qt-$QT_VER version = $QT_VERSION qhp.projects = QtQuickLayouts diff --git a/src/layouts/qmldir b/src/layouts/qmldir index ec1d66a2..6a260f02 100644 --- a/src/layouts/qmldir +++ b/src/layouts/qmldir @@ -1,3 +1,4 @@ module QtQuick.Layouts plugin qquicklayoutsplugin +classname QtQuickLayoutsPlugin typeinfo plugins.qmltypes diff --git a/tests/auto/activeFocusOnTab/data/images/testIcon.png b/tests/auto/activeFocusOnTab/data/images/testIcon.png Binary files differnew file mode 100644 index 00000000..7ac5f840 --- /dev/null +++ b/tests/auto/activeFocusOnTab/data/images/testIcon.png diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 0b3cfd2b..7eba7586 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs SUBDIRS += testplugin controls activeFocusOnTab applicationwindow -CONFIG += ordered +controls.depends = testplugin diff --git a/tests/auto/controls/data/tst_applicationwindow.qml b/tests/auto/controls/data/tst_applicationwindow.qml new file mode 100644 index 00000000..e424cc2d --- /dev/null +++ b/tests/auto/controls/data/tst_applicationwindow.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.1 +import QtTest 1.0 +import QtQuickControlsTests 1.0 + +Item { + id: container + width: 400 + height: 400 + +TestCase { + id: testCase + name: "Tests_ApplicationWindow" + when:windowShown + width:400 + height:400 + + function test_minimumHeight() { + var test_control = 'import QtQuick 2.1; \ + import QtQuick.Controls 1.1; \ + ApplicationWindow { \ + width: 100; height: 100; \ + property alias contentArea: rect; \ + statusBar: StatusBar { \ + visible: false; \ + Label { \ + text: "Ready"; \ + } \ + } \ + \ + toolBar: ToolBar { \ + visible: false; \ + ToolButton { \ + text: "One"; \ + } \ + } \ + Rectangle { \ + id: rect; \ + anchors.fill: parent; \ + } \ + } ' + + var window = Qt.createQmlObject(test_control, container, '') + wait(0) + var contentArea = window.contentArea + var oldHeight = contentArea.height + compare(contentArea.height, 100) + window.statusBar.visible = true + wait(0) + verify(contentArea.height < oldHeight) + + oldHeight = contentArea.height; + window.toolBar.visible = true + wait(0) + verify(contentArea.height < oldHeight) + window.destroy() + } +} +} diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml index 5aba4376..ee555ac0 100644 --- a/tests/auto/controls/data/tst_button.qml +++ b/tests/auto/controls/data/tst_button.qml @@ -263,6 +263,19 @@ TestCase { verify(!button.checked) compare(checkSpy.count, checkCount) + // keyboard toggle + button.forceActiveFocus() + keyClick(Qt.Key_Space) + verify(button.checked) + compare(checkSpy.count, ++checkCount) + + // toggle on release + keyPress(Qt.Key_Space) + verify(button.checked) + keyRelease(Qt.Key_Space) + verify(!button.checked) + compare(checkSpy.count, ++checkCount) + button.destroy() } } diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index e6ea7c5c..802d23e4 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -118,15 +118,13 @@ TestCase { } function test_arraymodelwithtextrole() { - var arrayModel = [ - {text: 'Banana', color: 'Yellow'}, - {text: 'Apple', color: 'Green'}, - {text: 'Coconut', color: 'Brown'} - ]; - - var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.1 ; ComboBox {}', testCase, ''); - comboBox.textRole = "text" - comboBox.model = arrayModel + // FIXME The use-case before this change should work. + var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.1 ; \ + ComboBox { \ + model: [ { "text": "Banana", "color": "Yellow"}, \ + { "text": "Apple", "color": "Green"}, \ + { "text": "Coconut", "color": "Brown"} ]; \ + textRole: "text" }', testCase, ''); compare(comboBox.currentIndex, 0) compare(comboBox.currentText, "Banana") comboBox.textRole = "color" @@ -535,6 +533,65 @@ TestCase { comboBox.destroy() } + SignalSpy { + id: modelSpy + signalName: "modelChanged" + } + + SignalSpy { + id: textSpy + signalName: "currentTextChanged" + } + + SignalSpy { + id: indexSpy + signalName: "currentIndexChanged" + } + + function test_modelChange() { + var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.1 ; ComboBox { model: ["a", "b", "c", "d"] }', container, ''); + modelSpy.target = textSpy.target = indexSpy.target = comboBox + + compare(comboBox.currentIndex, 0) + compare(comboBox.currentText, "a") + + // 1st model change + comboBox.model = ["A", "B", "C", "D"] + compare(comboBox.currentIndex, 0) + compare(modelSpy.count, 1) + compare(indexSpy.count, 0) + compare(textSpy.count, 1) + modelSpy.clear() + indexSpy.clear() + textSpy.clear() + + // Setting currentIndex + comboBox.currentIndex = 3 + compare(indexSpy.count, 1) + compare(textSpy.count, 1) + indexSpy.clear() + textSpy.clear() + + // 2nd model change + comboBox.model = 4 + compare(comboBox.currentIndex, 0) + compare(modelSpy.count, 1) + compare(indexSpy.count, 1) + compare(textSpy.count, 1) + modelSpy.clear() + indexSpy.clear() + textSpy.clear() + + // 3rd model change + comboBox.model = ["a", "b", "c", "d"] + compare(comboBox.currentIndex, 0) + compare(modelSpy.count, 1) + compare(indexSpy.count, 0) + compare(textSpy.count, 1) + + comboBox.destroy() + } + function test_addRemoveItemsInModel_QTBUG_30379() { var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.1 ; ComboBox {}', testCase, ''); comboBox.textRole = "text" diff --git a/tests/auto/controls/data/tst_scrollview.qml b/tests/auto/controls/data/tst_scrollview.qml index c9503b88..16ebf6c2 100644 --- a/tests/auto/controls/data/tst_scrollview.qml +++ b/tests/auto/controls/data/tst_scrollview.qml @@ -92,16 +92,20 @@ TestCase { function test_clickToCenter() { - var test_control = 'import QtQuick 2.1; \ - import QtQuick.Controls 1.1; \ - import QtQuick.Controls.Styles 1.1; \ - ScrollView { \ - id: _control1; \ - width: 100 ; height: 100; \ - Item { width: 200; height: 200 }\ - activeFocusOnTab: true; \ - style:ScrollViewStyle{} \ - } ' + var test_control = 'import QtQuick 2.1; \ + import QtQuick.Controls 1.1; \ + import QtQuick.Controls.Styles 1.1; \ + ScrollView { \ + id: _control1; \ + width: 100 ; height: 100; \ + Item { width: 200; height: 200 } \ + activeFocusOnTab: true; \ + style:ScrollViewStyle{ \ + handle: Item {width: 16 ; height: 16} \ + scrollBarBackground: Item {width: 16 ; height: 16} \ + incrementControl: Item {width: 16 ; height: 16} \ + decrementControl: Item {width: 16 ; height: 16}} }' + var scrollView = Qt.createQmlObject(test_control, container, '') verify(scrollView !== null, "view created is null") verify(scrollView.flickableItem.contentY === 0) diff --git a/tests/auto/controls/data/tst_styles.qml b/tests/auto/controls/data/tst_styles.qml index a458a78d..c1af406d 100644 --- a/tests/auto/controls/data/tst_styles.qml +++ b/tests/auto/controls/data/tst_styles.qml @@ -118,14 +118,14 @@ Item { function test_createToolBarStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.1; import QtQuick.Controls.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.1; import QtQuick.Controls.Styles 1.1; \ Rectangle { width: 50; height: 50; property Component style: ToolBarStyle {}}' , container, '') } function test_createStatusBarStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.1; import QtQuick.Controls.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.1; import QtQuick.Controls.Styles 1.1; \ Rectangle { width: 50; height: 50; property Component style: StatusBarStyle {}}' , container, '') } diff --git a/tests/auto/controls/data/tst_tabview.qml b/tests/auto/controls/data/tst_tabview.qml index 9405f793..1648d6c3 100644 --- a/tests/auto/controls/data/tst_tabview.qml +++ b/tests/auto/controls/data/tst_tabview.qml @@ -390,7 +390,7 @@ TestCase { verify(!tab3.activeFocus) verify(!textField.activeFocus) - tabView.destroy() + item.destroy() } function printGeometry(control) { diff --git a/tests/manual/testbench/content/Components.qml b/tests/manual/testbench/content/Components.qml index 98642aff..be7bf972 100644 --- a/tests/manual/testbench/content/Components.qml +++ b/tests/manual/testbench/content/Components.qml @@ -56,6 +56,7 @@ Item { property Component textarea: TextArea { text: loremIpsum } property Component toolbar: ToolBar { } property Component statusbar: StatusBar { } + property Component switchcontrol: Switch { } property Component label: Label {text: "I am a label" } property Component tableview: TableView { property bool movableColumns: true; model: testDataModel ; TableViewColumn {title: "Column 1"; movable: movableColumns} TableViewColumn {title: "Column 2"; movable: movableColumns} } property Component tabView: TabView { Repeater { model: 3 ; delegate:Tab { title: "Tab " + index } }} @@ -121,6 +122,7 @@ Item { append({ name: "ComboBox", component: combobox}); append({ name: "RadioButton", component: radiobutton}); append({ name: "Slider", component: slider}); + append({ name: "Switch", component: switchcontrol}); append({ name: "ProgressBar", component: progressbar}); append({ name: "TextField", component: textfield}); append({ name: "TextArea", component: textarea}); @@ -147,6 +149,7 @@ Item { property Component spinboxStyle: SpinBoxStyle {} property Component toolbarStyle: ToolBarStyle {} property Component statusbarStyle: StatusBarStyle {} + property Component switchStyle: SwitchStyle {} property Component tableviewStyle: TableViewStyle {} property Component scrollviewStyle: ScrollViewStyle {} property Component groupboxStyle: GroupBoxStyle {} @@ -163,6 +166,7 @@ Item { append({ name: "ComboBox", component: comboboxStyle}); append({ name: "RadioButton", component: radiobuttonStyle}); append({ name: "Slider", component: sliderStyle}); + append({ name: "Switch", component: switchStyle}); append({ name: "ProgressBar", component: progressbarStyle}); append({ name: "TextField", component: textfieldStyle}); append({ name: "TextArea", component: textareaStyle}); |