From dca452260217b1b63f9874d3d436a1b910ad4a41 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 27 May 2013 12:58:08 +0200 Subject: Update all plugins.qmltypes files Task-number: QTBUG-31388 Change-Id: I6b8ed2c7f641e38242540633fefe9ed0dc7cc8bf Reviewed-by: Shawn Rutledge --- src/controls/plugins.qmltypes | 4 +++- src/layouts/plugins.qmltypes | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controls/plugins.qmltypes b/src/controls/plugins.qmltypes index 89363578..8997cecf 100644 --- a/src/controls/plugins.qmltypes +++ b/src/controls/plugins.qmltypes @@ -3,7 +3,7 @@ import QtQuick.tooling 1.1 // This file describes the plugin-supplied types contained in the library. // It is used for QML tooling purposes only. // -// This file was auto-generated with the command '/home/jpnurmi/Projects/qt5-stable/qtbase/bin/qmlplugindump -notrelocatable QtQuick.Controls 1.0'. +// This file was auto-generated with the command 'qmlplugindump -notrelocatable QtQuick.Controls 1.0'. Module { Component { @@ -67,6 +67,8 @@ Module { Property { name: "__contentItem"; type: "QQuickItem"; isPointer: true } Property { name: "__minimumWidth"; type: "int" } Property { name: "__font"; type: "QFont" } + Property { name: "__xOffset"; type: "double" } + Property { name: "__yOffset"; type: "double" } Signal { name: "__menuClosed" } Signal { name: "popupVisibleChanged" } Method { name: "__closeMenu" } diff --git a/src/layouts/plugins.qmltypes b/src/layouts/plugins.qmltypes index c3f1c77c..a0744951 100644 --- a/src/layouts/plugins.qmltypes +++ b/src/layouts/plugins.qmltypes @@ -3,7 +3,7 @@ import QtQuick.tooling 1.1 // This file describes the plugin-supplied types contained in the library. // It is used for QML tooling purposes only. // -// This file was auto-generated with the command '/Users/thohartm/dev/qt5/qtbase/bin/qmlplugindump.app/Contents/MacOS/qmlplugindump QtQuick.Layouts 1.0 -notrelocatable'. +// This file was auto-generated with the command 'qmlplugindump QtQuick.Layouts 1.0 -notrelocatable'. Module { Component { @@ -11,12 +11,14 @@ Module { defaultProperty: "data" prototype: "QQuickLinearLayout" exports: ["QtQuick.Layouts/ColumnLayout 1.0"] + exportMetaObjectRevisions: [0] } Component { name: "QQuickGridLayout" defaultProperty: "data" prototype: "QQuickGridLayoutBase" exports: ["QtQuick.Layouts/GridLayout 1.0"] + exportMetaObjectRevisions: [0] Enum { name: "Flow" values: { @@ -36,6 +38,7 @@ Module { defaultProperty: "data" prototype: "QQuickItem" exports: ["QtQuick.Layouts/Layout 1.0"] + exportMetaObjectRevisions: [0] attachedType: "QQuickLayoutAttached" } Component { @@ -66,5 +69,6 @@ Module { defaultProperty: "data" prototype: "QQuickLinearLayout" exports: ["QtQuick.Layouts/RowLayout 1.0"] + exportMetaObjectRevisions: [0] } } -- cgit v1.2.1 From c796677a7b8f049b2bb902f1ec7f2251f295ead3 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 27 May 2013 13:27:01 +0200 Subject: Fix item view selection color We need to update the active palette text color every time the state changes. Change-Id: I7861eb4be76ccaeb58e9ff9aea58fa54d4f8d4c9 Reviewed-by: Gabriel de Dietrich --- src/private/qquickstyleitem.cpp | 11 +++++++---- src/styles/Desktop/TableViewStyle.qml | 8 ++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/private/qquickstyleitem.cpp b/src/private/qquickstyleitem.cpp index cfbb36c8..422d9a8e 100644 --- a/src/private/qquickstyleitem.cpp +++ b/src/private/qquickstyleitem.cpp @@ -938,8 +938,8 @@ QVariant QQuickStyleItem::styleHint(const QString &metric) if (metric == "comboboxpopup") { return qApp->style()->styleHint(QStyle::SH_ComboBox_Popup, m_styleoption); } else if (metric == "highlightedTextColor") { - QPalette pal = qApp->palette(); - pal.setCurrentColorGroup(active()? QPalette::Active : QPalette::Inactive); + QPalette pal = QApplication::palette("QAbstractItemView"); + pal.setCurrentColorGroup(m_styleoption->palette.currentColorGroup()); return pal.highlightedText().color().name(); } else if (metric == "textColor") { QPalette pal = qApp->palette(); @@ -1192,8 +1192,11 @@ void QQuickStyleItem::paint(QPainter *painter) pixmap.fill(Qt::transparent); QPainter pixpainter(&pixmap); qApp->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, m_styleoption, &pixpainter); - if (!qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected) && selected()) - pixpainter.fillRect(m_styleoption->rect, m_styleoption->palette.highlight()); + if ((style() == "mac" || !qApp->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected)) && selected()) { + QPalette pal = QApplication::palette("QAbstractItemView"); + pal.setCurrentColorGroup(m_styleoption->palette.currentColorGroup()); + pixpainter.fillRect(m_styleoption->rect, pal.highlight()); + } QPixmapCache::insert(pmKey, pixmap); } painter->drawPixmap(0, 0, pixmap); diff --git a/src/styles/Desktop/TableViewStyle.qml b/src/styles/Desktop/TableViewStyle.qml index da6a47e5..52fb9635 100644 --- a/src/styles/Desktop/TableViewStyle.qml +++ b/src/styles/Desktop/TableViewStyle.qml @@ -46,8 +46,8 @@ ScrollViewStyle { readonly property TableView control: __control property bool activateItemOnSingleClick: __styleitem.styleHint("activateItemOnSingleClick") - property color textColor: __styleitem.styleHint("textColor") - property color highlightedTextColor: __styleitem.styleHint("highlightedTextColor") + property color textColor: __styleitem.textColor + property color highlightedTextColor: __styleitem.highlightedTextColor property StyleItem __styleitem: StyleItem{ property color textColor: styleHint("textColor") @@ -55,6 +55,10 @@ ScrollViewStyle { elementType: "item" visible: false active: control.activeFocus + onActiveChanged: { + highlightedTextColor = styleHint("highlightedTextColor") + textColor = styleHint("textColor") + } } property Component headerDelegate: StyleItem { -- cgit v1.2.1 From 9b34e4377d3bbbcfd600bb056d77453eaa76fd3e Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 27 May 2013 12:38:42 +0200 Subject: Yet another plugin rename For consistency we should use "plugin" as suffix on plugin names. Change-Id: Ieea483cc1d7642e4fcd7d0907de8efd7e00743e1 Reviewed-by: Caroline Chao Reviewed-by: J-P Nurmi --- src/controls/controls.pro | 2 +- src/controls/qmldir | 2 +- src/private/private.pro | 2 +- src/private/qmldir | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controls/controls.pro b/src/controls/controls.pro index 928708c2..fbda88fc 100644 --- a/src/controls/controls.pro +++ b/src/controls/controls.pro @@ -1,4 +1,4 @@ -TARGET = qtquickcontrols +TARGET = qtquickcontrolsplugin TARGETPATH = QtQuick/Controls QT += qml quick gui-private core-private diff --git a/src/controls/qmldir b/src/controls/qmldir index f593439f..c243360c 100644 --- a/src/controls/qmldir +++ b/src/controls/qmldir @@ -1,5 +1,5 @@ module QtQuick.Controls -plugin qtquickcontrols +plugin qtquickcontrolsplugin ApplicationWindow 1.0 ApplicationWindow.qml Button 1.0 Button.qml CheckBox 1.0 CheckBox.qml diff --git a/src/private/private.pro b/src/private/private.pro index 9f892452..cbb08a80 100644 --- a/src/private/private.pro +++ b/src/private/private.pro @@ -1,4 +1,4 @@ -TARGET = qtquickcontrolsprivate +TARGET = qtquickcontrolsprivateplugin TARGETPATH = QtQuick/Controls/Private QT += qml quick gui-private core-private diff --git a/src/private/qmldir b/src/private/qmldir index d4b7fc46..7f73028e 100644 --- a/src/private/qmldir +++ b/src/private/qmldir @@ -1,5 +1,5 @@ module QtQuick.Controls.Private -plugin qtquickcontrolsprivate +plugin qtquickcontrolsprivateplugin AbstractCheckable 1.0 AbstractCheckable.qml Control 1.0 Control.qml FocusFrame 1.0 FocusFrame.qml -- cgit v1.2.1 From 78713a31058472c8a83813510d39fdf31056a35f Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Mon, 27 May 2013 08:57:12 +0200 Subject: Slider: Fix "Binding loop detected" warning Change-Id: Iffdf1b65a3ac80af73c3567c49bf8f0a9070dccb Reviewed-by: Jens Bache-Wiig --- src/controls/Slider.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index 711c449b..b6f3e551 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -273,7 +273,7 @@ Control { // means that setting a value while dragging will not "interrupt" the // dragging activity. Binding { - when: !mouseArea.drag.active + when: !updateValueWhileDragging && !mouseArea.drag.active target: fakeHandle property: __horizontal ? "x" : "y" value: range.position -- cgit v1.2.1 From 89b6c336f1670a24bdc9ffbea8ad236b8148176d Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 27 May 2013 15:09:50 +0200 Subject: Revert "Slider: Fix "Binding loop detected" warning" This reverts commit 1283dffcae90ace0cd97e10f28082318a3049271 As Tomasz pointed out, this causes a regression when setting value so we need to revise. Change-Id: I965b815b14b7ec7497e1a09d42fd973c74759f2b Reviewed-by: Caroline Chao --- src/controls/Slider.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index b6f3e551..711c449b 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -273,7 +273,7 @@ Control { // means that setting a value while dragging will not "interrupt" the // dragging activity. Binding { - when: !updateValueWhileDragging && !mouseArea.drag.active + when: !mouseArea.drag.active target: fakeHandle property: __horizontal ? "x" : "y" value: range.position -- cgit v1.2.1 From d3e9b0e8e0ee822e02e3e89d4e890de4ed0ffcd4 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Mon, 27 May 2013 11:31:18 +0200 Subject: Autotest: Move the README file to the tests/auto folder So it is more visible. Add some tips if user needs to run the autotests. Change-Id: I86739a06b1cd62a061aec20fb640f7c66cfc557c Reviewed-by: Liang Qi --- tests/auto/README.txt | 38 ++++++++++++++++++++++++++++++++++++++ tests/auto/testplugin/README.txt | 11 ----------- 2 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 tests/auto/README.txt delete mode 100644 tests/auto/testplugin/README.txt diff --git a/tests/auto/README.txt b/tests/auto/README.txt new file mode 100644 index 00000000..948242f0 --- /dev/null +++ b/tests/auto/README.txt @@ -0,0 +1,38 @@ + +Here are some tips if you need to run the Qt Quick Controls auto tests. + + - Testplugin + +Some autotests require the test plugin under testplugin/QtQuickControlsTests. + +The test plugin is not installed (i.e. to the qml folder), so +in order for the tst_controls to find it, you can either: + +- Run make check in the controls folder. The plugin will be found +at run time because IMPORTPATH is defined in the pro file. + +- In Qt Creator run settings or in the console, set QML2_IMPORT_PATH +macro to the testplugin path. At run time QML2_IMPORT_PATH is used by +by qmlscene to find imports required. +i.e: export QML2_IMPORT_PATH=/tests/auto/testplugin + +- Use the -import command-line option: +$ cd build/qt5/qtquickcontrols/tests/auto/controls +$ ./tst_controls -import ../testplugin + + - Running specific tests: + +i) It is possible to run a single file using the -input option. For example: + +$ ./tst_controls -input data/test.qml + +$ ./tst_controls -input /test.qml + +Specifying the full path to the qml test file is for example needed for shadow builds. + + +ii) The -functions command-line option will return a list of the current tests functions. +It is possible to run a single test function using the name of the test function as an argument. For example: + +tst_controls Test_Name::function1 + diff --git a/tests/auto/testplugin/README.txt b/tests/auto/testplugin/README.txt deleted file mode 100644 index c22837db..00000000 --- a/tests/auto/testplugin/README.txt +++ /dev/null @@ -1,11 +0,0 @@ - -The test plugin is not installed (i.e. to the qml folder). -In order for the tst_controls to find it, you can either: - -- Run make check in the controls folder. The plugin will be found -at run time because IMPORTPATH is defined in the pro file. - -- In Qt Creator run settings or in the console, set QML2_IMPORT_PATH -macro to the testplugin path. At run time QML2_IMPORT_PATH is used by -by qmlscene to find imports required. -i.e: export QML2_IMPORT_PATH=/tests/auto/testplugin -- cgit v1.2.1 From dbf42fc0028acc0170bb0d0dad966c74b86a456e Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 27 May 2013 15:51:08 +0200 Subject: Make GroupBox size respect anchor margins and update Gallery We now implicitly add the margins to GroupBox so that you can easily add them to a layout. This also gets rid of the silly Sidebar example and adds a much more useful Layout tab for effective testing. Change-Id: I6026c32b2a198062d9b11a67245df0529aa61f8a Reviewed-by: J-P Nurmi --- .../quick/controls/gallery/content/Layouts.qml | 108 ++++++++++++++++ examples/quick/controls/gallery/content/Panel.qml | 140 --------------------- examples/quick/controls/gallery/images/page.png | Bin 639 -> 0 bytes examples/quick/controls/gallery/images/panel.png | Bin 1756 -> 0 bytes examples/quick/controls/gallery/main.qml | 4 +- examples/quick/controls/gallery/resources.qrc | 4 +- src/controls/GroupBox.qml | 8 +- 7 files changed, 117 insertions(+), 147 deletions(-) create mode 100644 examples/quick/controls/gallery/content/Layouts.qml delete mode 100644 examples/quick/controls/gallery/content/Panel.qml delete mode 100644 examples/quick/controls/gallery/images/page.png delete mode 100644 examples/quick/controls/gallery/images/panel.png diff --git a/examples/quick/controls/gallery/content/Layouts.qml b/examples/quick/controls/gallery/content/Layouts.qml new file mode 100644 index 00000000..1251947a --- /dev/null +++ b/examples/quick/controls/gallery/content/Layouts.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** 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 QtQuick.Controls 1.0 +import QtQuick.Layouts 1.0 + +Item { + id:root + anchors.fill: parent + anchors.margins: 8 + + ColumnLayout { + id: mainLayout + anchors.fill: parent + spacing: 4 + GroupBox { + id: rowBox + title: "Row layout" + Layout.fillWidth: true + RowLayout { + id: rowLayout + anchors.fill: parent + TextField { + placeholderText: "This wants to grow horizontally" + Layout.fillWidth: true + } + Button { + text: "Button" + } + } + } + + GroupBox { + id: gridBox + title: "Grid layout" + Layout.fillWidth: true + + GridLayout { + id: gridLayout + anchors.fill: parent + anchors.margins: 4 + rows: 3 + flow: GridLayout.TopToBottom + + Label { text: "Line 1" } + Label { text: "Line 2" } + Label { text: "Line 3" } + + TextField { } + TextField { } + TextField { } + + TextArea { + text: "This widget spans over three rows in the GridLayout.\n" + + "All items in the GridLayout are implicitly positioned from top to bottom." + Layout.rowSpan: 3 + Layout.fillHeight: true + Layout.fillWidth: true + } + } + } + TextArea { + id: t3 + text: "This fills the whole cell" + Layout.minimumHeight: 30 + Layout.fillHeight: true + Layout.fillWidth: true + } + } +} diff --git a/examples/quick/controls/gallery/content/Panel.qml b/examples/quick/controls/gallery/content/Panel.qml deleted file mode 100644 index bdb10f83..00000000 --- a/examples/quick/controls/gallery/content/Panel.qml +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Controls 1.0 - -Rectangle { - id:root - - width: 540 - height: 340 - color:"#c3c3c3" - ScrollView { - frameVisible: false - anchors.fill: parent - - Item { - width:600 - height:600 - BorderImage { - id: page - source: "../images/page.png" - y:10; x:50 - width: 400; height: 400 - border.left: 12; border.top: 12 - border.right: 12; border.bottom: 12 - Text { - id:text - anchors.fill: parent - anchors.margins: 40 - text:textfield.text - } - Rectangle { - border.color: "#444" - anchors.centerIn: parent - color: Qt.rgba(s1.value, s2.value, s3.value) - width: 200 - height: width - } - - } - - BorderImage { - id: sidebar - source: "../images/panel.png" - anchors.left: parent.left - anchors.top: parent.top - width: show ? 160 : 40 - height:root.height - Behavior on width { NumberAnimation { easing.type: Easing.OutSine ; duration: 250 } } - property bool show: false - border.left: 0; - border.right: 26; - MouseArea { - id:mouseArea - anchors.fill: parent - onClicked: sidebar.show = !sidebar.show - } - Column { - id: panel1 - opacity: sidebar.show ? 1 : 0 - Behavior on opacity { NumberAnimation { easing.type:Easing.InCubic; duration: 600} } - - scale: sidebar.show ? 1 : 0 - Behavior on scale { NumberAnimation { easing.type:Easing.InCubic; duration: 200 } } - transformOrigin: Item.Top - - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: 12 - spacing:12 - - Button { width: parent.width - 12; text: "Close Panel"; onClicked: sidebar.show = false} - TextField { id: textfield; text: "Some text" ; width: parent.width - 12} - SpinBox { width: parent.width - 12} - CheckBox{ id: expander; text:"Sliders"} - } - - Column { - id: panel2 - opacity: expander.checked && sidebar.show ? 1 : 0 - scale: opacity - Behavior on opacity{ NumberAnimation { easing.type:Easing.OutSine; duration: 300}} - transformOrigin: Item.Top - anchors.top: panel1.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: 12 - spacing: 12 - Slider { id: s1; width:parent.width - 12; value:0.5} - Slider { id: s2; width:parent.width - 12; value:0.5} - Slider { id: s3; width:parent.width - 12; value:0.5} - - } - } - } - } -} diff --git a/examples/quick/controls/gallery/images/page.png b/examples/quick/controls/gallery/images/page.png deleted file mode 100644 index b46f205d..00000000 Binary files a/examples/quick/controls/gallery/images/page.png and /dev/null differ diff --git a/examples/quick/controls/gallery/images/panel.png b/examples/quick/controls/gallery/images/panel.png deleted file mode 100644 index 02d655eb..00000000 Binary files a/examples/quick/controls/gallery/images/panel.png and /dev/null differ diff --git a/examples/quick/controls/gallery/main.qml b/examples/quick/controls/gallery/main.qml index 7da74031..e34858cd 100644 --- a/examples/quick/controls/gallery/main.qml +++ b/examples/quick/controls/gallery/main.qml @@ -281,8 +281,8 @@ ApplicationWindow { Styles { anchors.fill: parent } } Tab { - title: "Sidebar" - Panel { anchors.fill:parent } + title: "Layouts" + Layouts { anchors.fill:parent } } } } diff --git a/examples/quick/controls/gallery/resources.qrc b/examples/quick/controls/gallery/resources.qrc index 14e88e52..21362787 100644 --- a/examples/quick/controls/gallery/resources.qrc +++ b/examples/quick/controls/gallery/resources.qrc @@ -5,18 +5,16 @@ content/Controls.qml content/ImageViewer.qml content/ModelView.qml - content/Panel.qml + content/Layouts.qml content/Styles.qml images/document-open.png images/document-open@2x.png images/document-save-as.png images/document-save-as@2x.png images/folder_new.png - images/page.png images/tab.png images/tab_selected.png images/window-new.png images/window-new@2x.png - images/panel.png diff --git a/src/controls/GroupBox.qml b/src/controls/GroupBox.qml index e358dd9d..9bf1c0cc 100644 --- a/src/controls/GroupBox.qml +++ b/src/controls/GroupBox.qml @@ -212,7 +212,11 @@ Item { enabled: (!groupbox.checkable || groupbox.checked) property Item layoutItem: container.children.length === 1 ? container.children[0] : null - function calcWidth () { return (layoutItem ? (layoutItem.implicitWidth || layoutItem.width) : container.childrenRect.width) } - function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) : container.childrenRect.height) } + function calcWidth () { return (layoutItem ? (layoutItem.implicitWidth || layoutItem.width) + + (layoutItem.anchors.fill ? layoutItem.anchors.leftMargin + + layoutItem.anchors.rightMargin : 0) : container.childrenRect.width) } + function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) + + (layoutItem.anchors.fill ? layoutItem.anchors.topMargin + + layoutItem.anchors.bottomMargin : 0) : container.childrenRect.height) } }] } -- cgit v1.2.1 From a84444f3809e9372c61ace8f5b973ad59fcaa9af Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 27 May 2013 15:07:33 +0200 Subject: ScrollView: take Flickable::originX and originY into account Change-Id: I16eb186a2b1f706bbc961d34a614bf2f9a9a0646 Reviewed-by: Jens Bache-Wiig --- src/controls/ScrollView.qml | 8 ++++++-- src/private/ScrollViewHelper.qml | 12 ++++++++---- tests/manual/scrollview/main.qml | 20 +++++++++++++++++++- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml index 31f69b8f..3262648e 100644 --- a/src/controls/ScrollView.qml +++ b/src/controls/ScrollView.qml @@ -236,11 +236,15 @@ FocusScope { property bool horizontalRecursionGuard: false property bool verticalRecursionGuard: false - horizontalMaximumValue: flickableItem ? flickableItem.contentWidth - viewport.width : 0 - verticalMaximumValue: flickableItem ? flickableItem.contentHeight - viewport.height + __viewTopMargin : 0 + horizontalMinimumValue: flickableItem ? flickableItem.originX : 0 + horizontalMaximumValue: flickableItem ? flickableItem.originX + flickableItem.contentWidth - viewport.width : 0 + + verticalMinimumValue: flickableItem ? flickableItem.originY : 0 + verticalMaximumValue: flickableItem ? flickableItem.originY + flickableItem.contentHeight - viewport.height + __viewTopMargin : 0 Connections { target: flickableItem + onContentYChanged: { wheelArea.verticalRecursionGuard = true wheelArea.verticalValue = flickableItem.contentY diff --git a/src/private/ScrollViewHelper.qml b/src/private/ScrollViewHelper.qml index cf5c514f..9e8e78d6 100644 --- a/src/private/ScrollViewHelper.qml +++ b/src/private/ScrollViewHelper.qml @@ -57,6 +57,8 @@ Item { property int availableWidth property int contentHeight property int contentWidth + property real originX + property real originY property int leftMargin: outerFrame ? root.__style.padding.left : 0 property int rightMargin: outerFrame ? root.__style.padding.right : 0 @@ -74,6 +76,8 @@ Item { wheelarea.availableHeight = viewport.height wheelarea.contentWidth = flickableItem !== null ? flickableItem.contentWidth : 0 wheelarea.contentHeight = flickableItem !== null ? flickableItem.contentHeight : 0 + wheelarea.originX = flickableItem !== null ? flickableItem.originX : 0 + wheelarea.originY = flickableItem !== null ? flickableItem.originY : 0 recursionGuard = false } } @@ -123,8 +127,8 @@ Item { visible: contentWidth > availableWidth height: visible ? implicitHeight : 0 z: 1 - maximumValue: contentWidth > availableWidth ? contentWidth - availableWidth : 0 - minimumValue: 0 + maximumValue: contentWidth > availableWidth ? originX + contentWidth - availableWidth : 0 + minimumValue: originX anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: cornerFill.left @@ -158,8 +162,8 @@ Item { width: visible ? implicitWidth : 0 z: 1 anchors.bottom: cornerFill.top - maximumValue: contentHeight > availableHeight ? contentHeight - availableHeight + __viewTopMargin : 0 - minimumValue: 0 + maximumValue: contentHeight > availableHeight ? originY + contentHeight - availableHeight + __viewTopMargin : 0 + minimumValue: originY anchors.right: parent.right anchors.top: parent.top anchors.topMargin: __scrollBarTopMargin + topMargin diff --git a/tests/manual/scrollview/main.qml b/tests/manual/scrollview/main.qml index 71accd8e..a245ca88 100644 --- a/tests/manual/scrollview/main.qml +++ b/tests/manual/scrollview/main.qml @@ -78,6 +78,12 @@ ApplicationWindow { value: 1000 implicitWidth: 80 } + CheckBox { + id: largeCheck + text: "Large" + checked: false + implicitWidth: 80 + } Item { Layout.fillWidth: true } } } @@ -139,6 +145,7 @@ ApplicationWindow { frameVisible: frameCheck.checked text: loremIpsum + loremIpsum + loremIpsum + loremIpsum anchors.fill: parent + font.pixelSize: largeCheck.checked ? 26 : 13 } } Tab { @@ -152,7 +159,7 @@ ApplicationWindow { model: 30 delegate: Rectangle { width: parent.width - height: 30 + height: largeCheck.checked ? 60 : 30 Text { anchors.fill: parent anchors.margins: 4 @@ -177,6 +184,17 @@ ApplicationWindow { model: 10 frameVisible: frameCheck.checked + rowDelegate: Rectangle { + width: parent.width + height: largeCheck.checked ? 60 : 30 + Rectangle { + anchors.bottom: parent.bottom + width: parent.width + height: 1 + color: "darkgray" + } + } + TableViewColumn {title: "first" width: view.viewport.width } -- cgit v1.2.1 From 5b36fa87bca007c0fac50b5b99f424e2fed59fab Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Mon, 27 May 2013 15:26:37 +0200 Subject: Doc: Add a section for Styles Change-Id: I96af8ea444754e7c3cab954622d0f385b75f9689 Reviewed-by: Jens Bache-Wiig --- src/controls/doc/src/qtquickcontrols-index.qdoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controls/doc/src/qtquickcontrols-index.qdoc b/src/controls/doc/src/qtquickcontrols-index.qdoc index 011de527..658d117b 100644 --- a/src/controls/doc/src/qtquickcontrols-index.qdoc +++ b/src/controls/doc/src/qtquickcontrols-index.qdoc @@ -82,6 +82,9 @@ \li \l{Qt Quick Controls Examples} \endlist - \l {Qt Quick Controls Styles QML Types} + \section2 Styles + \list + \li \l {Qt Quick Controls Styles QML Types} + \endlist */ -- cgit v1.2.1 From bb64aef56bd43891bd6f91aee25bdfe6633c3a98 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 27 May 2013 17:54:54 +0200 Subject: Refactor TableView styling API We don't want to directly expose the item properties in the namespace of the loader. Instead we standardize on styleData as a property container. Change-Id: Ib451e06ab393ba4945c96076d71dd3f96489e0c7 Reviewed-by: J-P Nurmi --- examples/quick/controls/tableview/main.qml | 86 ++++++--------- src/controls/TableView.qml | 119 ++++++++++++--------- src/styles/Base/TableViewStyle.qml | 23 ++-- src/styles/Desktop/TableViewStyle.qml | 28 ++--- .../controls/data/tableview/table_delegate.qml | 6 +- 5 files changed, 134 insertions(+), 128 deletions(-) diff --git a/examples/quick/controls/tableview/main.qml b/examples/quick/controls/tableview/main.qml index 0e568314..02c7e6f0 100644 --- a/examples/quick/controls/tableview/main.qml +++ b/examples/quick/controls/tableview/main.qml @@ -183,7 +183,7 @@ Window { itemDelegate: Item { Rectangle{ - color: itemValue.get(0).color + color: styleData.value.get(0).color anchors.top:parent.top anchors.right:parent.right anchors.bottom:parent.bottom @@ -196,9 +196,9 @@ Window { anchors.margins: 4 anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter - elide: itemElideMode - text: itemValue.get(0).description - color: itemTextColor + elide: styleData.elideMode + text: styleData.value.get(0).description + color: styleData.textColor } } @@ -251,32 +251,23 @@ Window { anchors.margins: 4 anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter - elide: itemElideMode - text: itemValue !== undefined ? itemValue : "" - color: itemTextColor + elide: styleData.elideMode + text: styleData.value !== undefined ? styleData.value : "" + color: styleData.textColor } } } - Component { - id: slickRowDelegate - Rectangle { color: alternateBackground ? "#cef" : "white" } - } - Component { id: delegate2 - Item { - height: itemSelected? 60 : 20 - Behavior on height{ NumberAnimation{} } - Text { - width: parent.width - anchors.margins: 4 - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - elide: itemElideMode - text: itemValue !== undefined ? itemValue : "" - color: itemTextColor - } + Text { + width: parent.width + anchors.margins: 4 + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + elide: styleData.elideMode + text: styleData.value !== undefined ? styleData.value : "" + color: styleData.textColor } } @@ -289,10 +280,10 @@ Window { anchors.margins: 4 anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter - elide: itemElideMode - text: itemValue !== undefined ? itemValue : "" - color: itemTextColor - visible: !itemSelected + elide: styleData.elideMode + text: styleData.value !== undefined ? styleData.value : "" + color: styleData.textColor + visible: !styleData.selected } Loader { // Initialize text editor lazily to improve performance id: loaderEditor @@ -301,19 +292,19 @@ Window { Connections { target: loaderEditor.item onAccepted: { - if (typeof itemValue === 'number') - model.setProperty(row, role, Number(parseFloat(loaderEditor.item.text).toFixed(0))) + if (typeof styleData.value === 'number') + model.setProperty(styleData.row, styleData.role, Number(parseFloat(loaderEditor.item.text).toFixed(0))) else - model.setProperty(row, role, loaderEditor.item.text) + model.setProperty(styleData.row, styleData.role, loaderEditor.item.text) } } - sourceComponent: itemSelected ? editor : null + sourceComponent: styleData.selected ? editor : null Component { id: editor TextInput { id: textinput - color: itemTextColor - text: itemValue + color: styleData.textColor + text: styleData.value MouseArea { id: mouseArea anchors.fill: parent @@ -354,25 +345,22 @@ Window { source: "images/header.png" border{left:2;right:2;top:2;bottom:2} Text { - text: itemValue + text: styleData.value anchors.centerIn:parent color:"#333" } } rowDelegate: Rectangle { - height: 20 - color: rowSelected ? "#448" : (alternateBackground ? "#eee" : "#fff") - border.color:"#ccc" - border.width: 1 - anchors.left: parent ? parent.left : undefined - anchors.leftMargin: -2 - anchors.rightMargin: -1 + height: (delegateChooser.currentIndex == 1 && styleData.selected) ? 30 : 20 + Behavior on height{ NumberAnimation{} } + + color: styleData.selected ? "#448" : (styleData.alternate? "#eee" : "#fff") BorderImage{ id: selected anchors.fill: parent source: "images/selectedrow.png" - visible: rowSelected + visible: styleData.selected border{left:2; right:2; top:2; bottom:2} SequentialAnimation { running: true; loops: Animation.Infinite @@ -383,14 +371,10 @@ Window { } itemDelegate: { - switch (delegateChooser.currentIndex) { - case 0: - return delegate1 - case 1: - return delegate2 - case 2: - return editableDelegate - } + if (delegateChooser.currentIndex == 2) + return editableDelegate; + else + return delegate1; } } } diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index ca0df45a..4cde5d3e 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -128,22 +128,23 @@ ScrollView { In the item delegate you have access to the following special properties: \list - \li itemSelected - if the item is currently selected - \li itemValue - the value or text for this item - \li itemTextColor - the default text color for an item - \li row - the index of the row - \li column - the index of the column - \li itemElideMode - the elide mode of the column - \li itemTextAlignment - the horizontal text alignment of the column + \li styleData.selected - if the item is currently selected + \li styleData.value - the value or text for this item + \li styleData.textColor - the default text color for an item + \li styleData.row - the index of the row + \li styleData.column - the index of the column + \li styleData.elideMode - the elide mode of the column + \li styleData.textAlignment - the horizontal text alignment of the column \endlist + Example: \code itemDelegate: Item { Text { anchors.verticalCenter: parent.verticalCenter - color: itemTextColor - elide: itemElideMode - text: itemValue + color: styleData.textColor + elide: styleData.elideMode + text: styleData.value } } \endcode */ @@ -153,9 +154,9 @@ ScrollView { In the row delegate you have access to the following special properties: \list - \li alternateBackground - if the row uses the alternate background color - \li rowSelected - if the row is currently selected - \li index - the index of the row + \li styleData.alternate - true when the row uses the alternate background color + \li styleData.selected - true when the row is currently selected + \li styleData.row - the index of the row \endlist */ property Component rowDelegate: __style ? __style.rowDelegate : null @@ -166,7 +167,16 @@ ScrollView { The default value is the base color of the SystemPalette. */ property alias backgroundColor: colorRect.color - /*! This property defines a delegate to draw a header. */ + /*! This property defines a delegate to draw a header. + + In the header delegate you have access to the following special properties: + \list + \li styleData.value - the value or text for this item + \li styleData.column - the index of the column + \li styleData.pressed - true when the column is being pressed + \li styleData.containsMouse - true when the column is under the mouse + \endlist + */ property Component headerDelegate: __style ? __style.headerDelegate : null /*! Index of the current sort column. @@ -408,11 +418,13 @@ ScrollView { width: rowfiller.width height: rowfiller.rowHeight sourceComponent: root.rowDelegate - readonly property bool alternateBackground: (index + rowCount) % 2 === 1 - readonly property bool rowSelected: false + property QtObject styleData: QtObject { + readonly property bool alternate: (index + rowCount) % 2 === 1 + readonly property bool selected: false + readonly property bool hasActiveFocus: root.activeFocus + } readonly property var model: listView.model readonly property var modelData: null - readonly property bool hasActiveFocus: root.activeFocus } } } @@ -439,7 +451,7 @@ ScrollView { height: rowstyle.height readonly property int rowIndex: model.index - readonly property bool alternateBackground: alternatingRowColors && rowIndex % 2 == 1 + readonly property bool alternate: alternatingRowColors && rowIndex % 2 == 1 readonly property var itemModelData: typeof modelData == "undefined" ? null : modelData readonly property var itemModel: model readonly property bool itemSelected: ListView.isCurrentItem @@ -457,12 +469,14 @@ ScrollView { // these properties are exposed to the row delegate // Note: these properties should be mirrored in the row filler as well - readonly property bool alternateBackground: rowitem.alternateBackground - readonly property bool rowSelected: rowitem.itemSelected - readonly property int row: rowitem.rowIndex + property QtObject styleData: QtObject { + readonly property int row: rowitem.rowIndex + readonly property bool alternate: rowitem.alternate + readonly property bool selected: rowitem.itemSelected + readonly property bool hasActiveFocus: root.activeFocus + } readonly property var model: listView.model readonly property var modelData: rowitem.itemModelData - readonly property bool hasActiveFocus: root.activeFocus } Row { id: itemrow @@ -482,20 +496,22 @@ ScrollView { readonly property var model: listView.model readonly property var modelData: itemModelData - readonly property var itemValue: __hasModelRole ? itemModel[role] // Qml ListModel and QAbstractItemModel - : __hasModelDataRole ? modelData[role] // QObjectList / QObject - : modelData != undefined ? modelData : "" // Models without role - readonly property bool itemSelected: rowitem.itemSelected - readonly property color itemTextColor: rowitem.itemTextColor - readonly property int row: rowitem.rowIndex - readonly property int column: index - readonly property int itemElideMode: __column.elideMode - readonly property int itemTextAlignment: __column.horizontalAlignment - readonly property string role: __column.role + property QtObject styleData: QtObject { + readonly property var value: __hasModelRole ? itemModel[role] // Qml ListModel and QAbstractItemModel + : __hasModelDataRole ? modelData[role] // QObjectList / QObject + : modelData != undefined ? modelData : "" // Models without role + readonly property int row: rowitem.rowIndex + readonly property int column: index + readonly property int elideMode: __column.elideMode + readonly property int textAlignment: __column.horizontalAlignment + readonly property bool selected: rowitem.itemSelected + readonly property color textColor: rowitem.itemTextColor + readonly property string role: __column.role + } readonly property TableViewColumn __column: columns[index] - readonly property bool __hasModelRole: role && itemModel.hasOwnProperty(role) - readonly property bool __hasModelDataRole: role && modelData && modelData.hasOwnProperty(role) + readonly property bool __hasModelRole: styleData.role && itemModel.hasOwnProperty(styleData.role) + readonly property bool __hasModelDataRole: styleData.role && modelData && modelData.hasOwnProperty(styleData.role) } } onWidthChanged: listView.contentWidth = width @@ -545,13 +561,12 @@ ScrollView { sourceComponent: root.headerDelegate anchors.left: parent.left anchors.right: parent.right - property string itemValue: columns[index].title - property string itemSort: (sortIndicatorVisible && index == sortIndicatorColumn) ? (sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : ""; - property bool itemPressed: headerClickArea.pressed - property bool itemContainsMouse: headerClickArea.containsMouse - property string itemPosition: columnCount === 1 ? "only" : - index===columnCount-1 ? "end" : - index===0 ? "beginning" : "" + property QtObject styleData: QtObject { + readonly property string value: columns[index].title + readonly property bool pressed: headerClickArea.pressed + readonly property bool containsMouse: headerClickArea.containsMouse + readonly property int column: index + } } Rectangle{ id: targetmark @@ -612,11 +627,12 @@ ScrollView { Loader { id: draghandle - property string itemValue: columns[index].title - property string itemSort: (sortIndicatorVisible && index == sortIndicatorColumn) ? (sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : ""; - property bool itemPressed: headerClickArea.pressed - property bool itemContainsMouse: headerClickArea.containsMouse - property string itemPosition + property QtObject styleData: QtObject{ + readonly property string value: columns[index].title + readonly property bool pressed: headerClickArea.pressed + readonly property bool containsMouse: headerClickArea.containsMouse + readonly property int column: index + } parent: tableHeader width: columns[index].width @@ -661,11 +677,12 @@ ScrollView { } Loader { id: loader - property string itemValue - property string itemSort - property bool itemPressed - property bool itemContainsMouse - property string itemPosition + property QtObject styleData: QtObject{ + readonly property string value: "" + readonly property bool pressed: false + readonly property bool containsMouse: false + readonly property int column: -1 + } anchors.top: parent.top anchors.right: parent.right diff --git a/src/styles/Base/TableViewStyle.qml b/src/styles/Base/TableViewStyle.qml index 669b934f..6d4f9feb 100644 --- a/src/styles/Base/TableViewStyle.qml +++ b/src/styles/Base/TableViewStyle.qml @@ -70,12 +70,13 @@ ScrollViewStyle { /* Delegate for header. This delegate is described in \l TableView::headerDelegate */ property Component headerDelegate: BorderImage { source: "images/header.png" + border.left: 4 Text { anchors.fill: parent verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignLeft anchors.leftMargin: 4 - text: itemValue + text: styleData.value color: textColor renderType: Text.NativeRendering } @@ -93,21 +94,21 @@ ScrollViewStyle { property Component rowDelegate: Rectangle { implicitHeight: 20 implicitWidth: 80 - property color selectedColor: hasActiveFocus ? "#38d" : "#999" + property color selectedColor: styleData.hasActiveFocus ? "#38d" : "#999" gradient: Gradient { - GradientStop { color: rowSelected ? Qt.lighter(selectedColor, 1.3) : alternateBackground ? "#f2f2f2" : "white" ; position: 0 } - GradientStop { color: rowSelected ? Qt.lighter(selectedColor, 1.0) : alternateBackground ? "#f2f2f2" : "white" ; position: 1 } + GradientStop { color: styleData.selected ? Qt.lighter(selectedColor, 1.3) : styleData.alternate ? "#f2f2f2" : "white" ; position: 0 } + GradientStop { color: styleData.selected ? Qt.lighter(selectedColor, 1.0) : styleData.alternate ? "#f2f2f2" : "white" ; position: 1 } } Rectangle { anchors.bottom: parent.bottom width: parent.width height: 1 - color: rowSelected ? Qt.darker(selectedColor, 1.4) : "transparent" + color: styleData.elected ? Qt.darker(selectedColor, 1.4) : "transparent" } Rectangle { anchors.top: parent.top width: parent.width ; height: 1 - color: rowSelected ? Qt.darker(selectedColor, 1.1) : "transparent" + color: styleData.elected ? Qt.darker(selectedColor, 1.1) : "transparent" } } @@ -123,18 +124,18 @@ ScrollViewStyle { anchors.margins: 6 anchors.left: parent.left anchors.right: parent.right - horizontalAlignment: itemTextAlignment + horizontalAlignment: styleData.textAlignment anchors.verticalCenter: parent.verticalCenter anchors.verticalCenterOffset: 1 - elide: itemElideMode - text: itemValue != undefined ? itemValue : "" - color: itemTextColor + elide: styleData.elideMode + text: styleData.value != undefined ? styleData.value : "" + color: styleData.textColor renderType: Text.NativeRendering } Text { id: sizehint font: label.font - text: itemValue ? itemValue : "" + text: styleData.value ? styleData.value : "" visible: false } } diff --git a/src/styles/Desktop/TableViewStyle.qml b/src/styles/Desktop/TableViewStyle.qml index 52fb9635..c8eac3c6 100644 --- a/src/styles/Desktop/TableViewStyle.qml +++ b/src/styles/Desktop/TableViewStyle.qml @@ -65,19 +65,23 @@ ScrollViewStyle { elementType: "header" activeControl: itemSort raised: true - sunken: itemPressed - text: itemValue - hover: itemContainsMouse - hints: itemPosition + sunken: styleData.pressed + text: styleData.value + hover: styleData.containsMouse + hints: headerPosition + property string itemSort: (control.sortIndicatorVisible && styleData.column === control.sortIndicatorColumn) ? (control.sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : ""; + property string headerPosition: control.columnCount === 1 ? "only" : + styleData.column === control.columnCount-1 ? "end" : + styleData.column === 0 ? "beginning" : "" } property Component rowDelegate: StyleItem { id: rowstyle elementType: "itemrow" - activeControl: alternateBackground ? "alternate" : "" - selected: rowSelected ? true : false + activeControl: styleData.alternate ? "alternate" : "" + selected: styleData.selected ? true : false height: Math.max(16, rowstyle.implicitHeight) - active: hasActiveFocus + active: styleData.hasActiveFocus } property Component itemDelegate: Item { @@ -92,17 +96,17 @@ ScrollViewStyle { font: __styleitem.font anchors.left: parent.left anchors.right: parent.right - horizontalAlignment: itemTextAlignment + horizontalAlignment: styleData.textAlignment anchors.verticalCenter: parent.verticalCenter - elide: itemElideMode - text: itemValue != undefined ? itemValue : "" - color: itemTextColor + elide: styleData.elideMode + text: styleData.value !== undefined ? styleData.value : "" + color: styleData.textColor renderType: Text.NativeRendering } Text { id: sizehint font: label.font - text: itemValue ? itemValue : "" + text: styleData.value ? styleData.value : "" visible: false } } diff --git a/tests/auto/controls/data/tableview/table_delegate.qml b/tests/auto/controls/data/tableview/table_delegate.qml index a3ab621d..82b08ba5 100644 --- a/tests/auto/controls/data/tableview/table_delegate.qml +++ b/tests/auto/controls/data/tableview/table_delegate.qml @@ -56,14 +56,14 @@ TableView { } headerDelegate: Text { height: 40 - text: itemValue + text: styleData.value } itemDelegate: Text { width: parent.width anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter - text: itemValue !== undefined ? itemValue : "" - color: itemTextColor + text: styleData.value !== undefined ? styleData.value : "" + color: styleData.textColor MouseArea { anchors.fill: parent onClicked: table.test = 1 -- cgit v1.2.1 From e0c8035c3db5c3c68602a90a5addbb2d48c0733f Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 27 May 2013 18:34:37 +0200 Subject: Rename controlState to styleData Change-Id: I06c9f4b0d9b6eef7d2ca608827eee982d8d97027 Reviewed-by: Jens Bache-Wiig --- examples/quick/controls/tableview/main.qml | 8 +- src/controls/SpinBox.qml | 2 +- src/private/Control.qml | 4 +- src/private/ScrollBar.qml | 2 +- src/styles/Base/ProgressBarStyle.qml | 2 +- src/styles/Base/ScrollViewStyle.qml | 127 ++++++++++++++++------------- src/styles/Base/SpinBoxStyle.qml | 2 +- src/styles/Desktop/ScrollViewStyle.qml | 4 +- src/styles/Desktop/SpinBoxStyle.qml | 16 ++-- tests/auto/controls/data/tst_spinbox.qml | 20 ++--- 10 files changed, 100 insertions(+), 87 deletions(-) diff --git a/examples/quick/controls/tableview/main.qml b/examples/quick/controls/tableview/main.qml index 02c7e6f0..3ecf5ddb 100644 --- a/examples/quick/controls/tableview/main.qml +++ b/examples/quick/controls/tableview/main.qml @@ -104,9 +104,9 @@ Window { ListModel { id: nestedModel - ListElement{controlState: ListElement { description: "Core" ; color:"#ffaacc"}} - ListElement{controlState: ListElement { description: "Second" ; color:"#ffccaa"}} - ListElement{controlState: ListElement { description: "Third" ; color:"#ffffaa"}} + ListElement{content: ListElement { description: "Core" ; color:"#ffaacc"}} + ListElement{content: ListElement { description: "Second" ; color:"#ffccaa"}} + ListElement{content: ListElement { description: "Third" ; color:"#ffffaa"}} } ListModel { @@ -176,7 +176,7 @@ Window { anchors.margins: 12 TableViewColumn { - role: "controlState" + role: "content" title: "Text and Color" width: 220 } diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index ec563afc..4db67c8d 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -148,7 +148,7 @@ Control { /*! \internal */ property alias __text: input.text - __controlState: QtObject { + __styleData: QtObject { readonly property bool upEnabled: value != maximumValue; readonly property alias upHovered: mouseUp.containsMouse readonly property alias upPressed: mouseUp.pressed diff --git a/src/private/Control.qml b/src/private/Control.qml index d518adb2..109e37ed 100644 --- a/src/private/Control.qml +++ b/src/private/Control.qml @@ -71,7 +71,7 @@ FocusScope { activeFocusOnTab: false /*! \internal */ - property alias __controlState: styleLoader.controlState + property alias __styleData: styleLoader.styleData Loader { id: panelLoader @@ -82,7 +82,7 @@ FocusScope { id: styleLoader sourceComponent: style property Item __control: root - property QtObject controlState: null + property QtObject styleData: null onStatusChanged: { if (status === Loader.Error) console.error("Failed to load Style for", root) diff --git a/src/private/ScrollBar.qml b/src/private/ScrollBar.qml index ad26d249..2f8e80bc 100644 --- a/src/private/ScrollBar.qml +++ b/src/private/ScrollBar.qml @@ -75,7 +75,7 @@ Item { sourceComponent: __style ? __style.__scrollbar : null onStatusChanged: if (status === Loader.Error) console.error("Failed to load Style for", root) property alias __control: scrollbar - property QtObject controlState: QtObject { + property QtObject __styleData: QtObject { readonly property alias horizontal: internal.horizontal readonly property alias upPressed: scrollbar.upPressed readonly property alias downPressed: scrollbar.downPressed diff --git a/src/styles/Base/ProgressBarStyle.qml b/src/styles/Base/ProgressBarStyle.qml index 1d7c98a8..c93a6356 100644 --- a/src/styles/Base/ProgressBarStyle.qml +++ b/src/styles/Base/ProgressBarStyle.qml @@ -89,7 +89,7 @@ PaddedStyle { /*! This property holds the visible contents of the progress bar You can access the Slider through the \c control property. - For convenience, you can also access the readonly property \c controlState.progress + For convenience, you can also access the readonly property \c styleData.progress which provides the current progress as a \c real in the range [0-1] */ padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 } diff --git a/src/styles/Base/ScrollViewStyle.qml b/src/styles/Base/ScrollViewStyle.qml index 8bf5a120..b1fe789f 100644 --- a/src/styles/Base/ScrollViewStyle.qml +++ b/src/styles/Base/ScrollViewStyle.qml @@ -95,9 +95,11 @@ PaddedStyle { /*! This component controls the appearance of the scroll bar background. + You can access the following state properties: + \list - \li property bool hovered - \li property bool horizontal + \li property bool styleData.hovered + \li property bool styleData.horizontal \endlist */ @@ -109,26 +111,28 @@ PaddedStyle { anchors.fill: parent color: "#ddd" border.color: "#aaa" - anchors.rightMargin: horizontal ? -2 : -1 - anchors.leftMargin: horizontal ? -2 : 0 - anchors.topMargin: horizontal ? 0 : -2 - anchors.bottomMargin: horizontal ? -1 : -2 + anchors.rightMargin: styleData.horizontal ? -2 : -1 + anchors.leftMargin: styleData.horizontal ? -2 : 0 + anchors.topMargin: styleData.horizontal ? 0 : -2 + anchors.bottomMargin: styleData.horizontal ? -1 : -2 } } /*! This component controls the appearance of the scroll bar handle. + You can access the following state properties: + \list - \li property bool hovered - \li property bool pressed - \li property bool horizontal + \li property bool styleData.hovered + \li property bool styleData.pressed + \li property bool styleData.horizontal \endlist */ property Component handle: BorderImage{ - opacity: pressed ? 0.5 : hovered ? 1 : 0.8 - source: "images/scrollbar-handle-" + (horizontal ? "horizontal" : "vertical") + ".png" + opacity: styleData.pressed ? 0.5 : styleData.hovered ? 1 : 0.8 + source: "images/scrollbar-handle-" + (styleData.horizontal ? "horizontal" : "vertical") + ".png" border.left: 2 border.top: 2 border.right: 2 @@ -141,9 +145,9 @@ PaddedStyle { You can access the following state properties: \list - \li property bool hovered - \li property bool pressed - \li property bool horizontal + \li property bool styleData.hovered + \li property bool styleData.pressed + \li property bool styleData.horizontal \endlist */ property Component incrementControl: Rectangle { @@ -161,13 +165,13 @@ PaddedStyle { border.color: "#88ffffff" } Image { - source: horizontal ? "images/arrow-right.png" : "images/arrow-down.png" + source: styleData.horizontal ? "images/arrow-right.png" : "images/arrow-down.png" anchors.centerIn: parent opacity: control.enabled ? 0.7 : 0.5 } gradient: Gradient { - GradientStop {color: pressed ? "lightgray" : "white" ; position: 0} - GradientStop {color: pressed ? "lightgray" : "lightgray" ; position: 1} + GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0} + GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1} } } } @@ -175,10 +179,12 @@ PaddedStyle { /*! This component controls the appearance of the scroll bar decrement button. + You can access the following state properties: + \list - \li property bool hovered - \li property bool pressed - \li property bool horizontal + \li property bool styleData.hovered + \li property bool styleData.pressed + \li property bool styleData.horizontal \endlist */ property Component decrementControl: Rectangle { @@ -186,10 +192,10 @@ PaddedStyle { implicitHeight: 16 Rectangle { anchors.fill: parent - anchors.topMargin: horizontal ? 0 : -1 - anchors.leftMargin: horizontal ? -1 : 0 - anchors.bottomMargin: horizontal ? -1 : 0 - anchors.rightMargin: horizontal ? 0 : -1 + anchors.topMargin: styleData.horizontal ? 0 : -1 + anchors.leftMargin: styleData.horizontal ? -1 : 0 + anchors.bottomMargin: styleData.horizontal ? -1 : 0 + anchors.rightMargin: styleData.horizontal ? 0 : -1 color: "lightgray" Rectangle { anchors.fill: parent @@ -198,15 +204,15 @@ PaddedStyle { border.color: "#88ffffff" } Image { - source: horizontal ? "images/arrow-left.png" : "images/arrow-up.png" + source: styleData.horizontal ? "images/arrow-left.png" : "images/arrow-up.png" anchors.centerIn: parent - anchors.verticalCenterOffset: horizontal ? 0 : -1 - anchors.horizontalCenterOffset: horizontal ? -1 : 0 + anchors.verticalCenterOffset: styleData.horizontal ? 0 : -1 + anchors.horizontalCenterOffset: styleData.horizontal ? -1 : 0 opacity: control.enabled ? 0.7 : 0.5 } gradient: Gradient { - GradientStop {color: pressed ? "lightgray" : "white" ; position: 0} - GradientStop {color: pressed ? "lightgray" : "lightgray" ; position: 1} + GradientStop {color: styleData.pressed ? "lightgray" : "white" ; position: 0} + GradientStop {color: styleData.pressed ? "lightgray" : "lightgray" ; position: 1} } border.color: "#aaa" } @@ -217,14 +223,13 @@ PaddedStyle { id: panel property string activeControl: "" property bool scrollToClickPosition: true - property var controlStateRef: controlState - implicitWidth: controlState.horizontal ? 200 : bg.implicitWidth - implicitHeight: controlState.horizontal ? bg.implicitHeight : 200 + implicitWidth: __styleData.horizontal ? 200 : bg.implicitWidth + implicitHeight: __styleData.horizontal ? bg.implicitHeight : 200 function pixelMetric(arg) { if (arg === "scrollbarExtent") - return (controlState.horizontal ? bg.height : bg.width); + return (__styleData.horizontal ? bg.height : bg.width); return 0; } @@ -240,7 +245,7 @@ PaddedStyle { else if (itemIsHit(decrementLoader, argX, argY)) return "down"; else if (itemIsHit(bg, argX, argY)) { - if (controlState.horizontal && argX < handleControl.x || !controlState.horizontal && argY < handleControl.y) + if (__styleData.horizontal && argX < handleControl.x || !__styleData.horizontal && argY < handleControl.y) return "upPage" else return "downPage" @@ -253,7 +258,7 @@ PaddedStyle { if (arg === "handle") { return Qt.rect(handleControl.x, handleControl.y, handleControl.width, handleControl.height); } else if (arg === "groove") { - if (controlState.horizontal) { + if (__styleData.horizontal) { return Qt.rect(incrementLoader.width - handleOverlap, 0, __control.width - (incrementLoader.width + decrementLoader.width - handleOverlap * 2), @@ -278,49 +283,57 @@ PaddedStyle { anchors.top: parent.top anchors.left: parent.left sourceComponent: decrementControl - property bool hovered: activeControl === "up" - property bool pressed: controlState.upPressed - property bool horizontal: controlState.horizontal + property QtObject styleData: QtObject { + readonly property bool hovered: activeControl === "up" + readonly property bool pressed: __styleData.upPressed + readonly property bool horizontal: __styleData.horizontal + } } Loader { id: bg - anchors.top: controlState.horizontal ? undefined : incrementLoader.bottom - anchors.bottom: controlState.horizontal ? undefined : decrementLoader.top - anchors.left: controlState.horizontal ? incrementLoader.right : undefined - anchors.right: controlState.horizontal ? decrementLoader.left : undefined + anchors.top: __styleData.horizontal ? undefined : incrementLoader.bottom + anchors.bottom: __styleData.horizontal ? undefined : decrementLoader.top + anchors.left: __styleData.horizontal ? incrementLoader.right : undefined + anchors.right: __styleData.horizontal ? decrementLoader.left : undefined sourceComponent: scrollBarBackground - property bool horizontal: controlState.horizontal - property bool hovered: activeControl !== "none" + property QtObject styleData: QtObject { + readonly property bool horizontal: __styleData.horizontal + readonly property bool hovered: activeControl !== "none" + } } Loader { id: decrementLoader - anchors.bottom: controlState.horizontal ? undefined : parent.bottom - anchors.right: controlState.horizontal ? parent.right : undefined + anchors.bottom: __styleData.horizontal ? undefined : parent.bottom + anchors.right: __styleData.horizontal ? parent.right : undefined sourceComponent: incrementControl - property bool hovered: activeControl === "down" - property bool pressed: controlState.downPressed - property bool horizontal: controlState.horizontal + property QtObject styleData: QtObject { + readonly property bool hovered: activeControl === "down" + readonly property bool pressed: __styleData.downPressed + readonly property bool horizontal: __styleData.horizontal + } } property var flickableItem: control.flickableItem - property int extent: Math.max(minimumHandleLength, controlState.horizontal ? + property int extent: Math.max(minimumHandleLength, __styleData.horizontal ? (flickableItem ? flickableItem.width/flickableItem.contentWidth : 0 ) * bg.width : (flickableItem ? flickableItem.height/flickableItem.contentHeight : 0) * bg.height) Loader { id: handleControl - height: controlState.horizontal ? implicitHeight : extent - width: controlState.horizontal ? extent : implicitWidth + height: __styleData.horizontal ? implicitHeight : extent + width: __styleData.horizontal ? extent : implicitWidth anchors.top: bg.top anchors.left: bg.left - anchors.topMargin: controlState.horizontal ? 0 : -handleOverlap + (__control.value / __control.maximumValue) * (bg.height + 2 * handleOverlap- height) - anchors.leftMargin: controlState.horizontal ? -handleOverlap + (__control.value / __control.maximumValue) * (bg.width + 2 * handleOverlap - width) : 0 + anchors.topMargin: __styleData.horizontal ? 0 : -handleOverlap + (__control.value / __control.maximumValue) * (bg.height + 2 * handleOverlap- height) + anchors.leftMargin: __styleData.horizontal ? -handleOverlap + (__control.value / __control.maximumValue) * (bg.width + 2 * handleOverlap - width) : 0 sourceComponent: handle - property bool hovered: activeControl === "handle" - property bool pressed: controlState.handlePressed - property bool horizontal: controlState.horizontal + property QtObject styleData: QtObject { + readonly property bool hovered: activeControl === "handle" + readonly property bool pressed: __styleData.handlePressed + readonly property bool horizontal: __styleData.horizontal + } } } diff --git a/src/styles/Base/SpinBoxStyle.qml b/src/styles/Base/SpinBoxStyle.qml index 9b37fe5b..6280ea93 100644 --- a/src/styles/Base/SpinBoxStyle.qml +++ b/src/styles/Base/SpinBoxStyle.qml @@ -129,7 +129,7 @@ PaddedStyle { /*! \internal */ property Component panel: Item { id: styleitem - implicitWidth: controlState.contentWidth + 26 + implicitWidth: styleData.contentWidth + 26 implicitHeight: backgroundLoader.implicitHeight property color foregroundColor: spinboxStyle.textColor diff --git a/src/styles/Desktop/ScrollViewStyle.qml b/src/styles/Desktop/ScrollViewStyle.qml index 42c9fc3e..d504c59b 100644 --- a/src/styles/Desktop/ScrollViewStyle.qml +++ b/src/styles/Desktop/ScrollViewStyle.qml @@ -74,11 +74,11 @@ PaddedStyle { elementType: "scrollbar" hover: activeControl != "none" activeControl: "none" - sunken: __control.upPressed | __control.downPressed | __control.handlePressed + sunken: __styleData.upPressed | __styleData.downPressed | __styleData.handlePressed minimum: __control.minimumValue maximum: __control.maximumValue value: __control.value - horizontal: __control.orientation === Qt.Horizontal + horizontal: __styleData.horizontal enabled: __control.enabled implicitWidth: horizontal ? 200 : pixelMetric("scrollbarExtent") diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml index 2da3db1f..e8012a69 100644 --- a/src/styles/Desktop/SpinBoxStyle.qml +++ b/src/styles/Desktop/SpinBoxStyle.qml @@ -114,17 +114,17 @@ PaddedStyle { id: styleitem elementType: "spinbox" anchors.fill: parent - sunken: (controlState.downEnabled && controlState.downPressed) || (controlState.upEnabled && controlState.upPressed) - hover: controlState.containsMouse + sunken: (styleData.downEnabled && styleData.downPressed) || (styleData.upEnabled && styleData.upPressed) + hover: styleData.containsMouse hints: control.styleHints hasFocus: control.activeFocus enabled: control.enabled - value: (controlState.upPressed ? 1 : 0) | - (controlState.downPressed ? 1<<1 : 0) | - (controlState.upEnabled ? (1<<2) : 0) | - (controlState.downEnabled ? (1<<3) : 0) - contentWidth: controlState.contentWidth - contentHeight: controlState.contentHeight + value: (styleData.upPressed ? 1 : 0) | + (styleData.downPressed ? 1<<1 : 0) | + (styleData.upEnabled ? (1<<2) : 0) | + (styleData.downEnabled ? (1<<3) : 0) + contentWidth: styleData.contentWidth + contentHeight: styleData.contentHeight } } } diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index 9cc0662e..4e701cc0 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -178,22 +178,22 @@ Item { setCoordinates(spinbox) mouseMove(spinbox, mainCoord.x, mainCoord.y) - compare(spinbox.__controlState.containsMouse, true) - compare(spinbox.__controlState.upHovered, false) - compare(spinbox.__controlState.downHovered, false) + compare(spinbox.__styleData.containsMouse, true) + compare(spinbox.__styleData.upHovered, false) + compare(spinbox.__styleData.downHovered, false) mouseMove(spinbox.parent, upCoord.x, upCoord.y) - compare(spinbox.__controlState.upHovered, true) - compare(spinbox.__controlState.downHovered, false) + compare(spinbox.__styleData.upHovered, true) + compare(spinbox.__styleData.downHovered, false) mouseMove(spinbox, downCoord.x, downCoord.y) - compare(spinbox.__controlState.upHovered, false) - compare(spinbox.__controlState.downHovered, true) + compare(spinbox.__styleData.upHovered, false) + compare(spinbox.__styleData.downHovered, true) mouseMove(spinbox, mainCoord.x - 2, mainCoord.y - 2) - compare(spinbox.__controlState.containsMouse, false) - compare(spinbox.__controlState.upHovered, false) - compare(spinbox.__controlState.downHovered, false) + compare(spinbox.__styleData.containsMouse, false) + compare(spinbox.__styleData.upHovered, false) + compare(spinbox.__styleData.downHovered, false) spinbox.destroy() } -- cgit v1.2.1 From 2f2933a2975d86bfb33e2250a03b2414fc207a09 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 27 May 2013 18:43:37 +0200 Subject: TabViewStyle: rename 'tab' grouped property to 'styleData' Change-Id: If56b5ca4af119d7897425609dcaf04336f77e032 Reviewed-by: Jens Bache-Wiig --- examples/quick/controls/gallery/content/Styles.qml | 4 +-- .../quick/controls/touch/content/TabBarPage.qml | 4 +-- src/private/TabBar.qml | 2 +- src/styles/Base/TabViewStyle.qml | 32 +++++++++++----------- src/styles/Desktop/TabViewStyle.qml | 10 +++---- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/examples/quick/controls/gallery/content/Styles.qml b/examples/quick/controls/gallery/content/Styles.qml index b5e98f80..a65f3024 100644 --- a/examples/quick/controls/gallery/content/Styles.qml +++ b/examples/quick/controls/gallery/content/Styles.qml @@ -258,13 +258,13 @@ Item { BorderImage { id: image anchors.fill: parent - source: tab.selected ? "../images/tab_selected.png" : "../images/tab.png" + source: styleData.selected ? "../images/tab_selected.png" : "../images/tab.png" border.left: 50 smooth: false border.right: 50 } Text { - text: tab.title + text: styleData.title anchors.centerIn: parent } } diff --git a/examples/quick/controls/touch/content/TabBarPage.qml b/examples/quick/controls/touch/content/TabBarPage.qml index c96314be..7651a3c1 100644 --- a/examples/quick/controls/touch/content/TabBarPage.qml +++ b/examples/quick/controls/touch/content/TabBarPage.qml @@ -80,11 +80,11 @@ Item { anchors.fill: parent border.bottom: 8 border.top: 8 - source: tab.selected ? "../images/tab_selected.png":"../images/tabs_standard.png" + source: styleData.selected ? "../images/tab_selected.png":"../images/tabs_standard.png" Text { anchors.centerIn: parent color: "white" - text: tab.title.toUpperCase() + text: styleData.title.toUpperCase() font.pixelSize: 16 } Rectangle { diff --git a/src/private/TabBar.qml b/src/private/TabBar.qml index 49b10584..aa1f919b 100644 --- a/src/private/TabBar.qml +++ b/src/private/TabBar.qml @@ -195,7 +195,7 @@ FocusScope { property int index: tabindex property real availableWidth: tabbar.availableWidth - property QtObject tab: QtObject { + property QtObject styleData: QtObject { readonly property alias index: tabitem.tabindex readonly property alias selected: tabitem.selected readonly property alias title: tabitem.title diff --git a/src/styles/Base/TabViewStyle.qml b/src/styles/Base/TabViewStyle.qml index dfe1e4e9..91750ba9 100644 --- a/src/styles/Base/TabViewStyle.qml +++ b/src/styles/Base/TabViewStyle.qml @@ -59,7 +59,7 @@ import QtQuick.Controls.Private 1.0 style: TabViewStyle { frameOverlap: 1 tab: Rectangle { - color: tab.selected ? "steelblue" :"lightsteelblue" + color: styleData.selected ? "steelblue" :"lightsteelblue" border.color: "steelblue" implicitWidth: Math.max(text.width + 4, 80) implicitHeight: 20 @@ -67,8 +67,8 @@ import QtQuick.Controls.Private 1.0 Text { id: text anchors.centerIn: parent - text: tab.title - color: tab.selected ? "white" : "black" + text: styleData.title + color: styleData.selected ? "white" : "black" } } frame: Rectangle { color: "steelblue" } @@ -119,16 +119,16 @@ Style { } /*! This defines the tab. You can access the tab state through the - \c tab property, with the following properties: + \c styleData property, with the following properties: \table - \li readonly property int index - This is the current tab index. - \li readonly property bool selected - This is the active tab. - \li readonly property string title - Tab title text. - \li readonly property bool nextSelected - The next tab is selected. - \li readonly property bool previousSelected - The previous tab is selected. - \li readonly property bool hovered - The tab is currently under the mouse. - \li readonly property bool activeFocus - The tab button has keyboard focus. + \li readonly property int styleData.index - This is the current tab index. + \li readonly property bool styleData.selected - This is the active tab. + \li readonly property string styleData.title - Tab title text. + \li readonly property bool styleData.nextSelected - The next tab is selected. + \li readonly property bool styleData.previousSelected - The previous tab is selected. + \li readonly property bool styleData.hovered - The tab is currently under the mouse. + \li readonly property bool styleData.activeFocus - The tab button has keyboard focus. \endtable */ property Component tab: Item { @@ -143,16 +143,16 @@ Style { clip: true Item { anchors.fill: parent - anchors.bottomMargin: tab.selected ? 0 : 2 + anchors.bottomMargin: styleData.selected ? 0 : 2 clip: true BorderImage { anchors.fill: parent - source: tab.selected ? "images/tab_selected.png" : "images/tab.png" + source: styleData.selected ? "images/tab_selected.png" : "images/tab.png" border.top: 6 border.bottom: 6 border.left: 6 border.right: 6 - anchors.topMargin: tab.selected ? 0 : 1 + anchors.topMargin: styleData.selected ? 0 : 1 } BorderImage { anchors.fill: parent @@ -160,7 +160,7 @@ Style { anchors.leftMargin: -2 anchors.rightMargin: -1 source: "images/focusframe.png" - visible: tab.activeFocus && tab.selected + visible: styleData.activeFocus && styleData.selected border.left: 4 border.right: 4 border.top: 4 @@ -170,7 +170,7 @@ Style { Text { id: textitem anchors.centerIn: parent - text: tab.title + text: styleData.title renderType: Text.NativeRendering scale: control.tabPosition === Qt.TopEdge ? 1 : -1 color: __syspal.text diff --git a/src/styles/Desktop/TabViewStyle.qml b/src/styles/Desktop/TabViewStyle.qml index 455b99db..b28300e2 100644 --- a/src/styles/Desktop/TabViewStyle.qml +++ b/src/styles/Desktop/TabViewStyle.qml @@ -74,13 +74,13 @@ Style { property Component tab: Item { id: item property string tabpos: control.count === 1 ? "only" : index === 0 ? "beginning" : index === control.count - 1 ? "end" : "middle" - property string selectedpos: tab.nextSelected ? "next" : tab.previousSelected ? "previous" : "" + property string selectedpos: styleData.nextSelected ? "next" : styleData.previousSelected ? "previous" : "" property string orientation: control.tabPosition === Qt.TopEdge ? "Top" : "Bottom" property int tabHSpace: __barstyle.pixelMetric("tabhspace"); property int tabVSpace: __barstyle.pixelMetric("tabvspace"); property int totalOverlap: tabOverlap * (control.count - 1) property real maxTabWidth: (control.width + totalOverlap) / control.count - implicitWidth: Math.min(maxTabWidth, Math.max(50, styleitem.textWidth(tab.title)) + tabHSpace + 2) + implicitWidth: Math.min(maxTabWidth, Math.max(50, styleitem.textWidth(styleData.title)) + tabHSpace + 2) implicitHeight: Math.max(styleitem.font.pixelSize + tabVSpace + 6, 0) StyleItem { @@ -97,9 +97,9 @@ Style { properties: { "hasFrame" : true } hints: [orientation, tabpos, selectedpos] - selected: tab.selected - text: elidedText(tab.title, tabbarItem.elide, item.width - item.tabHSpace) - hover: tab.hovered + selected: styleData.selected + text: elidedText(styleData.title, tabbarItem.elide, item.width - item.tabHSpace) + hover: styleData.hovered hasFocus: tabbarItem.activeFocus && selected } } -- cgit v1.2.1 From d0eadc7b164d2f00cd19885907d57a4e1aa02d4b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 27 May 2013 19:57:46 +0200 Subject: ButtonStyle: expose styleData.hovered Change-Id: I8f977a171ea18420e326b79181d634eeb43b1de8 Reviewed-by: Jens Bache-Wiig --- examples/quick/controls/gallery/content/Styles.qml | 24 +++++++++------------- src/styles/Base/ButtonStyle.qml | 22 ++++++++++++++++++-- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/examples/quick/controls/gallery/content/Styles.qml b/examples/quick/controls/gallery/content/Styles.qml index a65f3024..01b2646f 100644 --- a/examples/quick/controls/gallery/content/Styles.qml +++ b/examples/quick/controls/gallery/content/Styles.qml @@ -172,17 +172,13 @@ Item { // Style delegates: property Component buttonStyle: ButtonStyle { - panel: Rectangle { + background: Rectangle { implicitHeight: 20 implicitWidth: 100 color: control.pressed ? "darkGray" : "lightGray" antialiasing: true border.color: "gray" radius: height/2 - Text { - anchors.centerIn: parent - text: control.text - } } } @@ -220,21 +216,21 @@ Item { } property Component progressbarStyle: ProgressBarStyle { - panel: Rectangle { + background: Rectangle { implicitWidth: 100 implicitHeight: 20 color: "#f0f0f0" border.color: "gray" antialiasing: true radius: height/2 - Rectangle { - implicitWidth: 100 - implicitHeight: 20 - color: "#f0f0f0" - border.color: "gray" - antialiasing: true - radius: height/2 - } + } + progress: Rectangle { + implicitWidth: 100 + implicitHeight: 20 + color: "#c0c0c0" + border.color: "gray" + antialiasing: true + radius: height/2 } } diff --git a/src/styles/Base/ButtonStyle.qml b/src/styles/Base/ButtonStyle.qml index a524d93f..e668b042 100644 --- a/src/styles/Base/ButtonStyle.qml +++ b/src/styles/Base/ButtonStyle.qml @@ -92,7 +92,13 @@ PaddedStyle { bottom: 4 } - /*! The background of the button. */ + /*! This defines the background of the button. In addition to the public + properties of \c control, the following state properties are available: + + \table + \li readonly property bool styleData.hovered - The button is currently hovered. + \endtable + */ property Component background: Item { implicitWidth: 100 implicitHeight: 25 @@ -129,7 +135,13 @@ PaddedStyle { } } - /*! The label of the button. */ + /*! This defines the label of the button. In addition to the public + properties of \c control, the following state properties are available: + + \table + \li readonly property bool styleData.hovered - The button is currently hovered. + \endtable + */ property Component label: Text { renderType: Text.NativeRendering verticalAlignment: Text.AlignVCenter @@ -149,6 +161,9 @@ PaddedStyle { id: backgroundLoader anchors.fill: parent sourceComponent: background + property QtObject styleData: QtObject { + readonly property bool hovered: control.__containsMouse + } } Loader { @@ -159,6 +174,9 @@ PaddedStyle { anchors.topMargin: padding.top anchors.rightMargin: padding.right anchors.bottomMargin: padding.bottom + property QtObject styleData: QtObject { + readonly property bool hovered: control.__containsMouse + } } } } -- cgit v1.2.1 From 960a78ae6231767a34a6e4de76bf4fa28ff401f1 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 27 May 2013 11:32:39 +0200 Subject: The function was moved to QtDeclarative It is about default behavior for QQuickWindow, when there is no any activeFocusItem in the whole window, Tab/BackTab key could help you to focus the item in the tab focus chain. Change-Id: Iccd770794e2f99a9a74c3a11f0ed278264a02d9e Reviewed-by: Gabriel de Dietrich --- src/controls/ApplicationWindow.qml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index f2e181a5..602661a3 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -125,14 +125,6 @@ Window { /*! \internal */ default property alias data: contentArea.data - /*! \internal */ - Binding { - target: contentItem - property: "activeFocusOnTab" - when: activeFocusItem - value: activeFocusItem ? ( (activeFocusItem != contentItem) ? !activeFocusItem.activeFocusOnTab : true ) : false - } - color: syspal.window SystemPalette {id: syspal} -- cgit v1.2.1 From f5f42d2a3e1cbd25b17ea87cff78255b79f38dfc Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Mon, 27 May 2013 09:46:13 +0200 Subject: Doc: Add Qt Quick Layouts QML Types page Change-Id: If99150e2124dfdbf0bd99889129e66d487a9bd6a Reviewed-by: Jerome Pasion --- src/layouts/doc/src/qtquicklayouts-index.qdoc | 7 +++- src/layouts/doc/src/qtquicklayouts.qdoc | 46 +++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/layouts/doc/src/qtquicklayouts.qdoc diff --git a/src/layouts/doc/src/qtquicklayouts-index.qdoc b/src/layouts/doc/src/qtquicklayouts-index.qdoc index 433de433..fdc1c70a 100644 --- a/src/layouts/doc/src/qtquicklayouts-index.qdoc +++ b/src/layouts/doc/src/qtquicklayouts-index.qdoc @@ -28,7 +28,6 @@ /*! \page qtquicklayouts-index.html \title Qt Quick Layouts - \ingroup qmlmodules \brief A module with a set of QML elements that arranges QML items in an user interface. @@ -47,4 +46,10 @@ \annotatedlist layouts + \section1 Related information + + \section2 Reference + \list + \li \l{Qt Quick Layouts QML Types}{Qt Quick Layouts QML Types} + \endlist */ diff --git a/src/layouts/doc/src/qtquicklayouts.qdoc b/src/layouts/doc/src/qtquicklayouts.qdoc new file mode 100644 index 00000000..b03ff69b --- /dev/null +++ b/src/layouts/doc/src/qtquicklayouts.qdoc @@ -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 documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \qmlmodule QtQuick.Layouts 1 + \title Qt Quick Layouts QML Types + \ingroup qmlmodules + \brief Provides QML types for arranging QML items in a user interface. + + The \l{Qt Quick Layouts} module provides QML types for arranging + QML items in a user interface. + These QML types work in conjunction with \l{Qt Quick} and + \l{Qt Quick Controls}. + + The QML types can be imported into your application using the + following import statement in your .qml file. + + \code + import QtQuick.Layouts 1.0 + \endcode + +*/ -- cgit v1.2.1 From 44be216fda6590225dd45fb565361d6328a482f4 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 28 May 2013 11:08:48 +0200 Subject: Gallery example: Increase minimumWidth Change-Id: I3f97de79c8afed44f7b01778d94cc40bed8cc603 Reviewed-by: Jens Bache-Wiig Reviewed-by: Caroline Chao --- examples/quick/controls/gallery/main.qml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/quick/controls/gallery/main.qml b/examples/quick/controls/gallery/main.qml index e34858cd..93502423 100644 --- a/examples/quick/controls/gallery/main.qml +++ b/examples/quick/controls/gallery/main.qml @@ -51,10 +51,11 @@ import "content" ApplicationWindow { title: "Component Gallery" - width: 580 + width: 600 height: 400 minimumHeight: 400 - minimumWidth: 340 + minimumWidth: 570 + property string loremIpsum: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor "+ -- cgit v1.2.1 From eb7cb933b8ba592f9086c5392e246aebbf921d7a Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 28 May 2013 09:30:26 +0200 Subject: Fix typo in TableViewStyle Change-Id: I0b4a917500ec7a520ebd38a4158e707e4dd80c9c Reviewed-by: Caroline Chao Reviewed-by: J-P Nurmi --- src/styles/Base/TableViewStyle.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/styles/Base/TableViewStyle.qml b/src/styles/Base/TableViewStyle.qml index 6d4f9feb..f44893f6 100644 --- a/src/styles/Base/TableViewStyle.qml +++ b/src/styles/Base/TableViewStyle.qml @@ -103,12 +103,12 @@ ScrollViewStyle { anchors.bottom: parent.bottom width: parent.width height: 1 - color: styleData.elected ? Qt.darker(selectedColor, 1.4) : "transparent" + color: styleData.selected ? Qt.darker(selectedColor, 1.4) : "transparent" } Rectangle { anchors.top: parent.top width: parent.width ; height: 1 - color: styleData.elected ? Qt.darker(selectedColor, 1.1) : "transparent" + color: styleData.selected ? Qt.darker(selectedColor, 1.1) : "transparent" } } -- cgit v1.2.1 From 5eb54a1a9fcb25790fa7e54c4c20f61b39368e8b Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 28 May 2013 16:06:31 +0200 Subject: Fixed incorrect size hints for TableView This ensures that double click to adjust content size on headers doesn't end up eliding text. We also added significantly more space by default. Change-Id: I05a05649a41ef4b70ee839195a87c684786760b1 Reviewed-by: J-P Nurmi Reviewed-by: Gabriel de Dietrich --- src/styles/Base/TableViewStyle.qml | 10 +++++----- src/styles/Desktop/TableViewStyle.qml | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/styles/Base/TableViewStyle.qml b/src/styles/Base/TableViewStyle.qml index f44893f6..b53b3c64 100644 --- a/src/styles/Base/TableViewStyle.qml +++ b/src/styles/Base/TableViewStyle.qml @@ -75,8 +75,9 @@ ScrollViewStyle { anchors.fill: parent verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignLeft - anchors.leftMargin: 4 + anchors.leftMargin: 12 text: styleData.value + elide: Text.ElideRight color: textColor renderType: Text.NativeRendering } @@ -92,8 +93,7 @@ ScrollViewStyle { /* Delegate for header. This delegate is described in \l TableView::rowDelegate */ property Component rowDelegate: Rectangle { - implicitHeight: 20 - implicitWidth: 80 + height: 20 property color selectedColor: styleData.hasActiveFocus ? "#38d" : "#999" gradient: Gradient { GradientStop { color: styleData.selected ? Qt.lighter(selectedColor, 1.3) : styleData.alternate ? "#f2f2f2" : "white" ; position: 0 } @@ -115,13 +115,13 @@ ScrollViewStyle { /* Delegate for header. This delegate is described in \l TableView::itemDelegate */ property Component itemDelegate: Item { height: Math.max(16, label.implicitHeight) - property int implicitWidth: sizehint.paintedWidth + 4 + property int implicitWidth: sizehint.paintedWidth + 20 Text { id: label objectName: "label" width: parent.width - anchors.margins: 6 + anchors.leftMargin: 12 anchors.left: parent.left anchors.right: parent.right horizontalAlignment: styleData.textAlignment diff --git a/src/styles/Desktop/TableViewStyle.qml b/src/styles/Desktop/TableViewStyle.qml index c8eac3c6..9a3584d2 100644 --- a/src/styles/Desktop/TableViewStyle.qml +++ b/src/styles/Desktop/TableViewStyle.qml @@ -86,13 +86,13 @@ ScrollViewStyle { property Component itemDelegate: Item { height: Math.max(16, label.implicitHeight) - property int implicitWidth: sizehint.paintedWidth + 4 + property int implicitWidth: sizehint.paintedWidth + 16 Text { id: label objectName: "label" width: parent.width - anchors.margins: 6 + anchors.leftMargin: 8 font: __styleitem.font anchors.left: parent.left anchors.right: parent.right -- cgit v1.2.1 From 10851004e327f4ab798753c645ab987f10160100 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 28 May 2013 17:27:09 +0200 Subject: Consistent use of "hovered" and style API conventions We were still using "containsMouse" in a few places, and we should consistently add "hovered" to all button types for consistency. Also fixed the SplitView to follow the new style conventions. Change-Id: Iebc333c0cecc5bcde27e626b1a611c2f2edcf7dc Reviewed-by: J-P Nurmi Reviewed-by: Caroline Chao --- src/controls/ScrollView.qml | 2 +- src/controls/SpinBox.qml | 2 +- src/controls/SplitView.qml | 50 ++++++++++++++++++-------------- src/private/TabBar.qml | 3 +- src/styles/Base/ButtonStyle.qml | 4 +-- src/styles/Base/CheckBoxStyle.qml | 2 ++ src/styles/Base/ComboBoxStyle.qml | 22 ++++++++++++-- src/styles/Base/RadioButtonStyle.qml | 18 ++++++++++-- src/styles/Base/TabViewStyle.qml | 2 +- src/styles/Desktop/SpinBoxStyle.qml | 2 +- tests/auto/controls/data/tst_spinbox.qml | 4 +-- 11 files changed, 75 insertions(+), 36 deletions(-) diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml index 3262648e..efa6e631 100644 --- a/src/controls/ScrollView.qml +++ b/src/controls/ScrollView.qml @@ -146,7 +146,7 @@ FocusScope { /*! \internal */ property Component style: Qt.createComponent(Settings.style + "/ScrollViewStyle.qml", root) - /* \internal */ + /*! \internal */ property PaddedStyle __style: styleLoader.item activeFocusOnTab: true diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index 4db67c8d..92f25fbc 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -157,7 +157,7 @@ Control { readonly property alias downPressed: mouseDown.pressed readonly property alias downHovered: mouseDown.containsMouse - readonly property alias containsMouse: mouseArea.containsMouse + readonly property alias hovered: mouseArea.containsMouse readonly property int contentHeight: Math.max(input.implicitHeight, 16) readonly property int contentWidth: Math.max(maxSizeHint.implicitWidth, minSizeHint.implicitWidth) diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml index fc43874e..0adb4282 100644 --- a/src/controls/SplitView.qml +++ b/src/controls/SplitView.qml @@ -117,14 +117,17 @@ Item { /*! This property holds the delegate that will be instantiated between each child item. Inside the delegate the following properties are available: - \list - \li int \c handleIndex - specifies the index of the splitter handle. The handle - between the first and the second item will get index 0, - the next handle index 1 etc. - \li bool \c pressed: the handle is being pressed. - \li bool \c resizing: the handle is being dragged. - \endlist - */ + + \table + \li readonly property bool styleData.index - Specifies the index of the splitter handle. The handle + between the first and the second item will get index 0, + the next handle index 1 etc. + \li readonly property bool styleData.hovered - The handle is being hovered. + \li readonly property bool styleData.pressed - The handle is being pressed. + \li readonly property bool styleData.resizing - The handle is being dragged. + \endtable + +*/ property Component handleDelegate: Rectangle { width: 1 height: 1 @@ -176,7 +179,7 @@ Item { continue if (splitterItems.children.length > 0) - handleLoader.createObject(splitterHandles, {"handleIndex":splitterItems.children.length - 1}) + handleLoader.createObject(splitterHandles, {"__handleIndex":splitterItems.children.length - 1}) item.parent = splitterItems i-- // item was removed from list item.widthChanged.connect(d.updateLayout) @@ -319,18 +322,21 @@ Item { id: handleLoader Loader { id: itemHandle - property int handleIndex: -1 - property alias containsMouse: mouseArea.containsMouse - property alias pressed: mouseArea.pressed - property bool resizing: mouseArea.drag.active - visible: __items[handleIndex + ((d.fillIndex >= handleIndex) ? 0 : 1)].visible + property int __handleIndex: -1 + property QtObject styleData: QtObject { + readonly property int index: __handleIndex + readonly property alias hovered: mouseArea.containsMouse + readonly property alias pressed: mouseArea.pressed + readonly property bool resizing: mouseArea.drag.active + onResizingChanged: root.resizing = resizing + } + visible: __items[__handleIndex + ((d.fillIndex >= __handleIndex) ? 0 : 1)].visible sourceComponent: handleDelegate onWidthChanged: d.updateLayout() onHeightChanged: d.updateLayout() onXChanged: moveHandle() onYChanged: moveHandle() - onResizingChanged: root.resizing = resizing MouseArea { id: mouseArea @@ -357,12 +363,12 @@ Item { var leftEdge, rightEdge, newWidth, leftStopX, rightStopX var i - if (d.fillIndex > handleIndex) { + if (d.fillIndex > __handleIndex) { // Resize item to the left. // Ensure that the handle is not crossing other handles. So // find the first visible handle to the left to determine the left edge: leftEdge = 0 - for (i=handleIndex-1; i>=0; --i) { + for (i=__handleIndex-1; i>=0; --i) { leftHandle = __handles[i] if (leftHandle.visible) { leftEdge = leftHandle[d.offset] + leftHandle[d.size] @@ -371,13 +377,13 @@ Item { } // Ensure: leftStopX >= itemHandle[d.offset] >= rightStopX - var min = d.accumulatedSize(handleIndex+1, __items.length, true) + var min = d.accumulatedSize(__handleIndex+1, __items.length, true) rightStopX = root[d.size] - min - itemHandle[d.size] leftStopX = Math.max(leftEdge, itemHandle[d.offset]) itemHandle[d.offset] = Math.min(rightStopX, Math.max(leftStopX, itemHandle[d.offset])) newWidth = itemHandle[d.offset] - leftEdge - leftItem = __items[handleIndex] + leftItem = __items[__handleIndex] // The next line will trigger 'updateLayout': leftItem[d.size] = newWidth } else { @@ -385,7 +391,7 @@ Item { // Ensure that the handle is not crossing other handles. So // find the first visible handle to the right to determine the right edge: rightEdge = root[d.size] - for (i=handleIndex+1; i<__handles.length; ++i) { + for (i=__handleIndex+1; i<__handles.length; ++i) { rightHandle = __handles[i] if (rightHandle.visible) { rightEdge = rightHandle[d.offset] @@ -394,13 +400,13 @@ Item { } // Ensure: leftStopX <= itemHandle[d.offset] <= rightStopX - min = d.accumulatedSize(0, handleIndex+1, true) + min = d.accumulatedSize(0, __handleIndex+1, true) leftStopX = min - itemHandle[d.size] rightStopX = Math.min((rightEdge - itemHandle[d.size]), itemHandle[d.offset]) itemHandle[d.offset] = Math.max(leftStopX, Math.min(itemHandle[d.offset], rightStopX)) newWidth = rightEdge - (itemHandle[d.offset] + itemHandle[d.size]) - rightItem = __items[handleIndex+1] + rightItem = __items[__handleIndex+1] // The next line will trigger 'updateLayout': rightItem[d.size] = newWidth } diff --git a/src/private/TabBar.qml b/src/private/TabBar.qml index aa1f919b..a856cedd 100644 --- a/src/private/TabBar.qml +++ b/src/private/TabBar.qml @@ -170,7 +170,6 @@ FocusScope { property int tabindex: index property bool selected : tabView.currentIndex === index - property bool hover: containsMouse property string title: modelData.title property bool nextSelected: tabView.currentIndex === index + 1 property bool previousSelected: tabView.currentIndex === index - 1 @@ -201,7 +200,7 @@ FocusScope { readonly property alias title: tabitem.title readonly property alias nextSelected: tabitem.nextSelected readonly property alias previsousSelected: tabitem.previousSelected - readonly property alias hovered: tabitem.hover + readonly property alias hovered: tabitem.containsMouse readonly property bool activeFocus: tabbar.activeFocus } diff --git a/src/styles/Base/ButtonStyle.qml b/src/styles/Base/ButtonStyle.qml index e668b042..5674c118 100644 --- a/src/styles/Base/ButtonStyle.qml +++ b/src/styles/Base/ButtonStyle.qml @@ -96,7 +96,7 @@ PaddedStyle { properties of \c control, the following state properties are available: \table - \li readonly property bool styleData.hovered - The button is currently hovered. + \li readonly property bool styleData.hovered - The control is being hovered. \endtable */ property Component background: Item { @@ -139,7 +139,7 @@ PaddedStyle { properties of \c control, the following state properties are available: \table - \li readonly property bool styleData.hovered - The button is currently hovered. + \li readonly property bool styleData.hovered - The control is being hovered. \endtable */ property Component label: Text { diff --git a/src/styles/Base/CheckBoxStyle.qml b/src/styles/Base/CheckBoxStyle.qml index 1323aa85..b10b2859 100644 --- a/src/styles/Base/CheckBoxStyle.qml +++ b/src/styles/Base/CheckBoxStyle.qml @@ -163,12 +163,14 @@ PaddedStyle { id: indicatorLoader sourceComponent: indicator anchors.verticalCenter: parent.verticalCenter + property QtObject styleData: QtObject { readonly property bool hovered: control.__containsMouse } } Loader { id: labelLoader sourceComponent: label anchors.top: parent.top anchors.bottom: parent.bottom + property QtObject styleData: QtObject { readonly property bool hovered: control.__containsMouse } } } } diff --git a/src/styles/Base/ComboBoxStyle.qml b/src/styles/Base/ComboBoxStyle.qml index 9795d1a8..5643d50f 100644 --- a/src/styles/Base/ComboBoxStyle.qml +++ b/src/styles/Base/ComboBoxStyle.qml @@ -62,7 +62,13 @@ PaddedStyle { /*! The padding between the background and the label components. */ padding { top: 4 ; left: 6 ; right: 6 ; bottom:4 } - /*! The background of the button. */ + /*! This defines the background of the button. In addition to the public + properties of \c control, the following state properties are available: + + \table + \li readonly property bool styleData.hovered - The control is being hovered. + \endtable + */ property Component background: Item { implicitWidth: 100 implicitHeight: 25 @@ -98,7 +104,13 @@ PaddedStyle { } } - /*! The label of the button. */ + /*! This defines the label of the button. In addition to the public + properties of \c control, the following state properties are available: + + \table + \li readonly property bool styleData.hovered - The control is being hovered. + \endtable + */ property Component label: Item { implicitWidth: textitem.implicitWidth + 20 Text { @@ -124,6 +136,9 @@ PaddedStyle { id: backgroundLoader anchors.fill: parent sourceComponent: background + property QtObject styleData: QtObject { + readonly property bool hovered: control.__containsMouse + } } Loader { @@ -134,6 +149,9 @@ PaddedStyle { anchors.topMargin: padding.top anchors.rightMargin: padding.right anchors.bottomMargin: padding.bottom + property QtObject styleData: QtObject { + readonly property bool hovered: control.__containsMouse + } } } diff --git a/src/styles/Base/RadioButtonStyle.qml b/src/styles/Base/RadioButtonStyle.qml index 49d15e3d..614a9537 100644 --- a/src/styles/Base/RadioButtonStyle.qml +++ b/src/styles/Base/RadioButtonStyle.qml @@ -83,7 +83,13 @@ PaddedStyle { /*! The \l RadioButton attached to this style. */ readonly property RadioButton control: __control - /*! The text label. */ + /*! This defines the text label. In addition to the public + properties of \c control, the following state properties are available: + + \table + \li readonly property bool styleData.hovered - The control is being hovered. + \endtable + */ property Component label: Text { text: control.text renderType: Text.NativeRendering @@ -97,7 +103,13 @@ PaddedStyle { /*! The spacing between indicator and label. */ property int spacing: 4 - /*! The indicator button. */ + /*! This defines the indicator button. In addition to the public + properties of \c control, the following state properties are available: + + \table + \li readonly property bool styleData.hovered - The control is being hovered. + \endtable + */ property Component indicator: Rectangle { width: 17 height: 17 @@ -133,12 +145,14 @@ PaddedStyle { id: indicatorLoader sourceComponent: indicator anchors.verticalCenter: parent.verticalCenter + property QtObject styleData: QtObject { readonly property bool hovered: control.__containsMouse } } Loader { id: labelLoader sourceComponent: label anchors.top: parent.top anchors.bottom: parent.bottom + property QtObject styleData: QtObject { readonly property bool hovered: control.__containsMouse } } } } diff --git a/src/styles/Base/TabViewStyle.qml b/src/styles/Base/TabViewStyle.qml index 91750ba9..344412b6 100644 --- a/src/styles/Base/TabViewStyle.qml +++ b/src/styles/Base/TabViewStyle.qml @@ -127,7 +127,7 @@ Style { \li readonly property string styleData.title - Tab title text. \li readonly property bool styleData.nextSelected - The next tab is selected. \li readonly property bool styleData.previousSelected - The previous tab is selected. - \li readonly property bool styleData.hovered - The tab is currently under the mouse. + \li readonly property bool styleData.hovered - The tab is being hovered. \li readonly property bool styleData.activeFocus - The tab button has keyboard focus. \endtable */ diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml index e8012a69..59c20f55 100644 --- a/src/styles/Desktop/SpinBoxStyle.qml +++ b/src/styles/Desktop/SpinBoxStyle.qml @@ -115,7 +115,7 @@ PaddedStyle { elementType: "spinbox" anchors.fill: parent sunken: (styleData.downEnabled && styleData.downPressed) || (styleData.upEnabled && styleData.upPressed) - hover: styleData.containsMouse + hover: styleData.hovered hints: control.styleHints hasFocus: control.activeFocus enabled: control.enabled diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index 4e701cc0..a00544b8 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -178,7 +178,7 @@ Item { setCoordinates(spinbox) mouseMove(spinbox, mainCoord.x, mainCoord.y) - compare(spinbox.__styleData.containsMouse, true) + compare(spinbox.__styleData.hovered, true) compare(spinbox.__styleData.upHovered, false) compare(spinbox.__styleData.downHovered, false) @@ -191,7 +191,7 @@ Item { compare(spinbox.__styleData.downHovered, true) mouseMove(spinbox, mainCoord.x - 2, mainCoord.y - 2) - compare(spinbox.__styleData.containsMouse, false) + compare(spinbox.__styleData.hovered, false) compare(spinbox.__styleData.upHovered, false) compare(spinbox.__styleData.downHovered, false) spinbox.destroy() -- cgit v1.2.1 From c47c502e794f7ae37c516a1db123139d9dc1270d Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 28 May 2013 13:39:00 +0200 Subject: Revise TableView API for managing the columns Replace "property list columns" with: - addColumn(column) - insertColumn(index, column) - moveColumn(from, to) - removeColumn(index) - getColumn(index) Exposing list type of property in the public API was problematic for several reasons. First of all, it limited the internal implementation too much. Secondly, modifying the list programmatically did not work as expected, and it also threw nasty warnings while reordering the columns interactively. Task-number: QTBUG-30319 Task-number: QTBUG-31028 Change-Id: I0039f7e4be2d6ee9303a4118bdf84146b6a96a05 Reviewed-by: Jens Bache-Wiig --- src/controls/TableView.qml | 112 +++++++++++++---- src/controls/TableViewColumn.qml | 2 + .../data/tableview/table_dynamiccolumns.qml | 65 ++++++++++ tests/auto/controls/data/tst_tableview.qml | 136 ++++++++++++++++++++- 4 files changed, 290 insertions(+), 25 deletions(-) create mode 100644 tests/auto/controls/data/tableview/table_dynamiccolumns.qml diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index 4cde5d3e..93d75e92 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -200,9 +200,8 @@ ScrollView { */ property int sortIndicatorOrder: Qt.AscendingOrder - /*! \qmlproperty list TableView::columns - This property contains the TableViewColumn items */ - default property alias columns: listView.columnheader + /*! \internal */ + default property alias __columns: root.data /*! \qmlproperty Component TableView::contentHeader This is the content header of the TableView */ @@ -216,8 +215,9 @@ ScrollView { The current number of rows */ readonly property alias rowCount: listView.count - /*! The current number of columns */ - readonly property int columnCount: columns.length + /*! \qmlproperty int TableView::columnCount + The current number of columns */ + readonly property alias columnCount: columnModel.count /*! \qmlproperty string TableView::section.property \qmlproperty enumeration TableView::section.criteria @@ -288,6 +288,73 @@ ScrollView { return listView.indexAt(obj.x, obj.y) } + /*! Adds a \a column and returns the added column. + + The \a column argument can be an instance of TableViewColumn, + or a Component. The component has to contain a TableViewColumn. + Otherwise \c null is returned. + */ + function addColumn(column) { + return insertColumn(columnCount, column) + } + + /*! Inserts a \a column at the given \a index and returns the inserted column. + + The \a column argument can be an instance of TableViewColumn, + or a Component. The component has to contain a TableViewColumn. + Otherwise \c null is returned. + */ + function insertColumn(index, column) { + var object = column + if (typeof column['createObject'] === 'function') + object = column.createObject(root) + + if (index >= 0 && index <= columnCount && object.Accessible.role === Accessible.ColumnHeader) { + columnModel.insert(index, {columnItem: object}) + return object + } + + if (object !== column) + object.destroy() + console.warn("TableView::insertColumn(): invalid argument") + return null + } + + /*! Removes and destroys a column at the given \a index. */ + function removeColumn(index) { + if (index < 0 || index >= columnCount) { + console.warn("TableView::removeColumn(): invalid argument") + return + } + var column = columnModel.get(index).columnItem + columnModel.remove(index, 1) + column.destroy() + } + + /*! Moves a column \a from index \a to another. */ + function moveColumn(from, to) { + if (from < 0 || from >= columnCount || to < 0 || to >= columnCount) { + console.warn("TableView::moveColumn(): invalid argument") + return + } + columnModel.move(from, to, 1) + } + + /*! Returns the column at the given \a index + or \c null if the \a index is invalid. */ + function getColumn(index) { + if (index < 0 || index >= columnCount) + return null + return columnModel.get(index).columnItem + } + + Component.onCompleted: { + for (var i = 0; i < __columns.length; ++i) { + var column = __columns[i] + if (column.Accessible.role === Accessible.ColumnHeader) + addColumn(column) + } + } style: Qt.createComponent(Settings.style + "/TableViewStyle.qml", root) @@ -429,7 +496,10 @@ ScrollView { } } - property list columnheader + ListModel { + id: columnModel + } + highlightFollowsCurrentItem: true model: root.model @@ -483,7 +553,7 @@ ScrollView { height: parent.height Repeater { id: repeater - model: root.columnCount + model: columnModel Loader { id: itemDelegateLoader @@ -509,7 +579,7 @@ ScrollView { readonly property string role: __column.role } - readonly property TableViewColumn __column: columns[index] + readonly property TableViewColumn __column: columnItem readonly property bool __hasModelRole: styleData.role && itemModel.hasOwnProperty(styleData.role) readonly property bool __hasModelDataRole: styleData.role && modelData && modelData.hasOwnProperty(styleData.role) } @@ -548,12 +618,12 @@ ScrollView { property int targetIndex: -1 property int dragIndex: -1 - model: columnCount + model: columnModel delegate: Item { z:-index - width: columns[index].width - visible: columns[index].visible + width: modelData.width + visible: modelData.visible height: headerVisible ? headerStyle.height : 0 Loader { @@ -562,7 +632,7 @@ ScrollView { anchors.left: parent.left anchors.right: parent.right property QtObject styleData: QtObject { - readonly property string value: columns[index].title + readonly property string value: modelData.title readonly property bool pressed: headerClickArea.pressed readonly property bool containsMouse: headerClickArea.containsMouse readonly property int column: index @@ -608,13 +678,7 @@ ScrollView { onReleased: { if (repeater.targetIndex >= 0 && repeater.targetIndex != index ) { - // Rearrange the header sections - var items = new Array - for (var i = 0 ; i< columnCount ; ++i) - items.push(columns[i]) - items.splice(index, 1); - items.splice(repeater.targetIndex, 0, columns[index]); - columns = items + columnModel.move(index, repeater.targetIndex, 1) if (sortIndicatorColumn == index) sortIndicatorColumn = repeater.targetIndex } @@ -628,14 +692,14 @@ ScrollView { Loader { id: draghandle property QtObject styleData: QtObject{ - readonly property string value: columns[index].title + readonly property string value: modelData.title readonly property bool pressed: headerClickArea.pressed readonly property bool containsMouse: headerClickArea.containsMouse readonly property int column: index } parent: tableHeader - width: columns[index].width + width: modelData.width height: parent.height sourceComponent: root.headerDelegate visible: headerClickArea.pressed @@ -651,8 +715,8 @@ ScrollView { width: 16 ; height: parent.height anchors.right: parent.right onPositionChanged: { - var newHeaderWidth = columns[index].width + (mouseX - offset) - columns[index].width = Math.max(minimumSize, newHeaderWidth) + var newHeaderWidth = modelData.width + (mouseX - offset) + modelData.width = Math.max(minimumSize, newHeaderWidth) } property bool found:false @@ -667,7 +731,7 @@ ScrollView { minWidth = Math.max(minWidth, item.children[1].children[index].children[0].implicitWidth) } if (minWidth) - columns[index].width = minWidth + modelData.width = minWidth } onPressedChanged: if (pressed) offset=mouseX cursorShape: Qt.SplitHCursor diff --git a/src/controls/TableViewColumn.qml b/src/controls/TableViewColumn.qml index 919f30de..2c629dfb 100644 --- a/src/controls/TableViewColumn.qml +++ b/src/controls/TableViewColumn.qml @@ -89,4 +89,6 @@ QtObject { /*! The delegate of the column. This can be used to set the \l TableView::itemDelegate for a specific column. */ property Component delegate + + Accessible.role: Accessible.ColumnHeader } diff --git a/tests/auto/controls/data/tableview/table_dynamiccolumns.qml b/tests/auto/controls/data/tableview/table_dynamiccolumns.qml new file mode 100644 index 00000000..ce2cb93c --- /dev/null +++ b/tests/auto/controls/data/tableview/table_dynamiccolumns.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 QtQuick.Controls 1.0 + +TableView { + id: tableView + + TableViewColumn { title: "static" } + + Component { + id: component + TableViewColumn { } + } + + Component.onCompleted: { + addColumn(component.createObject(tableView, {title: "added item"})) + + var col1 = addColumn(component) + col1.title = "added component" + + insertColumn(0, component.createObject(tableView, {title: "inserted item"})) + + var col2 = insertColumn(0, component) + col2.title = "inserted component" + } +} diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml index 6de8d577..d092ae9d 100644 --- a/tests/auto/controls/data/tst_tableview.qml +++ b/tests/auto/controls/data/tst_tableview.qml @@ -55,6 +55,11 @@ TestCase { width:400 height:400 + Component { + id: newColumn + TableViewColumn { } + } + function test_usingqmlmodel_data() { return [ {tag: "listmodel", a: "tableview/table5_listmodel.qml", expected: "A"}, @@ -173,7 +178,14 @@ TestCase { compare(component.status, Component.Ready) var table = component.createObject(container); verify(table !== null, "table created is null") - table.forceActiveFocus(); + + // wait for items to be created + var timeout = 2000 + while (timeout >= 0 && table.rowAt(15, 55) === -1) { + timeout -= 50 + wait(50) + } + compare(table.test, 0) mouseClick(table, 15 , 55, Qt.LeftButton) compare(table.test, 1) @@ -228,6 +240,128 @@ TestCase { table.destroy() } + function test_dynamicColumns() { + var component = Qt.createComponent("tableview/table_dynamiccolumns.qml") + compare(component.status, Component.Ready) + var table = component.createObject(container) + + // insertColumn(component), insertColumn(item), + // addColumn(component), addColumn(item), and static TableViewColumn {} + compare(table.columnCount, 5) + compare(table.getColumn(0).title, "inserted component") + compare(table.getColumn(1).title, "inserted item") + table.destroy() + } + + function test_addRemoveColumn() { + var tableView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TableView { }', testCase, ''); + compare(tableView.columnCount, 0) + tableView.addColumn(newColumn.createObject(testCase, {title: "title 1"})) + compare(tableView.columnCount, 1) + tableView.addColumn(newColumn.createObject(testCase, {title: "title 2"})) + compare(tableView.columnCount, 2) + compare(tableView.getColumn(0).title, "title 1") + compare(tableView.getColumn(1).title, "title 2") + + tableView.insertColumn(1, newColumn.createObject(testCase, {title: "title 3"})) + compare(tableView.columnCount, 3) + compare(tableView.getColumn(0).title, "title 1") + compare(tableView.getColumn(1).title, "title 3") + compare(tableView.getColumn(2).title, "title 2") + + tableView.insertColumn(0, newColumn.createObject(testCase, {title: "title 4"})) + compare(tableView.columnCount, 4) + compare(tableView.getColumn(0).title, "title 4") + compare(tableView.getColumn(1).title, "title 1") + compare(tableView.getColumn(2).title, "title 3") + compare(tableView.getColumn(3).title, "title 2") + + tableView.removeColumn(0) + compare(tableView.columnCount, 3) + compare(tableView.getColumn(0).title, "title 1") + compare(tableView.getColumn(1).title, "title 3") + compare(tableView.getColumn(2).title, "title 2") + + tableView.removeColumn(1) + compare(tableView.columnCount, 2) + compare(tableView.getColumn(0).title, "title 1") + compare(tableView.getColumn(1).title, "title 2") + + tableView.removeColumn(1) + compare(tableView.columnCount, 1) + compare(tableView.getColumn(0).title, "title 1") + + tableView.removeColumn(0) + compare(tableView.columnCount, 0) + tableView.destroy() + } + + function test_moveColumn_data() { + return [ + {tag:"0->1 (0)", from: 0, to: 1}, + {tag:"0->1 (1)", from: 0, to: 1}, + {tag:"0->1 (2)", from: 0, to: 1}, + + {tag:"0->2 (0)", from: 0, to: 2}, + {tag:"0->2 (1)", from: 0, to: 2}, + {tag:"0->2 (2)", from: 0, to: 2}, + + {tag:"1->0 (0)", from: 1, to: 0}, + {tag:"1->0 (1)", from: 1, to: 0}, + {tag:"1->0 (2)", from: 1, to: 0}, + + {tag:"1->2 (0)", from: 1, to: 2}, + {tag:"1->2 (1)", from: 1, to: 2}, + {tag:"1->2 (2)", from: 1, to: 2}, + + {tag:"2->0 (0)", from: 2, to: 0}, + {tag:"2->0 (1)", from: 2, to: 0}, + {tag:"2->0 (2)", from: 2, to: 0}, + + {tag:"2->1 (0)", from: 2, to: 1}, + {tag:"2->1 (1)", from: 2, to: 1}, + {tag:"2->1 (2)", from: 2, to: 1}, + + {tag:"0->0", from: 0, to: 0}, + {tag:"-1->0", from: -1, to: 0}, + {tag:"0->-1", from: 0, to: -1}, + {tag:"1->10", from: 1, to: 10}, + {tag:"10->2", from: 10, to: 2}, + {tag:"10->-1", from: 10, to: -1} + ] + } + + function test_moveColumn(data) { + var tableView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TableView { }', testCase, ''); + compare(tableView.columnCount, 0) + + var titles = ["title 1", "title 2", "title 3"] + + var i = 0; + for (i = 0; i < titles.length; ++i) + tableView.addColumn(newColumn.createObject(testCase, {title: titles[i]})) + + compare(tableView.columnCount, titles.length) + for (i = 0; i < tableView.columnCount; ++i) + compare(tableView.getColumn(i).title, titles[i]) + + tableView.moveColumn(data.from, data.to) + + compare(tableView.columnCount, titles.length) + + if (data.from >= 0 && data.from < tableView.columnCount && data.to >= 0 && data.to < tableView.columnCount) { + var title = titles[data.from] + titles.splice(data.from, 1) + titles.splice(data.to, 0, title) + } + + compare(tableView.columnCount, titles.length) + for (i = 0; i < tableView.columnCount; ++i) + compare(tableView.getColumn(i).title, titles[i]) + + tableView.destroy() + } + // In TableView, drawn text = table.__currentRowItem.children[1].children[1].itemAt(0).children[0].children[0].text function findAChild(item, name) -- cgit v1.2.1 From 5cea9fc38eccfe6b2d999c305d6826a7e27583b4 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Wed, 29 May 2013 11:31:42 +0200 Subject: Doc: Fix various problems in Qt Quick Layouts documentation This change fixes the following things in .qdocconf: - CamelCase for project name - Proper selector for QML Types topic - Remove exampledirs since there is currently no example (Both exampledirs and exampleinstallpath should be used if examples are added) Change-Id: I5c56d2e57889fb0e9a94e03222af0cdf2858ddc2 Reviewed-by: Jerome Pasion --- src/layouts/doc/qtquicklayouts.qdocconf | 36 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/layouts/doc/qtquicklayouts.qdocconf b/src/layouts/doc/qtquicklayouts.qdocconf index b5649044..ad33416f 100644 --- a/src/layouts/doc/qtquicklayouts.qdocconf +++ b/src/layouts/doc/qtquicklayouts.qdocconf @@ -5,31 +5,29 @@ description = Qt Quick Layouts Reference Documentation url = http://qt-project.org/doc/qt-$QT_VER/qtquicklayouts/ version = $QT_VERSION -qhp.projects = qtquicklayouts +qhp.projects = QtQuickLayouts -qhp.qtquicklayouts.file = qtquicklayouts.qhp -qhp.qtquicklayouts.namespace = org.qt-project.qtquicklayouts.$QT_VERSION_TAG -qhp.qtquicklayouts.virtualFolder = qtquicklayouts -qhp.qtquicklayouts.indexTitle = Qt Quick Layouts -qhp.qtquicklayouts.indexRoot = +qhp.QtQuickLayouts.file = qtquicklayouts.qhp +qhp.QtQuickLayouts.namespace = org.qt-project.qtquicklayouts.$QT_VERSION_TAG +qhp.QtQuickLayouts.virtualFolder = qtquicklayouts +qhp.QtQuickLayouts.indexTitle = Qt Quick Layouts +qhp.QtQuickLayouts.indexRoot = -qhp.qtquicklayouts.filterAttributes = qtquicklayouts $QT_VERSION qtrefdoc -qhp.qtquicklayouts.customFilters.Qt.name = QtQuickLayouts $QT_VERSION -qhp.qtquicklayouts.customFilters.Qt.filterAttributes = qtquicklayouts $QT_VERSION +qhp.QtQuickLayouts.filterAttributes = qtquicklayouts $QT_VERSION qtrefdoc +qhp.QtQuickLayouts.customFilters.Qt.name = QtQuickLayouts $QT_VERSION +qhp.QtQuickLayouts.customFilters.Qt.filterAttributes = qtquicklayouts $QT_VERSION -qhp.qtquicklayouts.subprojects = qtquicklayoutsqmltypes -qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.title = QML Types -qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.indexTitle = Qt Quick Layouts -qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.selectors = class fake:headerfile -qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.sortPages = true -qhp.qtquicklayouts.subprojects.qtquicklayoutsqmltypes.type = manual +qhp.QtQuickLayouts.subprojects = qtquicklayoutsqmltypes +qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.title = QML Types +qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.indexTitle = Qt Quick Layouts +qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.selectors = class fake:qmlClass +qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.sortPages = true +qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.type = manual depends = qtqml qtquick qtwidgets qtdoc qtquickcontrols -exampledirs += ../../../examples/quick/controls/ +headerdirs += .. -headerdirs += ../ - -sourcedirs += ../ +sourcedirs += .. imagedirs += images -- cgit v1.2.1 From 158fe2a0c551f7aaeaa07bdbb0096bee0ade0fdf Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Tue, 28 May 2013 10:09:03 +0200 Subject: Change default layout spacing to 5, and make it depend on DPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6f34ace6a24ce918cdd417bbfcd2fe8126aa321b Reviewed-by: Jens Bache-Wiig Reviewed-by: Jan Arve Sæther --- src/layouts/qquicklinearlayout.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/layouts/qquicklinearlayout.cpp b/src/layouts/qquicklinearlayout.cpp index 541e4aca..b9a8e224 100644 --- a/src/layouts/qquicklinearlayout.cpp +++ b/src/layouts/qquicklinearlayout.cpp @@ -143,8 +143,15 @@ QT_BEGIN_NAMESPACE -static const qreal q_declarativeLayoutDefaultSpacing = 4.0; - +static qreal quickLayoutDefaultSpacing() +{ + qreal spacing = 5.0; +#ifndef Q_OS_MAC + // On mac the DPI is always 72 so we should not scale it + spacing = qRound(spacing * (qreal(qt_defaultDpiX()) / 96.0)); +#endif + return spacing; +} QQuickGridLayoutBase::QQuickGridLayoutBase(QQuickGridLayoutBasePrivate &dd, Qt::Orientation orientation, @@ -412,9 +419,10 @@ QQuickGridLayout::QQuickGridLayout(QQuickItem *parent /* = 0*/) : QQuickGridLayoutBase(*new QQuickGridLayoutPrivate, Qt::Horizontal, parent) { Q_D(QQuickGridLayout); - d->columnSpacing = q_declarativeLayoutDefaultSpacing; - d->rowSpacing = q_declarativeLayoutDefaultSpacing; - d->engine.setSpacing(q_declarativeLayoutDefaultSpacing, Qt::Horizontal | Qt::Vertical); + const qreal defaultSpacing = quickLayoutDefaultSpacing(); + d->columnSpacing = defaultSpacing; + d->rowSpacing = defaultSpacing; + d->engine.setSpacing(defaultSpacing, Qt::Horizontal | Qt::Vertical); } /*! @@ -672,7 +680,7 @@ QQuickLinearLayout::QQuickLinearLayout(Qt::Orientation orientation, : QQuickGridLayoutBase(*new QQuickLinearLayoutPrivate, orientation, parent) { Q_D(QQuickLinearLayout); - d->spacing = q_declarativeLayoutDefaultSpacing; + d->spacing = quickLayoutDefaultSpacing(); d->engine.setSpacing(d->spacing, Qt::Horizontal | Qt::Vertical); } -- cgit v1.2.1 From c6389d78fc51fb404043848f5d7da2d4e3e19599 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 28 May 2013 13:14:15 +0200 Subject: Move backgroundColor from TableView to TableViewStyle This property was not respected by some of the native styles and makes more sense as a styling attribute. Change-Id: I9cc1d3a130b764a67552ed7f0cec49ccc87ea246 Reviewed-by: J-P Nurmi --- src/controls/TableView.qml | 8 +------- src/styles/Base/TableViewStyle.qml | 20 +++++++++++++++++--- src/styles/Desktop/TableViewStyle.qml | 5 +++++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index 93d75e92..d0417bfa 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -161,12 +161,6 @@ ScrollView { */ property Component rowDelegate: __style ? __style.rowDelegate : null - /*! \qmlproperty color TableView::backgroundColor - - This property sets the background color of the viewport. - The default value is the base color of the SystemPalette. */ - property alias backgroundColor: colorRect.color - /*! This property defines a delegate to draw a header. In the header delegate you have access to the following special properties: @@ -404,7 +398,7 @@ ScrollView { id: colorRect parent: viewport anchors.fill: parent - color: palette.base + color: __style ? __style.backgroundColor : palette.base z: -1 } diff --git a/src/styles/Base/TableViewStyle.qml b/src/styles/Base/TableViewStyle.qml index b53b3c64..a7b3ba49 100644 --- a/src/styles/Base/TableViewStyle.qml +++ b/src/styles/Base/TableViewStyle.qml @@ -59,7 +59,13 @@ ScrollViewStyle { /*! The text color. */ property color textColor: __syspal.text - /*! The text highlight color, used behind selections. */ + /*! The background color. */ + property color backgroundColor: __syspal.base + + /*! The alternate background color. */ + property color alternateBackgroundColor: Qt.darker(__syspal.base, 1.06) + + /*! The text highlight color, used within selections. */ property color highlightedTextColor: "white" /*! Activates items on single click. */ @@ -96,8 +102,16 @@ ScrollViewStyle { height: 20 property color selectedColor: styleData.hasActiveFocus ? "#38d" : "#999" gradient: Gradient { - GradientStop { color: styleData.selected ? Qt.lighter(selectedColor, 1.3) : styleData.alternate ? "#f2f2f2" : "white" ; position: 0 } - GradientStop { color: styleData.selected ? Qt.lighter(selectedColor, 1.0) : styleData.alternate ? "#f2f2f2" : "white" ; position: 1 } + GradientStop { + color: styleData.selected ? Qt.lighter(selectedColor, 1.3) : + styleData.alternate ? alternateBackgroundColor : backgroundColor + position: 0 + } + GradientStop { + color: styleData.selected ? Qt.lighter(selectedColor, 1.0) : + styleData.alternate ? alternateBackgroundColor : backgroundColor + position: 1 + } } Rectangle { anchors.bottom: parent.bottom diff --git a/src/styles/Desktop/TableViewStyle.qml b/src/styles/Desktop/TableViewStyle.qml index 9a3584d2..97dfcd5c 100644 --- a/src/styles/Desktop/TableViewStyle.qml +++ b/src/styles/Desktop/TableViewStyle.qml @@ -44,9 +44,14 @@ import QtQuick.Controls.Private 1.0 ScrollViewStyle { id: root + property var __syspal: SystemPalette { + colorGroup: control.enabled ? + SystemPalette.Active : SystemPalette.Disabled + } readonly property TableView control: __control property bool activateItemOnSingleClick: __styleitem.styleHint("activateItemOnSingleClick") property color textColor: __styleitem.textColor + property color backgroundColor: __syspal.base property color highlightedTextColor: __styleitem.highlightedTextColor property StyleItem __styleitem: StyleItem{ -- cgit v1.2.1 From a48849649e9d534449f6feb685dbb708f354d270 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 28 May 2013 16:50:49 +0200 Subject: MenuItem: Connect to own action's 'shortcutChanged' signal Otherwise, we won't be setting the shortcut on the platform item. Task-number: QTBUG-31368 Change-Id: I333b903719d6e95a411f4f423c0e9b8ce15e640e Reviewed-by: J-P Nurmi --- src/controls/qquickmenuitem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controls/qquickmenuitem.cpp b/src/controls/qquickmenuitem.cpp index 4ac7c7ff..de215df1 100644 --- a/src/controls/qquickmenuitem.cpp +++ b/src/controls/qquickmenuitem.cpp @@ -401,6 +401,7 @@ QQuickMenuItem::QQuickMenuItem(QObject *parent) { connect(this, SIGNAL(__textChanged()), this, SIGNAL(textChanged())); + connect(action(), SIGNAL(shortcutChanged(QString)), this, SLOT(updateShortcut())); connect(action(), SIGNAL(triggered()), this, SIGNAL(triggered())); connect(action(), SIGNAL(toggled(bool)), this, SLOT(updateChecked())); if (platformItem()) -- cgit v1.2.1 From 6e62a72c72abc5ad6e241541208a36378d448853 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 28 May 2013 10:19:30 +0200 Subject: Improved size calculation of GroupBox This adds some pixel tweaks on mac, adds minimum size to fit the label and fixes dpi scaling on Windows Change-Id: I4c43ba4a7815be87356336a9dafc1a217437940b Reviewed-by: Gabriel de Dietrich --- examples/quick/controls/gallery/content/Layouts.qml | 1 - src/controls/GroupBox.qml | 4 +++- src/private/qquickcontrolsettings.cpp | 11 +++++++++++ src/private/qquickcontrolsettings_p.h | 3 +++ src/styles/Desktop/GroupBoxStyle.qml | 8 ++++---- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/examples/quick/controls/gallery/content/Layouts.qml b/examples/quick/controls/gallery/content/Layouts.qml index 1251947a..ac0a53a3 100644 --- a/examples/quick/controls/gallery/content/Layouts.qml +++ b/examples/quick/controls/gallery/content/Layouts.qml @@ -76,7 +76,6 @@ Item { GridLayout { id: gridLayout anchors.fill: parent - anchors.margins: 4 rows: 3 flow: GridLayout.TopToBottom diff --git a/src/controls/GroupBox.qml b/src/controls/GroupBox.qml index 9bf1c0cc..4aa6a50f 100644 --- a/src/controls/GroupBox.qml +++ b/src/controls/GroupBox.qml @@ -159,7 +159,8 @@ Item { /*! \internal */ property alias __style: styleLoader.item - implicitWidth: (!anchors.fill ? container.calcWidth() : 0) + loader.leftMargin + loader.rightMargin + implicitWidth: Math.max((!anchors.fill ? container.calcWidth() : 0) + loader.leftMargin + loader.rightMargin, + sizeHint.implicitWidth + (checkable ? 24 : 6)) implicitHeight: (!anchors.fill ? container.calcHeight() : 0) + loader.topMargin + loader.bottomMargin Layout.minimumWidth: implicitWidth @@ -181,6 +182,7 @@ Item { property int rightMargin: __style ? __style.padding.right : 0 sourceComponent: styleLoader.item ? styleLoader.item.panel : null onLoaded: item.z = -1 + Text { id: sizeHint ; visible: false ; text: title } Loader { id: styleLoader property alias __control: groupbox diff --git a/src/private/qquickcontrolsettings.cpp b/src/private/qquickcontrolsettings.cpp index 44db49c2..e2daa17f 100644 --- a/src/private/qquickcontrolsettings.cpp +++ b/src/private/qquickcontrolsettings.cpp @@ -133,4 +133,15 @@ QString QQuickControlSettings::styleFilePath() const return m_path + QLatin1Char('/') + m_name; } +extern Q_GUI_EXPORT int qt_defaultDpiX(); + +qreal QQuickControlSettings::dpiScaleFactor() const +{ +#ifndef Q_OS_MAC + return (qreal(qt_defaultDpiX()) / 96.0); +#endif + return 1.0; +} + + QT_END_NAMESPACE diff --git a/src/private/qquickcontrolsettings_p.h b/src/private/qquickcontrolsettings_p.h index 98e85151..8ff0ecbf 100644 --- a/src/private/qquickcontrolsettings_p.h +++ b/src/private/qquickcontrolsettings_p.h @@ -55,6 +55,7 @@ class QQuickControlSettings : public QObject Q_PROPERTY(QUrl style READ style NOTIFY styleChanged) Q_PROPERTY(QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged) Q_PROPERTY(QString stylePath READ stylePath WRITE setStylePath NOTIFY stylePathChanged) + Q_PROPERTY(qreal dpiScaleFactor READ dpiScaleFactor CONSTANT) public: QQuickControlSettings(QQmlEngine *engine); @@ -67,6 +68,8 @@ public: QString stylePath() const; void setStylePath(const QString &path); + qreal dpiScaleFactor() const; + signals: void styleChanged(); void styleNameChanged(); diff --git a/src/styles/Desktop/GroupBoxStyle.qml b/src/styles/Desktop/GroupBoxStyle.qml index 3c4bfc43..2348e663 100644 --- a/src/styles/Desktop/GroupBoxStyle.qml +++ b/src/styles/Desktop/GroupBoxStyle.qml @@ -55,10 +55,10 @@ PaddedStyle { } padding { - top: (control.title.length > 0 || control.checkable ? titleHeight : 0) + 6 - left: 8 - right: 8 - bottom: 6 + top: Math.round(Settings.dpiScaleFactor * (control.title.length > 0 || control.checkable ? titleHeight : 0) + (style.style == "mac" ? 9 : 6)) + left: Math.round(Settings.dpiScaleFactor * 8) + right: Math.round(Settings.dpiScaleFactor * 8) + bottom: Math.round(Settings.dpiScaleFactor * 7 + (style.style.indexOf("windows") > -1 ? 2 : 0)) } property Component panel: StyleItem { -- cgit v1.2.1 From b0510b53256cbc3d2ea46dd936e85c0d1f463b37 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 28 May 2013 13:49:44 +0200 Subject: Rename::tabAt(index) to getTab(index) The fooAt() type methods are reserved for coordinate based queries. Change-Id: Iea91bdd29df4fa53cc1c7a07880f466ef2325725 Reviewed-by: Caroline Chao --- src/controls/TabView.qml | 2 +- src/private/TabBar.qml | 2 +- tests/auto/controls/data/tst_tabview.qml | 46 ++++++++++++++++---------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/controls/TabView.qml b/src/controls/TabView.qml index d292ce05..3273f825 100644 --- a/src/controls/TabView.qml +++ b/src/controls/TabView.qml @@ -133,7 +133,7 @@ FocusScope { } /*! Returns the \l Tab item at \a index. */ - function tabAt(index) { + function getTab(index) { return __tabs.get(index).tab } diff --git a/src/private/TabBar.qml b/src/private/TabBar.qml index a856cedd..7f4db779 100644 --- a/src/private/TabBar.qml +++ b/src/private/TabBar.qml @@ -181,7 +181,7 @@ FocusScope { onPressed: { tabView.currentIndex = index; var next = tabbar.nextItemInFocusChain(true); - if (__isAncestorOf(tabView.tabAt(currentIndex), next)) + if (__isAncestorOf(tabView.getTab(currentIndex), next)) next.forceActiveFocus(); else tabitem.forceActiveFocus(); diff --git a/tests/auto/controls/data/tst_tabview.qml b/tests/auto/controls/data/tst_tabview.qml index 992baf22..85ad4346 100644 --- a/tests/auto/controls/data/tst_tabview.qml +++ b/tests/auto/controls/data/tst_tabview.qml @@ -72,12 +72,12 @@ TestCase { function test_changeIndex() { var tabView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TabView { Repeater { model: 3; Tab { Text { text: index } } } }', testCase, ''); compare(tabView.count, 3) - verify(tabView.tabAt(1).item == undefined) + verify(tabView.getTab(1).item == undefined) tabView.currentIndex = 1 - verify(tabView.tabAt(1).item !== undefined) - verify(tabView.tabAt(2).item == undefined) + verify(tabView.getTab(1).item !== undefined) + verify(tabView.getTab(2).item == undefined) tabView.currentIndex = 1 - verify(tabView.tabAt(2).item !== undefined) + verify(tabView.getTab(2).item !== undefined) tabView.destroy() } @@ -89,36 +89,36 @@ TestCase { compare(tabView.count, 1) tabView.addTab("title 2", newTab) compare(tabView.count, 2) - compare(tabView.tabAt(0).title, "title 1") - compare(tabView.tabAt(1).title, "title 2") + compare(tabView.getTab(0).title, "title 1") + compare(tabView.getTab(1).title, "title 2") tabView.insertTab(1, "title 3") compare(tabView.count, 3) - compare(tabView.tabAt(0).title, "title 1") - compare(tabView.tabAt(1).title, "title 3") - compare(tabView.tabAt(2).title, "title 2") + compare(tabView.getTab(0).title, "title 1") + compare(tabView.getTab(1).title, "title 3") + compare(tabView.getTab(2).title, "title 2") tabView.insertTab(0, "title 4") compare(tabView.count, 4) - compare(tabView.tabAt(0).title, "title 4") - compare(tabView.tabAt(1).title, "title 1") - compare(tabView.tabAt(2).title, "title 3") - compare(tabView.tabAt(3).title, "title 2") + compare(tabView.getTab(0).title, "title 4") + compare(tabView.getTab(1).title, "title 1") + compare(tabView.getTab(2).title, "title 3") + compare(tabView.getTab(3).title, "title 2") tabView.removeTab(0) compare(tabView.count, 3) - compare(tabView.tabAt(0).title, "title 1") - compare(tabView.tabAt(1).title, "title 3") - compare(tabView.tabAt(2).title, "title 2") + compare(tabView.getTab(0).title, "title 1") + compare(tabView.getTab(1).title, "title 3") + compare(tabView.getTab(2).title, "title 2") tabView.removeTab(1) compare(tabView.count, 2) - compare(tabView.tabAt(0).title, "title 1") - compare(tabView.tabAt(1).title, "title 2") + compare(tabView.getTab(0).title, "title 1") + compare(tabView.getTab(1).title, "title 2") tabView.removeTab(1) compare(tabView.count, 1) - compare(tabView.tabAt(0).title, "title 1") + compare(tabView.getTab(0).title, "title 1") tabView.removeTab(0) compare(tabView.count, 0) @@ -172,7 +172,7 @@ TestCase { compare(tabView.count, titles.length) for (i = 0; i < tabView.count; ++i) - compare(tabView.tabAt(i).title, titles[i]) + compare(tabView.getTab(i).title, titles[i]) tabView.currentIndex = data.currentBefore tabView.moveTab(data.from, data.to) @@ -186,7 +186,7 @@ TestCase { compare(tabView.count, titles.length) for (i = 0; i < tabView.count; ++i) - compare(tabView.tabAt(i).title, titles[i]) + compare(tabView.getTab(i).title, titles[i]) tabView.destroy() } @@ -212,11 +212,11 @@ TestCase { var tabView = Qt.createQmlObject(test_tabView, testCase, '') // insertTab(), addTab(), createObject() and static Tab {} compare(tabView.count, 4) - compare(tabView.tabAt(0).title, "inserted") + compare(tabView.getTab(0).title, "inserted") var tab = tabView.tabComponent.createObject(tabView) compare(tabView.count, 5) - compare(tabView.tabAt(4).title, "dynamic") + compare(tabView.getTab(4).title, "dynamic") tab.destroy() wait(0) compare(tabView.count, 4) -- cgit v1.2.1 From 26dda49ccb3572bedc785c85c41cec5db8114579 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 29 May 2013 13:06:34 +0200 Subject: Rename PaddedStyle to AbstractStyle Make Style inherit AbstractStyle, so it becomes the base class of all styles. AbstractStyle also now has a default "data" property so it's possible to conveniently declare helper content inside styles. Change-Id: Id84f3762cfae506e65021322619d7fb77b137994 Reviewed-by: Tomasz Olszak Reviewed-by: Jens Bache-Wiig --- src/controls/ScrollView.qml | 2 +- src/controls/doc/qtquickcontrols.qdocconf | 4 +- src/private/Style.qml | 3 +- src/private/plugin.cpp | 4 +- src/private/private.pro | 4 +- src/private/qquickabstractstyle.cpp | 98 +++++++++++++++++++++++++++++++ src/private/qquickabstractstyle_p.h | 78 ++++++++++++++++++++++++ src/private/qquickpaddedstyle.cpp | 68 --------------------- src/private/qquickpaddedstyle_p.h | 67 --------------------- src/styles/Base/ButtonStyle.qml | 2 +- src/styles/Base/CheckBoxStyle.qml | 2 +- src/styles/Base/ComboBoxStyle.qml | 2 +- src/styles/Base/GroupBoxStyle.qml | 2 +- src/styles/Base/ProgressBarStyle.qml | 2 +- src/styles/Base/RadioButtonStyle.qml | 2 +- src/styles/Base/ScrollViewStyle.qml | 2 +- src/styles/Base/SliderStyle.qml | 2 +- src/styles/Base/SpinBoxStyle.qml | 2 +- src/styles/Base/TextFieldStyle.qml | 2 +- src/styles/Desktop/GroupBoxStyle.qml | 2 +- src/styles/Desktop/ScrollViewStyle.qml | 2 +- src/styles/Desktop/SliderStyle.qml | 2 +- src/styles/Desktop/SpinBoxStyle.qml | 2 +- 23 files changed, 199 insertions(+), 157 deletions(-) create mode 100644 src/private/qquickabstractstyle.cpp create mode 100644 src/private/qquickabstractstyle_p.h delete mode 100644 src/private/qquickpaddedstyle.cpp delete mode 100644 src/private/qquickpaddedstyle_p.h diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml index efa6e631..0af69a0d 100644 --- a/src/controls/ScrollView.qml +++ b/src/controls/ScrollView.qml @@ -147,7 +147,7 @@ FocusScope { property Component style: Qt.createComponent(Settings.style + "/ScrollViewStyle.qml", root) /*! \internal */ - property PaddedStyle __style: styleLoader.item + property Style __style: styleLoader.item activeFocusOnTab: true diff --git a/src/controls/doc/qtquickcontrols.qdocconf b/src/controls/doc/qtquickcontrols.qdocconf index c04bced2..1f692597 100644 --- a/src/controls/doc/qtquickcontrols.qdocconf +++ b/src/controls/doc/qtquickcontrols.qdocconf @@ -52,7 +52,7 @@ sources += ../../private/qstyleitem.cpp \ ../../private/TabBar.qml \ ../../private/Control.qml \ ../../private/Style.qml \ - ../../private/qquickpaddedstyle.h \ - ../../private/qquickpaddedstyle.cpp + ../../private/qquickabstractstyle.h \ + ../../private/qquickabstractstyle.cpp imagedirs += images diff --git a/src/private/Style.qml b/src/private/Style.qml index 990f61dd..6b4c08ef 100644 --- a/src/private/Style.qml +++ b/src/private/Style.qml @@ -39,6 +39,7 @@ ****************************************************************************/ import QtQuick 2.1 import QtQuick.Controls 1.0 +import QtQuick.Controls.Private 1.0 /*! \qmltype Style @@ -46,7 +47,7 @@ import QtQuick.Controls 1.0 \inqmlmodule QtQuick.Controls.Private 1.0 */ -QtObject { +AbstractStyle { /*! The control attached to this style */ readonly property Item control: __control diff --git a/src/private/plugin.cpp b/src/private/plugin.cpp index 17bfed07..e33c2d37 100644 --- a/src/private/plugin.cpp +++ b/src/private/plugin.cpp @@ -45,7 +45,7 @@ #include "qquicktooltip_p.h" #include "qquickcontrolsettings_p.h" #include "qquickspinboxvalidator_p.h" -#include "qquickpaddedstyle_p.h" +#include "qquickabstractstyle_p.h" #ifndef QT_NO_WIDGETS #include "qquickstyleitem_p.h" @@ -81,7 +81,7 @@ public: void QtQuickControlsPrivatePlugin::registerTypes(const char *uri) { - qmlRegisterType(uri, 1, 0, "PaddedStyle"); + qmlRegisterType(uri, 1, 0, "AbstractStyle"); qmlRegisterType(); qmlRegisterType(uri, 1, 0, "RangeModel"); qmlRegisterType(uri, 1, 0, "WheelArea"); diff --git a/src/private/private.pro b/src/private/private.pro index cbb08a80..803b703f 100644 --- a/src/private/private.pro +++ b/src/private/private.pro @@ -10,7 +10,7 @@ HEADERS += \ $$PWD/qquickrangemodel_p_p.h \ $$PWD/qquickcontrolsettings_p.h \ $$PWD/qquickwheelarea_p.h \ - $$PWD/qquickpaddedstyle_p.h \ + $$PWD/qquickabstractstyle_p.h \ $$PWD/qquickpadding_p.h SOURCES += \ @@ -20,7 +20,7 @@ SOURCES += \ $$PWD/qquickrangemodel.cpp \ $$PWD/qquickcontrolsettings.cpp \ $$PWD/qquickwheelarea.cpp \ - $$PWD/qquickpaddedstyle.cpp + $$PWD/qquickabstractstyle.cpp # private qml files QML_FILES += \ diff --git a/src/private/qquickabstractstyle.cpp b/src/private/qquickabstractstyle.cpp new file mode 100644 index 00000000..eba57b03 --- /dev/null +++ b/src/private/qquickabstractstyle.cpp @@ -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: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$ +** +****************************************************************************/ + +#include "qquickabstractstyle_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \qmltype AbstractStyle + \instantiates QQuickAbstractStyle + \qmlabstract + \internal +*/ + +/*! + \qmlproperty int AbstractStyle::padding.top + \qmlproperty int AbstractStyle::padding.left + \qmlproperty int AbstractStyle::padding.right + \qmlproperty int AbstractStyle::padding.bottom + + This grouped property holds the \c top, \c left, \c right and \c bottom padding. +*/ + +QQuickAbstractStyle::QQuickAbstractStyle(QObject *parent) : QObject(parent) +{ +} + +QQmlListProperty QQuickAbstractStyle::data() +{ + return QQmlListProperty(this, 0, &QQuickAbstractStyle::data_append, &QQuickAbstractStyle::data_count, + &QQuickAbstractStyle::data_at, &QQuickAbstractStyle::data_clear); +} + +void QQuickAbstractStyle::data_append(QQmlListProperty *list, QObject *object) +{ + if (QQuickAbstractStyle *style = qobject_cast(list->object)) + style->m_data.append(object); +} + +int QQuickAbstractStyle::data_count(QQmlListProperty *list) +{ + if (QQuickAbstractStyle *style = qobject_cast(list->object)) + return style->m_data.count(); + return 0; +} + +QObject *QQuickAbstractStyle::data_at(QQmlListProperty *list, int index) +{ + if (QQuickAbstractStyle *style = qobject_cast(list->object)) + return style->m_data.at(index); + return 0; +} + +void QQuickAbstractStyle::data_clear(QQmlListProperty *list) +{ + if (QQuickAbstractStyle *style = qobject_cast(list->object)) + style->m_data.clear(); +} + +QT_END_NAMESPACE diff --git a/src/private/qquickabstractstyle_p.h b/src/private/qquickabstractstyle_p.h new file mode 100644 index 00000000..13764053 --- /dev/null +++ b/src/private/qquickabstractstyle_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#ifndef QQUICKABSTRACTSTYLE_H +#define QQUICKABSTRACTSTYLE_H + +#include +#include +#include "qquickpadding_p.h" + +QT_BEGIN_NAMESPACE + +class QQuickAbstractStyle : public QObject +{ + Q_OBJECT + + Q_PROPERTY(QQuickPadding* padding READ padding CONSTANT) + Q_PROPERTY(QQmlListProperty data READ data DESIGNABLE false) + Q_CLASSINFO("DefaultProperty", "data") + +public: + QQuickAbstractStyle(QObject *parent = 0); + + QQuickPadding* padding() { return &m_padding; } + + QQmlListProperty data(); + +private: + static void data_append(QQmlListProperty *list, QObject *object); + static int data_count(QQmlListProperty *list); + static QObject *data_at(QQmlListProperty *list, int index); + static void data_clear(QQmlListProperty *list); + + QQuickPadding m_padding; + QList m_data; +}; + +QT_END_NAMESPACE + +#endif // QQUICKABSTRACTSTYLE_H diff --git a/src/private/qquickpaddedstyle.cpp b/src/private/qquickpaddedstyle.cpp deleted file mode 100644 index 320a3f53..00000000 --- a/src/private/qquickpaddedstyle.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qquickpaddedstyle_p.h" -#include "qquickpadding_p.h" - -/*! - \qmltype PaddedStyle - \instantiates QQuickPaddedStyle - \qmlabstract - \internal -*/ - -QT_BEGIN_NAMESPACE - -QQuickPaddedStyle::QQuickPaddedStyle(QQuickItem *parent) : - QQuickItem(parent) -{ -} - -/*! - \qmlproperty int PaddedStyle::padding.top - \qmlproperty int PaddedStyle::padding.left - \qmlproperty int PaddedStyle::padding.right - \qmlproperty int PaddedStyle::padding.bottom - - This grouped property holds the \c top, \c left, \c right and \c bottom padding. -*/ - -QT_END_NAMESPACE diff --git a/src/private/qquickpaddedstyle_p.h b/src/private/qquickpaddedstyle_p.h deleted file mode 100644 index 1a5a3c95..00000000 --- a/src/private/qquickpaddedstyle_p.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QQUICKPADDEDSTYLE_H -#define QQUICKPADDEDSTYLE_H - -#include -#include -#include "qquickpadding_p.h" - -QT_BEGIN_NAMESPACE - -class QQuickPaddedStyle : public QQuickItem -{ - Q_OBJECT - - Q_PROPERTY(QQuickPadding* padding READ padding CONSTANT) - -public: - QQuickPaddedStyle(QQuickItem *parent = 0); - QQuickPadding* padding() { return &m_padding; } - -private: - QQuickPadding m_padding; -}; - -QT_END_NAMESPACE - -#endif // QQUICKPADDEDSTYLE_H diff --git a/src/styles/Base/ButtonStyle.qml b/src/styles/Base/ButtonStyle.qml index 5674c118..fe37d170 100644 --- a/src/styles/Base/ButtonStyle.qml +++ b/src/styles/Base/ButtonStyle.qml @@ -72,7 +72,7 @@ import QtQuick.Controls.Private 1.0 If you need a custom label, you can replace the label item. */ -PaddedStyle { +Style { id: buttonstyle /*! The \l Button attached to this style. */ diff --git a/src/styles/Base/CheckBoxStyle.qml b/src/styles/Base/CheckBoxStyle.qml index b10b2859..4311c629 100644 --- a/src/styles/Base/CheckBoxStyle.qml +++ b/src/styles/Base/CheckBoxStyle.qml @@ -72,7 +72,7 @@ import QtQuick.Controls.Private 1.0 } \endqml */ -PaddedStyle { +Style { id: checkboxStyle /*! The \l CheckBox attached to this style. */ diff --git a/src/styles/Base/ComboBoxStyle.qml b/src/styles/Base/ComboBoxStyle.qml index 5643d50f..08382f15 100644 --- a/src/styles/Base/ComboBoxStyle.qml +++ b/src/styles/Base/ComboBoxStyle.qml @@ -49,7 +49,7 @@ import QtQuick.Controls.Private 1.0 \brief Provides custom styling for ComboBox */ -PaddedStyle { +Style { /*! \internal */ property var __syspal: SystemPalette { diff --git a/src/styles/Base/GroupBoxStyle.qml b/src/styles/Base/GroupBoxStyle.qml index 86fc83fe..db0c3bf6 100644 --- a/src/styles/Base/GroupBoxStyle.qml +++ b/src/styles/Base/GroupBoxStyle.qml @@ -47,7 +47,7 @@ import QtQuick.Controls.Private 1.0 \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 */ -PaddedStyle { +Style { /*! \internal */ property var __syspal: SystemPalette { diff --git a/src/styles/Base/ProgressBarStyle.qml b/src/styles/Base/ProgressBarStyle.qml index c93a6356..eab286f0 100644 --- a/src/styles/Base/ProgressBarStyle.qml +++ b/src/styles/Base/ProgressBarStyle.qml @@ -71,7 +71,7 @@ import QtQuick.Controls.Private 1.0 \endqml */ -PaddedStyle { +Style { id: progressBarStyle /*! \internal */ diff --git a/src/styles/Base/RadioButtonStyle.qml b/src/styles/Base/RadioButtonStyle.qml index 614a9537..f8fdb647 100644 --- a/src/styles/Base/RadioButtonStyle.qml +++ b/src/styles/Base/RadioButtonStyle.qml @@ -72,7 +72,7 @@ import QtQuick.Controls.Private 1.0 \endqml */ -PaddedStyle { +Style { id: radiobuttonStyle /*! \internal */ diff --git a/src/styles/Base/ScrollViewStyle.qml b/src/styles/Base/ScrollViewStyle.qml index b1fe789f..fb65fe2c 100644 --- a/src/styles/Base/ScrollViewStyle.qml +++ b/src/styles/Base/ScrollViewStyle.qml @@ -47,7 +47,7 @@ import QtQuick.Controls.Private 1.0 \since QtQuick.Controls.Styles 1.0 \brief Provides custom styling for ScrollView */ -PaddedStyle { +Style { id: root /*! \internal */ diff --git a/src/styles/Base/SliderStyle.qml b/src/styles/Base/SliderStyle.qml index 7870e2f2..a17de0a1 100644 --- a/src/styles/Base/SliderStyle.qml +++ b/src/styles/Base/SliderStyle.qml @@ -78,7 +78,7 @@ import QtQuick.Controls.Private 1.0 } \endqml */ -PaddedStyle { +Style { id: styleitem /*! \internal */ diff --git a/src/styles/Base/SpinBoxStyle.qml b/src/styles/Base/SpinBoxStyle.qml index 6280ea93..c239483e 100644 --- a/src/styles/Base/SpinBoxStyle.qml +++ b/src/styles/Base/SpinBoxStyle.qml @@ -49,7 +49,7 @@ import QtQuick.Controls.Private 1.0 \brief Provides custom styling for SpinBox */ -PaddedStyle { +Style { id: spinboxStyle /*! The \l SpinBox attached to this style. */ diff --git a/src/styles/Base/TextFieldStyle.qml b/src/styles/Base/TextFieldStyle.qml index 3c1a10a6..7b0ba6b2 100644 --- a/src/styles/Base/TextFieldStyle.qml +++ b/src/styles/Base/TextFieldStyle.qml @@ -64,7 +64,7 @@ import QtQuick.Controls.Private 1.0 \endqml */ -PaddedStyle { +Style { id: style /*! \internal */ diff --git a/src/styles/Desktop/GroupBoxStyle.qml b/src/styles/Desktop/GroupBoxStyle.qml index 2348e663..81d6de86 100644 --- a/src/styles/Desktop/GroupBoxStyle.qml +++ b/src/styles/Desktop/GroupBoxStyle.qml @@ -42,7 +42,7 @@ import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -PaddedStyle { +Style { readonly property GroupBox control: __control property var __style: StyleItem { id: style } diff --git a/src/styles/Desktop/ScrollViewStyle.qml b/src/styles/Desktop/ScrollViewStyle.qml index d504c59b..deddc354 100644 --- a/src/styles/Desktop/ScrollViewStyle.qml +++ b/src/styles/Desktop/ScrollViewStyle.qml @@ -42,7 +42,7 @@ import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 import "." as Desktop -PaddedStyle { +Style { id: root padding { diff --git a/src/styles/Desktop/SliderStyle.qml b/src/styles/Desktop/SliderStyle.qml index 1c89d21c..fbe2cfb6 100644 --- a/src/styles/Desktop/SliderStyle.qml +++ b/src/styles/Desktop/SliderStyle.qml @@ -40,7 +40,7 @@ import QtQuick 2.1 import QtQuick.Controls.Private 1.0 -PaddedStyle { +Style { readonly property Item control: __control property Component panel: StyleItem { elementType: "slider" diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml index 59c20f55..2f05838e 100644 --- a/src/styles/Desktop/SpinBoxStyle.qml +++ b/src/styles/Desktop/SpinBoxStyle.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -PaddedStyle { +Style { readonly property SpinBox control: __control property var __syspal: SystemPalette { -- cgit v1.2.1 From c536d0cf324bd7cb2299ecd3e5212b9826b2bf42 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 29 May 2013 14:38:21 +0200 Subject: Removed reference to nonexistent file PageSlideTransition.qml. Change-Id: I2b4a4369496d85829fb2de14078042c0a76f2aba Reviewed-by: Jerome Pasion --- src/controls/doc/qtquickcontrols.qdocconf | 1 - 1 file changed, 1 deletion(-) diff --git a/src/controls/doc/qtquickcontrols.qdocconf b/src/controls/doc/qtquickcontrols.qdocconf index 1f692597..7cf1ee54 100644 --- a/src/controls/doc/qtquickcontrols.qdocconf +++ b/src/controls/doc/qtquickcontrols.qdocconf @@ -47,7 +47,6 @@ sources += ../../private/qstyleitem.cpp \ ../../private/BasicButton.qml \ ../../private/FocusFrame.qml \ ../../private/ModalPopupBehavior.qml \ - ../../private/PageSlideTransition.qml \ ../../private/ScrollBar.qml \ ../../private/TabBar.qml \ ../../private/Control.qml \ -- cgit v1.2.1 From cf3d91d6db86fb74d5968405371c4e83b1410d86 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 29 May 2013 13:32:25 +0200 Subject: Make styleHints a variant map The styleHints are not really flexible enough as a stringlist as we want to be able to pass actual properties. Since we already have a properties member of the style we should move all of our internal properties to that. Change-Id: Id7a66ade243461f54c41b9ec89144668aaf19483 Reviewed-by: Gabriel de Dietrich --- src/private/Control.qml | 2 +- src/private/qquickstyleitem.cpp | 95 ++++++++++++++++++---------------- src/private/qquickstyleitem_p.h | 9 ++-- src/styles/Desktop/CheckBoxStyle.qml | 12 +---- src/styles/Desktop/SpinBoxStyle.qml | 3 +- src/styles/Desktop/TabViewStyle.qml | 7 +-- src/styles/Desktop/TableViewStyle.qml | 3 +- src/styles/Desktop/TextFieldStyle.qml | 6 +-- src/styles/Desktop/ToolButtonStyle.qml | 5 +- 9 files changed, 71 insertions(+), 71 deletions(-) diff --git a/src/private/Control.qml b/src/private/Control.qml index 109e37ed..05916c0a 100644 --- a/src/private/Control.qml +++ b/src/private/Control.qml @@ -64,7 +64,7 @@ FocusScope { property Item __panel: panelLoader.item /*! \internal */ - property var styleHints: [] + property var styleHints implicitWidth: __panel ? __panel.implicitWidth: 0 implicitHeight: __panel ? __panel.implicitHeight: 0 diff --git a/src/private/qquickstyleitem.cpp b/src/private/qquickstyleitem.cpp index 422d9a8e..71d98bb6 100644 --- a/src/private/qquickstyleitem.cpp +++ b/src/private/qquickstyleitem.cpp @@ -177,8 +177,9 @@ void QQuickStyleItem::initStyleOption() if (m_styleoption) m_styleoption->state = 0; - QPlatformTheme::Font platformFont = (m_hints.indexOf("mini") != -1) ? QPlatformTheme::MiniFont : - (m_hints.indexOf("small") != -1) ? QPlatformTheme::SmallFont : + QString sizeHint = m_hints.value("size").toString(); + QPlatformTheme::Font platformFont = (sizeHint == "mini") ? QPlatformTheme::MiniFont : + (sizeHint == "small") ? QPlatformTheme::SmallFont : QPlatformTheme::SystemFont; switch (m_itemType) { @@ -266,11 +267,12 @@ void QQuickStyleItem::initStyleOption() QStyleOptionHeader::SortDown : activeControl() == "up" ? QStyleOptionHeader::SortUp : QStyleOptionHeader::None; - if (hints().contains("beginning")) + QString headerpos = m_properties.value("headerpos").toString(); + if (headerpos == "beginning") opt->position = QStyleOptionHeader::Beginning; - else if (hints().contains("end")) + else if (headerpos == "end") opt->position = QStyleOptionHeader::End; - else if (hints().contains("only")) + else if (headerpos == "only") opt->position = QStyleOptionHeader::OnlyOneSection; else opt->position = QStyleOptionHeader::Middle; @@ -318,32 +320,30 @@ void QQuickStyleItem::initStyleOption() QStyleOptionTab *opt = qstyleoption_cast(m_styleoption); opt->text = text(); - if (m_properties["hasFrame"].toBool()) + if (m_properties.value("hasFrame").toBool()) opt->features |= QStyleOptionTab::HasFrame; - if (hints().length() > 2) { - QString orientation = hints()[0]; - QString position = hints()[1]; - QString selectedPosition = hints()[2]; + QString orientation = m_properties.value("orientation").toString(); + QString position = m_properties.value("tabpos").toString(); + QString selectedPosition = m_properties.value("selectedpos").toString(); + + opt->shape = (orientation == "Bottom") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; + if (position == QLatin1String("beginning")) + opt->position = QStyleOptionTab::Beginning; + else if (position == QLatin1String("end")) + opt->position = QStyleOptionTab::End; + else if (position == QLatin1String("only")) + opt->position = QStyleOptionTab::OnlyOneTab; + else + opt->position = QStyleOptionTab::Middle; - opt->shape = (orientation == "Bottom") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth; + if (selectedPosition == QLatin1String("next")) + opt->selectedPosition = QStyleOptionTab::NextIsSelected; + else if (selectedPosition == QLatin1String("previous")) + opt->selectedPosition = QStyleOptionTab::PreviousIsSelected; + else + opt->selectedPosition = QStyleOptionTab::NotAdjacent; - if (position == QLatin1String("beginning")) - opt->position = QStyleOptionTab::Beginning; - else if (position == QLatin1String("end")) - opt->position = QStyleOptionTab::End; - else if (position == QLatin1String("only")) - opt->position = QStyleOptionTab::OnlyOneTab; - else - opt->position = QStyleOptionTab::Middle; - - if (selectedPosition == QLatin1String("next")) - opt->selectedPosition = QStyleOptionTab::NextIsSelected; - else if (selectedPosition == QLatin1String("previous")) - opt->selectedPosition = QStyleOptionTab::PreviousIsSelected; - else - opt->selectedPosition = QStyleOptionTab::NotAdjacent; - } } break; @@ -459,7 +459,7 @@ void QQuickStyleItem::initStyleOption() QStyleOptionButton *opt = qstyleoption_cast(m_styleoption); if (!on()) opt->state |= QStyle::State_Off; - if (m_hints.contains("partiallyChecked")) + if (m_properties.value("partiallyChecked").toBool()) opt->state |= QStyle::State_NoChange; opt->text = text(); } @@ -643,9 +643,9 @@ void QQuickStyleItem::initStyleOption() if (m_horizontal) m_styleoption->state |= QStyle::State_Horizontal; - if (m_hints.indexOf("mini") != -1) { + if (sizeHint == "mini") { m_styleoption->state |= QStyle::State_Mini; - } else if (m_hints.indexOf("small") != -1) { + } else if (sizeHint == "small") { m_styleoption->state |= QStyle::State_Small; } @@ -801,10 +801,14 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height) case Edit: #ifdef Q_OS_MAC if (style() =="mac") { - if (m_hints.indexOf("small") != -1 || m_hints.indexOf("mini") != -1) + QString sizeHint = m_hints.value("size").toString(); + if ((sizeHint == "small") || (sizeHint == "mini")) size = QSize(width, 19); else size = QSize(width, 22); + if (style() == "mac" && hints().value("rounded").toBool()) + size += QSize(4, 4); + } else #endif { @@ -965,7 +969,7 @@ QVariant QQuickStyleItem::styleHint(const QString &metric) // Add SH_Menu_SpaceActivatesItem, SH_Menu_SubMenuPopupDelay } -void QQuickStyleItem::setHints(const QStringList &str) +void QQuickStyleItem::setHints(const QVariantMap &str) { if (m_hints != str) { m_hints = str; @@ -983,6 +987,11 @@ void QQuickStyleItem::setHints(const QStringList &str) } } +void QQuickStyleItem::resetHints() +{ + m_hints.clear(); +} + void QQuickStyleItem::setElementType(const QString &str) { @@ -1211,7 +1220,7 @@ void QQuickStyleItem::paint(QPainter *painter) case ToolButton: #ifdef Q_OS_MAC - if (style() == "mac" && hints().indexOf("segmented") != -1) { + if (style() == "mac" && hints().value("segmented").toBool()) { const QPaintDevice *target = painter->device(); HIThemeSegmentDrawInfo sgi; sgi.version = 0; @@ -1227,9 +1236,10 @@ void QQuickStyleItem::paint(QPainter *painter) } SInt32 button_height; GetThemeMetric(kThemeMetricButtonRoundedHeight, &button_height); - sgi.position = hints().contains("leftmost") ? kHIThemeSegmentPositionFirst: - hints().contains("rightmost") ? kHIThemeSegmentPositionLast : - hints().contains("h_middle") ? kHIThemeSegmentPositionMiddle : + QString buttonPos = m_properties.value("position").toString(); + sgi.position = buttonPos == "leftmost" ? kHIThemeSegmentPositionFirst : + buttonPos == "rightmost" ? kHIThemeSegmentPositionLast : + buttonPos == "h_middle" ? kHIThemeSegmentPositionMiddle : kHIThemeSegmentPositionOnly; QRect centered = m_styleoption->rect; centered.setHeight(button_height); @@ -1257,12 +1267,7 @@ void QQuickStyleItem::paint(QPainter *painter) qApp->style()->drawControl(QStyle::CE_ShapedFrame, m_styleoption, painter); break; case FocusFrame: -#ifdef Q_OS_MAC - if (style() == "mac" && hints().indexOf("rounded") != -1) - break; // embedded in the line itself - else -#endif - qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter); + qApp->style()->drawControl(QStyle::CE_FocusFrame, m_styleoption, painter); break; case FocusRect: qApp->style()->drawPrimitive(QStyle::PE_FrameFocusRect, m_styleoption, painter); @@ -1288,7 +1293,7 @@ void QQuickStyleItem::paint(QPainter *painter) break; case Edit: { #ifdef Q_OS_MAC - if (style() == "mac" && hints().indexOf("rounded") != -1) { + if (style() == "mac" && hints().value("rounded").toBool()) { const QPaintDevice *target = painter->device(); HIThemeFrameDrawInfo fdi; fdi.version = 0; @@ -1299,9 +1304,7 @@ void QQuickStyleItem::paint(QPainter *painter) if ((m_styleoption->state & QStyle::State_ReadOnly) || !(m_styleoption->state & QStyle::State_Enabled)) fdi.state = kThemeStateInactive; fdi.isFocused = hasFocus(); - HIRect hirect = qt_hirectForQRect(m_styleoption->rect, - QRect(frame_size, frame_size, - frame_size * 2, frame_size * 2)); + HIRect hirect = qt_hirectForQRect(m_styleoption->rect.adjusted(2, 2, -2, 2), QRect(0, 0, 0, 0)); HIThemeDrawFrame(&hirect, &fdi, qt_mac_cg_context(target), kHIThemeOrientationNormal); } else #endif diff --git a/src/private/qquickstyleitem_p.h b/src/private/qquickstyleitem_p.h index 6deaeb16..eee9e6e5 100644 --- a/src/private/qquickstyleitem_p.h +++ b/src/private/qquickstyleitem_p.h @@ -67,7 +67,7 @@ class QQuickStyleItem: public QQuickItem Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY( QString activeControl READ activeControl WRITE setActiveControl NOTIFY activeControlChanged) Q_PROPERTY( QString style READ style NOTIFY styleChanged) - Q_PROPERTY( QStringList hints READ hints WRITE setHints NOTIFY hintChanged) + Q_PROPERTY( QVariantMap hints READ hints WRITE setHints NOTIFY hintChanged RESET resetHints) Q_PROPERTY( QVariantMap properties READ properties WRITE setProperties NOTIFY propertiesChanged) Q_PROPERTY( QFont font READ font NOTIFY fontChanged) @@ -140,7 +140,7 @@ public: QString elementType() const { return m_type; } QString text() const { return m_text; } QString activeControl() const { return m_activeControl; } - QStringList hints() const { return m_hints; } + QVariantMap hints() const { return m_hints; } QVariantMap properties() const { return m_properties; } QFont font() const { return m_font;} QString style() const; @@ -161,8 +161,9 @@ public: void setElementType(const QString &str); void setText(const QString &str) { if (m_text != str) {m_text = str; emit textChanged();}} void setActiveControl(const QString &str) { if (m_activeControl != str) {m_activeControl = str; emit activeControlChanged();}} - void setHints(const QStringList &str); + void setHints(const QVariantMap &str); void setProperties(const QVariantMap &props) { if (m_properties != props) { m_properties = props; emit propertiesChanged(); } } + void resetHints(); int contentWidth() const { return m_contentWidth; } void setContentWidth(int arg); @@ -228,7 +229,7 @@ protected: QString m_type; QString m_text; QString m_activeControl; - QStringList m_hints; + QVariantMap m_hints; QVariantMap m_properties; QFont m_font; diff --git a/src/styles/Desktop/CheckBoxStyle.qml b/src/styles/Desktop/CheckBoxStyle.qml index 65c517ba..d85a2cb3 100644 --- a/src/styles/Desktop/CheckBoxStyle.qml +++ b/src/styles/Desktop/CheckBoxStyle.qml @@ -55,16 +55,8 @@ Style { hover: control.__containsMouse enabled: control.enabled hasFocus: control.activeFocus && styleitem.style == "mac" - hints: { - if (control.checkedState === Qt.PartiallyChecked) - control.styleHints.push("partiallyChecked"); - else { - var index = control.styleHints.indexOf("partiallyChecked"); - if (index !== -1) - control.styleHints.splice(index, 1); - } - control.styleHints; - } + hints: control.styleHints + properties: {"partiallyChecked": (control.checkedState === Qt.PartiallyChecked) } contentHeight: textitem.implicitHeight contentWidth: textitem.implicitWidth + indicatorWidth property int indicatorWidth: pixelMetric("indicatorwidth") + (macStyle ? 2 : 4) diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml index 2f05838e..d43a2630 100644 --- a/src/styles/Desktop/SpinBoxStyle.qml +++ b/src/styles/Desktop/SpinBoxStyle.qml @@ -50,11 +50,12 @@ Style { } padding { - top: control.__panel ? control.__panel.topPadding + (control.__panel.style === "mac" ? 1 : 0) : 0 + top: control.__panel ? control.__panel.topPadding + (styleitem.style === "mac" ? 2 : 0) : 0 left: control.__panel ? control.__panel.leftPadding : 0 right: control.__panel ? control.__panel.rightPadding : 0 bottom: control.__panel ? control.__panel.bottomPadding : 0 } + StyleItem {id: styleitem ; visible: false} property Component panel: Item { id: style diff --git a/src/styles/Desktop/TabViewStyle.qml b/src/styles/Desktop/TabViewStyle.qml index b28300e2..51b70ea4 100644 --- a/src/styles/Desktop/TabViewStyle.qml +++ b/src/styles/Desktop/TabViewStyle.qml @@ -51,7 +51,7 @@ Style { property StyleItem __barstyle: StyleItem { elementType: "tab" - hints: [control.tabPosition === Qt.TopEdge ? "Top" : "Bottom"] + properties: { "tabposition" : (control.tabPosition === Qt.TopEdge ? "Top" : "Bottom") } visible: false } @@ -65,6 +65,7 @@ Style { minimum: tabbarItem && tabsVisible && tabbarItem.tab(currentIndex) ? tabbarItem.tab(currentIndex).width : 0 maximum: tabbarItem && tabsVisible ? tabbarItem.width : width properties: { "selectedTabRect" : tabbarItem.__selectedTabRect, "orientation" : control.tabPosition } + hints: control.styleHints Component.onCompleted: { stack.frameWidth = styleitem.pixelMetric("defaultframewidth"); stack.style = style; @@ -94,8 +95,8 @@ Style { anchors.rightMargin: -paintMargins anchors.bottomMargin: -1 anchors.leftMargin: -paintMargins + (style === "mac" && selected ? -1 : 0) - properties: { "hasFrame" : true } - hints: [orientation, tabpos, selectedpos] + properties: { "hasFrame" : true, "orientation": orientation, "tabpos": tabpos, "selectedpos": selectedpos } + hints: control.styleHints selected: styleData.selected text: elidedText(styleData.title, tabbarItem.elide, item.width - item.tabHSpace) diff --git a/src/styles/Desktop/TableViewStyle.qml b/src/styles/Desktop/TableViewStyle.qml index 97dfcd5c..171678a3 100644 --- a/src/styles/Desktop/TableViewStyle.qml +++ b/src/styles/Desktop/TableViewStyle.qml @@ -73,7 +73,8 @@ ScrollViewStyle { sunken: styleData.pressed text: styleData.value hover: styleData.containsMouse - hints: headerPosition + hints: control.styleHints + properties: {"headerpos": headerPosition} property string itemSort: (control.sortIndicatorVisible && styleData.column === control.sortIndicatorColumn) ? (control.sortIndicatorOrder == Qt.AscendingOrder ? "up" : "down") : ""; property string headerPosition: control.columnCount === 1 ? "only" : styleData.column === control.columnCount-1 ? "end" : diff --git a/src/styles/Desktop/TextFieldStyle.qml b/src/styles/Desktop/TextFieldStyle.qml index 9a093d2a..ee6779eb 100644 --- a/src/styles/Desktop/TextFieldStyle.qml +++ b/src/styles/Desktop/TextFieldStyle.qml @@ -64,9 +64,9 @@ Style { property color selectedTextColor: syspal.highlightedText - property bool rounded: hints.indexOf("rounded") > -1 + property bool rounded: !!hints["rounded"] property int topMargin: style === "mac" ? 3 : 2 - property int leftMargin: rounded ? 8 : 4 + property int leftMargin: rounded ? 12 : 4 property int rightMargin: leftMargin property int bottomMargin: 2 @@ -76,7 +76,7 @@ Style { FocusFrame { anchors.fill: parent - visible: textfield.activeFocus && textfieldstyle.styleHint("focuswidget") + visible: textfield.activeFocus && textfieldstyle.styleHint("focuswidget") && !rounded } } } diff --git a/src/styles/Desktop/ToolButtonStyle.qml b/src/styles/Desktop/ToolButtonStyle.qml index b54eeee2..ebeec761 100644 --- a/src/styles/Desktop/ToolButtonStyle.qml +++ b/src/styles/Desktop/ToolButtonStyle.qml @@ -51,11 +51,12 @@ Style { raised: !(control.checkable && control.checked) && control.__containsMouse hover: control.__containsMouse hasFocus: control.activeFocus - hints: control.styleHints.concat([control.__position]) + hints: control.styleHints text: control.text properties: { - "icon": control.__action.__icon + "icon": control.__action.__icon, + "position": control.__position } } } -- cgit v1.2.1 From 6de2c97d064daa069066bb46880f04bfd5be43b7 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 29 May 2013 15:23:14 +0200 Subject: Docs: fix missing/leftover docs, types, tags... Task-number: QTBUG-31262 Change-Id: I6bf48604b9392a2a9c63c344363188a4693a8547 Reviewed-by: Jens Bache-Wiig --- src/controls/ComboBox.qml | 12 +++++++++--- src/controls/ProgressBar.qml | 2 +- src/controls/Slider.qml | 13 ------------- src/controls/SpinBox.qml | 17 +++++++++++++---- src/controls/SplitView.qml | 23 +++++++++++++++++------ src/controls/TextArea.qml | 2 +- 6 files changed, 41 insertions(+), 28 deletions(-) diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index 7b13bc8e..e5efb63c 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -80,13 +80,19 @@ import QtQuick.Controls.Private 1.0 Control { id: comboBox - /*! The model to populate the ComboBox from. */ + /*! \qmlproperty model ComboBox::model + The model to populate the ComboBox from. */ property alias model: popupItems.model + + /*! The model role used for populating the ComboBox. */ property string textRole: "" - /*! The index of the currently selected item in the ComboBox. */ + /*! \qmlproperty int ComboBox::currentIndex + The index of the currently selected item in the ComboBox. */ property alias currentIndex: popup.__selectedIndex - /*! The text of the currently selected item in the ComboBox. */ + + /*! \qmlproperty string ComboBox::currentText + The text of the currently selected item in the ComboBox. */ readonly property alias currentText: popup.selectedText /*! This property specifies whether the combobox should gain active focus when pressed. diff --git a/src/controls/ProgressBar.qml b/src/controls/ProgressBar.qml index 33e21514..6d9f8be1 100644 --- a/src/controls/ProgressBar.qml +++ b/src/controls/ProgressBar.qml @@ -123,7 +123,7 @@ Control { implicitWidth:(__panel ? __panel.implicitWidth : 0) implicitHeight: (__panel ? __panel.implicitHeight: 0) - /* \internal */ + /*! \internal */ function setValue(v) { var newval = parseFloat(v) if (!isNaN(newval)) { diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index 711c449b..b31d4f78 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -174,19 +174,6 @@ Control { Accessible.role: Accessible.Slider Accessible.name: value - /*! - \qmlmethod Slider::formatValue - - This method returns the current slider value in a way that is more suitable - for user display, such as the \l value rounded to only two decimal places. - - By default this function returns the nearest \c int value. - */ - - function formatValue(v) { - return Math.round(v); - } - style: Qt.createComponent(Settings.style + "/SliderStyle.qml", slider) Keys.onRightPressed: value += (maximumValue - minimumValue)/10.0 diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index 92f25fbc..68f97e0a 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -75,6 +75,8 @@ Control { id: spinbox /*! + \qmlproperty real SpinBox::value + The value of this SpinBox, clamped to \l minimumValue and \l maximumValue. The default value is \c{0.0}. @@ -82,6 +84,8 @@ Control { property alias value: validator.value /*! + \qmlproperty real SpinBox::minimumValue + The minimum value of the SpinBox range. The \l value is clamped to this value. @@ -90,6 +94,8 @@ Control { property alias minimumValue: validator.minimumValue /*! + \qmlproperty real SpinBox::maximumValue + The maximum value of the SpinBox range. The \l value is clamped to this value. If maximumValue is smaller than \l minimumValue, \l minimumValue will be enforced. @@ -98,7 +104,7 @@ Control { */ property alias maximumValue: validator.maximumValue - /*! + /*! \qmlproperty real SpinBox::stepSize The amount by which the \l value is incremented/decremented when a spin button is pressed. @@ -106,13 +112,16 @@ Control { */ property alias stepSize: validator.stepSize - /*! The suffix for the value. I.e "cm" */ + /*! \qmlproperty string SpinBox::suffix + The suffix for the value. I.e "cm" */ property alias suffix: validator.suffix - /*! The prefix for the value. I.e "$" */ + /*! \qmlproperty string SpinBox::prefix + The prefix for the value. I.e "$" */ property alias prefix: validator.prefix - /*! This property indicates the amount of decimals. + /*! \qmlproperty int SpinBox::decimals + This property indicates the amount of decimals. Note that if you enter more decimals than specified, they will be truncated to the specified amount of decimal places. The default value is \c{0}. diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml index 0adb4282..aba7809f 100644 --- a/src/controls/SplitView.qml +++ b/src/controls/SplitView.qml @@ -53,13 +53,14 @@ import QtQuick.Controls.Private 1.0 as Private SplitView is a control that lays out items horizontally or vertically with a draggable splitter between each item. - There will always be one (and only one) item in the SplitView that has \l {Layout}{Layout.fillWidth} - set to \c true (or Layout.fillHeight, if orientation is Qt.Vertical). This means that the + There will always be one (and only one) item in the SplitView that has \l{Layout::fillWidth}{Layout.fillWidth} + set to \c true (or \l{Layout::fillHeight}{Layout.fillHeight}, if orientation is Qt.Vertical). This means that the item will get all leftover space when other items have been laid out. By default, the last visible child of the SplitView will have this set, but it can be changed by explicitly setting fillWidth to \c true on another item. As the fillWidth item will automatically be resized to fit the extra space, explicit assignments - to width and height will be ignored (but Layout.minimumWidth and Layout.maximumWidth will still be respected). + to width and height will be ignored (but \l{Layout::minimumWidth}{Layout.minimumWidth} and + \l{Layout::maximumWidth}{Layout.maximumWidth} will still be respected). A handle can belong to the item either on the left or top side, or on the right or bottom side: \list @@ -69,9 +70,19 @@ import QtQuick.Controls.Private 1.0 as Private This will again control which item gets resized when the user drags a handle, and which handle gets hidden when an item is told to hide. - SplitView supports setting attached \l Layout properties on child items, which means that you - can control minimumWidth, minimumHeight, maximumWidth and maximumHeight (in addition - to fillWidth/fillHeight) for each child. + + SplitView supports setting attached Layout properties on child items, which + means that you can set the following attached properties for each child: + \list + \li \l{Layout::minimumWidth}{Layout.minimumWidth} + \li \l{Layout::minimumHeight}{Layout.minimumHeight} + \li \l{Layout::preferredWidth}{Layout.preferredWidth} + \li \l{Layout::preferredHeight}{Layout.preferredHeight} + \li \l{Layout::maximumWidth}{Layout.maximumWidth} + \li \l{Layout::maximumHeight}{Layout.maximumHeight} + \li \l{Layout::fillWidth}{Layout.fillWidth} (\c true for only one child) + \li \l{Layout::fillHeight}{Layout.fillHeight} (\c true for only one child) + \endlist Example: diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml index 6dab90fd..43cc347c 100644 --- a/src/controls/TextArea.qml +++ b/src/controls/TextArea.qml @@ -621,7 +621,7 @@ ScrollView { Accessible.role: Accessible.EditableText /*! - \qmlproperty textDocument TextArea::textDocument + \qmlproperty TextDocument TextArea::textDocument This property exposes the \l QTextDocument of this TextArea. \sa TextEdit::textDocument -- cgit v1.2.1 From f6a716a11a26e2ce76f8ed71ad1733e939ca468b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 29 May 2013 16:17:02 +0200 Subject: Remove remaining references to PageStack Change-Id: I59a9846c83340d0752659ef22cbb19a4be6a4129 Reviewed-by: Jens Bache-Wiig Reviewed-by: Gabriel de Dietrich --- .../quick/controls/touch/content/ButtonPage.qml | 2 +- examples/quick/controls/touch/main.qml | 12 ++-- src/controls/StackView.qml | 6 +- src/controls/plugins.qmltypes | 4 +- src/controls/qquickstack.cpp | 24 +++---- src/controls/qquickstack_p.h | 12 ++-- tests/auto/controls/data/tst_pagestack.qml | 77 ---------------------- tests/auto/controls/data/tst_stack.qml | 6 +- tests/auto/controls/data/tst_stackview.qml | 77 ++++++++++++++++++++++ 9 files changed, 110 insertions(+), 110 deletions(-) delete mode 100644 tests/auto/controls/data/tst_pagestack.qml create mode 100644 tests/auto/controls/data/tst_stackview.qml diff --git a/examples/quick/controls/touch/content/ButtonPage.qml b/examples/quick/controls/touch/content/ButtonPage.qml index 635ce3b9..f431a52e 100644 --- a/examples/quick/controls/touch/content/ButtonPage.qml +++ b/examples/quick/controls/touch/content/ButtonPage.qml @@ -86,7 +86,7 @@ Item { anchors.margins: 20 style: touchStyle text: "Dont press me" - onClicked: if (pageStack) pageStack.pop() + onClicked: if (stackView) stackView.pop() } } diff --git a/examples/quick/controls/touch/main.qml b/examples/quick/controls/touch/main.qml index 3058a0d3..9f93cb78 100644 --- a/examples/quick/controls/touch/main.qml +++ b/examples/quick/controls/touch/main.qml @@ -54,8 +54,8 @@ ApplicationWindow { // Implements back key navigation Keys.onReleased: { if (event.key === Qt.Key_Back) { - if (pageStack.depth > 1) { - pageStack.pop(); + if (stackView.depth > 1) { + stackView.pop(); event.accepted = true; } else { Qt.quit(); } } @@ -72,7 +72,7 @@ ApplicationWindow { width: opacity ? 60 : 0 anchors.left: parent.left anchors.leftMargin: 20 - opacity: pageStack.depth > 1 ? 1 : 0 + opacity: stackView.depth > 1 ? 1 : 0 anchors.verticalCenter: parent.verticalCenter antialiasing: true height: 60 @@ -87,7 +87,7 @@ ApplicationWindow { id: backmouse anchors.fill: parent anchors.margins: -10 - onClicked: pageStack.pop() + onClicked: stackView.pop() } } @@ -126,7 +126,7 @@ ApplicationWindow { } StackView { - id: pageStack + id: stackView anchors.fill: parent initialItem: Item { @@ -137,7 +137,7 @@ ApplicationWindow { anchors.fill: parent delegate: AndroidDelegate { text: title - onClicked: pageStack.push(Qt.resolvedUrl(page)) + onClicked: stackView.push(Qt.resolvedUrl(page)) } } } diff --git a/src/controls/StackView.qml b/src/controls/StackView.qml index c7b2366f..2c760e89 100644 --- a/src/controls/StackView.qml +++ b/src/controls/StackView.qml @@ -797,7 +797,7 @@ Item { } element.item.Stack.__index = element.index - element.item.Stack.__stackView = root + element.item.Stack.__view = root // Let item fill all available space by default: element.item.width = Qt.binding(function() { return root.width }) element.item.height = Qt.binding(function() { return root.height }) @@ -842,7 +842,7 @@ Item { // might reenter on pop if pushed several times: item.visible = false __setStatus(item, Stack.Inactive) - item.Stack.__stackView = null + item.Stack.__view = null item.Stack.__index = -1 if (element.originalParent) item.parent = element.originalParent @@ -871,7 +871,7 @@ Item { // Since an item can be pushed several times, we need to update its properties: enterItem.parent = root - enterItem.Stack.__stackView = root + enterItem.Stack.__view = root enterItem.Stack.__index = transition.inElement.index __currentItem = enterItem diff --git a/src/controls/plugins.qmltypes b/src/controls/plugins.qmltypes index 8997cecf..bd8508da 100644 --- a/src/controls/plugins.qmltypes +++ b/src/controls/plugins.qmltypes @@ -199,7 +199,7 @@ Module { Property { name: "__index"; type: "int" } Property { name: "status"; type: "Status"; isReadonly: true } Property { name: "__status"; type: "Status" } - Property { name: "pageStack"; type: "QQuickItem"; isReadonly: true; isPointer: true } - Property { name: "__stackView"; type: "QQuickItem"; isPointer: true } + Property { name: "view"; type: "QQuickItem"; isReadonly: true; isPointer: true } + Property { name: "__view"; type: "QQuickItem"; isPointer: true } } } diff --git a/src/controls/qquickstack.cpp b/src/controls/qquickstack.cpp index 1723ef72..5d3accff 100644 --- a/src/controls/qquickstack.cpp +++ b/src/controls/qquickstack.cpp @@ -64,7 +64,7 @@ QQuickStack::QQuickStack(QObject *object) : QObject(object), m_index(-1), m_status(Inactive), - m_pageStack(0) + m_view(0) { } @@ -77,9 +77,9 @@ QQuickStack *QQuickStack::qmlAttachedProperties(QObject *object) \readonly \qmlproperty int Stack::index - This property holds the index of the item inside \l{pageStack}{StackView}, - so that \l{StackView::get()}{pageStack.get(index)} will return the item itself. - If \l{Stack::pageStack}{pageStack} is \c null, \a index will be \c -1. + This property holds the index of the item inside \l{view}{StackView}, + so that \l{StackView::get()}{StackView.get(index)} will return the item itself. + If \l{Stack::view}{view} is \c null, \a index will be \c -1. */ int QQuickStack::index() const { @@ -121,21 +121,21 @@ void QQuickStack::setStatus(Status status) /*! \readonly - \qmlproperty StackView Stack::pageStack + \qmlproperty StackView Stack::view This property holds the StackView the item is in. If the item is not inside - a StackView, \a pageStack will be \c null. + a StackView, \a view will be \c null. */ -QQuickItem *QQuickStack::pageStack() const +QQuickItem *QQuickStack::view() const { - return m_pageStack; + return m_view; } -void QQuickStack::setStackView(QQuickItem *pageStack) +void QQuickStack::setView(QQuickItem *view) { - if (m_pageStack != pageStack) { - m_pageStack = pageStack; - emit pageStackChanged(); + if (m_view != view) { + m_view = view; + emit viewChanged(); } } diff --git a/src/controls/qquickstack_p.h b/src/controls/qquickstack_p.h index a4b36644..c34dd1a3 100644 --- a/src/controls/qquickstack_p.h +++ b/src/controls/qquickstack_p.h @@ -53,8 +53,8 @@ class QQuickStack : public QObject Q_PROPERTY(int __index READ index WRITE setIndex NOTIFY indexChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) Q_PROPERTY(Status __status READ status WRITE setStatus NOTIFY statusChanged) - Q_PROPERTY(QQuickItem* pageStack READ pageStack NOTIFY pageStackChanged) - Q_PROPERTY(QQuickItem* __stackView READ pageStack WRITE setStackView NOTIFY pageStackChanged) + Q_PROPERTY(QQuickItem* view READ view NOTIFY viewChanged) + Q_PROPERTY(QQuickItem* __view READ view WRITE setView NOTIFY viewChanged) Q_ENUMS(Status) public: @@ -75,18 +75,18 @@ public: Status status() const; void setStatus(Status status); - QQuickItem *pageStack() const; - void setStackView(QQuickItem *pageStack); + QQuickItem *view() const; + void setView(QQuickItem *view); signals: void statusChanged(); - void pageStackChanged(); + void viewChanged(); void indexChanged(); private: int m_index; Status m_status; - QQuickItem *m_pageStack; + QQuickItem *m_view; }; QT_END_NAMESPACE diff --git a/tests/auto/controls/data/tst_pagestack.qml b/tests/auto/controls/data/tst_pagestack.qml deleted file mode 100644 index b20556fb..00000000 --- a/tests/auto/controls/data/tst_pagestack.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Controls 1.0 - -TestCase { - id: testCase - name: "Tests_StackView" - when: windowShown - width: 400 - height: 400 - - Item { id: anItem } - Component { - id: pageComponent - Item {} - } - - Component { - id: stackComponent - StackView {} - } - - function test_pagestack() { - var component = stackComponent - var stack = component.createObject(testCase); - verify (stack !== null, "pagestack created is null") - verify (stack.depth === 0) - stack.push(anItem) - verify (stack.depth === 1) - stack.push(anItem) - verify (stack.depth === 2) - stack.pop() - verify (stack.depth === 1) - stack.push(pageComponent) - verify (stack.depth === 2) - } -} diff --git a/tests/auto/controls/data/tst_stack.qml b/tests/auto/controls/data/tst_stack.qml index fa833680..a7363de7 100644 --- a/tests/auto/controls/data/tst_stack.qml +++ b/tests/auto/controls/data/tst_stack.qml @@ -58,8 +58,8 @@ TestCase { compare(item.status, 0); // Stack.Inactive } - function test_pageStack() { - var item = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; Item { property StackView pageStack: Stack.pageStack }', testCase, ''); - compare(item.pageStack, null); + function test_view() { + var item = Qt.createQmlObject('import QtQuick 2.0; import QtQuick.Controls 1.0; Item { property StackView view: Stack.view }', testCase, ''); + compare(item.view, null); } } diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml new file mode 100644 index 00000000..3daac785 --- /dev/null +++ b/tests/auto/controls/data/tst_stackview.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** 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 QtQuick.Controls 1.0 + +TestCase { + id: testCase + name: "Tests_StackView" + when: windowShown + width: 400 + height: 400 + + Item { id: anItem } + Component { + id: pageComponent + Item {} + } + + Component { + id: stackComponent + StackView {} + } + + function test_stackview() { + var component = stackComponent + var stack = component.createObject(testCase); + verify (stack !== null, "stackview created is null") + verify (stack.depth === 0) + stack.push(anItem) + verify (stack.depth === 1) + stack.push(anItem) + verify (stack.depth === 2) + stack.pop() + verify (stack.depth === 1) + stack.push(pageComponent) + verify (stack.depth === 2) + } +} -- cgit v1.2.1 From cf6f7de3f03d52174f3dfa57031159caa4e7be31 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Wed, 29 May 2013 15:34:48 +0200 Subject: Do not crash when deleting a layout onItemVisibleChanged() was in some cases called after the dtor of QQuickGridLayoutBase was called. After having called the dtor of QQuickGridLayoutBase it would continue to call the dtors of its base classes until it entered the dtor of QQuickItem. In QQuickItem it would call setParentItem(0) on all its child items. This caused the item to become visible again, thus it would emit visibleChanged() and finally invoke QQuickGridLayoutBase::onItemVisibleChanged() which lead to the crash (while trying to call the virtual invalidate()) The fix is to do an early return if we know that the layout is in the destruction phase. isReady() will return only true *after* the component is completed, and before the component is destructing. Task-number: QTBUG-31276 Change-Id: I191e348278e3d052c109bffb92a1ccd9326859bd Reviewed-by: Jens Bache-Wiig --- src/layouts/qquicklinearlayout.cpp | 29 ++++++++++++++++++++++------- src/layouts/qquicklinearlayout_p.h | 7 ++++--- tests/auto/controls/data/tst_rowlayout.qml | 20 ++++++++++++++++++++ 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/layouts/qquicklinearlayout.cpp b/src/layouts/qquicklinearlayout.cpp index b9a8e224..13b582f9 100644 --- a/src/layouts/qquicklinearlayout.cpp +++ b/src/layouts/qquicklinearlayout.cpp @@ -184,12 +184,18 @@ QSizeF QQuickGridLayoutBase::sizeHint(Qt::SizeHint whichSizeHint) const return d->engine.sizeHint(whichSizeHint, QSizeF()); } +QQuickGridLayoutBase::~QQuickGridLayoutBase() +{ + d_func()->m_isReady = false; +} + void QQuickGridLayoutBase::componentComplete() { Q_D(QQuickGridLayoutBase); quickLayoutDebug() << objectName() << "QQuickGridLayoutBase::componentComplete()" << parent(); d->m_disableRearrange = true; QQuickLayout::componentComplete(); // will call our geometryChange(), (where isComponentComplete() == true) + d->m_isReady = true; d->m_disableRearrange = false; updateLayoutItems(); @@ -235,7 +241,7 @@ void QQuickGridLayoutBase::componentComplete() void QQuickGridLayoutBase::invalidate(QQuickItem *childItem) { Q_D(QQuickGridLayoutBase); - if (!isComponentComplete()) + if (!isReady()) return; quickLayoutDebug() << "QQuickGridLayoutBase::invalidate()"; @@ -274,7 +280,7 @@ void QQuickGridLayoutBase::invalidate(QQuickItem *childItem) void QQuickGridLayoutBase::updateLayoutItems() { Q_D(QQuickGridLayoutBase); - if (!isComponentComplete() || !isVisible()) + if (!isReady() || !isVisible()) return; quickLayoutDebug() << "QQuickGridLayoutBase::updateLayoutItems"; d->engine.deleteItems(); @@ -294,7 +300,7 @@ void QQuickGridLayoutBase::itemChange(ItemChange change, const ItemChangeData &v QObject::connect(item, SIGNAL(implicitWidthChanged()), this, SLOT(onItemImplicitSizeChanged())); QObject::connect(item, SIGNAL(implicitHeightChanged()), this, SLOT(onItemImplicitSizeChanged())); - if (isComponentComplete() && isVisible()) + if (isReady() && isVisible()) updateLayoutItems(); } else if (change == ItemChildRemovedChange) { quickLayoutDebug() << "ItemChildRemovedChange"; @@ -303,7 +309,7 @@ void QQuickGridLayoutBase::itemChange(ItemChange change, const ItemChangeData &v QObject::disconnect(item, SIGNAL(visibleChanged()), this, SLOT(onItemVisibleChanged())); QObject::disconnect(item, SIGNAL(implicitWidthChanged()), this, SLOT(onItemImplicitSizeChanged())); QObject::disconnect(item, SIGNAL(implicitHeightChanged()), this, SLOT(onItemImplicitSizeChanged())); - if (isComponentComplete() && isVisible()) + if (isReady() && isVisible()) updateLayoutItems(); } @@ -314,7 +320,7 @@ void QQuickGridLayoutBase::geometryChanged(const QRectF &newGeometry, const QRec { Q_D(QQuickGridLayoutBase); QQuickLayout::geometryChanged(newGeometry, oldGeometry); - if (d->m_disableRearrange || !isComponentComplete() || !newGeometry.isValid()) + if (d->m_disableRearrange || !isReady() || !newGeometry.isValid()) return; quickLayoutDebug() << "QQuickGridLayoutBase::geometryChanged" << newGeometry << oldGeometry; rearrange(newGeometry.size()); @@ -328,6 +334,11 @@ void QQuickGridLayoutBase::removeGridItem(QGridLayoutItem *gridItem) d->engine.removeRows(index, 1, d->orientation); } +bool QQuickGridLayoutBase::isReady() const +{ + return d_func()->m_isReady; +} + void QQuickGridLayoutBase::removeLayoutItem(QQuickItem *item) { Q_D(QQuickGridLayoutBase); @@ -341,7 +352,7 @@ void QQuickGridLayoutBase::removeLayoutItem(QQuickItem *item) void QQuickGridLayoutBase::onItemVisibleChanged() { - if (!isComponentComplete()) + if (!isReady()) return; quickLayoutDebug() << "QQuickGridLayoutBase::onItemVisibleChanged"; updateLayoutItems(); @@ -349,6 +360,8 @@ void QQuickGridLayoutBase::onItemVisibleChanged() void QQuickGridLayoutBase::onItemDestroyed() { + if (!isReady()) + return; Q_D(QQuickGridLayoutBase); quickLayoutDebug() << "QQuickGridLayoutBase::onItemDestroyed"; QQuickItem *inDestruction = static_cast(sender()); @@ -361,6 +374,8 @@ void QQuickGridLayoutBase::onItemDestroyed() void QQuickGridLayoutBase::onItemImplicitSizeChanged() { + if (!isReady()) + return; QQuickItem *item = static_cast(sender()); Q_ASSERT(item); invalidate(item); @@ -369,7 +384,7 @@ void QQuickGridLayoutBase::onItemImplicitSizeChanged() void QQuickGridLayoutBase::rearrange(const QSizeF &size) { Q_D(QQuickGridLayoutBase); - if (!isComponentComplete()) + if (!isReady()) return; quickLayoutDebug() << objectName() << "QQuickGridLayoutBase::rearrange()" << size; diff --git a/src/layouts/qquicklinearlayout_p.h b/src/layouts/qquicklinearlayout_p.h index 76cc206b..b38bd97f 100644 --- a/src/layouts/qquicklinearlayout_p.h +++ b/src/layouts/qquicklinearlayout_p.h @@ -62,8 +62,7 @@ public: explicit QQuickGridLayoutBase(QQuickGridLayoutBasePrivate &dd, Qt::Orientation orientation, QQuickItem *parent = 0); - ~QQuickGridLayoutBase() {} - + ~QQuickGridLayoutBase(); void componentComplete(); void invalidate(QQuickItem *childItem = 0); Qt::Orientation orientation() const; @@ -86,6 +85,7 @@ protected slots: private: void removeGridItem(QGridLayoutItem *gridItem); + bool isReady() const; Q_DECLARE_PRIVATE(QQuickGridLayoutBase) }; @@ -95,10 +95,11 @@ class QQuickGridLayoutBasePrivate : public QQuickLayoutPrivate Q_DECLARE_PUBLIC(QQuickGridLayoutBase) public: - QQuickGridLayoutBasePrivate() : m_disableRearrange(true) { } + QQuickGridLayoutBasePrivate() : m_disableRearrange(true), m_isReady(false) { } QQuickGridLayoutEngine engine; Qt::Orientation orientation; bool m_disableRearrange; + bool m_isReady; QSet m_ignoredItems; }; diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml index fd21f475..458a2885 100644 --- a/tests/auto/controls/data/tst_rowlayout.qml +++ b/tests/auto/controls/data/tst_rowlayout.qml @@ -633,5 +633,25 @@ Item { compare(r1.y, 6) // 5.5 layout.destroy(); } + + + Component { + id: layout_deleteLayout + ColumnLayout { + property int dummyproperty: 0 // yes really - its needed + RowLayout { + Text { text: "label1" } // yes, both are needed + Text { text: "label2" } + } + } + } + + function test_destroyLayout() + { + var layout = layout_deleteLayout.createObject(container) + layout.children[0].children[0].visible = true + layout.visible = false + layout.destroy() // Do not crash + } } } -- cgit v1.2.1 From c94a6f44d5d1ba5532de48419ce10ef9000d4511 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Thu, 30 May 2013 10:34:06 +0200 Subject: Doc: Make Stack attached properties more visible And use \qmlattachedproperty instead of \qmlproperty for properties in the Stack. Change-Id: I1ffbd84ce91fd5a9040c082a8bcb403589becf91 Reviewed-by: J-P Nurmi Reviewed-by: Jerome Pasion --- src/controls/StackView.qml | 11 +++++++++++ src/controls/qquickstack.cpp | 15 ++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/controls/StackView.qml b/src/controls/StackView.qml index 2c760e89..be1ddf06 100644 --- a/src/controls/StackView.qml +++ b/src/controls/StackView.qml @@ -65,6 +65,8 @@ import "Private/StackView.js" as JSArray The stack can then be used by invoking its navigation methods. The first item to show in the StackView is commonly loaded assigning it to \l initialItem. + \note Items pushed onto the stack view have \l{Supported Attached Properties}{Stack attached properties}. + \section1 Basic Navigation There are three primary navigation operations in StackView: push(), pop() and replace (you replace by specifying argument \c replace to push()). @@ -435,6 +437,15 @@ import "Private/StackView.js" as JSArray } } \endqml + + \section1 Supported Attached Properties + + Items in a StackView support these attached properties: + \list + \li \l{Stack::index}{Stack.index} - Contains the index of the item inside the StackView + \li \l{Stack::view}{Stack.view} - Contains the StackView the item is in + \li \l{Stack::status}{Stack.status} - Contains the status of the item + \endlist */ Item { diff --git a/src/controls/qquickstack.cpp b/src/controls/qquickstack.cpp index 5d3accff..ecf873d7 100644 --- a/src/controls/qquickstack.cpp +++ b/src/controls/qquickstack.cpp @@ -50,12 +50,9 @@ QT_BEGIN_NAMESPACE \ingroup views \brief Provides attached properties for items pushed onto a StackView. - The Stack attached property provides information when an item becomes - active or inactive through the \l{Stack::status}{Stack.status} property. - Status will be \c Stack.Activating when an item is transitioning into - being the current item on the screen, and \c Stack.Active once the - transition stops. When it leaves the screen, it will be - \c Stack.Deactivating, and then \c Stack.Inactive. + The Stack type provides attached properties for items pushed onto a \l StackView. + It gives specific information about the item, such as its \l status and + \l index in the stack \l view the item is in. \sa StackView */ @@ -75,7 +72,7 @@ QQuickStack *QQuickStack::qmlAttachedProperties(QObject *object) /*! \readonly - \qmlproperty int Stack::index + \qmlattachedproperty int Stack::index This property holds the index of the item inside \l{view}{StackView}, so that \l{StackView::get()}{StackView.get(index)} will return the item itself. @@ -96,7 +93,7 @@ void QQuickStack::setIndex(int index) /*! \readonly - \qmlproperty enumeration Stack::status + \qmlattachedproperty enumeration Stack::status This property holds the status of the item. It can have one of the following values: \list @@ -121,7 +118,7 @@ void QQuickStack::setStatus(Status status) /*! \readonly - \qmlproperty StackView Stack::view + \qmlattachedproperty StackView Stack::view This property holds the StackView the item is in. If the item is not inside a StackView, \a view will be \c null. -- cgit v1.2.1 From c5d39cb125a0fe1080e32a2cade0975d4f99832f Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Fri, 24 May 2013 16:49:59 +0200 Subject: Several improvements to documentation * List all applicable attached properties for each layout * Move the stuff that describes min,pref and max sizes from GridLayout to the Layout docs. * Document that all layouts \inherits Item. (Even if they don't directly inherit, this is consistent with how the positioners are documented) * Add some links to Row, Column and Grid where appropriate * Use \qmlattachedproperty instead of \qmlproperty for the attached properties. (Again, consistent with how the Positioners attached properties are documented) * Change POSITIVE_INFINITE to the correct POSITIVE_INFINITY Change-Id: Ia9272faa479b48a97300b031402c0380ca113d7b Reviewed-by: Caroline Chao Reviewed-by: Jerome Pasion --- src/layouts/doc/src/qtquicklayouts-index.qdoc | 12 +++-- src/layouts/qquicklayout.cpp | 60 +++++++++++++++-------- src/layouts/qquicklinearlayout.cpp | 68 ++++++++++++++++++--------- 3 files changed, 96 insertions(+), 44 deletions(-) diff --git a/src/layouts/doc/src/qtquicklayouts-index.qdoc b/src/layouts/doc/src/qtquicklayouts-index.qdoc index fdc1c70a..c2280f5d 100644 --- a/src/layouts/doc/src/qtquicklayouts-index.qdoc +++ b/src/layouts/doc/src/qtquicklayouts-index.qdoc @@ -29,7 +29,14 @@ \page qtquicklayouts-index.html \title Qt Quick Layouts - \brief A module with a set of QML elements that arranges QML items in an user interface. + \brief A module with a set of QML elements that arrange QML items in a user interface. + + Qt Quick Layouts are a set of QML types used to arrange items in a user interface. In contrast + to \l{Item Positioners}{positioners}, Qt Quick Layouts can also resize their items. This makes + them well suited for resizable user interfaces. Since layouts are items they can consequently + be nested. + + The module is new in Qt 5.1 and requires \l{Qt Quick} 2.1. \section1 Getting started @@ -40,9 +47,6 @@ \endcode \section1 Layouts - Layouts are items that are used to arrange items in the user interface. The layout is dynamic - - when the layout changes geometry it will typically influence the arrangement of its child - items. Since a layout is an item, layouts can consequently be nested. \annotatedlist layouts diff --git a/src/layouts/qquicklayout.cpp b/src/layouts/qquicklayout.cpp index 48b80255..86eac072 100644 --- a/src/layouts/qquicklayout.cpp +++ b/src/layouts/qquicklayout.cpp @@ -60,11 +60,33 @@ For instance, you can specify \l minimumWidth, \l preferredWidth, and \l maximumWidth if the default values are not satisfactory. - \l fillWidth and \l fillHeight allows you to specify whether an item should - fill the cell(s) it occupies. This allows it to stretch between \l minimumWidth - and \l maximumWidth (or \l minimumHeight and \l maximumHeight if \l fillHeight is \c true). + When a layout is resized, items may grow or shrink. Due to this, items have a + \l{Layout::minimumWidth}{minimum size}, \l{Layout::preferredWidth}{preferred size} and a + \l{Layout::maximumWidth}{maximum size}. + + For each item, preferred size may come from one of several sources. It can be specified with + the \l preferredWidth and \l preferredHeight properties. If these properties are not + specified, it will use the item's \l{Item::implicitWidth}{implicitWidth} or + \l{Item::implicitHeight}{implicitHeight} as the preferred size. + Finally, if neither of these properties are set, it will use the \l{Item::width}{width} and + \l{Item::height}{height} properties of the item. Note that is provided only as a final + fallback. If you want to override the preferred size, you should use + \l preferredWidth or \l preferredHeight. + + If minimum size have not been explicitly specified on an item, the size is set to \c 0. + If maximum size have not been explicitly specified on an item, the size is set to + \c Number.POSITIVE_INFINITY. + + For layouts, the implicit minimum and maximum size depends on the content of the layouts. + + The \l fillWidth and \l fillHeight properties can either be \c true or \c false. If it is \c + false, the item's size will be fixed to its preferred size. Otherwise, it will grow or shrink + between its minimum and maximum size as the layout is resized. + + \note It is not recommended to have bindings to the x, y, width, or height properties of items + in a layout, since this would conflict with the goal of the Layout, and also cause binding + loops. - If \l fillWidth or \l fillHeight is \c false, the items' size will be fixed to its preferred size. \sa GridLayout \sa RowLayout @@ -100,7 +122,7 @@ QQuickLayoutAttached::QQuickLayoutAttached(QObject *parent) } /*! - \qmlproperty real Layout::minimumWidth + \qmlattachedproperty real Layout::minimumWidth This property holds the maximum width of an item in a layout. The default value is the items implicit minimum width. @@ -129,7 +151,7 @@ void QQuickLayoutAttached::setMinimumWidth(qreal width) } /*! - \qmlproperty real Layout::minimumHeight + \qmlattachedproperty real Layout::minimumHeight The default value is the items implicit minimum height. @@ -156,7 +178,7 @@ void QQuickLayoutAttached::setMinimumHeight(qreal height) } /*! - \qmlproperty real Layout::preferredWidth + \qmlattachedproperty real Layout::preferredWidth This property holds the preferred width of an item in a layout. If the preferred width is -1 it will be ignored, and the layout @@ -177,7 +199,7 @@ void QQuickLayoutAttached::setPreferredWidth(qreal width) } /*! - \qmlproperty real Layout::preferredHeight + \qmlattachedproperty real Layout::preferredHeight This property holds the preferred height of an item in a layout. If the preferred height is -1 it will be ignored, and the layout @@ -198,14 +220,14 @@ void QQuickLayoutAttached::setPreferredHeight(qreal height) } /*! - \qmlproperty real Layout::maximumWidth + \qmlattachedproperty real Layout::maximumWidth This property holds the maximum width of an item in a layout. The default value is the items implicit maximum width. If the item is a layout, the implicit maximum width will be the maximum width the layout can have without any of its items grow beyond their maximum width. - The implicit maximum width for any other item is \c Number.POSITIVE_INFINITE. + The implicit maximum width for any other item is \c Number.POSITIVE_INFINITY. Setting this value to -1 will reset the width back to its implicit maximum width. @@ -226,13 +248,13 @@ void QQuickLayoutAttached::setMaximumWidth(qreal width) } /*! - \qmlproperty real Layout::maximumHeight + \qmlattachedproperty real Layout::maximumHeight The default value is the items implicit maximum height. If the item is a layout, the implicit maximum height will be the maximum height the layout can have without any of its items grow beyond their maximum height. - The implicit maximum height for any other item is \c Number.POSITIVE_INFINITE. + The implicit maximum height for any other item is \c Number.POSITIVE_INFINITY. Setting this value to -1 will reset the height back to its implicit maximum height. @@ -299,7 +321,7 @@ void QQuickLayoutAttached::setMaximumImplicitSize(const QSizeF &sz) } /*! - \qmlproperty bool Layout::fillWidth + \qmlattachedproperty bool Layout::fillWidth If this property is \c true, the item will be as wide as possible while respecting the given constraints. If the property is \c false, the item will have a fixed width @@ -319,7 +341,7 @@ void QQuickLayoutAttached::setFillWidth(bool fill) } /*! - \qmlproperty bool Layout::fillHeight + \qmlattachedproperty bool Layout::fillHeight If this property is \c true, the item will be as tall as possible while respecting the given constraints. If the property is \c false, the item will have a fixed height @@ -339,7 +361,7 @@ void QQuickLayoutAttached::setFillHeight(bool fill) } /*! - \qmlproperty int Layout::row + \qmlattachedproperty int Layout::row This property allows you to specify the row position of an item in a \l GridLayout. @@ -357,7 +379,7 @@ void QQuickLayoutAttached::setRow(int row) } /*! - \qmlproperty int Layout::column + \qmlattachedproperty int Layout::column This property allows you to specify the column position of an item in a \l GridLayout. @@ -376,7 +398,7 @@ void QQuickLayoutAttached::setColumn(int column) /*! - \qmlproperty Qt.Alignment Layout::alignment + \qmlattachedproperty Qt.Alignment Layout::alignment This property allows you to specify the alignment of an item within the cell(s) it occupies. @@ -385,7 +407,7 @@ void QQuickLayoutAttached::setColumn(int column) /*! - \qmlproperty int Layout::rowSpan + \qmlattachedproperty int Layout::rowSpan This property allows you to specify the row span of an item in a \l GridLayout. @@ -397,7 +419,7 @@ void QQuickLayoutAttached::setColumn(int column) /*! - \qmlproperty int Layout::columnSpan + \qmlattachedproperty int Layout::columnSpan This property allows you to specify the column span of an item in a \l GridLayout. diff --git a/src/layouts/qquicklinearlayout.cpp b/src/layouts/qquicklinearlayout.cpp index 13b582f9..7c48248b 100644 --- a/src/layouts/qquicklinearlayout.cpp +++ b/src/layouts/qquicklinearlayout.cpp @@ -48,33 +48,63 @@ /*! \qmltype RowLayout \instantiates QQuickRowLayout + \inherits Item \inqmlmodule QtQuick.Layouts 1.0 \ingroup layouts \brief Identical to \l GridLayout, but having only one row. It is available as a convenience for developers, as it offers a cleaner API. + Items in a RowLayout support these attached properties: + \list + \li \l{Layout::minimumWidth}{Layout.minimumWidth} + \li \l{Layout::minimumHeight}{Layout.minimumHeight} + \li \l{Layout::preferredWidth}{Layout.preferredWidth} + \li \l{Layout::preferredHeight}{Layout.preferredHeight} + \li \l{Layout::maximumWidth}{Layout.maximumWidth} + \li \l{Layout::maximumHeight}{Layout.maximumHeight} + \li \l{Layout::fillWidth}{Layout.fillWidth} + \li \l{Layout::fillHeight}{Layout.fillHeight} + \li \l{Layout::alignment}{Layout.alignment} + \endlist \sa ColumnLayout \sa GridLayout + \sa Row */ /*! \qmltype ColumnLayout \instantiates QQuickColumnLayout + \inherits Item \inqmlmodule QtQuick.Layouts 1.0 \ingroup layouts \brief Identical to \l GridLayout, but having only one column. It is available as a convenience for developers, as it offers a cleaner API. + Items in a ColumnLayout support these attached properties: + \list + \li \l{Layout::minimumWidth}{Layout.minimumWidth} + \li \l{Layout::minimumHeight}{Layout.minimumHeight} + \li \l{Layout::preferredWidth}{Layout.preferredWidth} + \li \l{Layout::preferredHeight}{Layout.preferredHeight} + \li \l{Layout::maximumWidth}{Layout.maximumWidth} + \li \l{Layout::maximumHeight}{Layout.maximumHeight} + \li \l{Layout::fillWidth}{Layout.fillWidth} + \li \l{Layout::fillHeight}{Layout.fillHeight} + \li \l{Layout::alignment}{Layout.alignment} + \endlist + \sa RowLayout \sa GridLayout + \sa Column */ /*! \qmltype GridLayout \instantiates QQuickGridLayout + \inherits Item \inqmlmodule QtQuick.Layouts 1.0 \ingroup layouts \brief Provides a way of dynamically arranging items in a grid. @@ -112,31 +142,27 @@ specify the row span or column span by setting the \l{Layout::rowSpan}{Layout.rowSpan} or \l{Layout::columnSpan}{Layout.columnSpan} properties. - When the layout is resized, items may grow or shrink. Due to this, items have a - \l{Layout::minimumWidth}{minimum size}, \l{Layout::preferredWidth}{preferred size} and a - \l{Layout::maximumWidth}{maximum size}. - Preferred size may come from one of several sources. It can be specified with the - \l{Layout::preferredWidth}{Layout.preferredWidth} and - \l{Layout::preferredHeight}{Layout.preferredHeight} properties. If these properties are not - specified, it will use the items' \l{Item::implicitWidth}{implicitWidth} or - \l{Item::implicitHeight}{implicitHeight} as the preferred size. - Finally, if neither of these properties are set, it will use the \l{Item::width}{width} and - \l{Item::height}{height} properties of the item. Note that is provided only as a final - fallback. If you want to override the preferred size, you should use - \l{Layout::preferredWidth}{Layout.preferredWidth} or - \l{Layout::preferredHeight}{Layout.preferredHeight}. - - The \l{Layout::fillWidth}{Layout.fillWidth} and \l{Layout::fillHeight}{Layout.fillHeight} can - either be \c true or \c false. If it is \c false, the items size will be fixed to its preferred - size. Otherwise, it will grow or shrink between its minimum and maximum size. - - \note It is not recommended to have bindings to the width and height properties of items in a - GridLayout, since this would conflict with the goal of the GridLayout. + Items in a GridLayout support these attached properties: + \list + \li \l{Layout::row}{Layout.row} + \li \l{Layout::column}{Layout.column} + \li \l{Layout::rowSpan}{Layout.rowSpan} + \li \l{Layout::columnSpan}{Layout.columnSpan} + \li \l{Layout::minimumWidth}{Layout.minimumWidth} + \li \l{Layout::minimumHeight}{Layout.minimumHeight} + \li \l{Layout::preferredWidth}{Layout.preferredWidth} + \li \l{Layout::preferredHeight}{Layout.preferredHeight} + \li \l{Layout::maximumWidth}{Layout.maximumWidth} + \li \l{Layout::maximumHeight}{Layout.maximumHeight} + \li \l{Layout::fillWidth}{Layout.fillWidth} + \li \l{Layout::fillHeight}{Layout.fillHeight} + \li \l{Layout::alignment}{Layout.alignment} + \endlist \sa RowLayout \sa ColumnLayout - + \sa Grid */ -- cgit v1.2.1 From 1ddffbee547a702fad0669393dcf8e739007fbf1 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 30 May 2013 16:47:03 +0200 Subject: Styles docs: fix the styleData -tables Change-Id: I75fb45d3f6b7b93f5758bd1664f9ff674a492772 Reviewed-by: Jens Bache-Wiig --- src/styles/Base/ButtonStyle.qml | 4 ++-- src/styles/Base/CheckBoxStyle.qml | 16 +++++++++++++-- src/styles/Base/ComboBoxStyle.qml | 4 ++-- src/styles/Base/RadioButtonStyle.qml | 4 ++-- src/styles/Base/ScrollViewStyle.qml | 38 ++++++++++++++++++------------------ src/styles/Base/TabViewStyle.qml | 15 +++++++------- 6 files changed, 47 insertions(+), 34 deletions(-) diff --git a/src/styles/Base/ButtonStyle.qml b/src/styles/Base/ButtonStyle.qml index fe37d170..b1fabb86 100644 --- a/src/styles/Base/ButtonStyle.qml +++ b/src/styles/Base/ButtonStyle.qml @@ -96,7 +96,7 @@ Style { properties of \c control, the following state properties are available: \table - \li readonly property bool styleData.hovered - The control is being hovered. + \row \li readonly property bool \b styleData.hovered \li The control is being hovered. \endtable */ property Component background: Item { @@ -139,7 +139,7 @@ Style { properties of \c control, the following state properties are available: \table - \li readonly property bool styleData.hovered - The control is being hovered. + \row \li readonly property bool \b styleData.hovered \li The control is being hovered. \endtable */ property Component label: Text { diff --git a/src/styles/Base/CheckBoxStyle.qml b/src/styles/Base/CheckBoxStyle.qml index 4311c629..65b5450b 100644 --- a/src/styles/Base/CheckBoxStyle.qml +++ b/src/styles/Base/CheckBoxStyle.qml @@ -83,7 +83,13 @@ Style { SystemPalette.Active : SystemPalette.Disabled } - /*! The text label. */ + /*! This defines the text label. In addition to the public + properties of \c control, the following state properties are available: + + \table + \row \li readonly property bool \b styleData.hovered \li The control is being hovered. + \endtable + */ property Component label: Text { text: control.text color: __syspal.text @@ -102,7 +108,13 @@ Style { /*! The spacing between indicator and label. */ property int spacing: 4 - /*! The indicator button. */ + /*! This defines the indicator button. In addition to the public + properties of \c control, the following state properties are available: + + \table + \row \li readonly property bool \b styleData.hovered \li The control is being hovered. + \endtable + */ property Component indicator: Item { implicitWidth: 18 implicitHeight: 18 diff --git a/src/styles/Base/ComboBoxStyle.qml b/src/styles/Base/ComboBoxStyle.qml index 08382f15..982ce00e 100644 --- a/src/styles/Base/ComboBoxStyle.qml +++ b/src/styles/Base/ComboBoxStyle.qml @@ -66,7 +66,7 @@ Style { properties of \c control, the following state properties are available: \table - \li readonly property bool styleData.hovered - The control is being hovered. + \row \li readonly property bool \b styleData.hovered \li The control is being hovered. \endtable */ property Component background: Item { @@ -108,7 +108,7 @@ Style { properties of \c control, the following state properties are available: \table - \li readonly property bool styleData.hovered - The control is being hovered. + \row \li readonly property bool \b styleData.hovered \li The control is being hovered. \endtable */ property Component label: Item { diff --git a/src/styles/Base/RadioButtonStyle.qml b/src/styles/Base/RadioButtonStyle.qml index f8fdb647..d87f57c7 100644 --- a/src/styles/Base/RadioButtonStyle.qml +++ b/src/styles/Base/RadioButtonStyle.qml @@ -87,7 +87,7 @@ Style { properties of \c control, the following state properties are available: \table - \li readonly property bool styleData.hovered - The control is being hovered. + \row \li readonly property bool \b styleData.hovered \li The control is being hovered. \endtable */ property Component label: Text { @@ -107,7 +107,7 @@ Style { properties of \c control, the following state properties are available: \table - \li readonly property bool styleData.hovered - The control is being hovered. + \row \li readonly property bool \b styleData.hovered \li The control is being hovered. \endtable */ property Component indicator: Rectangle { diff --git a/src/styles/Base/ScrollViewStyle.qml b/src/styles/Base/ScrollViewStyle.qml index fb65fe2c..3d1f8d26 100644 --- a/src/styles/Base/ScrollViewStyle.qml +++ b/src/styles/Base/ScrollViewStyle.qml @@ -97,10 +97,10 @@ Style { You can access the following state properties: - \list - \li property bool styleData.hovered - \li property bool styleData.horizontal - \endlist + \table + \row \li property bool \b styleData.hovered + \row \li property bool \b styleData.horizontal + \endtable */ property Component scrollBarBackground: Item { @@ -123,11 +123,11 @@ Style { You can access the following state properties: - \list - \li property bool styleData.hovered - \li property bool styleData.pressed - \li property bool styleData.horizontal - \endlist + \table + \row \li property bool \b styleData.hovered + \row \li property bool \b styleData.pressed + \row \li property bool \b styleData.horizontal + \endtable */ property Component handle: BorderImage{ @@ -144,11 +144,11 @@ Style { You can access the following state properties: - \list - \li property bool styleData.hovered - \li property bool styleData.pressed - \li property bool styleData.horizontal - \endlist + \table + \row \li property bool \b styleData.hovered + \row \li property bool \b styleData.pressed + \row \li property bool \b styleData.horizontal + \endtable */ property Component incrementControl: Rectangle { implicitWidth: 16 @@ -181,11 +181,11 @@ Style { You can access the following state properties: - \list - \li property bool styleData.hovered - \li property bool styleData.pressed - \li property bool styleData.horizontal - \endlist + \table + \row \li property bool \b styleData.hovered + \row \li property bool \b styleData.pressed + \row \li property bool \b styleData.horizontal + \endtable */ property Component decrementControl: Rectangle { implicitWidth: 16 diff --git a/src/styles/Base/TabViewStyle.qml b/src/styles/Base/TabViewStyle.qml index 344412b6..a668f43b 100644 --- a/src/styles/Base/TabViewStyle.qml +++ b/src/styles/Base/TabViewStyle.qml @@ -122,13 +122,14 @@ Style { \c styleData property, with the following properties: \table - \li readonly property int styleData.index - This is the current tab index. - \li readonly property bool styleData.selected - This is the active tab. - \li readonly property string styleData.title - Tab title text. - \li readonly property bool styleData.nextSelected - The next tab is selected. - \li readonly property bool styleData.previousSelected - The previous tab is selected. - \li readonly property bool styleData.hovered - The tab is being hovered. - \li readonly property bool styleData.activeFocus - The tab button has keyboard focus. + \row \li readonly property int \b styleData.index \li This is the current tab index. + \row \li readonly property bool \b styleData.selected \li This is the active tab. + \row \li readonly property string \b styleData.title \li Tab title text. + \row \li readonly property bool \b styleData.nextSelected \li The next tab is selected. + \row \li readonly property bool \b styleData.previousSelected \li The previous tab is selected. + \row \li readonly property bool \b styleData.hovered \li The tab is being hovered. + \row \li readonly property bool \b styleData.activeFocus \li The tab button has keyboard focus. + \row \li readonly property bool \b styleData.availableWidth \li The available width for the tabs. \endtable */ property Component tab: Item { -- cgit v1.2.1 From 9490e1161817ad74d5441db79bd8bde5c8c8db91 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 29 May 2013 18:43:37 +0200 Subject: Fix missing margins and incorrect size for ToolBar and StatusBar Using the implicitHeight of an item makes ToolBar and StatusBar a lot more useable with layouts. In addition we enable the padding property from the style, allowing its content to be positioned in a more convenient way. This is similar to how we already do it for GroupBox. Change-Id: Ia2aa1bcb9ae109718fd752401400222adec242ac Reviewed-by: Gabriel de Dietrich --- src/controls/StatusBar.qml | 82 ++++++++++++++++++++++++++++++----- src/controls/ToolBar.qml | 81 +++++++++++++++++++++++++++++----- src/private/qquickstyleitem.cpp | 2 +- src/styles/Base/StatusBarStyle.qml | 13 +++--- src/styles/Base/ToolBarStyle.qml | 35 +++++++++------ src/styles/Desktop/StatusBarStyle.qml | 15 ++++--- src/styles/Desktop/ToolBarStyle.qml | 14 ++++-- 7 files changed, 191 insertions(+), 51 deletions(-) diff --git a/src/controls/StatusBar.qml b/src/controls/StatusBar.qml index 13edc5ef..068b6b20 100644 --- a/src/controls/StatusBar.qml +++ b/src/controls/StatusBar.qml @@ -52,14 +52,20 @@ import QtQuick.Controls.Private 1.0 The common way of using StatusBar is in relation to \l ApplicationWindow. Note that the StatusBar does not provide a layout of its own, but requires - you to position its contents, for instance by creating a \l Row. + you to position its contents, for instance by creating a \l RowLayout. + + If only a single item is used within the StatusBar, it will resize to fit the implicitHeight + of its contained item. This makes it particularly suitable for use together with layouts. + Otherwise the height is platform dependent. \code + import QtQuick.Controls 1.0 + import QtQuick.Layouts 1.0 + ApplicationWindow { statusBar: StatusBar { - Label { - text: "Read Only" - anchors.centerIn: parent + RowLayout { + Label { text: "Read Only" } } } } @@ -68,16 +74,68 @@ import QtQuick.Controls.Private 1.0 Item { id: statusbar + activeFocusOnTab: false Accessible.role: Accessible.StatusBar + width: parent ? parent.width : implicitWidth - implicitWidth: loader.item.implicitHeight - implicitHeight: loader.item ? loader.item.implicitHeight : 0 + implicitWidth: loader.item ? loader.item.implicitWidth : 200 + implicitHeight: Math.max(container.topMargin + container.bottomMargin + container.calcHeight(), + loader.item ? loader.item.implicitHeight : 19) + + /*! \internal */ property Component style: Qt.createComponent(Settings.style + "/StatusBarStyle.qml", statusbar) - Loader { - id: loader - anchors.fill: parent - sourceComponent: style - property var __control: statusbar - } + + /*! \internal */ + property alias __style: styleLoader.item + + /*! \internal */ + default property alias __content: container.data + + /*! + \qmlproperty Item StatusBar::contentItem + + This property holds the content Item of the status bar. + + Items declared as children of a StatusBar are automatically parented to the StatusBar's contentItem. + Items created dynamically need to be explicitly parented to the contentItem: + + \note The implicit size of the StatusBar is calculated based on the size of its content. If you want to anchor + items inside the status bar, you must specify an explicit width and height on the StatusBar itself. + */ + readonly property alias contentItem: container + + data: [ + Loader { + id: loader + anchors.fill: parent + sourceComponent: styleLoader.item ? styleLoader.item.panel : null + onLoaded: item.z = -1 + Loader { + id: styleLoader + property alias __control: statusbar + sourceComponent: style + } + }, + Item { + id: container + z: 1 + focus: true + anchors.fill: parent + + anchors.topMargin: topMargin + anchors.leftMargin: leftMargin + anchors.rightMargin: rightMargin + anchors.bottomMargin: bottomMargin + + property int topMargin: __style ? __style.padding.top : 0 + property int bottomMargin: __style ? __style.padding.bottom : 0 + property int leftMargin: __style ? __style.padding.left : 0 + property int rightMargin: __style ? __style.padding.right : 0 + + property Item layoutItem: container.children.length === 1 ? container.children[0] : null + function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) + + (layoutItem.anchors.fill ? layoutItem.anchors.topMargin + + layoutItem.anchors.bottomMargin : 0) : loader.item ? loader.item.implicitHeight : 0) } + }] } diff --git a/src/controls/ToolBar.qml b/src/controls/ToolBar.qml index d2adea56..e5cc8419 100644 --- a/src/controls/ToolBar.qml +++ b/src/controls/ToolBar.qml @@ -53,13 +53,20 @@ import QtQuick.Controls.Private 1.0 provides styling and is generally designed to work well with ToolButton as well as other controls. - Note that the ToolBar does not provide a layout of its own, but requires you - to position its contents, for instance by creating a Row. + Note that the ToolBar does not provide a layout of its own, but requires + you to position its contents, for instance by creating a \l RowLayout. + + If only a single item is used within the ToolBar, it will resize to fit the implicitHeight + of its contained item. This makes it particularly suitable for use together with layouts. + Otherwise the height is platform dependent. \code + import QtQuick.Controls 1.0 + import QtQuick.Layouts 1.0 + ApplicationWindow { toolBar: ToolBar { - Row { + RowLayout { ToolButton { ... } ToolButton { ... } ToolButton { ... } @@ -71,16 +78,68 @@ import QtQuick.Controls.Private 1.0 Item { id: toolbar + activeFocusOnTab: false Accessible.role: Accessible.ToolBar + width: parent ? parent.width : implicitWidth - implicitWidth: loader.item ? loader.item.implicitWidth : 0 - implicitHeight: loader.item ? loader.item.implicitHeight : 0 + implicitWidth: loader.item ? loader.item.implicitWidth : 200 + implicitHeight: container.topMargin + container.bottomMargin + container.calcHeight() + + /*! \internal */ property Component style: Qt.createComponent(Settings.style + "/ToolBarStyle.qml", toolbar) - Loader { - id: loader - anchors.fill: parent - sourceComponent: style - property var __control: toolbar - } + + /*! \internal */ + property alias __style: styleLoader.item + + /*! \internal */ + default property alias __content: container.data + + /*! + \qmlproperty Item ToolBar::contentItem + + This property holds the content Item of the tool bar. + + Items declared as children of a ToolBar are automatically parented to the ToolBar's contentItem. + Items created dynamically need to be explicitly parented to the contentItem: + + \note The implicit size of the ToolBar is calculated based on the size of its content. If you want to anchor + items inside the tool bar, you must specify an explicit width and height on the ToolBar itself. + */ + readonly property alias contentItem: container + + data: [ + Loader { + id: loader + anchors.fill: parent + sourceComponent: styleLoader.item ? styleLoader.item.panel : null + onLoaded: item.z = -1 + Loader { + id: styleLoader + property alias __control: toolbar + sourceComponent: style + } + }, + Item { + id: container + z: 1 + focus: true + anchors.fill: parent + + anchors.topMargin: topMargin + anchors.leftMargin: leftMargin + anchors.rightMargin: rightMargin + anchors.bottomMargin: bottomMargin + + property int topMargin: __style ? __style.padding.top : 0 + property int bottomMargin: __style ? __style.padding.bottom : 0 + property int leftMargin: __style ? __style.padding.left : 0 + property int rightMargin: __style ? __style.padding.right : 0 + + property Item layoutItem: container.children.length === 1 ? container.children[0] : null + function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) + + (layoutItem.anchors.fill ? layoutItem.anchors.topMargin + + layoutItem.anchors.bottomMargin : 0) : + loader.item ? loader.item.implicitHeight : 0) } + }] } diff --git a/src/private/qquickstyleitem.cpp b/src/private/qquickstyleitem.cpp index 71d98bb6..115841ad 100644 --- a/src/private/qquickstyleitem.cpp +++ b/src/private/qquickstyleitem.cpp @@ -734,7 +734,7 @@ QSize QQuickStyleItem::sizeFromContents(int width, int height) size = qApp->style()->sizeFromContents(QStyle::CT_CheckBox, m_styleoption, QSize(width,height)); break; case ToolBar: - size = QSize(200, 40); + size = QSize(200, style().contains("windows") ? 30 : 42); break; case ToolButton: { QStyleOptionToolButton *btn = qstyleoption_cast(m_styleoption); diff --git a/src/styles/Base/StatusBarStyle.qml b/src/styles/Base/StatusBarStyle.qml index 049b15f2..e8abe19b 100644 --- a/src/styles/Base/StatusBarStyle.qml +++ b/src/styles/Base/StatusBarStyle.qml @@ -47,13 +47,16 @@ import QtQuick.Controls.Private 1.0 \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 */ -Item { - implicitHeight: 22 - implicitWidth: 200 +Style { - Rectangle { + padding.left: 3 + padding.right: 3 + padding.top: 3 + padding.bottom: 2 - anchors.fill: parent + property Component panel: Rectangle { + implicitHeight: 16 + implicitWidth: 200 gradient: Gradient{ GradientStop{color: "#eee" ; position: 0} diff --git a/src/styles/Base/ToolBarStyle.qml b/src/styles/Base/ToolBarStyle.qml index aa21195a..835f8219 100644 --- a/src/styles/Base/ToolBarStyle.qml +++ b/src/styles/Base/ToolBarStyle.qml @@ -39,26 +39,35 @@ ****************************************************************************/ import QtQuick 2.1 import QtQuick.Controls 1.0 +import QtQuick.Controls.Private 1.0 /*! \qmltype ToolBarStyle \internal \inqmlmodule QtQuick.Controls.Styles 1.0 */ -Item { - implicitHeight: 42 - implicitWidth: 200 - Rectangle { - anchors.fill: parent - gradient: Gradient{ - GradientStop{color: "#eee" ; position: 0} - GradientStop{color: "#ccc" ; position: 1} - } +Style { + + padding.left: 6 + padding.right: 6 + padding.top: 3 + padding.bottom: 3 + + property Component panel: Item { + implicitHeight: 40 + implicitWidth: 200 Rectangle { - anchors.bottom: parent.bottom - width: parent.width - height: 1 - color: "#999" + anchors.fill: parent + gradient: Gradient{ + GradientStop{color: "#eee" ; position: 0} + GradientStop{color: "#ccc" ; position: 1} + } + Rectangle { + anchors.bottom: parent.bottom + width: parent.width + height: 1 + color: "#999" + } } } } diff --git a/src/styles/Desktop/StatusBarStyle.qml b/src/styles/Desktop/StatusBarStyle.qml index 6921a2fe..930ca773 100644 --- a/src/styles/Desktop/StatusBarStyle.qml +++ b/src/styles/Desktop/StatusBarStyle.qml @@ -46,11 +46,16 @@ import QtQuick.Controls.Private 1.0 \internal \inqmlmodule QtQuick.Controls.Styles 1.0 */ -Item { - implicitHeight: 20 - implicitWidth: parent ? parent.width : style.implicitWidth - StyleItem { - id: style +Style { + + padding.left: 4 + padding.right: 4 + padding.top: 3 + padding.bottom: 2 + + property Component panel: StyleItem { + implicitHeight: 16 + implicitWidth: 200 anchors.fill: parent elementType: "statusbar" } diff --git a/src/styles/Desktop/ToolBarStyle.qml b/src/styles/Desktop/ToolBarStyle.qml index 4c7e036e..56dfbce3 100644 --- a/src/styles/Desktop/ToolBarStyle.qml +++ b/src/styles/Desktop/ToolBarStyle.qml @@ -46,10 +46,16 @@ import QtQuick.Controls.Private 1.0 \internal \inqmlmodule QtQuick.Controls.Styles 1.0 */ -Item { - implicitHeight: Math.max(childrenRect.height, toolbar.implicitHeight) - implicitWidth: parent ? parent.width : toolbar.implicitWidth - StyleItem { +Style { + + padding.left: 6 + padding.right: 6 + padding.top: 1 + padding.bottom: style.style == "mac" ? 1 : 2 + + StyleItem { id: style ; visible: false} + + property Component panel: StyleItem { id: toolbar anchors.fill: parent elementType: "toolbar" -- cgit v1.2.1 From 8beda08087effd684cfcb325855c9f4b47186135 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 30 May 2013 16:51:34 +0200 Subject: Cleaning up some examples and removing clutter We want to use more layouts in our examples as it is the recommended way to create tool bars etc. Change-Id: Ib3b1e8e907cc5277d522557a19d2c294a7d251b1 Reviewed-by: J-P Nurmi --- .../quick/controls/gallery/content/Controls.qml | 8 + examples/quick/controls/gallery/content/Styles.qml | 229 +++++++++++---------- examples/quick/controls/gallery/main.qml | 216 ++++++++----------- examples/quick/controls/splitview/main.qml | 8 - .../quick/controls/text/qml/ToolBarSeparator.qml | 61 ++++++ examples/quick/controls/text/qml/main.qml | 77 ++++--- examples/quick/controls/text/resources.qrc | 1 + .../quick/controls/text/src/documenthandler.cpp | 12 +- examples/quick/controls/text/text.pro | 3 +- .../doc/images/qtquickcontrols-example-gallery.png | Bin 53632 -> 34070 bytes 10 files changed, 325 insertions(+), 290 deletions(-) create mode 100644 examples/quick/controls/text/qml/ToolBarSeparator.qml diff --git a/examples/quick/controls/gallery/content/Controls.qml b/examples/quick/controls/gallery/content/Controls.qml index 310eee59..c1403da5 100644 --- a/examples/quick/controls/gallery/content/Controls.qml +++ b/examples/quick/controls/gallery/content/Controls.qml @@ -180,6 +180,14 @@ Item { height: parent.height - group1.height - group2.height - 2 * parent.spacing anchors { right: parent.right } } + + MouseArea { + id: contextMenu + parent: area.viewport + anchors.fill: parent + acceptedButtons: Qt.RightButton + onPressed: editmenu.popup() + } } } } diff --git a/examples/quick/controls/gallery/content/Styles.qml b/examples/quick/controls/gallery/content/Styles.qml index 01b2646f..97797f83 100644 --- a/examples/quick/controls/gallery/content/Styles.qml +++ b/examples/quick/controls/gallery/content/Styles.qml @@ -45,127 +45,132 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.0 -import QtQuick.Dialogs 1.0 +import QtQuick.Layouts 1.0 Item { id: root width: 300 height: 200 - ColorDialog { - id: colorDialog - color: "#afe" - property color last: "#afe" - onRejected: color = last - onVisibleChanged: if (visible) last = color - } - - Column { - anchors.margins: 20 - anchors.horizontalCenter: parent.horizontalCenter + property int columnWidth: 120 + GridLayout { + rowSpacing: 12 + columnSpacing: 30 anchors.top: parent.top - spacing: 20 + anchors.horizontalCenter: parent.horizontalCenter + anchors.margins: 30 - Row { - spacing: 8 - Button { - text: "Set color…" - style: ButtonStyle { } - onClicked: colorDialog.open() - } - Button { - text: "Push me" - style: ButtonStyle { } - } - Button { - text: "Push me" - style: buttonStyle - } + Button { + text: "Push me" + style: ButtonStyle { } + onClicked: colorDialog.open() + implicitWidth: columnWidth } - Row { - spacing: 8 - TextField { - style: TextFieldStyle { } - } - TextField { - style: TextFieldStyle { } - } - TextField { - style: textfieldStyle - } + Button { + text: "Push me" + style: ButtonStyle { } + implicitWidth: columnWidth + } + Button { + text: "Push me" + style: buttonStyle + implicitWidth: columnWidth } - Row { - spacing: 8 - Slider { - value: 50 - maximumValue: 100 - width: 100 - style: SliderStyle { } - } - Slider { - value: 50 - maximumValue: 100 - width: 100 - style: SliderStyle { } - } - Slider { - value: 50 - maximumValue: 100 - width: 100 - style: sliderStyle - } + TextField { + Layout.row: 1 + style: TextFieldStyle { } + implicitWidth: columnWidth + } + TextField { + style: TextFieldStyle { } + implicitWidth: columnWidth + } + TextField { + style: textfieldStyle + implicitWidth: columnWidth } - Row { - spacing: 8 - ProgressBar { - value: 50 - maximumValue: 100 - width: 100 - style: ProgressBarStyle{ } - } - ProgressBar { - value: 50 - maximumValue: 100 - width: 100 - style: ProgressBarStyle{ } - } - ProgressBar { - value: 50 - maximumValue: 100 - width: 100 - style: progressbarStyle - } + Slider { + Layout.row: 2 + value: 50 + maximumValue: 100 + implicitWidth: columnWidth + style: SliderStyle { } + } + Slider { + value: 50 + maximumValue: 100 + implicitWidth: columnWidth + style: SliderStyle { } + } + Slider { + value: 50 + maximumValue: 100 + implicitWidth: columnWidth + style: sliderStyle } - Row { - spacing: 8 - CheckBox { - text: "CheckBox" - style: CheckBoxStyle{} - } - RadioButton { - style: RadioButtonStyle{} - text: "RadioButton" - } + ProgressBar { + Layout.row: 3 + value: 50 + maximumValue: 100 + implicitWidth: columnWidth + style: ProgressBarStyle{ } + } + ProgressBar { + value: 50 + maximumValue: 100 + implicitWidth: columnWidth + style: ProgressBarStyle{ } + } + ProgressBar { + value: 50 + maximumValue: 100 + implicitWidth: columnWidth + style: progressbarStyle + } - ComboBox { - model: ["Paris", "Oslo", "New York"] - style: ComboBoxStyle{} - } + CheckBox { + text: "CheckBox" + style: CheckBoxStyle{} + Layout.row: 4 + implicitWidth: columnWidth + } + RadioButton { + style: RadioButtonStyle{} + text: "RadioButton" + implicitWidth: columnWidth } - Row { - TabView { - width: 400 - height: 30 - Tab { title: "One" ; Item {}} - Tab { title: "Two" ; Item {}} - Tab { title: "Three" ; Item {}} - Tab { title: "Four" ; Item {}} - style: tabViewStyle - } + ComboBox { + model: ["Paris", "Oslo", "New York"] + style: ComboBoxStyle{} + implicitWidth: columnWidth + } + + TabView { + Layout.row: 5 + Layout.columnSpan: 3 + Layout.fillWidth: true + implicitHeight: 30 + Tab { title: "One" ; Item {}} + Tab { title: "Two" ; Item {}} + Tab { title: "Three" ; Item {}} + Tab { title: "Four" ; Item {}} + style: TabViewStyle {} + } + + TabView { + Layout.row: 6 + Layout.columnSpan: 3 + Layout.fillWidth: true + implicitHeight: 30 + Tab { title: "One" ; Item {}} + Tab { title: "Two" ; Item {}} + Tab { title: "Three" ; Item {}} + Tab { title: "Four" ; Item {}} + style: tabViewStyle } } @@ -174,7 +179,7 @@ Item { property Component buttonStyle: ButtonStyle { background: Rectangle { implicitHeight: 20 - implicitWidth: 100 + implicitWidth: columnWidth color: control.pressed ? "darkGray" : "lightGray" antialiasing: true border.color: "gray" @@ -184,7 +189,7 @@ Item { property Component textfieldStyle: TextFieldStyle { background: Rectangle { - implicitWidth: 100 + implicitWidth: columnWidth implicitHeight: 20 color: "#f0f0f0" antialiasing: true @@ -205,7 +210,7 @@ Item { groove: Rectangle { height: 8 - implicitWidth: 100 + implicitWidth: columnWidth implicitHeight: 20 antialiasing: true @@ -217,7 +222,7 @@ Item { property Component progressbarStyle: ProgressBarStyle { background: Rectangle { - implicitWidth: 100 + implicitWidth: columnWidth implicitHeight: 20 color: "#f0f0f0" border.color: "gray" @@ -225,7 +230,7 @@ Item { radius: height/2 } progress: Rectangle { - implicitWidth: 100 + implicitWidth: columnWidth implicitHeight: 20 color: "#c0c0c0" border.color: "gray" @@ -246,18 +251,18 @@ Item { } border.color: "#898989" Rectangle { anchors.fill: parent ; anchors.margins: 1 ; border.color: "white" ; color: "transparent" } - } tab: Item { - implicitWidth: image.sourceSize.width + property int totalOverlap: tabOverlap * (control.count - 1) + implicitWidth: Math.min ((styleData.availableWidth + totalOverlap)/control.count - 4, image.sourceSize.width) implicitHeight: image.sourceSize.height BorderImage { id: image anchors.fill: parent source: styleData.selected ? "../images/tab_selected.png" : "../images/tab.png" - border.left: 50 + border.left: 30 smooth: false - border.right: 50 + border.right: 30 } Text { text: styleData.title diff --git a/examples/quick/controls/gallery/main.qml b/examples/quick/controls/gallery/main.qml index 93502423..86dddbe2 100644 --- a/examples/quick/controls/gallery/main.qml +++ b/examples/quick/controls/gallery/main.qml @@ -70,150 +70,112 @@ ApplicationWindow { onAccepted: imageViewer.open(fileUrl) } - toolBar: ToolBar { - id: toolbar - RowLayout { - spacing: 2 - anchors.verticalCenter: parent.verticalCenter - ToolButton { - iconSource: "images/window-new.png" - anchors.verticalCenter: parent.verticalCenter - onClicked: window1.visible = !window1.visible - Accessible.name: "New window" - tooltip: "Toggle visibility of the second window" - } - ToolButton { - action: openAction - } - ToolButton { - iconSource: "images/document-save-as.png" - anchors.verticalCenter: parent.verticalCenter - tooltip: "(Pretend to) save as..." - } - } + Action { + id: openAction + text: "&Open" + shortcut: "Ctrl+O" + iconSource: "images/document-open.png" + onTriggered: fileDialog.open() + tooltip: "open an image" + } - ChildWindow { id: window1 } + Action { + id: copyAction + text: "&Copy" + shortcut: "Ctrl+C" + iconName: "edit-copy" + enabled: (!!activeFocusItem && !!activeFocusItem["copy"]) + onTriggered: activeFocusItem.copy() + } - Action { - id: openAction - text: "&Open" - shortcut: "Ctrl+O" - iconSource: "images/document-open.png" - onTriggered: fileDialog.open() - tooltip: "open an image" - } + Action { + id: cutAction + text: "Cu&t" + shortcut: "Ctrl+X" + iconName: "edit-cut" + enabled: (!!activeFocusItem && !!activeFocusItem["cut"]) + onTriggered: activeFocusItem.cut() + } + + Action { + id: pasteAction + text: "&Paste" + shortcut: "Ctrl+V" + iconName: "edit-paste" + enabled: (!!activeFocusItem && !!activeFocusItem["paste"]) + onTriggered: activeFocusItem.paste() + } + + ExclusiveGroup { + id: textFormatGroup Action { - id: copyAction - text: "&Copy" - shortcut: "Ctrl+C" - iconName: "edit-copy" - enabled: (!!activeFocusItem && !!activeFocusItem["copy"]) - onTriggered: activeFocusItem.copy() + id: a1 + text: "Align Left" + checkable: true + Component.onCompleted: checked = true } Action { - id: cutAction - text: "Cu&t" - shortcut: "Ctrl+X" - iconName: "edit-cut" - enabled: (!!activeFocusItem && !!activeFocusItem["cut"]) - onTriggered: activeFocusItem.cut() + id: a2 + text: "Center" + checkable: true } Action { - id: pasteAction - text: "&Paste" - shortcut: "Ctrl+V" - iconName: "edit-paste" - enabled: (!!activeFocusItem && !!activeFocusItem["paste"]) - onTriggered: activeFocusItem.paste() + id: a3 + text: "Align Right" + checkable: true } + } - ExclusiveGroup { - id: textFormatGroup - - Action { - id: a1 - text: "Align Left" - checkable: true - Component.onCompleted: checked = true - } - - Action { - id: a2 - text: "Center" - checkable: true - } - - Action { - id: a3 - text: "Align Right" - checkable: true - } - } + ChildWindow { id: window1 } + Menu { + id: editmenu + MenuItem { action: cutAction } + MenuItem { action: copyAction } + MenuItem { action: pasteAction } + MenuSeparator {} Menu { - id: editmenu - MenuItem { action: cutAction } - MenuItem { action: copyAction } - MenuItem { action: pasteAction } - MenuSeparator {} - Menu { - title: "Text Format" - MenuItem { action: a1 } - MenuItem { action: a2 } - MenuItem { action: a3 } - MenuSeparator { } - MenuItem { text: "Allow Hyphenation"; checkable: true } - MenuSeparator { } - Menu { - title: "More Stuff" - MenuItem { action: cutAction } - MenuItem { action: copyAction } - MenuItem { action: pasteAction } - MenuSeparator { } - Menu { - title: "More Stuff" - MenuItem { action: cutAction } - MenuItem { action: copyAction } - MenuItem { action: pasteAction } - MenuSeparator { } - Menu { - title: "More Stuff" - MenuItem { action: cutAction } - MenuItem { action: copyAction } - MenuItem { action: pasteAction } - MenuSeparator { } - Menu { - title: "More Stuff" - MenuItem { action: cutAction } - MenuItem { action: copyAction } - MenuItem { action: pasteAction } - } - } - } - } - } - Menu { - title: "Font Style" - MenuItem { text: "Bold"; checkable: true } - MenuItem { text: "Italic"; checkable: true } - MenuItem { text: "Underline"; checkable: true } - } + title: "Text Format" + MenuItem { action: a1 } + MenuItem { action: a2 } + MenuItem { action: a3 } + MenuSeparator { } + MenuItem { text: "Allow Hyphenation"; checkable: true } } - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.RightButton - onPressed: editmenu.popup() + Menu { + title: "Font Style" + MenuItem { text: "Bold"; checkable: true } + MenuItem { text: "Italic"; checkable: true } + MenuItem { text: "Underline"; checkable: true } } + } - CheckBox { - id: enabledCheck - text: "Enabled" - checked: true - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter + toolBar: ToolBar { + id: toolbar + RowLayout { + id: toolbarLayout + spacing: 0 + width: parent.width + ToolButton { + iconSource: "images/window-new.png" + onClicked: window1.visible = !window1.visible + Accessible.name: "New window" + tooltip: "Toggle visibility of the second window" + } + ToolButton { action: openAction } + ToolButton { + iconSource: "images/document-save-as.png" + tooltip: "(Pretend to) save as..." + } + Item { Layout.fillWidth: true } + CheckBox { + id: enabledCheck + text: "Enabled" + checked: true + } } } diff --git a/examples/quick/controls/splitview/main.qml b/examples/quick/controls/splitview/main.qml index f035e644..4fa8504a 100644 --- a/examples/quick/controls/splitview/main.qml +++ b/examples/quick/controls/splitview/main.qml @@ -61,14 +61,6 @@ ApplicationWindow { color: "lightsteelblue" } - Rectangle { - id: column1 - width: 200 - Layout.minimumWidth: 100 - Layout.maximumWidth: 300 - color: "lightsteelblue" - } - SplitView { orientation: Qt.Vertical Layout.fillWidth: true diff --git a/examples/quick/controls/text/qml/ToolBarSeparator.qml b/examples/quick/controls/text/qml/ToolBarSeparator.qml new file mode 100644 index 00000000..40a2bc58 --- /dev/null +++ b/examples/quick/controls/text/qml/ToolBarSeparator.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** 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 + +Item { + width: 8 + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: 6 + Rectangle { + width: 1 + height: parent.height + anchors.horizontalCenter: parent.horizontalCenter + color: "#22000000" + } + Rectangle { + width: 1 + height: parent.height + anchors.horizontalCenterOffset: 1 + anchors.horizontalCenter: parent.horizontalCenter + color: "#33ffffff" + } +} diff --git a/examples/quick/controls/text/qml/main.qml b/examples/quick/controls/text/qml/main.qml index dd8b1848..ec6bff7b 100644 --- a/examples/quick/controls/text/qml/main.qml +++ b/examples/quick/controls/text/qml/main.qml @@ -42,6 +42,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 import QtQuick.Dialogs 1.0 +import QtQuick.Window 2.1 import org.qtproject.example 1.0 ApplicationWindow { @@ -52,6 +53,37 @@ ApplicationWindow { title: document.documentTitle + " - Text Editor Example" + ApplicationWindow { + id: aboutBox + + width: 280 + height: 120 + title: "About Text" + + ColumnLayout { + anchors.fill: parent + anchors.margins: 8 + Item { + Layout.fillWidth: true + Layout.fillHeight: true + Label { + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + text: "This is a basic text editor \nwritten with Qt Quick Controls" + } + } + Button { + text: "Ok" + isDefault: true + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + onClicked: aboutBox.close() + } + Keys.onReturnPressed: aboutBox.close() + focus: true + } + } + Action { id: cut text: "Cut" @@ -142,12 +174,6 @@ ApplicationWindow { checkable: true checked: document.underline } - Action { - id: color - text: "&Color ..." - iconSource: "images/textcolor.png" - iconName: "format-text-color" - } FileDialog { id: file @@ -185,13 +211,10 @@ ApplicationWindow { MenuItem { action: alignCenter } MenuItem { action: alignRight } MenuItem { action: alignJustify } - MenuSeparator {} - MenuItem { action: color } } Menu { title: "&Help" - MenuItem { text: "About..." } - MenuItem { text: "About Qt" } + MenuItem { text: "About..." ; onTriggered: aboutBox.show() } } } @@ -200,19 +223,23 @@ ApplicationWindow { width: parent.width RowLayout { anchors.fill: parent - spacing: 1 + spacing: 0 ToolButton { action: fileOpen } - Item { width: 4 } + ToolBarSeparator {} + ToolButton { action: copy } ToolButton { action: cut } ToolButton { action: paste } - Item { width: 4 } + + ToolBarSeparator {} + ToolButton { action: bold } ToolButton { action: italic } ToolButton { action: underline } - Item { width: 4 } + ToolBarSeparator {} + ToolButton { action: alignLeft } ToolButton { action: alignCenter } ToolButton { action: alignRight } @@ -220,28 +247,13 @@ ApplicationWindow { Item { Layout.fillWidth: true } } } - ToolBar { - id: secondaryToolBar - width: parent.width - - RowLayout { - anchors.fill: parent - anchors.margins: 4 - ComboBox { - model: document.defaultFontSizes - onCurrentTextChanged: document.fontSize = currentText - currentIndex: document.defaultFontSizes.indexOf(document.fontSize + "") - } - TextField { id: fontEdit; enabled: false } - Item { Layout.fillWidth: true } - } - } TextArea { Accessible.name: "document" id: textArea + frameVisible: false width: parent.width - anchors.top: secondaryToolBar.bottom + anchors.top: parent.top anchors.bottom: parent.bottom text: document.text textFormat: Qt.RichText @@ -254,8 +266,5 @@ ApplicationWindow { cursorPosition: textArea.cursorPosition selectionStart: textArea.selectionStart selectionEnd: textArea.selectionEnd - onCurrentFontChanged: { - fontEdit.text = currentFont.family - } } } diff --git a/examples/quick/controls/text/resources.qrc b/examples/quick/controls/text/resources.qrc index e67fac6a..4d137ff7 100644 --- a/examples/quick/controls/text/resources.qrc +++ b/examples/quick/controls/text/resources.qrc @@ -1,6 +1,7 @@ qml/main.qml + qml/ToolBarSeparator.qml qml/images/logo32.png qml/images/editcopy.png qml/images/editcut.png diff --git a/examples/quick/controls/text/src/documenthandler.cpp b/examples/quick/controls/text/src/documenthandler.cpp index 48b6d033..81eb744b 100644 --- a/examples/quick/controls/text/src/documenthandler.cpp +++ b/examples/quick/controls/text/src/documenthandler.cpp @@ -166,13 +166,11 @@ void DocumentHandler::mergeFormatOnWordOrSelection(const QTextCharFormat &format void DocumentHandler::setSelectionStart(int position) { m_selectionStart = position; -// emit selectionStartChanged(); } void DocumentHandler::setSelectionEnd(int position) { m_selectionEnd = position; -// emit selectionEndChanged(); } void DocumentHandler::setAlignment(Qt::Alignment a) @@ -188,10 +186,8 @@ void DocumentHandler::setAlignment(Qt::Alignment a) Qt::Alignment DocumentHandler::alignment() const { -// if (!m_doc || m_doc->isEmpty() || m_cursorPosition < 0) -// return Qt::AlignLeft; QTextCursor cursor = textCursor(); - if (cursor.isNull() || cursor.blockNumber() == 0) + if (cursor.isNull()) return Qt::AlignLeft; return textCursor().blockFormat().alignment(); } @@ -199,7 +195,7 @@ Qt::Alignment DocumentHandler::alignment() const bool DocumentHandler::bold() const { QTextCursor cursor = textCursor(); - if (cursor.isNull() || cursor.blockNumber() == 0) + if (cursor.isNull()) return false; return textCursor().charFormat().fontWeight() == QFont::Bold; } @@ -207,7 +203,7 @@ bool DocumentHandler::bold() const bool DocumentHandler::italic() const { QTextCursor cursor = textCursor(); - if (cursor.isNull() || cursor.blockNumber() == 0) + if (cursor.isNull()) return false; return textCursor().charFormat().fontItalic(); } @@ -215,7 +211,7 @@ bool DocumentHandler::italic() const bool DocumentHandler::underline() const { QTextCursor cursor = textCursor(); - if (cursor.isNull() || cursor.blockNumber() == 0) + if (cursor.isNull()) return false; return textCursor().charFormat().fontUnderline(); } diff --git a/examples/quick/controls/text/text.pro b/examples/quick/controls/text/text.pro index ce6d5f33..864ce0bb 100644 --- a/examples/quick/controls/text/text.pro +++ b/examples/quick/controls/text/text.pro @@ -7,7 +7,8 @@ qtHaveModule(widgets) { include(src/src.pri) OTHER_FILES += \ - qml/main.qml + qml/main.qml \ + qml/ToolBarSeparator.qml RESOURCES += \ resources.qrc diff --git a/src/controls/doc/images/qtquickcontrols-example-gallery.png b/src/controls/doc/images/qtquickcontrols-example-gallery.png index d3b19bb5..a88eab79 100644 Binary files a/src/controls/doc/images/qtquickcontrols-example-gallery.png and b/src/controls/doc/images/qtquickcontrols-example-gallery.png differ -- cgit v1.2.1 From 099e0294179126db5c98cc3dac309f2463360f3c Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 30 May 2013 16:31:31 +0200 Subject: TabViewStyle: expose styleData.availableWidth Change-Id: Ib209ec7311c64f172718c8baa7d7f63f6f79a3a8 Reviewed-by: Jens Bache-Wiig --- src/private/TabBar.qml | 2 +- src/styles/Base/TabViewStyle.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/private/TabBar.qml b/src/private/TabBar.qml index 7f4db779..6bcf795c 100644 --- a/src/private/TabBar.qml +++ b/src/private/TabBar.qml @@ -192,7 +192,6 @@ FocusScope { property Item control: tabView property int index: tabindex - property real availableWidth: tabbar.availableWidth property QtObject styleData: QtObject { readonly property alias index: tabitem.tabindex @@ -202,6 +201,7 @@ FocusScope { readonly property alias previsousSelected: tabitem.previousSelected readonly property alias hovered: tabitem.containsMouse readonly property bool activeFocus: tabbar.activeFocus + readonly property real availableWidth: tabbar.availableWidth } sourceComponent: loader.item ? loader.item.tab : null diff --git a/src/styles/Base/TabViewStyle.qml b/src/styles/Base/TabViewStyle.qml index a668f43b..04e34d4c 100644 --- a/src/styles/Base/TabViewStyle.qml +++ b/src/styles/Base/TabViewStyle.qml @@ -136,7 +136,7 @@ Style { scale: control.tabPosition === Qt.TopEdge ? 1 : -1 property int totalOverlap: tabOverlap * (control.count - 1) - property real maxTabWidth: (availableWidth + totalOverlap) / control.count + property real maxTabWidth: (styleData.availableWidth + totalOverlap) / control.count implicitWidth: Math.round(Math.min(maxTabWidth, textitem.implicitWidth + 20)) implicitHeight: Math.round(textitem.implicitHeight + 10) -- cgit v1.2.1 From 0155e0833c56ccd21ca5668eb1be8b359400535b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 29 May 2013 17:45:10 +0200 Subject: ToolBar: Get proper pressed state on Mac Depends on https://codereview.qt-project.org/57500 Change-Id: I131fa8e25322a10a10878e5f603084e951d101ad Reviewed-by: J-P Nurmi Reviewed-by: Jens Bache-Wiig --- src/styles/Desktop/ToolButtonStyle.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/styles/Desktop/ToolButtonStyle.qml b/src/styles/Desktop/ToolButtonStyle.qml index ebeec761..b5b260e6 100644 --- a/src/styles/Desktop/ToolButtonStyle.qml +++ b/src/styles/Desktop/ToolButtonStyle.qml @@ -46,8 +46,8 @@ Style { anchors.fill: parent elementType: "toolbutton" - on: control.pressed || (control.checkable && control.checked) - sunken: control.pressed || (control.checkable && control.checked) + on: control.checkable && control.checked + sunken: control.pressed raised: !(control.checkable && control.checked) && control.__containsMouse hover: control.__containsMouse hasFocus: control.activeFocus -- cgit v1.2.1 From 33850881a074f93622869cc4dc6bc77fbbc1fa0c Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Fri, 31 May 2013 13:10:02 +0200 Subject: TableView: Expand to single column and prevent multiple use This fix ensures that we can only add a TableViewColumn exactly once. It also automatically expands the column with to the viewport when only one column is in use. In addition I have disabled dragging when columnCount == 1 as it was pointless. Change-Id: Ief6011c3e58166907836bf55b0fa6643698192d2 Reviewed-by: Caroline Chao --- src/controls/TableView.qml | 14 ++++++++++---- src/controls/TableViewColumn.qml | 10 ++++++++-- tests/auto/controls/data/tst_tableview.qml | 17 +++++++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index d0417bfa..88a897e1 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -303,7 +303,12 @@ ScrollView { if (typeof column['createObject'] === 'function') object = column.createObject(root) + else if (object.__view) { + console.warn("TableView::insertColumn(): you cannot add a column to multiple views") + return null + } if (index >= 0 && index <= columnCount && object.Accessible.role === Accessible.ColumnHeader) { + object.__view = root columnModel.insert(index, {columnItem: object}) return object } @@ -616,7 +621,7 @@ ScrollView { delegate: Item { z:-index - width: modelData.width + width: columnCount == 1 ? viewport.width + __verticalScrollBar.width : modelData.width visible: modelData.visible height: headerVisible ? headerStyle.height : 0 @@ -655,7 +660,7 @@ ScrollView { // NOTE: the direction is different from the master branch // so this indicates that I am using an invalid assumption on item ordering onPositionChanged: { - if (pressed) { // only do this while dragging + if (pressed && columnCount > 1) { // only do this while dragging for (var h = columnCount-1 ; h >= 0 ; --h) { if (drag.target.x > headerrow.children[h].x) { repeater.targetIndex = h @@ -680,7 +685,7 @@ ScrollView { } drag.maximumX: 1000 drag.minimumX: -1000 - drag.target: draghandle + drag.target: columnCount > 1 ? draghandle : null } Loader { @@ -708,6 +713,7 @@ ScrollView { anchors.rightMargin: -width/2 width: 16 ; height: parent.height anchors.right: parent.right + enabled: columnCount > 1 onPositionChanged: { var newHeaderWidth = modelData.width + (mouseX - offset) modelData.width = Math.max(minimumSize, newHeaderWidth) @@ -728,7 +734,7 @@ ScrollView { modelData.width = minWidth } onPressedChanged: if (pressed) offset=mouseX - cursorShape: Qt.SplitHCursor + cursorShape: enabled ? Qt.SplitHCursor : Qt.ArrowCursor } } } diff --git a/src/controls/TableViewColumn.qml b/src/controls/TableViewColumn.qml index 2c629dfb..f1abc553 100644 --- a/src/controls/TableViewColumn.qml +++ b/src/controls/TableViewColumn.qml @@ -49,6 +49,10 @@ import QtQuick 2.1 */ QtObject { + + /*! \internal */ + property Item __view: null + /*! The title text of the column. */ property string title @@ -56,8 +60,10 @@ QtObject { property string role /*! The current width of the column - The default value depends on platform. */ - property int width: 160 + The default value depends on platform. If only one + column is defined, the width expands to the viewport. + */ + property int width: (__view && __view.columnCount === 1) ? __view.viewport.width : 160 /*! The visible status of the column. */ property bool visible: true diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml index d092ae9d..8763900e 100644 --- a/tests/auto/controls/data/tst_tableview.qml +++ b/tests/auto/controls/data/tst_tableview.qml @@ -240,6 +240,23 @@ TestCase { table.destroy() } + function test_columnWidth() { + var tableView = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TableView { }', testCase, ''); + compare(tableView.columnCount, 0) + var column = newColumn.createObject(testCase, {title: "title 1"}); + verify(column.__view === null) + compare(column.width, 160) + compare(column.title, "title 1") + tableView.addColumn(column) + compare(column.__view, tableView) + compare(column.width, tableView.viewport.width) + var tableView2 = Qt.createQmlObject('import QtQuick 2.1; import QtQuick.Controls 1.0; TableView { }', testCase, ''); + tableView2.addColumn(column) // should not work + compare(column.__view, tableView) //same as before + tableView2.destroy() + tableView.destroy() + } + function test_dynamicColumns() { var component = Qt.createComponent("tableview/table_dynamiccolumns.qml") compare(component.status, Component.Ready) -- cgit v1.2.1 From ea2de46b77aa42f857d79cf0b23113c57e02c759 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Sun, 2 Jun 2013 13:56:30 +0200 Subject: Remove unnecessary bottom margin for TabView on mac This extra padding at the bottom is not needed and only serves to make the borders uneven on mac. Change-Id: Ibb3f8a3ba1f37ce1e9c6674a53cfb13e257fb97f Reviewed-by: Richard Moe Gustavsen --- src/controls/TabView.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controls/TabView.qml b/src/controls/TabView.qml index 3273f825..e0d3ca3b 100644 --- a/src/controls/TabView.qml +++ b/src/controls/TabView.qml @@ -198,7 +198,7 @@ FocusScope { anchors.fill: parent anchors.margins: (frameVisible ? frameWidth : 0) anchors.topMargin: anchors.margins + (style =="mac" ? 6 : 0) - anchors.bottomMargin: anchors.margins + (style =="mac" ? 6 : 0) + anchors.bottomMargin: anchors.margins property int frameWidth property string style -- cgit v1.2.1 From 3eee91908e8bd0c5f3c3ebe59ef1e179c8d1eb68 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Sat, 1 Jun 2013 17:16:10 +0200 Subject: Doc: Add doc structure for Styles And: - Add an index page for the Styles - Add missing documentation for some properties (Component) - Fix unexpected curly brackets in a couple of code snippets Change-Id: Ib7265d1cd011a81012eb4b7f69738b84fba5b531 Reviewed-by: Jerome Pasion --- src/controls/doc/qtquickcontrols.qdocconf | 17 +--- src/controls/doc/src/qtquickcontrols-index.qdoc | 7 +- src/controls/doc/src/styles.qdoc | 41 --------- src/styles/Base/ButtonStyle.qml | 1 + src/styles/Base/CheckBoxStyle.qml | 4 +- src/styles/Base/ComboBoxStyle.qml | 1 + src/styles/Base/GroupBoxStyle.qml | 1 + src/styles/Base/MenuBarStyle.qml | 1 + src/styles/Base/MenuStyle.qml | 7 ++ src/styles/Base/ProgressBarStyle.qml | 10 +++ src/styles/Base/RadioButtonStyle.qml | 6 +- src/styles/Base/ScrollViewStyle.qml | 1 + src/styles/Base/SliderStyle.qml | 1 + src/styles/Base/SpinBoxStyle.qml | 1 + src/styles/Base/StatusBarStyle.qml | 1 + src/styles/Base/TabViewStyle.qml | 1 + src/styles/Base/TableViewStyle.qml | 13 ++- src/styles/Base/TextFieldStyle.qml | 1 + src/styles/Base/ToolBarStyle.qml | 1 + src/styles/Base/ToolButtonStyle.qml | 1 + src/styles/doc/qtquickcontrolsstyles.qdocconf | 43 ++++++++++ .../doc/src/qtquickcontrolsstyles-index.qdoc | 98 ++++++++++++++++++++++ src/styles/styles.pro | 2 + 23 files changed, 196 insertions(+), 64 deletions(-) delete mode 100644 src/controls/doc/src/styles.qdoc create mode 100644 src/styles/doc/qtquickcontrolsstyles.qdocconf create mode 100644 src/styles/doc/src/qtquickcontrolsstyles-index.qdoc diff --git a/src/controls/doc/qtquickcontrols.qdocconf b/src/controls/doc/qtquickcontrols.qdocconf index 7cf1ee54..ab321a74 100644 --- a/src/controls/doc/qtquickcontrols.qdocconf +++ b/src/controls/doc/qtquickcontrols.qdocconf @@ -18,18 +18,13 @@ qhp.QtQuickControls.filterAttributes = qtcontrols $QT_VERSION qtrefdoc qhp.QtQuickControls.customFilters.Qt.name = QtQuickControls $QT_VERSION qhp.QtQuickControls.customFilters.Qt.filterAttributes = qtquickcontrols $QT_VERSION -qhp.QtQuickControls.subprojects = qtquickcontrolsqmltypes styleqmltypes +qhp.QtQuickControls.subprojects = qtquickcontrolsqmltypes qhp.QtQuickControls.subprojects.qtquickcontrolsqmltypes.title = QML Types qhp.QtQuickControls.subprojects.qtquickcontrolsqmltypes.indexTitle = Qt Quick Controls QML Types qhp.QtQuickControls.subprojects.qtquickcontrolsqmltypes.selectors = class fake:qmlclass qhp.QtQuickControls.subprojects.qtquickcontrolsqmltypes.sortPages = true -qhp.QtQuickControls.subprojects.styleqmltypes.title = Styles QML Types -qhp.QtQuickControls.subprojects.styleqmltypes.indexTitle = Qt Quick Controls Styles QML Types -qhp.QtQuickControls.subprojects.styleqmltypes.selectors = class fake:qmlclass -qhp.QtQuickControls.subprojects.styleqmltypes.sortPages = true - -depends = qtqml qtquick qtwidgets qtdoc qtquicklayouts +depends = qtqml qtquick qtwidgets qtdoc qtquicklayouts qtquickcontrolsstyles exampledirs += ../../../examples/quick/controls @@ -37,21 +32,15 @@ exampledirs += ../../../examples/quick/controls examplesinstallpath = quick/controls headerdirs += ../ -headerdirs += ../ ../../styles/Base sourcedirs += ../ -sourcedirs += ../ ../../styles/Base -sources += ../../private/qstyleitem.cpp \ - ../../private/AbstractCheckable.qml \ +sources += ../../private/AbstractCheckable.qml \ ../../private/BasicButton.qml \ ../../private/FocusFrame.qml \ ../../private/ModalPopupBehavior.qml \ ../../private/ScrollBar.qml \ ../../private/TabBar.qml \ ../../private/Control.qml \ - ../../private/Style.qml \ - ../../private/qquickabstractstyle.h \ - ../../private/qquickabstractstyle.cpp imagedirs += images diff --git a/src/controls/doc/src/qtquickcontrols-index.qdoc b/src/controls/doc/src/qtquickcontrols-index.qdoc index 658d117b..0272755f 100644 --- a/src/controls/doc/src/qtquickcontrols-index.qdoc +++ b/src/controls/doc/src/qtquickcontrols-index.qdoc @@ -84,7 +84,12 @@ \section2 Styles \list - \li \l {Qt Quick Controls Styles QML Types} + \li \l {Qt Quick Controls Styles} + \endlist + + \section2 Styles + \list + \li \l {Qt Quick Layouts} \endlist */ diff --git a/src/controls/doc/src/styles.qdoc b/src/controls/doc/src/styles.qdoc deleted file mode 100644 index 40809414..00000000 --- a/src/controls/doc/src/styles.qdoc +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \qmlmodule QtQuick.Controls.Styles 1 - \title Qt Quick Controls Styles QML Types - \ingroup qmlmodules - \brief Provides QML types for Qt Quick Controls styles. - - The \l{Qt Quick Controls} module provides a set of QML types for handling - styles. - - Some of the controls allow custom styling similar to widget style sheets. - A styling object is usually a collection of properties that control behavior and simple delegates - that can be replaced with custom QML snippets. - -*/ diff --git a/src/styles/Base/ButtonStyle.qml b/src/styles/Base/ButtonStyle.qml index b1fabb86..3144a1a6 100644 --- a/src/styles/Base/ButtonStyle.qml +++ b/src/styles/Base/ButtonStyle.qml @@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0 \qmltype ButtonStyle \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 + \ingroup controlsstyling \brief Provides custom styling for Button You can create a custom button by replacing the "background" delegate diff --git a/src/styles/Base/CheckBoxStyle.qml b/src/styles/Base/CheckBoxStyle.qml index 65b5450b..aa24a94a 100644 --- a/src/styles/Base/CheckBoxStyle.qml +++ b/src/styles/Base/CheckBoxStyle.qml @@ -45,13 +45,14 @@ import QtQuick.Controls.Private 1.0 \qmltype CheckBoxStyle \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 + \ingroup controlsstyling \brief Provides custom styling for CheckBox Example: \qml CheckBox { text: "Check Box" - style: CheckBoxStyle{ + style: CheckBoxStyle { indicator: Rectangle { implicitWidth: 16 implicitHeight: 16 @@ -66,7 +67,6 @@ import QtQuick.Controls.Private 1.0 anchors.margins: 4 anchors.fill: parent } - } } } } diff --git a/src/styles/Base/ComboBoxStyle.qml b/src/styles/Base/ComboBoxStyle.qml index 982ce00e..241f3550 100644 --- a/src/styles/Base/ComboBoxStyle.qml +++ b/src/styles/Base/ComboBoxStyle.qml @@ -46,6 +46,7 @@ import QtQuick.Controls.Private 1.0 \qmltype ComboBoxStyle \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 + \ingroup controlsstyling \brief Provides custom styling for ComboBox */ diff --git a/src/styles/Base/GroupBoxStyle.qml b/src/styles/Base/GroupBoxStyle.qml index db0c3bf6..1c3acada 100644 --- a/src/styles/Base/GroupBoxStyle.qml +++ b/src/styles/Base/GroupBoxStyle.qml @@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0 \qmltype GroupBoxStyle \internal \inqmlmodule QtQuick.Controls.Styles 1.0 + \ingroup controlsstyling \since QtQuick.Controls.Styles 1.0 */ Style { diff --git a/src/styles/Base/MenuBarStyle.qml b/src/styles/Base/MenuBarStyle.qml index e5b91be6..4effd6ee 100644 --- a/src/styles/Base/MenuBarStyle.qml +++ b/src/styles/Base/MenuBarStyle.qml @@ -45,6 +45,7 @@ import "../../Private/style.js" as StyleHelpers /*! \qmltype MenuBarStyle \internal + \ingroup applicationwindowstyling \inqmlmodule QtQuick.Controls.Styles 1.0 */ diff --git a/src/styles/Base/MenuStyle.qml b/src/styles/Base/MenuStyle.qml index 69dffc73..eab18f7d 100644 --- a/src/styles/Base/MenuStyle.qml +++ b/src/styles/Base/MenuStyle.qml @@ -43,6 +43,13 @@ import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 import "../../Private/style.js" as StyleHelpers +/*! + \qmltype MenuStyle + \internal + \ingroup menusstyling + \inqmlmodule QtQuick.Controls.Styles 1.0 +*/ + Style { id: styleRoot diff --git a/src/styles/Base/ProgressBarStyle.qml b/src/styles/Base/ProgressBarStyle.qml index eab286f0..ada97c10 100644 --- a/src/styles/Base/ProgressBarStyle.qml +++ b/src/styles/Base/ProgressBarStyle.qml @@ -47,6 +47,7 @@ import QtQuick.Controls.Private 1.0 \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 + \ingroup controlsstyling \brief Provides custom styling for ProgressBar Example: @@ -94,6 +95,9 @@ Style { */ padding { top: 0 ; left: 0 ; right: 0 ; bottom: 0 } + /*! \qmlproperty Component ProgressBarStyle::progress + The progress component for this style. + */ property Component progress: Rectangle { property color progressColor: "#49d" anchors.fill: parent @@ -129,6 +133,9 @@ Style { } } + /*! \qmlproperty Component ProgressBarStyle::background + The background component for this style. + */ property Component background: Item { implicitWidth: 200 implicitHeight: 24 @@ -145,6 +152,9 @@ Style { } } + /*! \qmlproperty Component ProgressBarStyle::panel + The panel component for this style. + */ property Component panel: Item{ property bool horizontal: control.orientation == Qt.Horizontal implicitWidth: horizontal ? backgroundLoader.implicitWidth : backgroundLoader.implicitHeight diff --git a/src/styles/Base/RadioButtonStyle.qml b/src/styles/Base/RadioButtonStyle.qml index d87f57c7..b42ac1bd 100644 --- a/src/styles/Base/RadioButtonStyle.qml +++ b/src/styles/Base/RadioButtonStyle.qml @@ -45,13 +45,14 @@ import QtQuick.Controls.Private 1.0 \qmltype RadioButtonStyle \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 + \ingroup controlsstyling \brief Provides custom styling for RadioButton Example: \qml RadioButton { text: "Radio Button" - style: RadioButtonStyle{ + style: RadioButtonStyle { indicator: Rectangle { implicitWidth: 16 implicitHeight: 16 @@ -65,10 +66,9 @@ import QtQuick.Controls.Private 1.0 radius: 9 anchors.margins: 4 } - } } } - } + } \endqml */ diff --git a/src/styles/Base/ScrollViewStyle.qml b/src/styles/Base/ScrollViewStyle.qml index 3d1f8d26..ed7dd171 100644 --- a/src/styles/Base/ScrollViewStyle.qml +++ b/src/styles/Base/ScrollViewStyle.qml @@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0 \qmltype ScrollViewStyle \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 + \ingroup viewsstyling \brief Provides custom styling for ScrollView */ Style { diff --git a/src/styles/Base/SliderStyle.qml b/src/styles/Base/SliderStyle.qml index a17de0a1..e21936a2 100644 --- a/src/styles/Base/SliderStyle.qml +++ b/src/styles/Base/SliderStyle.qml @@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0 \qmltype SliderStyle \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 + \ingroup controlsstyling \brief Provides custom styling for Slider The slider style allows you to create a custom appearance for diff --git a/src/styles/Base/SpinBoxStyle.qml b/src/styles/Base/SpinBoxStyle.qml index c239483e..931db588 100644 --- a/src/styles/Base/SpinBoxStyle.qml +++ b/src/styles/Base/SpinBoxStyle.qml @@ -46,6 +46,7 @@ import QtQuick.Controls.Private 1.0 \internal \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 + \ingroup controlsstyling \brief Provides custom styling for SpinBox */ diff --git a/src/styles/Base/StatusBarStyle.qml b/src/styles/Base/StatusBarStyle.qml index e8abe19b..f8ffffd9 100644 --- a/src/styles/Base/StatusBarStyle.qml +++ b/src/styles/Base/StatusBarStyle.qml @@ -44,6 +44,7 @@ import QtQuick.Controls.Private 1.0 /*! \qmltype StatusBarStyle \internal + \ingroup applicationwindowstyling \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 */ diff --git a/src/styles/Base/TabViewStyle.qml b/src/styles/Base/TabViewStyle.qml index 04e34d4c..f5cd1047 100644 --- a/src/styles/Base/TabViewStyle.qml +++ b/src/styles/Base/TabViewStyle.qml @@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0 \qmltype TabViewStyle \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 + \ingroup viewsstyling \brief Provides custom styling for TabView \qml diff --git a/src/styles/Base/TableViewStyle.qml b/src/styles/Base/TableViewStyle.qml index a7b3ba49..1a0605dc 100644 --- a/src/styles/Base/TableViewStyle.qml +++ b/src/styles/Base/TableViewStyle.qml @@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0 \qmltype TableViewStyle \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 + \ingroup viewsstyling \brief Provides custom styling for TableView Note that this class derives from \l ScrollViewStyle @@ -73,7 +74,9 @@ ScrollViewStyle { padding.top: control.headerVisible ? 0 : 1 - /* Delegate for header. This delegate is described in \l TableView::headerDelegate */ + /*! \qmlproperty Component TableViewStyle::headerDelegate + Delegate for header. This delegate is described in \l {TableView::headerDelegate} + */ property Component headerDelegate: BorderImage { source: "images/header.png" border.left: 4 @@ -97,7 +100,9 @@ ScrollViewStyle { } } - /* Delegate for header. This delegate is described in \l TableView::rowDelegate */ + /*! \qmlproperty Component TableViewStyle::rowDelegate + Delegate for header. This delegate is described in \l {TableView::rowDelegate} + */ property Component rowDelegate: Rectangle { height: 20 property color selectedColor: styleData.hasActiveFocus ? "#38d" : "#999" @@ -126,7 +131,9 @@ ScrollViewStyle { } } - /* Delegate for header. This delegate is described in \l TableView::itemDelegate */ + /*! \qmlproperty Component TableViewStyle::rowDelegate + Delegate for item. This delegate is described in \l {TableView::itemDelegate} + */ property Component itemDelegate: Item { height: Math.max(16, label.implicitHeight) property int implicitWidth: sizehint.paintedWidth + 20 diff --git a/src/styles/Base/TextFieldStyle.qml b/src/styles/Base/TextFieldStyle.qml index 7b0ba6b2..16d0fe94 100644 --- a/src/styles/Base/TextFieldStyle.qml +++ b/src/styles/Base/TextFieldStyle.qml @@ -45,6 +45,7 @@ import QtQuick.Controls.Private 1.0 \qmltype TextFieldStyle \inqmlmodule QtQuick.Controls.Styles 1.0 \since QtQuick.Controls.Styles 1.0 + \ingroup controlsstyling \brief Provides custom styling for TextField. Example: diff --git a/src/styles/Base/ToolBarStyle.qml b/src/styles/Base/ToolBarStyle.qml index 835f8219..a5c03e7a 100644 --- a/src/styles/Base/ToolBarStyle.qml +++ b/src/styles/Base/ToolBarStyle.qml @@ -44,6 +44,7 @@ import QtQuick.Controls.Private 1.0 /*! \qmltype ToolBarStyle \internal + \ingroup applicationwindowstyling \inqmlmodule QtQuick.Controls.Styles 1.0 */ Style { diff --git a/src/styles/Base/ToolButtonStyle.qml b/src/styles/Base/ToolButtonStyle.qml index e8d05d6c..0ead0750 100644 --- a/src/styles/Base/ToolButtonStyle.qml +++ b/src/styles/Base/ToolButtonStyle.qml @@ -44,6 +44,7 @@ import QtQuick.Controls.Private 1.0 /*! \qmltype ToolButtonStyle \internal + \ingroup controlsstyling \inqmlmodule QtQuick.Controls.Styles 1.0 */ Style { diff --git a/src/styles/doc/qtquickcontrolsstyles.qdocconf b/src/styles/doc/qtquickcontrolsstyles.qdocconf new file mode 100644 index 00000000..e559dcc4 --- /dev/null +++ b/src/styles/doc/qtquickcontrolsstyles.qdocconf @@ -0,0 +1,43 @@ +include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) + +project = QtQuickControlsStyles +description = Qt Quick Controls Styles Reference Documentation +url = http://qt-project.org/doc/qt-$QT_VER/qtquickcontrolsstyles/ +version = $QT_VERSION + +qhp.projects = QtQuickControlsStyles + +qhp.QtQuickControlsStyles.file = qtquickcontrolsstyles.qhp +qhp.QtQuickControlsStyles.namespace = org.qt-project.qtquickcontrolsstyles.$QT_VERSION_TAG +qhp.QtQuickControlsStyles.virtualFolder = qtquickcontrolsstyles +qhp.QtQuickControlsStyles.indexTitle = Qt Quick Controls Styles +qhp.QtQuickControlsStyles.indexRoot = +#qhp.QtQuickControlsStyles.extraFiles = style/qtquickcontrolsstyles.css + +qhp.QtQuickControlsStyles.filterAttributes = qtcontrolsstyles $QT_VERSION qtrefdoc +qhp.QtQuickControlsStyles.customFilters.Qt.name = QtQuickControlsStyles $QT_VERSION +qhp.QtQuickControlsStyles.customFilters.Qt.filterAttributes = qtquickcontrolsstyles $QT_VERSION + +qhp.QtQuickControlsStyles.subprojects = qtquickcontrolsstylesqmltypes +qhp.QtQuickControlsStyles.subprojects.qtquickcontrolsstylesqmltypes.title = QML Types +qhp.QtQuickControlsStyles.subprojects.qtquickcontrolsstylesqmltypes.indexTitle = Qt Quick Controls Styles QML Types +qhp.QtQuickControlsStyles.subprojects.qtquickcontrolsstylesqmltypes.selectors = class fake:qmlclass +qhp.QtQuickControlsStyles.subprojects.qtquickcontrolsstylesqmltypes.sortPages = true + +depends = qtqml qtquick qtwidgets qtdoc qtquicklayouts qtquickcontrols + +exampledirs += ../../../examples/quick/controlsstyles + +# Specify the install path under QT_INSTALL_EXAMPLES +examplesinstallpath = quick/controlsstyles + +headerdirs += ../Base + +sourcedirs += ../Base + +sources += ../../private/qquickstyleitem.cpp \ + ../../private/Style.qml \ + ../../private/qquickabstractstyle.h \ + ../../private/qquickabstractstyle.cpp + +imagedirs += images diff --git a/src/styles/doc/src/qtquickcontrolsstyles-index.qdoc b/src/styles/doc/src/qtquickcontrolsstyles-index.qdoc new file mode 100644 index 00000000..b2205bfc --- /dev/null +++ b/src/styles/doc/src/qtquickcontrolsstyles-index.qdoc @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + + + +/*! + \group applicationwindowstyling + \title Styling Application Window + \internal +*/ + +/*! + \group viewsstyling + \title Styling Views +*/ + +/*! + \group controlsstyling + \title Styling Controls +*/ + +/*! + \group menusstyling + \title Styling Menus + \internal +*/ + + +/*! + \page qtquickcontrolsstyles-index.html + \title Qt Quick Controls Styles + \brief The Qt Quick Controls Styles submodule provides custom styles for Qt Quick Controls. + + The Qt Quick Controls Styles submodule allows custom styling for \l {Qt Quick Controls}. + + The submodule is new in Qt 5.1 and requires \l{Qt Quick} 2.1. + + \section1 Getting started + + The QML types can be imported into your application using the following import statement in your \c {.qml} file. + + \code + import QtQuick.Controls.Styles 1.0 + \endcode + + \section1 Styling Views + \annotatedlist viewsstyling + + \section1 Styling Controls + \annotatedlist controlsstyling + + \section1 Related information + + \section2 QML Types + \list + \li \l{Qt Quick Controls Styles QML Types} + \endlist + +*/ + +/*! + \qmlmodule QtQuick.Controls.Styles 1 + \title Qt Quick Controls Styles QML Types + \ingroup qmlmodules + \brief Provides QML types for Qt Quick Controls styles. + + The \l{Qt Quick Controls} module provides a set of QML types for handling + styles. + + Some of the controls allow custom styling similar to widget style sheets. + A styling object is usually a collection of properties that control behavior and simple delegates + that can be replaced with custom QML snippets. + +*/ diff --git a/src/styles/styles.pro b/src/styles/styles.pro index 4c0ee5d3..158c1dd1 100644 --- a/src/styles/styles.pro +++ b/src/styles/styles.pro @@ -1,5 +1,7 @@ TARGETPATH = QtQuick/Controls/Styles +QMAKE_DOCS = $$PWD/doc/qtquickcontrolsstyles.qdocconf + # Base QML_FILES = \ Base/ButtonStyle.qml \ -- cgit v1.2.1 From cbd4b0f4e83cd458bd0f1ecbb53f1d789dfe9ff7 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Mon, 3 Jun 2013 10:43:33 +0200 Subject: Doc: Fixes warnings Fixes issues including: - Misspelled links - Links to signal with arguments - \table in SplitView.qml - Links to current file Change-Id: I2cbadf661a641f19ed55f6854922b2b69966bc9c Reviewed-by: Jerome Pasion --- src/controls/Button.qml | 2 +- src/controls/SplitView.qml | 8 ++++---- src/controls/TableView.qml | 5 ++--- src/controls/ToolButton.qml | 2 +- src/controls/qquickaction.cpp | 10 +++++----- src/controls/qquickexclusivegroup.cpp | 16 ++++++++-------- src/controls/qquickmenu.cpp | 4 ++-- src/controls/qquickmenuitem.cpp | 10 +++++----- 8 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/controls/Button.qml b/src/controls/Button.qml index 1a9b198e..21231e57 100644 --- a/src/controls/Button.qml +++ b/src/controls/Button.qml @@ -80,7 +80,7 @@ BasicButton { property string text /*! This property holds the icon shown on the button. If the button has no - icon, the \l iconSource property will be an empty string. + icon, the iconSource property will be an empty string. The default value is the empty string. */ diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml index aba7809f..ff44a03a 100644 --- a/src/controls/SplitView.qml +++ b/src/controls/SplitView.qml @@ -130,12 +130,12 @@ Item { child item. Inside the delegate the following properties are available: \table - \li readonly property bool styleData.index - Specifies the index of the splitter handle. The handle + \row \li readonly property bool styleData.index \li Specifies the index of the splitter handle. The handle between the first and the second item will get index 0, the next handle index 1 etc. - \li readonly property bool styleData.hovered - The handle is being hovered. - \li readonly property bool styleData.pressed - The handle is being pressed. - \li readonly property bool styleData.resizing - The handle is being dragged. + \row \li readonly property bool styleData.hovered \li The handle is being hovered. + \row \li readonly property bool styleData.pressed \li The handle is being pressed. + \row \li readonly property bool styleData.resizing \li The handle is being dragged. \endtable */ diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index 88a897e1..f6a8ed4b 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -65,8 +65,7 @@ import QtQuick.Controls.Styles 1.0 \endcode You provide title and size of a column header - by adding a \l TableViewColumn to the default \l header property - as demonstrated below. + by adding a \l TableViewColumn as demonstrated below. \code TableView { @@ -259,7 +258,7 @@ ScrollView { Depending on how the model is populated, the model may not be ready when TableView Component.onCompleted is called. In that case you may need to - delay the call to positionViewAtRow by using a \l {Timer}. + delay the call to positionViewAtRow by using a \l {QtQml::Timer}{Timer}. \note This method should only be called after the component has completed. */ diff --git a/src/controls/ToolButton.qml b/src/controls/ToolButton.qml index d6607d28..6cd3661b 100644 --- a/src/controls/ToolButton.qml +++ b/src/controls/ToolButton.qml @@ -46,7 +46,7 @@ import QtQuick.Controls.Private 1.0 \qmltype ToolButton \inqmlmodule QtQuick.Controls 1.0 \since QtQtuick.Controls 1.0 - \ingroup applicationwindow + \ingroup controls \brief Provides a button type that is typically used within a ToolBar. ToolButton is functionally similar to \l Button, but can provide a look that is more diff --git a/src/controls/qquickaction.cpp b/src/controls/qquickaction.cpp index a597515f..e240d111 100644 --- a/src/controls/qquickaction.cpp +++ b/src/controls/qquickaction.cpp @@ -123,7 +123,7 @@ QT_BEGIN_NAMESPACE Whether the action is enabled, and can be triggered. Defaults to \c true. - \sa tigger(), triggered() + \sa trigger(), triggered */ /*! @@ -140,7 +140,7 @@ QT_BEGIN_NAMESPACE If the action is \l checkable, this property reflects its checked state. Defaults to \c false. Its value is also false while \l checkable is false. - \sa toggled(), exclusiveGroup + \sa toggled, exclusiveGroup */ /*! @@ -169,14 +169,14 @@ QT_BEGIN_NAMESPACE /*! \qmlmethod Action::trigger() - Will emit the \l triggered() signal if the action is enabled. Will also emit the - \l toggled() signal if it is checkable. + Will emit the \l triggered signal if the action is enabled. Will also emit the + \l toggled signal if it is checkable. */ /*! \qmlsignal Action::toggled(checked) Emitted whenever a action's \l checked property changes. - This usually happens at the same time as \l triggered(). + This usually happens at the same time as \l triggered. */ QQuickAction::QQuickAction(QObject *parent) diff --git a/src/controls/qquickexclusivegroup.cpp b/src/controls/qquickexclusivegroup.cpp index eecff416..f1b6935e 100644 --- a/src/controls/qquickexclusivegroup.cpp +++ b/src/controls/qquickexclusivegroup.cpp @@ -97,9 +97,9 @@ static bool isChecked(const QObject *o) } \endcode - Several controls already support \l ExclusiveGroup, e.g. \l Action, \l MenuItem, \l Button, and \l RadioButton. + Several controls already support ExclusiveGroup, e.g. \l Action, \l MenuItem, \l Button, and \l RadioButton. - Since \l ExclusiveGroup only supports \l Action as child items, we need to manually assign the \c exclusiveGroup + Since ExclusiveGroup only supports \l Action as child items, we need to manually assign the \c exclusiveGroup property for other objects. \code @@ -131,9 +131,9 @@ static bool isChecked(const QObject *o) \section1 Adding support to ExclusiveGroup - It is possible to add support for \l ExclusiveGroup for an object, or control. It should have a \c checked + It is possible to add support for ExclusiveGroup for an object, or control. It should have a \c checked property, and either a \c checkedChanged, \c toggled(), or \c toggled(bool) signal. It also needs - to be bound with \l ExclusiveGroup::bindCheckable(object) when its \l ExclusiveGroup ty[ped property is set. + to be bound with \l ExclusiveGroup::bindCheckable() when its ExclusiveGroup ty[ped property is set. \code Item { @@ -149,13 +149,13 @@ static bool isChecked(const QObject *o) } \endcode - The example above shows the minimum necessary to add \l ExclusiveGroup support to any item. + The example above shows the minimum necessary to add ExclusiveGroup support to any item. */ /*! \qmlproperty object ExclusiveGroup::current - The currently selected object. Defaults to the first checked object bound to the \l ExclusiveGroup. + The currently selected object. Defaults to the first checked object bound to the ExclusiveGroup. If there is none, then it defaults to \c null. */ @@ -166,7 +166,7 @@ static bool isChecked(const QObject *o) You should only need to call this function when creating a component you want to be compatible with \c ExclusiveGroup. - \sa ExclusiveGroup::unbindCheckable(object) + \sa ExclusiveGroup::unbindCheckable() */ /*! @@ -176,7 +176,7 @@ static bool isChecked(const QObject *o) You should only need to call this function when creating a component you want to be compatible with \c ExclusiveGroup. - \sa ExclusiveGroup::bindCheckable(object) + \sa ExclusiveGroup::bindCheckable() */ QQuickExclusiveGroup::QQuickExclusiveGroup(QObject *parent) diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp index efc49cd6..bb0ddae9 100644 --- a/src/controls/qquickmenu.cpp +++ b/src/controls/qquickmenu.cpp @@ -100,7 +100,7 @@ QT_BEGIN_NAMESPACE \endcode Note that in this case, the \c index parameter passed to \l insertItem() is relative - to the position of the \l Instatiator in the menu, as opposed to absolute position + to the position of the \l Instantiator in the menu, as opposed to absolute position in the menu. \sa MenuItem, MenuSeparator @@ -170,7 +170,7 @@ QT_BEGIN_NAMESPACE Adds an item to the menu. Returns the newly created \l MenuItem. - \sa insertItem(int before, string title) + \sa insertItem() */ /*! diff --git a/src/controls/qquickmenuitem.cpp b/src/controls/qquickmenuitem.cpp index de215df1..622fdd2d 100644 --- a/src/controls/qquickmenuitem.cpp +++ b/src/controls/qquickmenuitem.cpp @@ -329,14 +329,14 @@ void QQuickMenuText::updateIcon() Emitted when either the menu item or its bound action have been activated. - \sa trigger(), Action::triggered(), Action::toggled() + \sa trigger(), Action::triggered, Action::toggled */ /*! \qmlmethod MenuItem::trigger() Manually trigger a menu item. Will also trigger the item's bound action. - \sa triggered(), Action::trigger() + \sa triggered, Action::trigger() */ /*! @@ -360,7 +360,7 @@ void QQuickMenuText::updateIcon() If the menu item is checkable, this property reflects its checked state. Defaults to \c false. - \sa checkable, Action::toggled() + \sa checkable, Action::toggled */ /*! \qmlproperty ExclusiveGroup MenuItem::exclusiveGroup @@ -378,9 +378,9 @@ void QQuickMenuText::updateIcon() /*! \qmlsignal MenuItem::toggled(checked) Emitted whenever a menu item's \c checked property changes. - This usually happens at the same time as \l triggered(). + This usually happens at the same time as \l triggered. - \sa checked, triggered(), Action::triggered(), Action::toggled() + \sa checked, triggered, Action::triggered, Action::toggled */ /*! -- cgit v1.2.1 From 207366038543adf5ee6384ff2577410f48df7a13 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 3 Jun 2013 13:37:25 +0200 Subject: Fix incorrect size hint for ToolBar and StatusBar We only cared about reserving space for the height but while trying to actually get the minimumSize for a window based on the toolbar content I realized that we really need to calculate the width as well. Change-Id: I7b55b66a2475a2355d30614095f173a39f47f2f1 Reviewed-by: Caroline Chao --- src/controls/StatusBar.qml | 6 +++++- src/controls/ToolBar.qml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/controls/StatusBar.qml b/src/controls/StatusBar.qml index 068b6b20..85cc6681 100644 --- a/src/controls/StatusBar.qml +++ b/src/controls/StatusBar.qml @@ -79,7 +79,7 @@ Item { Accessible.role: Accessible.StatusBar width: parent ? parent.width : implicitWidth - implicitWidth: loader.item ? loader.item.implicitWidth : 200 + implicitWidth: container.leftMargin + container.rightMargin + container.calcWidth() implicitHeight: Math.max(container.topMargin + container.bottomMargin + container.calcHeight(), loader.item ? loader.item.implicitHeight : 19) @@ -134,6 +134,10 @@ Item { property int rightMargin: __style ? __style.padding.right : 0 property Item layoutItem: container.children.length === 1 ? container.children[0] : null + function calcWidth() { return (layoutItem ? (layoutItem.implicitWidth || layoutItem.width) + + (layoutItem.anchors.fill ? layoutItem.anchors.leftMargin + + layoutItem.anchors.rightMargin : 0) : + loader.item ? loader.item.implicitWidth: 0) } function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) + (layoutItem.anchors.fill ? layoutItem.anchors.topMargin + layoutItem.anchors.bottomMargin : 0) : loader.item ? loader.item.implicitHeight : 0) } diff --git a/src/controls/ToolBar.qml b/src/controls/ToolBar.qml index e5cc8419..b73a6f3e 100644 --- a/src/controls/ToolBar.qml +++ b/src/controls/ToolBar.qml @@ -83,7 +83,7 @@ Item { Accessible.role: Accessible.ToolBar width: parent ? parent.width : implicitWidth - implicitWidth: loader.item ? loader.item.implicitWidth : 200 + implicitWidth: container.leftMargin + container.rightMargin + container.calcWidth() implicitHeight: container.topMargin + container.bottomMargin + container.calcHeight() /*! \internal */ @@ -137,6 +137,10 @@ Item { property int rightMargin: __style ? __style.padding.right : 0 property Item layoutItem: container.children.length === 1 ? container.children[0] : null + function calcWidth() { return (layoutItem ? (layoutItem.implicitWidth || layoutItem.width) + + (layoutItem.anchors.fill ? layoutItem.anchors.leftMargin + + layoutItem.anchors.rightMargin : 0) : + loader.item ? loader.item.implicitWidth : 0) } function calcHeight () { return (layoutItem ? (layoutItem.implicitHeight || layoutItem.height) + (layoutItem.anchors.fill ? layoutItem.anchors.topMargin + layoutItem.anchors.bottomMargin : 0) : -- cgit v1.2.1 From 4e5bf941f1b3089c22392bb5416d44cb8defe47d Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 3 Jun 2013 15:53:50 +0200 Subject: Improve default size for several controls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We should set this to some decent default value that doesn't look wrong. Note that the width and height definition in TextArea could cause conflicts when used in layouts. Change-Id: I815ff96c02f9a9a76c07d57181f3a24291c83c52 Reviewed-by: Jan Arve Sæther Reviewed-by: Gabriel de Dietrich --- src/controls/ScrollView.qml | 5 +++-- src/controls/TabView.qml | 3 ++- src/controls/TableView.qml | 4 ++-- src/controls/TextArea.qml | 3 --- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/controls/ScrollView.qml b/src/controls/ScrollView.qml index 0af69a0d..aa980ddd 100644 --- a/src/controls/ScrollView.qml +++ b/src/controls/ScrollView.qml @@ -86,8 +86,9 @@ import QtQuick.Controls.Styles 1.0 FocusScope { id: root - implicitWidth: 200 - implicitHeight: 100 + + implicitWidth: 240 + implicitHeight: 150 /*! This property tells the ScrollView if it should render diff --git a/src/controls/TabView.qml b/src/controls/TabView.qml index e0d3ca3b..6319d72c 100644 --- a/src/controls/TabView.qml +++ b/src/controls/TabView.qml @@ -55,7 +55,8 @@ import QtQuick.Controls.Private 1.0 FocusScope { id: root - implicitWidth: 150 + + implicitWidth: 240 implicitHeight: 150 /*! The current tab index */ diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index f6a8ed4b..a71264da 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -359,8 +359,8 @@ ScrollView { Accessible.role: Accessible.Table - width: 200 - height: 200 + implicitWidth: 200 + implicitHeight: 150 frameVisible: true __scrollBarTopMargin: Qt.platform.os === "mac" ? headerrow.height : 0 diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml index 43cc347c..cbef6e31 100644 --- a/src/controls/TextArea.qml +++ b/src/controls/TextArea.qml @@ -611,9 +611,6 @@ ScrollView { /*! \internal */ property int __documentMargin: 4 - width: 280 - height: 120 - frameVisible: true activeFocusOnTab: true -- cgit v1.2.1 From eeb3c959334d1e6b4ea9f7538b603a711f8a8262 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 3 Jun 2013 14:05:26 +0200 Subject: Buttons: Allow overriding of visual properties when 'action' is set Those properties are, text, tooltip, iconName, and iconSource. Also, properly capitalized gallery's tooltips. Change-Id: I1995a85565edd7aaa420279821d7c1a31ef18253 Reviewed-by: J-P Nurmi Reviewed-by: Jens Bache-Wiig --- examples/quick/controls/gallery/main.qml | 4 ++-- src/controls/Button.qml | 22 +++++++------------ src/controls/ToolButton.qml | 12 ----------- src/controls/qquickaction_p.h | 9 +++++--- src/controls/qquickmenuitem.cpp | 2 +- src/private/BasicButton.qml | 36 +++++++++++++++++++++++++++----- src/private/style.js | 15 +++++++++++-- src/styles/Desktop/ButtonStyle.qml | 2 +- src/styles/Desktop/ToolButtonStyle.qml | 2 +- 9 files changed, 63 insertions(+), 41 deletions(-) diff --git a/examples/quick/controls/gallery/main.qml b/examples/quick/controls/gallery/main.qml index 86dddbe2..8ea3cf9e 100644 --- a/examples/quick/controls/gallery/main.qml +++ b/examples/quick/controls/gallery/main.qml @@ -76,7 +76,7 @@ ApplicationWindow { shortcut: "Ctrl+O" iconSource: "images/document-open.png" onTriggered: fileDialog.open() - tooltip: "open an image" + tooltip: "Open an image" } Action { @@ -168,7 +168,7 @@ ApplicationWindow { ToolButton { action: openAction } ToolButton { iconSource: "images/document-save-as.png" - tooltip: "(Pretend to) save as..." + tooltip: "(Pretend to) Save as..." } Item { Layout.fillWidth: true } CheckBox { diff --git a/src/controls/Button.qml b/src/controls/Button.qml index 21231e57..1f00dccb 100644 --- a/src/controls/Button.qml +++ b/src/controls/Button.qml @@ -72,20 +72,6 @@ BasicButton { */ property bool isDefault: false - /*! This property holds the text shown on the button. If the button has no - text, the \l text property will be an empty string. - - The default value is the empty string. - */ - property string text - - /*! This property holds the icon shown on the button. If the button has no - icon, the iconSource property will be an empty string. - - The default value is the empty string. - */ - property url iconSource - /*! Assign a \l Menu to this property to get a pull-down menu button. The default value is \c null. @@ -115,6 +101,14 @@ BasicButton { value: button } + Binding { + target: button + property: "tooltip" + // We don't want a tooltip if it's the same as the button text + when: !!text && !(action && (!!action.tooltip || action.tooltip === text)) + value: "" + } + Connections { target: __behavior onEffectivePressedChanged: { diff --git a/src/controls/ToolButton.qml b/src/controls/ToolButton.qml index 6cd3661b..3c1eab1a 100644 --- a/src/controls/ToolButton.qml +++ b/src/controls/ToolButton.qml @@ -62,18 +62,6 @@ import QtQuick.Controls.Private 1.0 BasicButton { id: button - /*! The image label source as file name or resource. */ - property url iconSource - - /*! The image label source as theme name. - When an icon from the platform icon theme is found, this takes - precedence over iconSource. - */ - property url iconName - - /*! The label text. */ - property string text - activeFocusOnTab: true Accessible.name: text diff --git a/src/controls/qquickaction_p.h b/src/controls/qquickaction_p.h index e106a920..aa63b408 100644 --- a/src/controls/qquickaction_p.h +++ b/src/controls/qquickaction_p.h @@ -57,11 +57,11 @@ class QQuickAction : public QObject { Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged) + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged RESET resetText) + Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged RESET resetIconSource) Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged) Q_PROPERTY(QVariant __icon READ iconVariant NOTIFY iconChanged) - Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged) + Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged RESET resetTooltip) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged) Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled) @@ -76,6 +76,7 @@ public: ~QQuickAction(); QString text() const { return m_text; } + void resetText() { setText(QString()); } void setText(const QString &text); QString shortcut() const; @@ -87,9 +88,11 @@ public: void setIconName(const QString &iconName); QUrl iconSource() const { return m_iconSource; } + void resetIconSource() { setIconSource(QString()); } void setIconSource(const QUrl &iconSource); QString tooltip() const { return m_tooltip; } + void resetTooltip() { setTooltip(QString()); } void setTooltip(const QString &tooltip); bool isEnabled() const { return m_enabled; } diff --git a/src/controls/qquickmenuitem.cpp b/src/controls/qquickmenuitem.cpp index 622fdd2d..ed03b336 100644 --- a/src/controls/qquickmenuitem.cpp +++ b/src/controls/qquickmenuitem.cpp @@ -503,7 +503,7 @@ void QQuickMenuItem::setBoundAction(QQuickAction *a) QString QQuickMenuItem::text() const { QString ownText = QQuickMenuText::text(); - if (!ownText.isEmpty()) + if (!ownText.isNull()) return ownText; return m_boundAction ? m_boundAction->text() : QString(); } diff --git a/src/private/BasicButton.qml b/src/private/BasicButton.qml index 3ef4b6e9..a967f73f 100644 --- a/src/private/BasicButton.qml +++ b/src/private/BasicButton.qml @@ -42,6 +42,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 import QtQuick.Controls.Styles 1.0 +import "style.js" as StyleHelpers /*! \qmltype BasicButton @@ -83,6 +84,9 @@ Control { If a button has an action associated, the action defines the button's properties like checked, text, tooltip etc. + When an action is set, it's still possible to override the \l text, + \l tooltip, \l iconSource, and \l iconName properties. + The default value is \c null. */ property Action action: null @@ -91,8 +95,28 @@ Control { The default value is \c false. */ property bool activeFocusOnPress: false + /*! This property holds the text shown on the button. If the button has no + text, the \l text property will be an empty string. + + The default value is the empty string. + */ + property string text: action ? action.text : "" + /*! This property holds the button tooltip. */ - property string tooltip + property string tooltip: action ? (action.tooltip || StyleHelpers.removeMnemonics(action.text)) : "" + + /*! This property holds the icon shown on the button. If the button has no + icon, the iconSource property will be an empty string. + + The default value is the empty string. + */ + property url iconSource: action ? action.iconSource : "" + + /*! The image label source as theme name. + When an icon from the platform icon theme is found, this takes + precedence over iconSource. + */ + property string iconName: action ? action.iconName : "" /*! \internal */ property color __textColor: syspal.text @@ -101,7 +125,11 @@ Control { /*! \internal */ property alias __containsMouse: behavior.containsMouse /*! \internal */ + readonly property bool __iconOverriden: button.action && (button.action.iconSource !== button.iconSource || button.action.iconName !== button.iconName) + /*! \internal */ property Action __action: action || ownAction + /*! \internal */ + readonly property Action __iconAction: __iconOverriden ? ownAction : __action /*! \internal */ onExclusiveGroupChanged: { @@ -119,7 +147,8 @@ Control { Action { id: ownAction - iconSource: !button.action ? button.iconSource : "" + iconSource: !button.action || __iconOverriden ? button.iconSource : "" + iconName: !button.action || __iconOverriden ? button.iconName : "" } Connections { @@ -181,9 +210,6 @@ Control { enabled: action.enabled checkable: action.checkable checked: action.checked - text: action.text - iconSource: action.iconSource - tooltip: action.tooltip } } ] diff --git a/src/private/style.js b/src/private/style.js index 81d6b563..2c47ff0e 100644 --- a/src/private/style.js +++ b/src/private/style.js @@ -40,13 +40,24 @@ .pragma library -function replaceAmpersands(match, p1, p2, p3) { +function underlineAmpersands(match, p1, p2, p3) { if (p2 === "&") return p1.concat(p2, p3) return p1.concat("", p2, "", p3) } +function removeAmpersands(match, p1, p2, p3) { + return p1.concat(p2, p3) +} + +function replaceAmpersands(text, replaceFunction) { + return text.replace(/([^&]*)&(.)([^&]*)/g, replaceFunction) +} + function stylizeMnemonics(text) { + return replaceAmpersands(text, underlineAmpersands) +} - return text.replace(/([^&]*)&(.)([^&]*)/g, replaceAmpersands) +function removeMnemonics(text) { + return replaceAmpersands(text, removeAmpersands) } diff --git a/src/styles/Desktop/ButtonStyle.qml b/src/styles/Desktop/ButtonStyle.qml index 3ae42c03..3f0670bf 100644 --- a/src/styles/Desktop/ButtonStyle.qml +++ b/src/styles/Desktop/ButtonStyle.qml @@ -54,7 +54,7 @@ Style { activeControl: control.isDefault ? "default" : "f" properties: { - "icon": control.__action.__icon, + "icon": control.__iconAction.__icon, "menu": control.menu } } diff --git a/src/styles/Desktop/ToolButtonStyle.qml b/src/styles/Desktop/ToolButtonStyle.qml index b5b260e6..3dd22a53 100644 --- a/src/styles/Desktop/ToolButtonStyle.qml +++ b/src/styles/Desktop/ToolButtonStyle.qml @@ -55,7 +55,7 @@ Style { text: control.text properties: { - "icon": control.__action.__icon, + "icon": control.__iconAction.__icon, "position": control.__position } } -- cgit v1.2.1 From 86df745c940cd54ca9c7b11347ee4a80b7a5577c Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Mon, 3 Jun 2013 15:44:10 +0200 Subject: Gallery: remove reference to colorDialog Change-Id: I0433e350634b4a2bea6161f53e7c7363654e2cf6 Reviewed-by: Jens Bache-Wiig --- examples/quick/controls/gallery/content/Styles.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/quick/controls/gallery/content/Styles.qml b/examples/quick/controls/gallery/content/Styles.qml index 97797f83..3a7d2bfd 100644 --- a/examples/quick/controls/gallery/content/Styles.qml +++ b/examples/quick/controls/gallery/content/Styles.qml @@ -63,7 +63,6 @@ Item { Button { text: "Push me" style: ButtonStyle { } - onClicked: colorDialog.open() implicitWidth: columnWidth } Button { -- cgit v1.2.1 From 4051e69852cd648942e03cd36e14c2c34124c19f Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Fri, 31 May 2013 15:38:00 +0200 Subject: Fixed some bugs in how effective size hints were calculated Do not bound explicit preferred size with implicit sizes. This means that if Layout.preferredWidth was *explicitly* set to 50, and Layout.maximumWidth had the implicit value 20, the effective maximum width would be expanded to 50 in order to not disregard the explicitly set preferred width. (covered by the tag "expandMaxToExplicitPref" in test_sizeHint) Note that this doesn't break any autotests, but the row layout autotest was slightly changed to be able to add the new test cases. This should make the behavior match the behavior of QGraphicsGridLayout and QGraphicsLinearLayout Change-Id: Ia23c8ef909827f14349906c003c72bb83689ef9a Reviewed-by: Caroline Chao Reviewed-by: Jens Bache-Wiig --- src/layouts/qquickgridlayoutengine.cpp | 95 +++++++++++++++++++++--------- src/layouts/qquicklayout_p.h | 16 +++++ tests/auto/controls/data/tst_rowlayout.qml | 21 ++++--- 3 files changed, 97 insertions(+), 35 deletions(-) diff --git a/src/layouts/qquickgridlayoutengine.cpp b/src/layouts/qquickgridlayoutengine.cpp index bacfd965..7f65d0d5 100644 --- a/src/layouts/qquickgridlayoutengine.cpp +++ b/src/layouts/qquickgridlayoutengine.cpp @@ -98,14 +98,62 @@ static inline void combineHints(qreal ¤t, qreal fallbackHint) current = fallbackHint; } +static inline void combineSize(QSizeF &result, const QSizeF &fallbackSize) +{ + combineHints(result.rwidth(), fallbackSize.width()); + combineHints(result.rheight(), fallbackSize.height()); +} + +static inline void combineImplicitHints(QQuickLayoutAttached *info, Qt::SizeHint which, QSizeF *size) +{ + if (!info) return; + + Q_ASSERT(which == Qt::MinimumSize || which == Qt::MaximumSize); + + const QSizeF constraint(which == Qt::MinimumSize + ? QSizeF(info->minimumWidth(), info->minimumHeight()) + : QSizeF(info->maximumWidth(), info->maximumHeight())); + + if (!info->isExtentExplicitlySet(Qt::Horizontal, which)) + combineHints(size->rwidth(), constraint.width()); + if (!info->isExtentExplicitlySet(Qt::Vertical, which)) + combineHints(size->rheight(), constraint.height()); +} + /*! \internal Note: Can potentially return the attached QQuickLayoutAttached object through \a attachedInfo. It is like this is because it enables it to be reused. + + The goal of this function is to return the effective minimum, preferred and maximum size hints + that the layout will use for this item. + This function takes care of gathering all explicitly set size hints, normalizes them so + that min < pref < max. + Further, the hints _not_explicitly_ set will then be initialized with the implicit size hints, + which is usually derived from the content of the layouts (or items). + + The following table illustrates the preference of the properties used for measuring layout + items. If present, the USER properties will be preferred. If USER properties are not present, + the HINT properties will be preferred. Finally, the FALLBACK properties will be used as an + ultimate fallback. + + Note that one can query if the value of Layout.minimumWidth or Layout.maximumWidth has been + explicitly or implicitly set with QQuickLayoutAttached::isExtentExplicitlySet(). This + determines if it should be used as a USER or as a HINT value. + + + | *Minimum* | *Preferred* | *Maximum* | ++----------------+----------------------+-----------------------+--------------------------+ +|USER (explicit) | Layout.minimumWidth | Layout.preferredWidth | Layout.maximumWidth | +|HINT (implicit) | Layout.minimumWidth | implicitWidth | Layout.maximumWidth | +|FALLBACK | 0 | width | Number.POSITIVE_INFINITY | ++----------------+----------------------+-----------------------+--------------------------+ */ void QQuickGridLayoutItem::effectiveSizeHints_helper(QQuickItem *item, QSizeF *cachedSizeHints, QQuickLayoutAttached **attachedInfo, bool useFallbackToWidthOrHeight) { + for (int i = 0; i < Qt::NSizeHints; ++i) + cachedSizeHints[i] = QSizeF(); QQuickLayoutAttached *info = attachedLayoutObject(item, false); // First, retrieve the user-specified hints from the attached "Layout." properties if (info) { @@ -123,16 +171,16 @@ void QQuickGridLayoutItem::effectiveSizeHints_helper(QQuickItem *item, QSizeF *c for (int i = 0; i < NSizes; ++i) { SizeGetter getter = horGetters.call[i]; Q_ASSERT(getter); - cachedSizeHints[i].setWidth((info->*getter)()); + + if (info->isExtentExplicitlySet(Qt::Horizontal, (Qt::SizeHint)i)) + cachedSizeHints[i].setWidth((info->*getter)()); + getter = verGetters.call[i]; Q_ASSERT(getter); - cachedSizeHints[i].setHeight((info->*getter)()); + if (info->isExtentExplicitlySet(Qt::Vertical, (Qt::SizeHint)i)) + cachedSizeHints[i].setHeight((info->*getter)()); } - } else { - for (int i = 0; i < NSizes; ++i) - cachedSizeHints[i] = QSize(); } - cachedSizeHints[Qt::MinimumDescent] = QSize(); //### FIXME when baseline support is added QSizeF &minS = cachedSizeHints[Qt::MinimumSize]; QSizeF &prefS = cachedSizeHints[Qt::PreferredSize]; @@ -144,23 +192,21 @@ void QQuickGridLayoutItem::effectiveSizeHints_helper(QQuickItem *item, QSizeF *c // to: [10, 10, 60] normalizeHints(minS.rwidth(), prefS.rwidth(), maxS.rwidth(), descentS.rwidth()); normalizeHints(minS.rheight(), prefS.rheight(), maxS.rheight(), descentS.rheight()); -/* - The following table illustrates the preference of the properties used for measuring layout - items. If present, the USER properties will be preferred. If USER properties are not present, - the HINT 1 properties will be preferred. Finally, the HINT 2 properties will be used as an - ultimate fallback. - - | USER | HINT 1 | HINT 2 - -----+--------------------------------+-------------------+------- - MIN | Layout.minimumWidth | | 0 - PREF | Layout.preferredWidth | implicitWidth | width - MAX | Layout.maximumWidth | | 1000000000 (-1) - -----+--------------------------------+-------------------+-------- -Fixed | Layout.fillWidth | Expanding if layout, Fixed if item | - -*/ + + // All explicit values gathered, now continue to gather the implicit sizes + + //--- GATHER MAXIMUM SIZE HINTS --- + combineImplicitHints(info, Qt::MaximumSize, &maxS); + combineSize(maxS, QSizeF(std::numeric_limits::infinity(), std::numeric_limits::infinity())); + // implicit max or min sizes should not limit an explicitly set preferred size + expandSize(maxS, prefS); + expandSize(maxS, minS); + //--- GATHER MINIMUM SIZE HINTS --- - // They are always 0 + combineImplicitHints(info, Qt::MinimumSize, &minS); + expandSize(minS, QSizeF(0,0)); + boundSize(minS, prefS); + boundSize(minS, maxS); //--- GATHER PREFERRED SIZE HINTS --- // First, from implicitWidth/Height @@ -203,17 +249,12 @@ Fixed | Layout.fillWidth | Expanding if layout, Fixed if item | item->blockSignals(false); } } - //--- GATHER MAXIMUM SIZE HINTS --- - combineHints(cachedSizeHints[Qt::MaximumSize].rwidth(), std::numeric_limits::infinity()); - combineHints(cachedSizeHints[Qt::MaximumSize].rheight(), std::numeric_limits::infinity()); //--- GATHER DESCENT // ### Not implemented // Normalize again after the implicit hints have been gathered - expandSize(minS, QSizeF(0,0)); - boundSize(minS, maxS); expandSize(prefS, minS); boundSize(prefS, maxS); diff --git a/src/layouts/qquicklayout_p.h b/src/layouts/qquicklayout_p.h index 8a334677..0239739a 100644 --- a/src/layouts/qquicklayout_p.h +++ b/src/layouts/qquicklayout_p.h @@ -175,6 +175,22 @@ public: qreal sizeHint(Qt::SizeHint which, Qt::Orientation orientation) const; + bool isExtentExplicitlySet(Qt::Orientation o, Qt::SizeHint whichSize) const + { + switch (whichSize) { + case Qt::MinimumSize: + return o == Qt::Horizontal ? m_isMinimumWidthSet : m_isMinimumHeightSet; + case Qt::MaximumSize: + return o == Qt::Horizontal ? m_isMaximumWidthSet : m_isMaximumHeightSet; + case Qt::PreferredSize: + return true; // Layout.preferredWidth is always explicitly set + case Qt::MinimumDescent: // Not supported + case Qt::NSizeHints: + return false; + } + return false; + } + signals: void minimumWidthChanged(); void minimumHeightChanged(); diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml index 458a2885..e92dad47 100644 --- a/tests/auto/controls/data/tst_rowlayout.qml +++ b/tests/auto/controls/data/tst_rowlayout.qml @@ -459,6 +459,12 @@ Item { { tag: "propagateMaximumWidth", layoutHints: [10, 20, -1], childHints: [11, 21, 30], expected:[10, 20, 30]}, { tag: "propagateAll", layoutHints: [-1, -1, -1], childHints: [10, 20, 30], expected:[10, 20, 30]}, { tag: "propagateCrazy", layoutHints: [-1, -1, -1], childHints: [40, 21, 30], expected:[30, 30, 30]}, + { tag: "expandMinToExplicitPref", layoutHints: [-1, 1, -1], childHints: [11, 21, 31], expected:[ 1, 1, 31]}, + { tag: "expandMaxToExplicitPref", layoutHints: [-1, 99, -1], childHints: [11, 21, 31], expected:[11, 99, 99]}, + { tag: "expandAllToExplicitMin", layoutHints: [99, -1, -1], childHints: [11, 21, 31], expected:[99, 99, 99]}, + { tag: "expandPrefToExplicitMin", layoutHints: [24, -1, -1], childHints: [11, 21, 31], expected:[24, 24, 31]}, + { tag: "boundPrefToExplicitMax", layoutHints: [-1, -1, 19], childHints: [11, 21, 31], expected:[11, 19, 19]}, + { tag: "boundAllToExplicitMax", layoutHints: [-1, -1, 9], childHints: [11, 21, 31], expected:[ 9, 9, 9]}, ]; } @@ -468,22 +474,21 @@ Item { function test_sizeHint(data) { var layout = layout_sizeHint_Component.createObject(container) - layout.Layout.minimumWidth = data.layoutHints[0] - layout.Layout.preferredWidth = data.layoutHints[1] - layout.Layout.maximumWidth = data.layoutHints[2] - var child = layout.children[0].children[0] + var grid = layout.children[0] + grid.Layout.minimumWidth = data.layoutHints[0] + grid.Layout.preferredWidth = data.layoutHints[1] + grid.Layout.maximumWidth = data.layoutHints[2] + + var child = grid.children[0] if (data.implicitWidth !== undefined) { child.implicitWidth = data.implicitWidth } - child.Layout.minimumWidth = data.childHints[0] child.Layout.preferredWidth = data.childHints[1] child.Layout.maximumWidth = data.childHints[2] - var grid = layout.children[0] - var preferredWidth = layout.Layout.preferredWidth >= 0 ? layout.Layout.preferredWidth : layout.implicitWidth - var effectiveSizeHintResult = [layout.Layout.minimumWidth, preferredWidth, layout.Layout.maximumWidth] + var effectiveSizeHintResult = [layout.Layout.minimumWidth, layout.implicitWidth, layout.Layout.maximumWidth] compare(effectiveSizeHintResult, data.expected) layout.destroy() } -- cgit v1.2.1 From 8db84cb14a049ff27ccc5893517d8c5ffe0fd636 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 3 Jun 2013 18:54:40 +0200 Subject: TextArea: allow declaring child elements inline Change-Id: I7da8e3664d6bd3ee9a8c4f22d4a5b686d1c5b5a9 Reviewed-by: Gabriel de Dietrich Reviewed-by: Jens Bache-Wiig --- src/controls/TextArea.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml index cbef6e31..4771fcb0 100644 --- a/src/controls/TextArea.qml +++ b/src/controls/TextArea.qml @@ -608,6 +608,9 @@ ScrollView { */ property alias backgroundColor: colorRect.color + /*! \internal */ + default property alias data: area.data + /*! \internal */ property int __documentMargin: 4 -- cgit v1.2.1 From 1c7d06f2696465993d63a33bf4144f49f02552bc Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 4 Jun 2013 11:03:39 +0200 Subject: Fix warning in Slider when stepSize is set Also adding a new test for stepSize Task-number: QTBUG-31441 Change-Id: Ib8d9cc2188b5f73b6b0ac866ade1a7edb1d662b7 Reviewed-by: Caroline Chao --- src/controls/Slider.qml | 16 ++++++++-------- tests/auto/controls/data/tst_slider.qml | 11 +++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index b31d4f78..e7e49151 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -197,6 +197,14 @@ Control { anchors.horizontalCenter: !__horizontal ? parent.horizontalCenter : undefined width: __panel.handleWidth height: __panel.handleHeight + + function updatePos() { + if (updateValueWhileDragging && !mouseArea.drag.active) + range.position = __horizontal ? x : y + } + + onXChanged: updatePos(); + onYChanged: updatePos(); } MouseArea { @@ -247,14 +255,6 @@ Control { } } - // Range position normally follows handle, except when - // 'updateValueWhileDragging' is false. - Binding { - when: updateValueWhileDragging && !mouseArea.drag.active - target: range - property: "position" - value: __horizontal ? fakeHandle.x : fakeHandle.y - } // During the drag, we simply ignore the position set from the range, this // means that setting a value while dragging will not "interrupt" the diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index 96b4d422..177a8fcb 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -282,5 +282,16 @@ Item { verify(control.value > 0.5) control.destroy() } + + function test_valueAndHandlePosition() + { + var slider = Qt.createQmlObject('import QtQuick.Controls 1.0; Slider {minimumValue: 0; maximumValue: 100; width: 100; height: 20; stepSize: 1}', container, ''); + slider.forceActiveFocus() + slider.value = 0 + compare(slider.__handlePos, 0) + slider.value = 50 + compare(slider.__handlePos, 50) + slider.destroy() + } } } -- cgit v1.2.1 From ea30e6ff10180cea8f486e02d691a0d3410fd5c9 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 4 Jun 2013 13:18:42 +0200 Subject: Improve qtquick controls page Added more information for "Getting Started" - Cleaned up some language - Remove desktop specific - Mention widget dependency - Use QmlApplicationEngine in example Change-Id: I0e5d4bef124ce4571c1b6fe780ee78b8231cbb32 Reviewed-by: Jerome Pasion --- src/controls/doc/src/qtquickcontrols-index.qdoc | 54 +++++++++++++++++++++---- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/src/controls/doc/src/qtquickcontrols-index.qdoc b/src/controls/doc/src/qtquickcontrols-index.qdoc index 0272755f..5729fbae 100644 --- a/src/controls/doc/src/qtquickcontrols-index.qdoc +++ b/src/controls/doc/src/qtquickcontrols-index.qdoc @@ -29,19 +29,16 @@ \page qtquickcontrols-index.html \title Qt Quick Controls - \brief The Qt Quick Controls module provides a set of reusable Qt Quick UI components. + \brief The Qt Quick Controls module provides a set of UI controls for Qt Quick. - The Qt Quick Controls module provides a set of reusable UI components to create - classic desktop-style user interfaces using Qt Quick. + The Qt Quick Controls module provides a set of controls that can be used to + build complete interfaces in Qt Quick. The module is new in Qt 5.1 and requires \l{Qt Quick} 2.1. - \note \l{Qt Quick Layouts} can be used to arrange Qt Quick Controls in a user interface. + \image qtquickcontrols-example-gallery.png - \note The current focus is on desktop, but in the long term Qt Quick Controls - are expected to be supported on mobile platforms too. - - \section1 Getting started + \section1 Getting Started The QML types can be imported into your application using the following import statement in your \c {.qml} file. @@ -49,6 +46,47 @@ import QtQuick.Controls 1.0 \endcode + A basic example of a QML file that makes use of controls is shown here: + + \code + import QtQuick.Controls 1.0 + + ApplicationWindow { + title: "My Application" + + Button { + text: "Push Me" + anchors.centerIn: parent + } + } + \endcode + + \section2 Setting Up Controls from C++ + + While we traditionally have used a QQuickView window to display QML files + in a C++ application, doing this means you can only set window properties from C++. + + With Qt Quick Controls, declare an ApplicationWindow as the root item of your application and launch it by using the + QQmlApplicationEngine instead. This ensures that you can control top level window properties from QML. + + A basic example of a source file that makes use of controls is shown here: + + \code + #include + #include + + int main(int argc, char *argv[]) + { + QApplication app(argc, argv); + QQmlApplicationEngine engine("main.qml"); + return app.exec(); + } + \endcode + + \note We are using QApplication and not QGuiApplication in this example. + Though you can use QGuiApplication instead, doing this will eliminate platform-dependent styling. + This is because it is relying on the widget module to provide the native look and feel. + \section1 Application Window Components used to describe the basic window properties of an application. \annotatedlist applicationwindow -- cgit v1.2.1 From fef62c9b40ff1d79e62778e67c90f956da84b238 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Tue, 4 Jun 2013 19:28:26 +0200 Subject: Prevent possible division by zero This might cause problems on certain platforms. While hard to reproduce it seems safer to add the check. Note that we do not get the alternating pattern if there is nothing set on the model, but this was already the case. Change-Id: I984df9cfef30b4de0e72e8ccf14cc65bddbf04ef Reviewed-by: Gabriel de Dietrich --- src/controls/TableView.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index a71264da..fad6ee47 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -470,7 +470,7 @@ ScrollView { // Fills extra rows with alternate color Column { id: rowfiller - property int rowHeight: listView.contentHeight/count + property int rowHeight: count ? listView.contentHeight/count : height property int paddedRowCount: height/rowHeight property int count: listView.count y: listView.contentHeight -- cgit v1.2.1 From 0ad4925f94c86dbe75e01d890fdb9fce64ca52fe Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Wed, 5 Jun 2013 10:58:13 +0200 Subject: Doc: Small fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I163f69c14ecbc07a66b1bac7c5a53b22405c895e Reviewed-by: Jan Arve Sæther Reviewed-by: Frederik Gladhorn --- src/controls/TextArea.qml | 2 +- src/controls/doc/src/qtquickcontrols-index.qdoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml index 4771fcb0..84f67b23 100644 --- a/src/controls/TextArea.qml +++ b/src/controls/TextArea.qml @@ -623,7 +623,7 @@ ScrollView { /*! \qmlproperty TextDocument TextArea::textDocument - This property exposes the \l QTextDocument of this TextArea. + This property exposes the \l QQuickTextDocument of this TextArea. \sa TextEdit::textDocument */ property alias textDocument: edit.textDocument diff --git a/src/controls/doc/src/qtquickcontrols-index.qdoc b/src/controls/doc/src/qtquickcontrols-index.qdoc index 5729fbae..5c22276e 100644 --- a/src/controls/doc/src/qtquickcontrols-index.qdoc +++ b/src/controls/doc/src/qtquickcontrols-index.qdoc @@ -125,7 +125,7 @@ \li \l {Qt Quick Controls Styles} \endlist - \section2 Styles + \section2 Layouts \list \li \l {Qt Quick Layouts} \endlist -- cgit v1.2.1 From 420bb714a8c8ebc67ad958897939d7d96e11806c Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 5 Jun 2013 09:54:28 +0200 Subject: Expose hovered to our controls and document it consistently The current solution is messy and we only expose it partially to some of our styles. I think we should simply expose this to all. Change-Id: Ia546d5657ea416df99c9d9d92cc714b7f1c928fe Reviewed-by: Caroline Chao Reviewed-by: Nico Vertriest --- src/controls/Button.qml | 2 +- src/controls/ComboBox.qml | 13 ++++++++++--- src/controls/ProgressBar.qml | 12 ++++++++++++ src/controls/Slider.qml | 18 +++++++++++------- src/controls/SpinBox.qml | 11 ++++++++--- src/controls/TextField.qml | 7 +++++-- src/private/AbstractCheckable.qml | 17 ++++++++--------- src/private/BasicButton.qml | 12 ++++++++---- src/styles/Base/ButtonStyle.qml | 22 ++-------------------- src/styles/Base/CheckBoxStyle.qml | 18 ++---------------- src/styles/Base/ComboBoxStyle.qml | 22 ++-------------------- src/styles/Base/RadioButtonStyle.qml | 18 ++---------------- src/styles/Desktop/ButtonStyle.qml | 2 +- src/styles/Desktop/CheckBoxStyle.qml | 2 +- src/styles/Desktop/ComboBoxStyle.qml | 2 +- src/styles/Desktop/RadioButtonStyle.qml | 2 +- src/styles/Desktop/SpinBoxStyle.qml | 2 +- src/styles/Desktop/TextFieldStyle.qml | 2 +- src/styles/Desktop/ToolButtonStyle.qml | 4 ++-- tests/auto/controls/data/tst_spinbox.qml | 4 ++-- 20 files changed, 81 insertions(+), 111 deletions(-) diff --git a/src/controls/Button.qml b/src/controls/Button.qml index 1f00dccb..0a3cb131 100644 --- a/src/controls/Button.qml +++ b/src/controls/Button.qml @@ -80,7 +80,7 @@ BasicButton { /*! \qmlproperty bool BasicButton::pressed - This property holds whether the button is pressed. */ + This property holds whether the button is being pressed. */ readonly property bool pressed: __behavior.effectivePressed || menu && menu.__popupVisible activeFocusOnTab: true diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index e5efb63c..9282c58d 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -99,10 +99,17 @@ Control { The default value is \c false. */ property bool activeFocusOnPress: false - /*! \internal */ + /*! \qmlproperty bool ComboBox::pressed + + This property holds whether the button is being pressed. */ readonly property bool pressed: mouseArea.pressed && mouseArea.containsMouse || popup.__popupVisible - /*! \internal */ - property alias __containsMouse: mouseArea.containsMouse + + /*! \qmlproperty bool ComboBox::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: mouseArea.containsMouse + /*! \internal */ property var __popup: popup diff --git a/src/controls/ProgressBar.qml b/src/controls/ProgressBar.qml index 6d9f8be1..e472e66e 100644 --- a/src/controls/ProgressBar.qml +++ b/src/controls/ProgressBar.qml @@ -98,6 +98,12 @@ Control { */ property int orientation: Qt.Horizontal + /*! \qmlproperty bool ProgressBar::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: hoverArea.containsMouse + /*! \internal */ style: Qt.createComponent(Settings.style + "/ProgressBarStyle.qml", progressbar) @@ -123,6 +129,12 @@ Control { implicitWidth:(__panel ? __panel.implicitWidth : 0) implicitHeight: (__panel ? __panel.implicitHeight: 0) + MouseArea { + id: hoverArea + anchors.fill: parent + hoverEnabled: true + } + /*! \internal */ function setValue(v) { var newval = parseFloat(v) diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index e7e49151..64dcfff1 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -108,9 +108,16 @@ Control { /*! \qmlproperty bool Slider::pressed - This property indicates if slider handle is currently being pressed. + This property indicates whether the slider handle is being pressed. */ - property alias pressed: mouseArea.pressed + readonly property alias pressed: mouseArea.pressed + + /*! + \qmlproperty bool Slider::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: mouseArea.containsMouse /*! \qmlproperty real Slider::stepSize @@ -145,7 +152,7 @@ Control { /*! \qmlproperty bool Slider::activeFocusOnPress - This property indicates if the Slider should receive active focus when + This property indicates whether the Slider should receive active focus when pressed. */ property bool activeFocusOnPress: false @@ -153,16 +160,13 @@ Control { /*! \qmlproperty bool Slider::tickmarksEnabled - This property indicates if the Slider should display tickmarks + This property indicates whether the Slider should display tickmarks at step intervals. The default value is \c false. */ property bool tickmarksEnabled: false - /*! \internal */ - property bool __containsMouse: mouseArea.containsMouse - /*! \internal */ property bool __horizontal: orientation === Qt.Horizontal diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index 68f97e0a..b1f87cec 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -134,12 +134,19 @@ Control { */ property alias font: input.font - /*! This property indicates if the Spinbox should get active + /*! This property indicates whether the Spinbox should get active focus when pressed. The default value is \c true. */ property bool activeFocusOnPress: true + /*! + \qmlproperty bool SpinBox::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: mouseArea.containsMouse + style: Qt.createComponent(Settings.style + "/SpinBoxStyle.qml", spinbox) /*! \internal */ @@ -166,8 +173,6 @@ Control { readonly property alias downPressed: mouseDown.pressed readonly property alias downHovered: mouseDown.containsMouse - readonly property alias hovered: mouseArea.containsMouse - readonly property int contentHeight: Math.max(input.implicitHeight, 16) readonly property int contentWidth: Math.max(maxSizeHint.implicitWidth, minSizeHint.implicitWidth) } diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index 903a6462..32b2d4fb 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -524,8 +524,11 @@ Control { textInput.undo(); } - /*! \internal */ - property alias __containsMouse: mouseArea.containsMouse + /*! \qmlproperty bool TextField::hovered + + This property holds whether the control is being hovered. + */ + readonly property alias hovered: mouseArea.containsMouse /*! \internal */ property alias __contentHeight: textInput.contentHeight diff --git a/src/private/AbstractCheckable.qml b/src/private/AbstractCheckable.qml index ba203e4d..02348b71 100644 --- a/src/private/AbstractCheckable.qml +++ b/src/private/AbstractCheckable.qml @@ -69,10 +69,16 @@ Control { /*! \qmlproperty bool AbstractCheckable::pressed - This property is \c true if the control is pressed. + This property is \c true if the control is being pressed. Set this property to manually invoke a mouse click. */ - readonly property alias pressed: mouseArea.effectivePressed + property alias pressed: mouseArea.effectivePressed + + /*! \qmlproperty bool AbstractCheckcable::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: mouseArea.containsMouse /*! This property is \c true if the control is checked. @@ -99,13 +105,6 @@ Control { /*! \internal */ property var __cycleStatesHandler: cycleRadioButtonStates - /*! \internal - - This property is \c true if the control currently contains the - mouse cursor. - */ - readonly property alias __containsMouse: mouseArea.containsMouse - activeFocusOnTab: true MouseArea { diff --git a/src/private/BasicButton.qml b/src/private/BasicButton.qml index a967f73f..b5e9ab8f 100644 --- a/src/private/BasicButton.qml +++ b/src/private/BasicButton.qml @@ -59,8 +59,14 @@ Control { /*! \qmlproperty bool BasicButton::pressed - This property holds whether the button is pressed. */ - readonly property bool pressed: behavior.effectivePressed + This property holds whether the button is being pressed. */ + readonly property alias pressed: behavior.effectivePressed + + /*! \qmlproperty bool BasicButton::hovered + + This property indicates whether the control is being hovered. + */ + readonly property alias hovered: behavior.containsMouse /*! This property holds whether the button is checkable. @@ -123,8 +129,6 @@ Control { /*! \internal */ property string __position: "only" /*! \internal */ - property alias __containsMouse: behavior.containsMouse - /*! \internal */ readonly property bool __iconOverriden: button.action && (button.action.iconSource !== button.iconSource || button.action.iconName !== button.iconName) /*! \internal */ property Action __action: action || ownAction diff --git a/src/styles/Base/ButtonStyle.qml b/src/styles/Base/ButtonStyle.qml index 3144a1a6..519e4d67 100644 --- a/src/styles/Base/ButtonStyle.qml +++ b/src/styles/Base/ButtonStyle.qml @@ -93,13 +93,7 @@ Style { bottom: 4 } - /*! This defines the background of the button. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the background of the button. */ property Component background: Item { implicitWidth: 100 implicitHeight: 25 @@ -136,13 +130,7 @@ Style { } } - /*! This defines the label of the button. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the label of the button. */ property Component label: Text { renderType: Text.NativeRendering verticalAlignment: Text.AlignVCenter @@ -162,9 +150,6 @@ Style { id: backgroundLoader anchors.fill: parent sourceComponent: background - property QtObject styleData: QtObject { - readonly property bool hovered: control.__containsMouse - } } Loader { @@ -175,9 +160,6 @@ Style { anchors.topMargin: padding.top anchors.rightMargin: padding.right anchors.bottomMargin: padding.bottom - property QtObject styleData: QtObject { - readonly property bool hovered: control.__containsMouse - } } } } diff --git a/src/styles/Base/CheckBoxStyle.qml b/src/styles/Base/CheckBoxStyle.qml index aa24a94a..6aa6f9b5 100644 --- a/src/styles/Base/CheckBoxStyle.qml +++ b/src/styles/Base/CheckBoxStyle.qml @@ -83,13 +83,7 @@ Style { SystemPalette.Active : SystemPalette.Disabled } - /*! This defines the text label. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the text label. */ property Component label: Text { text: control.text color: __syspal.text @@ -108,13 +102,7 @@ Style { /*! The spacing between indicator and label. */ property int spacing: 4 - /*! This defines the indicator button. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the indicator button. */ property Component indicator: Item { implicitWidth: 18 implicitHeight: 18 @@ -175,14 +163,12 @@ Style { id: indicatorLoader sourceComponent: indicator anchors.verticalCenter: parent.verticalCenter - property QtObject styleData: QtObject { readonly property bool hovered: control.__containsMouse } } Loader { id: labelLoader sourceComponent: label anchors.top: parent.top anchors.bottom: parent.bottom - property QtObject styleData: QtObject { readonly property bool hovered: control.__containsMouse } } } } diff --git a/src/styles/Base/ComboBoxStyle.qml b/src/styles/Base/ComboBoxStyle.qml index 241f3550..7984a329 100644 --- a/src/styles/Base/ComboBoxStyle.qml +++ b/src/styles/Base/ComboBoxStyle.qml @@ -63,13 +63,7 @@ Style { /*! The padding between the background and the label components. */ padding { top: 4 ; left: 6 ; right: 6 ; bottom:4 } - /*! This defines the background of the button. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the background of the button. */ property Component background: Item { implicitWidth: 100 implicitHeight: 25 @@ -105,13 +99,7 @@ Style { } } - /*! This defines the label of the button. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the label of the button. */ property Component label: Item { implicitWidth: textitem.implicitWidth + 20 Text { @@ -137,9 +125,6 @@ Style { id: backgroundLoader anchors.fill: parent sourceComponent: background - property QtObject styleData: QtObject { - readonly property bool hovered: control.__containsMouse - } } Loader { @@ -150,9 +135,6 @@ Style { anchors.topMargin: padding.top anchors.rightMargin: padding.right anchors.bottomMargin: padding.bottom - property QtObject styleData: QtObject { - readonly property bool hovered: control.__containsMouse - } } } diff --git a/src/styles/Base/RadioButtonStyle.qml b/src/styles/Base/RadioButtonStyle.qml index b42ac1bd..ef3f2229 100644 --- a/src/styles/Base/RadioButtonStyle.qml +++ b/src/styles/Base/RadioButtonStyle.qml @@ -83,13 +83,7 @@ Style { /*! The \l RadioButton attached to this style. */ readonly property RadioButton control: __control - /*! This defines the text label. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the text label. */ property Component label: Text { text: control.text renderType: Text.NativeRendering @@ -103,13 +97,7 @@ Style { /*! The spacing between indicator and label. */ property int spacing: 4 - /*! This defines the indicator button. In addition to the public - properties of \c control, the following state properties are available: - - \table - \row \li readonly property bool \b styleData.hovered \li The control is being hovered. - \endtable - */ + /*! This defines the indicator button. */ property Component indicator: Rectangle { width: 17 height: 17 @@ -145,14 +133,12 @@ Style { id: indicatorLoader sourceComponent: indicator anchors.verticalCenter: parent.verticalCenter - property QtObject styleData: QtObject { readonly property bool hovered: control.__containsMouse } } Loader { id: labelLoader sourceComponent: label anchors.top: parent.top anchors.bottom: parent.bottom - property QtObject styleData: QtObject { readonly property bool hovered: control.__containsMouse } } } } diff --git a/src/styles/Desktop/ButtonStyle.qml b/src/styles/Desktop/ButtonStyle.qml index 3f0670bf..53c4ef7f 100644 --- a/src/styles/Desktop/ButtonStyle.qml +++ b/src/styles/Desktop/ButtonStyle.qml @@ -46,7 +46,7 @@ Style { elementType: "button" sunken: control.pressed || (control.checkable && control.checked) raised: !(control.pressed || (control.checkable && control.checked)) - hover: control.__containsMouse + hover: control.hovered text: control.iconSource === "" ? "" : control.text hasFocus: control.activeFocus hints: control.styleHints diff --git a/src/styles/Desktop/CheckBoxStyle.qml b/src/styles/Desktop/CheckBoxStyle.qml index d85a2cb3..9b19300f 100644 --- a/src/styles/Desktop/CheckBoxStyle.qml +++ b/src/styles/Desktop/CheckBoxStyle.qml @@ -52,7 +52,7 @@ Style { elementType: "checkbox" sunken: control.pressed on: control.checked || control.pressed - hover: control.__containsMouse + hover: control.hovered enabled: control.enabled hasFocus: control.activeFocus && styleitem.style == "mac" hints: control.styleHints diff --git a/src/styles/Desktop/ComboBoxStyle.qml b/src/styles/Desktop/ComboBoxStyle.qml index 78e52f53..95397641 100644 --- a/src/styles/Desktop/ComboBoxStyle.qml +++ b/src/styles/Desktop/ComboBoxStyle.qml @@ -58,7 +58,7 @@ Style { elementType: "combobox" sunken: control.pressed raised: !sunken - hover: control.__containsMouse + hover: control.hovered enabled: control.enabled // The style makes sure the text rendering won't overlap the decoration. // In that case, 35 pixels margin in this case looks good enough. Worst diff --git a/src/styles/Desktop/RadioButtonStyle.qml b/src/styles/Desktop/RadioButtonStyle.qml index c5a3c80d..b41b959a 100644 --- a/src/styles/Desktop/RadioButtonStyle.qml +++ b/src/styles/Desktop/RadioButtonStyle.qml @@ -56,7 +56,7 @@ Style { anchors.verticalCenterOffset: macStyle ? -1 : 0 sunken: control.pressed on: control.checked || control.pressed - hover: control.__containsMouse + hover: control.hovered enabled: control.enabled hasFocus: control.activeFocus && styleitem.style == "mac" hints: control.styleHints diff --git a/src/styles/Desktop/SpinBoxStyle.qml b/src/styles/Desktop/SpinBoxStyle.qml index d43a2630..24f51427 100644 --- a/src/styles/Desktop/SpinBoxStyle.qml +++ b/src/styles/Desktop/SpinBoxStyle.qml @@ -116,7 +116,7 @@ Style { elementType: "spinbox" anchors.fill: parent sunken: (styleData.downEnabled && styleData.downPressed) || (styleData.upEnabled && styleData.upPressed) - hover: styleData.hovered + hover: control.hovered hints: control.styleHints hasFocus: control.activeFocus enabled: control.enabled diff --git a/src/styles/Desktop/TextFieldStyle.qml b/src/styles/Desktop/TextFieldStyle.qml index ee6779eb..8f71a45c 100644 --- a/src/styles/Desktop/TextFieldStyle.qml +++ b/src/styles/Desktop/TextFieldStyle.qml @@ -48,7 +48,7 @@ Style { sunken: true hasFocus: control.activeFocus - hover: __containsMouse + hover: hovered hints: control.styleHints SystemPalette { diff --git a/src/styles/Desktop/ToolButtonStyle.qml b/src/styles/Desktop/ToolButtonStyle.qml index 3dd22a53..54726962 100644 --- a/src/styles/Desktop/ToolButtonStyle.qml +++ b/src/styles/Desktop/ToolButtonStyle.qml @@ -48,8 +48,8 @@ Style { elementType: "toolbutton" on: control.checkable && control.checked sunken: control.pressed - raised: !(control.checkable && control.checked) && control.__containsMouse - hover: control.__containsMouse + raised: !(control.checkable && control.checked) && control.hovered + hover: control.hovered hasFocus: control.activeFocus hints: control.styleHints text: control.text diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index a00544b8..15ac98b9 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -178,7 +178,7 @@ Item { setCoordinates(spinbox) mouseMove(spinbox, mainCoord.x, mainCoord.y) - compare(spinbox.__styleData.hovered, true) + compare(spinbox.hovered, true) compare(spinbox.__styleData.upHovered, false) compare(spinbox.__styleData.downHovered, false) @@ -191,7 +191,7 @@ Item { compare(spinbox.__styleData.downHovered, true) mouseMove(spinbox, mainCoord.x - 2, mainCoord.y - 2) - compare(spinbox.__styleData.hovered, false) + compare(spinbox.hovered, false) compare(spinbox.__styleData.upHovered, false) compare(spinbox.__styleData.downHovered, false) spinbox.destroy() -- cgit v1.2.1 From f31c8c1b567cb3c2c0704ef1edb982999f96fd74 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 5 Jun 2013 11:47:10 +0200 Subject: Replace backgroundColor with backgroundVisible This exposes backgroundVisible to TableView and replaces backgroundColor in TextArea. We think the backgroundVisible is more flexible and allows us to find a more appropriate solution to support palette in the future. Change-Id: Icfcd512c29cf030059c4ce2d32feb402d1a33662 Reviewed-by: Caroline Chao Reviewed-by: J-P Nurmi --- src/controls/TableView.qml | 10 ++++++++++ src/controls/TextArea.qml | 9 ++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index fad6ee47..c0212391 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -123,6 +123,16 @@ ScrollView { The default value is \c true. */ property bool headerVisible: true + /*! \qmlproperty bool TableView::backgroundVisible + + This property determines if the background should be filled or not. + + The default value is \c true. + + \note The rowDelegate is not affected by this property + */ + property alias backgroundVisible: colorRect.visible + /*! This property defines a delegate to draw a specific cell. In the item delegate you have access to the following special properties: diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml index 84f67b23..fd715a36 100644 --- a/src/controls/TextArea.qml +++ b/src/controls/TextArea.qml @@ -599,14 +599,13 @@ ScrollView { edit.undo(); } - /*! - \qmlproperty color TextArea::backgroundColor + /*! \qmlproperty bool TextArea::backgroundVisible - This property sets the background color of the viewport. + This property determines if the background should be filled or not. - The default value is the base color of the SystemPalette. + The default value is \c true. */ - property alias backgroundColor: colorRect.color + property alias backgroundVisible: colorRect.visible /*! \internal */ default property alias data: area.data -- cgit v1.2.1 From 6694cbabbf905ede781f430d6ec7587c79f94de9 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 5 Jun 2013 20:21:43 +0200 Subject: Fix missing headerview gap when not showing frame in TableView Tested on all three platforms and looks better. Change-Id: I8a68dfc7fe97a05c4313ac10de2f93dabec5a964 Reviewed-by: Gabriel de Dietrich --- src/controls/TableView.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index c0212391..17b2b186 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -607,7 +607,7 @@ ScrollView { anchors.topMargin: viewport.anchors.topMargin anchors.leftMargin: viewport.anchors.leftMargin anchors.margins: viewport.anchors.margins - anchors.rightMargin: __scroller.rightMargin + + anchors.rightMargin: (frameVisible ? __scroller.rightMargin : 0) + (__scroller.outerFrame && __scrollBarTopMargin ? 0 : __verticalScrollBar.width + __scroller.scrollBarSpacing + root.__style.padding.right) -- cgit v1.2.1 From 05e492cf7ab30286087f579cefd9829da569f48f Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Wed, 5 Jun 2013 13:48:27 +0200 Subject: Fixed a bug where a rearrange was not always done This happened only when the size of the layout didn't change. Task-number: QTBUG-31570 Change-Id: Ia090c0062fa8fc3eb6f648592529ee8fcd025593 Reviewed-by: J-P Nurmi --- src/layouts/qquickgridlayoutengine_p.h | 10 ++++++- src/layouts/qquicklayout_p.h | 3 +- tests/auto/controls/data/tst_rowlayout.qml | 45 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/layouts/qquickgridlayoutengine_p.h b/src/layouts/qquickgridlayoutengine_p.h index 29317ffb..8842d36a 100644 --- a/src/layouts/qquickgridlayoutengine_p.h +++ b/src/layouts/qquickgridlayoutengine_p.h @@ -112,8 +112,16 @@ public: void setGeometry(const QRectF &rect) { const QRect r(rect.toRect()); + const QSize newSize(r.size()); m_item->setPosition(r.topLeft()); - m_item->setSize(r.size()); + QSizeF oldSize(m_item->width(), m_item->height()); + if (newSize == oldSize) { + if (QQuickLayout *lay = qobject_cast(m_item)) + if (lay->arrangementIsDirty()) + lay->rearrange(newSize); + } else { + m_item->setSize(newSize); + } } QQuickItem *layoutItem() const { return m_item; } diff --git a/src/layouts/qquicklayout_p.h b/src/layouts/qquicklayout_p.h index 0239739a..76c19717 100644 --- a/src/layouts/qquicklayout_p.h +++ b/src/layouts/qquicklayout_p.h @@ -77,9 +77,10 @@ public: void componentComplete(); virtual QSizeF sizeHint(Qt::SizeHint whichSizeHint) const = 0; virtual void invalidate(QQuickItem * childItem = 0); + virtual void rearrange(const QSizeF &); + bool arrangementIsDirty() const { return m_dirty; } protected: bool event(QEvent *e); - virtual void rearrange(const QSizeF &); enum Orientation { Vertical = 0, diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml index e92dad47..d04419f0 100644 --- a/tests/auto/controls/data/tst_rowlayout.qml +++ b/tests/auto/controls/data/tst_rowlayout.qml @@ -658,5 +658,50 @@ Item { layout.visible = false layout.destroy() // Do not crash } + + + Component { + id: rearrangeNestedLayouts_Component + RowLayout { + id: layout + anchors.fill: parent + width: 200 + height: 20 + RowLayout { + id: row + spacing: 0 + + Rectangle { + id: fixed + color: 'red' + implicitWidth: 20 + implicitHeight: 20 + } + Rectangle { + id: filler + color: 'grey' + Layout.fillWidth: true + implicitHeight: 20 + } + } + } + } + + function test_rearrangeNestedLayouts() + { + var layout = rearrangeNestedLayouts_Component.createObject(container) + var fixed = layout.children[0].children[0] + var filler = layout.children[0].children[1] + + compare(itemRect(fixed), [0,0,20,20]) + compare(itemRect(filler), [20,0,180,20]) + + fixed.implicitWidth = 100 + wait(20); // wait for at least 20 ms (this matches the time between two frame + // repaints for 50hz displays) + compare(itemRect(fixed), [0,0,100,20]) + compare(itemRect(filler), [100,0,100,20]) + + } } } -- cgit v1.2.1 From e6ea417c15aa760e8b1a88e5db362f9642d1589e Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 5 Jun 2013 15:46:48 +0200 Subject: Improve the Styles page and add missing SliderStyle property - I noticed we incorrectly exposed sliderPosition. - This adds some more custom style examples for the gallery and makes the second column actually different from the first. Change-Id: I73f0d613f51f6e75aaf734fd4e4c9fdb890e3e42 Reviewed-by: Caroline Chao --- examples/quick/controls/gallery/content/Styles.qml | 181 +++++++++++++++++---- examples/quick/controls/gallery/images/bubble.png | Bin 0 -> 214 bytes .../controls/gallery/images/button-pressed.png | Bin 0 -> 3094 bytes examples/quick/controls/gallery/images/button.png | Bin 0 -> 3164 bytes .../gallery/images/progress-background.png | Bin 0 -> 456 bytes .../controls/gallery/images/progress-fill.png | Bin 0 -> 507 bytes .../controls/gallery/images/slider-handle.png | Bin 0 -> 3523 bytes .../quick/controls/gallery/images/textfield.png | Bin 0 -> 3023 bytes examples/quick/controls/gallery/resources.qrc | 7 + src/styles/Base/SliderStyle.qml | 7 +- 10 files changed, 159 insertions(+), 36 deletions(-) create mode 100644 examples/quick/controls/gallery/images/bubble.png create mode 100644 examples/quick/controls/gallery/images/button-pressed.png create mode 100644 examples/quick/controls/gallery/images/button.png create mode 100644 examples/quick/controls/gallery/images/progress-background.png create mode 100644 examples/quick/controls/gallery/images/progress-fill.png create mode 100644 examples/quick/controls/gallery/images/slider-handle.png create mode 100644 examples/quick/controls/gallery/images/textfield.png diff --git a/examples/quick/controls/gallery/content/Styles.qml b/examples/quick/controls/gallery/content/Styles.qml index 3a7d2bfd..e46a9ea0 100644 --- a/examples/quick/controls/gallery/content/Styles.qml +++ b/examples/quick/controls/gallery/content/Styles.qml @@ -45,6 +45,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.0 +import QtQuick.Particles 2.0 import QtQuick.Layouts 1.0 Item { @@ -67,7 +68,12 @@ Item { } Button { text: "Push me" - style: ButtonStyle { } + style: ButtonStyle { + background: BorderImage { + source: control.pressed ? "../images/button-pressed.png" : "../images/button.png" + border.left: 4 ; border.right: 4 ; border.top: 4 ; border.bottom: 4 + } + } implicitWidth: columnWidth } Button { @@ -82,7 +88,12 @@ Item { implicitWidth: columnWidth } TextField { - style: TextFieldStyle { } + style: TextFieldStyle { + background: BorderImage { + source: "../images/textfield.png" + border.left: 4 ; border.right: 4 ; border.top: 4 ; border.bottom: 4 + } + } implicitWidth: columnWidth } TextField { @@ -91,43 +102,65 @@ Item { } Slider { + id: slider1 Layout.row: 2 - value: 50 - maximumValue: 100 + value: 0.5 implicitWidth: columnWidth style: SliderStyle { } } Slider { - value: 50 - maximumValue: 100 + id: slider2 + value: 0.5 implicitWidth: columnWidth - style: SliderStyle { } + style: SliderStyle { + groove: BorderImage { + height: 6 + border.top: 1 + border.bottom: 1 + source: "../images/progress-background.png" + border.left: 6 + border.right: 6 + BorderImage { + anchors.verticalCenter: parent.verticalCenter + source: "../images/progress-fill.png" + border.left: 5 ; border.top: 1 + border.right: 5 ; border.bottom: 1 + width: styleData.handlePosition + height: parent.height + } + } + handle: Item { + width: 13 + height: 13 + Image { + anchors.centerIn: parent + source: "../images/slider-handle.png" + } + } + } } Slider { - value: 50 - maximumValue: 100 + id: slider3 + value: 0.5 implicitWidth: columnWidth style: sliderStyle } ProgressBar { Layout.row: 3 - value: 50 - maximumValue: 100 + value: slider1.value implicitWidth: columnWidth style: ProgressBarStyle{ } } ProgressBar { - value: 50 - maximumValue: 100 + value: slider2.value implicitWidth: columnWidth - style: ProgressBarStyle{ } + style: progressBarStyle } ProgressBar { - value: 50 - maximumValue: 100 + value: slider3.value implicitWidth: columnWidth - style: progressbarStyle + style: progressBarStyle2 } CheckBox { @@ -177,64 +210,144 @@ Item { property Component buttonStyle: ButtonStyle { background: Rectangle { - implicitHeight: 20 + implicitHeight: 22 implicitWidth: columnWidth - color: control.pressed ? "darkGray" : "lightGray" + color: control.pressed ? "darkGray" : control.activeFocus ? "#cdd" : "#ccc" antialiasing: true border.color: "gray" radius: height/2 + Rectangle { + anchors.fill: parent + anchors.margins: 1 + color: "transparent" + antialiasing: true + visible: !control.pressed + border.color: "#aaffffff" + radius: height/2 + } } } property Component textfieldStyle: TextFieldStyle { background: Rectangle { implicitWidth: columnWidth - implicitHeight: 20 + implicitHeight: 22 color: "#f0f0f0" antialiasing: true border.color: "gray" radius: height/2 + Rectangle { + anchors.fill: parent + anchors.margins: 1 + color: "transparent" + antialiasing: true + border.color: "#aaffffff" + radius: height/2 + } } } property Component sliderStyle: SliderStyle { handle: Rectangle { - width: 14 - height: 14 + width: 18 + height: 18 color: control.pressed ? "darkGray" : "lightGray" border.color: "gray" antialiasing: true radius: height/2 + Rectangle { + anchors.fill: parent + anchors.margins: 1 + color: "transparent" + antialiasing: true + border.color: "#eee" + radius: height/2 + } } groove: Rectangle { height: 8 implicitWidth: columnWidth - implicitHeight: 20 + implicitHeight: 22 antialiasing: true - color: "darkGray" - border.color: "gray" + color: "#ccc" + border.color: "#777" radius: height/2 + Rectangle { + anchors.fill: parent + anchors.margins: 1 + color: "transparent" + antialiasing: true + border.color: "#66ffffff" + radius: height/2 + } } } - property Component progressbarStyle: ProgressBarStyle { + property Component progressBarStyle: ProgressBarStyle { + background: BorderImage { + source: "../images/progress-background.png" + border.left: 2 ; border.right: 2 ; border.top: 2 ; border.bottom: 2 + } + progress: Item { + clip: true + BorderImage { + anchors.fill: parent + anchors.rightMargin: (control.value < control.maximumValue) ? -4 : 0 + source: "../images/progress-fill.png" + border.left: 10 ; border.right: 10 + Rectangle { + width: 1 + color: "#a70" + opacity: 0.8 + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.bottomMargin: 1 + anchors.right: parent.right + visible: control.value < control.maximumValue + anchors.rightMargin: -parent.anchors.rightMargin + } + } + ParticleSystem{ id: bubbles } + ImageParticle{ + id: fireball + system: bubbles + source: "../images/bubble.png" + opacity: 0.7 + } + Emitter{ + system: bubbles + anchors.bottom: parent.bottom + anchors.margins: 4 + anchors.bottomMargin: -4 + anchors.left: parent.left + anchors.right: parent.right + size: 4 + sizeVariation: 4 + acceleration: PointDirection{ y: -6; xVariation: 3 } + emitRate: 6 * control.value + lifeSpan: 3000 + } + } + } + + property Component progressBarStyle2: ProgressBarStyle { background: Rectangle { implicitWidth: columnWidth - implicitHeight: 20 + implicitHeight: 24 color: "#f0f0f0" border.color: "gray" - antialiasing: true - radius: height/2 } progress: Rectangle { - implicitWidth: columnWidth - implicitHeight: 20 - color: "#c0c0c0" + color: "#ccc" border.color: "gray" - antialiasing: true - radius: height/2 + Rectangle { + color: "transparent" + border.color: "#44ffffff" + anchors.fill: parent + anchors.margins: 1 + } } } diff --git a/examples/quick/controls/gallery/images/bubble.png b/examples/quick/controls/gallery/images/bubble.png new file mode 100644 index 00000000..62aa1efe Binary files /dev/null and b/examples/quick/controls/gallery/images/bubble.png differ diff --git a/examples/quick/controls/gallery/images/button-pressed.png b/examples/quick/controls/gallery/images/button-pressed.png new file mode 100644 index 00000000..d64cdaa7 Binary files /dev/null and b/examples/quick/controls/gallery/images/button-pressed.png differ diff --git a/examples/quick/controls/gallery/images/button.png b/examples/quick/controls/gallery/images/button.png new file mode 100644 index 00000000..8ab41cc8 Binary files /dev/null and b/examples/quick/controls/gallery/images/button.png differ diff --git a/examples/quick/controls/gallery/images/progress-background.png b/examples/quick/controls/gallery/images/progress-background.png new file mode 100644 index 00000000..55a069df Binary files /dev/null and b/examples/quick/controls/gallery/images/progress-background.png differ diff --git a/examples/quick/controls/gallery/images/progress-fill.png b/examples/quick/controls/gallery/images/progress-fill.png new file mode 100644 index 00000000..b588c958 Binary files /dev/null and b/examples/quick/controls/gallery/images/progress-fill.png differ diff --git a/examples/quick/controls/gallery/images/slider-handle.png b/examples/quick/controls/gallery/images/slider-handle.png new file mode 100644 index 00000000..ac4d4a0d Binary files /dev/null and b/examples/quick/controls/gallery/images/slider-handle.png differ diff --git a/examples/quick/controls/gallery/images/textfield.png b/examples/quick/controls/gallery/images/textfield.png new file mode 100644 index 00000000..1d4a38ab Binary files /dev/null and b/examples/quick/controls/gallery/images/textfield.png differ diff --git a/examples/quick/controls/gallery/resources.qrc b/examples/quick/controls/gallery/resources.qrc index 21362787..6f487274 100644 --- a/examples/quick/controls/gallery/resources.qrc +++ b/examples/quick/controls/gallery/resources.qrc @@ -16,5 +16,12 @@ images/tab_selected.png images/window-new.png images/window-new@2x.png + images/bubble.png + images/button-pressed.png + images/button.png + images/progress-background.png + images/progress-fill.png + images/textfield.png + images/slider-handle.png diff --git a/src/styles/Base/SliderStyle.qml b/src/styles/Base/SliderStyle.qml index e21936a2..a6df15c0 100644 --- a/src/styles/Base/SliderStyle.qml +++ b/src/styles/Base/SliderStyle.qml @@ -122,7 +122,8 @@ Style { } /*! This property holds the background groove of the slider. - You can access the handle position through the \c handlePosition property. + + You can access the handle position through the \c styleData.handlePosition property. */ property Component groove: Item { anchors.verticalCenter: parent.verticalCenter @@ -164,7 +165,9 @@ Style { Loader { id: grooveLoader - property int handlePosition: handleLoader.x + handleLoader.width/2 + property QtObject styleData: QtObject { + readonly property int handlePosition: handleLoader.x + handleLoader.width/2 + } x: padding.left sourceComponent: groove width: (horizontal ? parent.width : parent.height) - padding.left - padding.right -- cgit v1.2.1 From e67d67d0ad0c5c4549047f13be1999c65a9efb42 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 4 Jun 2013 13:36:18 +0200 Subject: Examples: several fixes for text * Cut/Copy/Paste works * The initial status for b/i/u and alignment works * Font size and family works * Text color works Task-number: QTBUG-31482 Change-Id: I299931dede9defbb1d3eb927f867e77d20ded5ae Reviewed-by: Caroline Chao Reviewed-by: Gabriel de Dietrich --- examples/quick/controls/text/qml/main.qml | 152 +++++++++++++++------ .../quick/controls/text/src/documenthandler.cpp | 48 ++++++- examples/quick/controls/text/src/documenthandler.h | 16 ++- 3 files changed, 166 insertions(+), 50 deletions(-) diff --git a/examples/quick/controls/text/qml/main.qml b/examples/quick/controls/text/qml/main.qml index ec6bff7b..d8f175ed 100644 --- a/examples/quick/controls/text/qml/main.qml +++ b/examples/quick/controls/text/qml/main.qml @@ -85,32 +85,34 @@ ApplicationWindow { } Action { - id: cut + id: cutAction text: "Cut" shortcut: "ctrl+x" iconSource: "images/editcut.png" iconName: "edit-cut" + onTriggered: textArea.cut() } Action { - id: copy + id: copyAction text: "Copy" shortcut: "Ctrl+C" iconSource: "images/editcopy.png" iconName: "edit-copy" - onTriggered: console.log("Ctrl C pressed - in action...") + onTriggered: textArea.copy() } Action { - id: paste + id: pasteAction text: "Paste" shortcut: "ctrl+v" iconSource: "qrc:images/editpaste.png" iconName: "edit-paste" + onTriggered: textArea.paste() } Action { - id: alignLeft + id: alignLeftAction text: "&Left" iconSource: "images/textleft.png" iconName: "format-justify-left" @@ -120,16 +122,16 @@ ApplicationWindow { checked: document.alignment == Qt.AlignLeft } Action { - id: alignCenter + id: alignCenterAction text: "C&enter" iconSource: "images/textcenter.png" iconName: "format-justify-center" - onTriggered: document.alignment = Qt.AlignCenter + onTriggered: document.alignment = Qt.AlignHCenter checkable: true - checked: document.alignment == Qt.AlignCenter + checked: document.alignment == Qt.AlignHCenter } Action { - id: alignRight + id: alignRightAction text: "&Right" iconSource: "images/textright.png" iconName: "format-justify-right" @@ -138,7 +140,7 @@ ApplicationWindow { checked: document.alignment == Qt.AlignRight } Action { - id: alignJustify + id: alignJustifyAction text: "&Justify" iconSource: "images/textjustify.png" iconName: "format-justify-fill" @@ -148,7 +150,7 @@ ApplicationWindow { } Action { - id: bold + id: boldAction text: "&Bold" iconSource: "images/textbold.png" iconName: "format-text-bold" @@ -156,8 +158,9 @@ ApplicationWindow { checkable: true checked: document.bold } + Action { - id: italic + id: italicAction text: "&Italic" iconSource: "images/textitalic.png" iconName: "format-text-italic" @@ -166,7 +169,7 @@ ApplicationWindow { checked: document.italic } Action { - id: underline + id: underlineAction text: "&Underline" iconSource: "images/textunder.png" iconName: "format-text-underline" @@ -176,41 +179,55 @@ ApplicationWindow { } FileDialog { - id: file + id: fileDialog nameFilters: ["Text files (*.txt)", "HTML files (*.html)"] onAccepted: document.fileUrl = fileUrl } + ColorDialog { + id: colorDialog + color: "black" + onAccepted: document.textColor = color + } + Action { - id: fileOpen + id: fileOpenAction iconSource: "images/fileopen.png" iconName: "document-open" text: "Open" - onTriggered: file.open() + onTriggered: fileDialog.open() } menuBar: MenuBar { Menu { title: "&File" - MenuItem { action: fileOpen } + MenuItem { action: fileOpenAction } MenuItem { text: "Quit"; onTriggered: Qt.quit() } } Menu { title: "&Edit" - MenuItem { action: copy } - MenuItem { action: cut } - MenuItem { action: paste } + MenuItem { action: copyAction } + MenuItem { action: cutAction } + MenuItem { action: pasteAction } } Menu { title: "F&ormat" - MenuItem { action: bold } - MenuItem { action: italic } - MenuItem { action: underline } + MenuItem { action: boldAction } + MenuItem { action: italicAction } + MenuItem { action: underlineAction } + MenuSeparator {} + MenuItem { action: alignLeftAction } + MenuItem { action: alignCenterAction } + MenuItem { action: alignRightAction } + MenuItem { action: alignJustifyAction } MenuSeparator {} - MenuItem { action: alignLeft } - MenuItem { action: alignCenter } - MenuItem { action: alignRight } - MenuItem { action: alignJustify } + MenuItem { + text: "&Color ..." + onTriggered: { + colorDialog.color = document.textColor + colorDialog.open() + } + } } Menu { title: "&Help" @@ -224,26 +241,71 @@ ApplicationWindow { RowLayout { anchors.fill: parent spacing: 0 - ToolButton { action: fileOpen } + ToolButton { action: fileOpenAction } ToolBarSeparator {} - ToolButton { action: copy } - ToolButton { action: cut } - ToolButton { action: paste } + ToolButton { action: copyAction } + ToolButton { action: cutAction } + ToolButton { action: pasteAction } ToolBarSeparator {} - ToolButton { action: bold } - ToolButton { action: italic } - ToolButton { action: underline } + ToolButton { action: boldAction } + ToolButton { action: italicAction } + ToolButton { action: underlineAction } ToolBarSeparator {} - ToolButton { action: alignLeft } - ToolButton { action: alignCenter } - ToolButton { action: alignRight } - ToolButton { action: alignJustify } + ToolButton { action: alignLeftAction } + ToolButton { action: alignCenterAction } + ToolButton { action: alignRightAction } + ToolButton { action: alignJustifyAction } + + ToolBarSeparator {} + + ToolButton { + id: colorButton + property var color : document.textColor + Rectangle { + id: colorRect + anchors.fill: parent + anchors.margins: 8 + color: Qt.darker(document.textColor, colorButton.pressed ? 1.4 : 1) + border.width: 1 + border.color: Qt.darker(colorRect.color, 2) + } + onClicked: { + colorDialog.color = document.textColor + colorDialog.open() + } + } + Item { Layout.fillWidth: true } + } + } + + ToolBar { + id: secondaryToolBar + width: parent.width + + RowLayout { + anchors.fill: parent + ComboBox { + id: fontFamilyComboBox + implicitWidth: 150 + model: Qt.fontFamilies() + property bool special : false + onCurrentTextChanged: { + if (special == false || currentIndex != 0) + document.fontFamily = currentText + } + } + SpinBox { + id: fontSizeSpinBox + implicitWidth: 50 + value: 0 + onValueChanged: document.fontSize = value + } Item { Layout.fillWidth: true } } } @@ -253,7 +315,7 @@ ApplicationWindow { id: textArea frameVisible: false width: parent.width - anchors.top: parent.top + anchors.top: secondaryToolBar.bottom anchors.bottom: parent.bottom text: document.text textFormat: Qt.RichText @@ -266,5 +328,17 @@ ApplicationWindow { cursorPosition: textArea.cursorPosition selectionStart: textArea.selectionStart selectionEnd: textArea.selectionEnd + Component.onCompleted: document.fileUrl = "qrc:/example.html" + onFontSizeChanged: fontSizeSpinBox.value = document.fontSize + onFontFamilyChanged: { + var index = Qt.fontFamilies().indexOf(document.fontFamily) + if (index == -1) { + fontFamilyComboBox.currentIndex = 0 + fontFamilyComboBox.special = true + } else { + fontFamilyComboBox.currentIndex = index + fontFamilyComboBox.special = false + } + } } } diff --git a/examples/quick/controls/text/src/documenthandler.cpp b/examples/quick/controls/text/src/documenthandler.cpp index 81eb744b..e0c9610d 100644 --- a/examples/quick/controls/text/src/documenthandler.cpp +++ b/examples/quick/controls/text/src/documenthandler.cpp @@ -52,7 +52,6 @@ DocumentHandler::DocumentHandler() , m_selectionStart(0) , m_selectionEnd(0) { - setFileUrl(QUrl("qrc:/example.html")); } void DocumentHandler::setTarget(QQuickItem *target) @@ -91,6 +90,8 @@ void DocumentHandler::setFileUrl(const QUrl &arg) emit textChanged(); emit documentTitleChanged(); + + reset(); } } emit fileUrlChanged(); @@ -135,12 +136,18 @@ void DocumentHandler::setCursorPosition(int position) m_cursorPosition = position; - emit currentFontChanged(); + reset(); +} + +void DocumentHandler::reset() +{ + emit fontFamilyChanged(); emit alignmentChanged(); emit boldChanged(); emit italicChanged(); emit underlineChanged(); emit fontSizeChanged(); + emit textColorChanged(); } QTextCursor DocumentHandler::textCursor() const @@ -260,13 +267,44 @@ void DocumentHandler::setFontSize(int arg) emit fontSizeChanged(); } -QFont DocumentHandler::currentFont() const +QColor DocumentHandler::textColor() const +{ + QTextCursor cursor = textCursor(); + if (cursor.isNull()) + return QColor(Qt::black); + QTextCharFormat format = cursor.charFormat(); + return format.foreground().color(); +} + +void DocumentHandler::setTextColor(const QColor &c) +{ + QTextCursor cursor = textCursor(); + if (cursor.isNull()) + return; + QTextCharFormat format; + format.setForeground(QBrush(c)); + mergeFormatOnWordOrSelection(format); + emit textColorChanged(); +} + +QString DocumentHandler::fontFamily() const { QTextCursor cursor = textCursor(); if (cursor.isNull()) - return QFont(); + return QString(); QTextCharFormat format = cursor.charFormat(); - return format.font(); + return format.font().family(); +} + +void DocumentHandler::setFontFamily(const QString &arg) +{ + QTextCursor cursor = textCursor(); + if (cursor.isNull()) + return; + QTextCharFormat format; + format.setFontFamily(arg); + mergeFormatOnWordOrSelection(format); + emit fontFamilyChanged(); } QStringList DocumentHandler::defaultFontSizes() const diff --git a/examples/quick/controls/text/src/documenthandler.h b/examples/quick/controls/text/src/documenthandler.h index c60bc1d5..a759c403 100644 --- a/examples/quick/controls/text/src/documenthandler.h +++ b/examples/quick/controls/text/src/documenthandler.h @@ -63,7 +63,8 @@ class DocumentHandler : public QObject Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged) Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged) - Q_PROPERTY(QFont currentFont READ currentFont NOTIFY currentFontChanged) + Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY textColorChanged) + Q_PROPERTY(QString fontFamily READ fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged) Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged) Q_PROPERTY(bool bold READ bold WRITE setBold NOTIFY boldChanged) @@ -93,7 +94,9 @@ public: int selectionStart() const { return m_selectionStart; } int selectionEnd() const { return m_selectionEnd; } - QFont currentFont() const; + QString fontFamily() const; + + QColor textColor() const; Qt::Alignment alignment() const; void setAlignment(Qt::Alignment a); @@ -114,6 +117,8 @@ public Q_SLOTS: void setItalic(bool arg); void setUnderline(bool arg); void setFontSize(int arg); + void setTextColor(const QColor &arg); + void setFontFamily(const QString &arg); void setFileUrl(const QUrl &arg); void setText(const QString &arg); @@ -126,7 +131,8 @@ Q_SIGNALS: void selectionStartChanged(); void selectionEndChanged(); - void currentFontChanged(); + void fontFamilyChanged(); + void textColorChanged(); void alignmentChanged(); void boldChanged(); @@ -142,6 +148,7 @@ Q_SIGNALS: void documentTitleChanged(); private: + void reset(); QTextCursor textCursor() const; void mergeFormatOnWordOrSelection(const QTextCharFormat &format); @@ -153,9 +160,6 @@ private: int m_selectionEnd; QFont m_font; - bool m_bold; - bool m_italic; - bool m_underline; int m_fontSize; QUrl m_fileUrl; QString m_text; -- cgit v1.2.1 From a258188d303f1d3767eda05cd1ce3a96f7541fd8 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 7 May 2013 15:48:07 +0200 Subject: Doc: check language and compliance with Writing Guidelines Task-number: QTBUG-30318 Change-Id: I6117c41344f1a5015a1fa2d4a59950306a719313 Reviewed-by: Venugopal Shivashankar Reviewed-by: Jerome Pasion --- src/controls/StackView.qml | 252 +++++++++++++++++++++++---------------------- 1 file changed, 127 insertions(+), 125 deletions(-) diff --git a/src/controls/StackView.qml b/src/controls/StackView.qml index be1ddf06..9559ea87 100644 --- a/src/controls/StackView.qml +++ b/src/controls/StackView.qml @@ -52,39 +52,38 @@ import "Private/StackView.js" as JSArray \brief Provides a stack-based navigation model. - StackView implements a stack-based navigation model. You use this view when you - have a set of interlinked information pages for the user to browse. - Items are pushed onto the stack as the user navigates deeper into the material, and - popped off again when he chooses to go back. + StackView implements a stack-based navigation model, which can be used + with a set of interlinked information pages. Items are pushed onto the stack + as the user navigates deeper into the material, and popped off again when he + chooses to go back. \section1 Using StackView in an Application Using the StackView in the application is typically a simple matter of adding - the StackView as a child of a Window. The stack is usually - anchored to the edges of the window, except at the top or bottom where it might - be anchored to a status bar, or some other similar UI component. - The stack can then be used by invoking its navigation methods. The first item - to show in the StackView is commonly loaded assigning it to \l initialItem. + the StackView as a child of a Window. The stack is usually anchored to the + edges of the window, except at the top or bottom where it might be anchored + to a status bar, or some other similar UI component. The stack can then be + used by invoking its navigation methods. The first item to show in the StackView + is commonly loaded assigning it to \l initialItem. \note Items pushed onto the stack view have \l{Supported Attached Properties}{Stack attached properties}. \section1 Basic Navigation - There are three primary navigation operations in StackView: push(), pop() and - replace (you replace by specifying argument \c replace to push()). + There are three primary navigation operations in StackView: push(), pop(), and + replace (replace by specifying argument \c replace to push()). These correspond to classic stack operations where "push" adds an item to the top of a stack, "pop" removes the top item from the stack, and "replace" is like a pop followed by a push in that it replaces the topmost item on the stack with a new item (but the applied transtition might be different). The topmost item - in the stack corresponds to the one that is \l{StackView::currentItem} {current}, - i.e. the one that is visible on - screen. That means that "push" is the logical equivalent of navigating forward or - deeper into the application, "pop" is the equivalent of navigation back and - "replace" is the equivalent of replacing the current item with a different item. - - Sometimes it is necessary to go back more than a single step in the stack, e.g. - to return to a "main" item or some kind of section item in the application. - For this use case, pop() can be provided with a item to pop to. This is called - an "unwind" operation as the stack gets unwound to the specified item. If the - item is not found then the stack unwinds until there is only a single item in + in the stack corresponds to the one that is \l{StackView::currentItem} {currently} + visible on the screen. That means that "push" is the logical equivalent of navigating + forward or deeper into the application, "pop" is the equivalent of navigating back, + and "replace" is the equivalent of replacing the current item. + + Sometimes it is necessary to go back more than a single step in the stack, for + example, to return to a "main" item or some kind of section item in the application. + For this use case, it is possible to specify an item as a parameter for pop(). + This is called an "unwind" operation as the stack gets unwound to the specified item. + If the item is not found then the stack unwinds until there is only a single item in the stack, which becomes the current item. To explicitly unwind to the bottom of the stack it is recommended to use \l{pop()} {pop(null)}, though technically any non-existent item will do. @@ -98,11 +97,11 @@ import "Private/StackView.js" as JSArray \li \l{pop()}{pop(A)} => [A] - "pop" transition between C and A \endlist - Note that when the stack is empty, a push() will not perform a - transition animation because there is nothing to transition from (which will - typically happend during application start-up). A pop() on a stack with - depth 1 or 0 is a no-operation. If removing all items from the stack is - needed, a separate function clear() is available. + \note Note that when the stack is empty, a push() will not perform a + transition animation because there is nothing to transition from (typically during + application start-up). A pop() on a stack with depth 1 or 0 is a no-operation. + If removing all items from the stack is needed, a separate function clear() is + available. Calling push() returns the item that was pushed onto the stack. Calling pop() returns the item that was popped off the stack. When pop() is @@ -110,22 +109,22 @@ import "Private/StackView.js" as JSArray popped, which will also be the one transitioning out) is returned. \section1 Deep Linking - Deep linking means launching an application into a particular state. For example - a Newspaper application could be launched into showing a particular article, - bypassing the front item (and possible a section item) that would normally have - to be navigated through to get to the article in question. In terms of StackView, deep - linking means the ability to modify the state of the stack so that - you e.g. push a set of items to the top of the stack, or that you completely reset + \e{Deep linking} means launching an application into a particular state. For example, + a newspaper application could be launched into showing a particular article, + bypassing the front item (and possibly a section item) that would normally have + to be navigated through to get to the article concerned. In terms of StackView, deep + linking means the ability to modify the state of the stack, so much so that it is + possible to push a set of items to the top of the stack, or to completely reset the stack to a given state. - The API for deep linking in StackView is the same as for basic navigation. If - you push an array instead of a single item then all the items in that array will + The API for deep linking in StackView is the same as for basic navigation. Pushing + an array instead of a single item, will involve that all the items in that array will be pushed onto the stack. The transition animation, however, will be conducted as if only the last item in the array was pushed onto the stack. The normal semantics - of push() apply for deep linking, meaning that push() adds whatever you push onto - the stack. Note also that only the last item in the array will actually be loaded. - The rest will be lazy loaded as needed when entering - the screen upon subsequent calls to pop (or when requesting the item by using \a get). + of push() apply for deep linking, meaning that push() adds whatever is pushed onto + the stack. Note also that only the last item of the array will be loaded. + The rest will be lazy-loaded as needed when entering the screen upon subsequent + calls to pop (or when requesting the item by using \a get). This gives us the following result, given the stack [A, B, C]: @@ -137,93 +136,95 @@ import "Private/StackView.js" as JSArray \section1 Pushing items - An item you push onto the StackView can be either an Item, a URL, a - string with a URL, or a Component. To push it, you assign it - to a property "item" inside a property list, and send it as argument to \l{StackView::push}{push}: + An item pushed onto the StackView can be either an Item, a URL, a string + with a URL, or a Component. To push it, assign it to a property "item" + inside a property list, and send it as an argument to \l{StackView::push}{push}: \code stackView.push({item: yourItem}) \endcode - The list can contain several properties that controls how the item should be pushed: + The list can contain several properties that control how the item should be pushed: \list - \li \c item: This property is required, and holds the item you want to push. - \li \c properties: You can set a property list of QML properties that should be assigned - to the item upon push. These properties will be copied into the item at the - time the item is loaded, or about to become the current item (normally upon push). - \li \c immediate: Set this property to \c true to skip transition effects. When pushing - an array, you only need to set this property on the first element to make the + \li \c item: this property is required, and holds the item to be pushed. + \li \c properties: a list of QML properties to be assigned to the item upon push. These + properties will be copied into the item at load time, or when the item will become + the current item (normally upon push). + \li \c immediate: set this property to \c true to skip transition effects. When pushing + an array, this property only needs to be set on the first element to make the whole operation immediate. - \li \c replace: Set this property to replace the current item on the stack. When pushing + \li \c replace: set this property to replace the current item on the stack. When pushing an array, you only need to set this property on the first element to replace as many elements on the stack as inside the array. - \li \c destroyOnPop: Set this property to be explicit to whether or not StackView should - destroy the item when its popped off the stack. By default (if \a destroyOnPop is - not specified), StackView will destroy items pushed as components or URLs. Items - not destroyed will be reparented back to the original parents they had before being - pushed onto the stack, and hidden. If you need to set this property, do it with - care, so that items are not leaked. + \li \c destroyOnPop: set this boolean to true if StackView needs to destroy the item when + it is popped off the stack. By default (if \a destroyOnPop is not specified), StackView + will destroy items pushed as components or URLs. Items not destroyed will be re-parented + back to the original parents they had before being pushed onto the stack and hidden. + If you need to set this property, do it with care, so that items are not leaked. \endlist - If the only argument needed is "item", you can also, as a short-hand - notation, do: + If the only argument needed is "item", the following short-hand notation can be applied: \code - stackView.push(yourItem). + stackView.push(yourItem) \endcode You can push several items in one go by using an array of property lists. This is optimizing compared to pushing items one by one, since StackView then can load only the last item in the list. The rest will be loaded as they are about to become - the current item (which happends when the stack is popped). The following example shows how + the current item (which happens when the stack is popped). The following example shows how to push an array of items: \code stackView.push([{item: yourItem1}, {item: yourItem2}]) \endcode - If inline items are pushed, the item gets re-parented into an internal - container in the StackView. When the item is later popped off, it gets - re-parented back to its original owner. If, however, an item is pushed - as a component or a URL, the actual item will be created as a item from that component. This - happens automatically when the item is about to become the current item in the stack. Ownership - over the item will then normally be taken by the StackView. It will as such automatically - destroy the item when it is later popped off. The component that declared the item, by + If an inline item is pushed, the item is temporarily re-parented into the StackView. When the item + is later popped off, it gets re-parented back to its original owner again. + If, however, an item is pushed as a component or a URL, the actual item will be created as an + item from that component. This happens automatically when the item is about to become the current + item in the stack. Ownership of the item will then normally be taken by the StackView. It will as + such automatically destroy the item when it is later popped off. The component that declared the item, by contrast, remains in the ownership of the application and is not destroyed by the stack. - You can override this behavior if needed by explicitly setting "destroyOnPop" in the list - argument given to push. + This can be overridden by explicitly setting \c{destroyOnPop} in the list of arguments given to push. - If you specify the \c properties property to push, these properties will be copied into - the item at the time the item is loaded (in case of a component or URL), or instead when - its about to become the current item (in case of an inline item). This normally happens when - the item is pushed. The following example shows how this can be done: + If the \c properties to be pushed are specified, they will be copied into the item at loading time + (in case of a component or URL), or when the item will become the current item (in case of an inline + item). The following example shows how this can be done: \code - stackView.push({item: someItem, properties: {fgcolor: "red", bgcolor: "blue"}}); + stackView.push({item: someItem, properties: {fgcolor: "red", bgcolor: "blue"}}) \endcode - Note that if an item is declared inside another item that is destroyed - even if a component - was used - that child item also gets destroyed. - This follows normal Qt parent-child destruction rules but sometimes comes as a surprise - for developers. In practice this means that if you declare a item B as a child of - item A and then do a replace from item A to item B, then item B will be destroyed when - item A was destroyed (as it was popped off the stack) and the application will effectively - be switching to a item that has been destroyed. + + \note Note that if an item is declared inside another item, and if that parent gets destroyed, + (even if a component was used), that child item will also be destroyed. + This follows normal Qt parent-child destruction rules, but sometimes comes as a surprise + for developers. \section1 Lifecycle - An items lifecycle in the StackView goes from instantiation to inactive, activating, active, - deactivating, inactive, and when no longer needed, destruction. + An item's lifecycle in the StackView can have the following transitions: + \list 1 + \li instantiation + \li inactive + \li activating + \li active + \li deactivating + \li inactive + \li destruction + \endlist + It can move any number of times between inactive and active. When an item is activated, it's visible on the screen and is considered to be the current item. An item in a StackView that is not visible is not activated, even if the item is currently the - top-most item in the stack. When the stack becomes visible the item that is top-most gets - activated. Likewise if the stack is then hidden, the top-most item would be deactivated. + top-most item in the stack. When the stack becomes visible, the item that is top-most gets + activated. Likewise if the stack is then hidden, the topmost item would be deactivated. Popping the item off the top of the stack at this point would not result in further deactivation since the item is not active. - There is an attached \l{Stack::status}{Stack.status} property that tracks the lifecycle. The value of status is - an enumeration with values \c Stack.Inactive, \c Stack.Activating, \c Stack.Active - and \c Stack.Deactivating. Combined with the normal \c Component.onComplete and + There is an attached \l{Stack::status}{Stack.status} property that tracks the lifecycle. The + status values list is an enumeration with values \c Stack.Inactive, \c Stack.Activating, + \c Stack.Active and \c Stack.Deactivating. Combined with the normal \c Component.onComplete and \c Component.onDestruction signals the entire lifecycle is thus: \list @@ -236,26 +237,26 @@ import "Private/StackView.js" as JSArray \endlist \section1 Finding items - Sometimes it is necessary to search for a item, e.g. in order to unwind the stack to + Sometimes it is necessary to search for an item, for example, in order to unwind the stack to an item to which the application does not have a reference. This is facilitated using a function find() in StackView. The find() function takes a callback function as its only argument. The callback gets invoked for each item in the stack (starting at the top). - If the callback returns true then it signals that a match has been found and the find() - function returns that item. If the callback fails to return true (i.e. no match is found) + If the callback returns true, then it signals that a match has been found and the find() + function returns that item. If the callback fails to return true (no match is found), then find() returns \c null. - The code below searches for an item in the stack that has a name "foo" and then unwinds to - that item. Note that since find() returns null if no item is found and since pop unwinds to - the bottom of the stack if null is given as the target item, the code works well even in the - case that no matching item was found. + The code below searches for an item in the stack that has a name "order_id" and then unwinds to + that item. Note that since find() returns \c {null} if no item is found, and since pop unwinds to + the bottom of the stack if null is given as the target item, the code works well even in + case no matching item is found. \code stackView.pop(stackView.find(function(item) { - return item.name == "foo"; + return item.name == "order_id"; })); \endcode - You can also get to a item in the stack using get(index). You should use + You can also get to an item in the stack using \l {get()}{get(index)}. You should use this function if your item depends on another item in the stack, as the function will ensure that the item at the given index gets loaded before it is returned. @@ -316,8 +317,8 @@ import "Private/StackView.js" as JSArray Implement this function to reset any properties animated on the exitItem so that later transitions can expect the items to be in a default state. - A more complex example could look like the following. Here, the items slides in lying on the side before - they are rotated up in an upright position: + A more complex example could look like the following. Here, the items are lying on the side before + being rotated to an upright position: \qml StackView { @@ -376,7 +377,7 @@ import "Private/StackView.js" as JSArray depending on the their internal state. StackView will expect you to return a Component that contains a StackViewTransition, or a StackViewTransition directly. The former is easier, as StackView will then create the transition and later destroy it when it's done, while avoiding any sideeffects - caused by the transition being alive long after it ran. Returning a StackViewTransition directly + caused by the transition being alive long after it has run. Returning a StackViewTransition directly can be useful if you need to write some sort of transition caching for performance reasons. As an optimization, you can also return \c null to signal that you just want to show/hide the items immediately without creating or running any transitions. You can also override this function if @@ -385,9 +386,9 @@ import "Private/StackView.js" as JSArray \c properties contains the properties that will be assigned to the StackViewTransition before it runs. In fact, you can add more properties to this object during the call if you need to initialize additional properties of your custom StackViewTransition when the returned - component is instanciated. + component is instantiated. - The following example shows how you can decide run-time which animation to use: + The following example shows how you can decide which animation to use during runtime : \qml StackViewDelegate { @@ -491,28 +492,28 @@ Item { /*! Pushes an item onto the stack. The function takes a property list as argument, which should contain one or more of the following properties: \list - \li \c item: This property is required, and holds the item you want to push. - \li \c properties: You can set a property list of QML properties that should be assigned - to the item upon push. These properties will be copied into the item at the - time the item is loaded (in case of a component or URL), or else the first time it - becomes the current item (normally upon push). - \li \c immediate: Set this property to \c true to skip transition effects. When pushing + \li \c item: this property is required, and holds the item you want to push. + \li \c properties: a list of QML properties that should be assigned + to the item upon push. These properties will be copied into the item when it is + loaded (in case of a component or URL), or when it becomes the current item for the + first time (normally upon push). + \li \c immediate: set this property to \c true to skip transition effects. When pushing an array, you only need to set this property on the first element to make the whole operation immediate. - \li \c replace: Set this property to replace the current item on the stack. When pushing + \li \c replace: set this property to replace the current item on the stack. When pushing an array, you only need to set this property on the first element to replace as many elements on the stack as inside the array. - \li \c destroyOnPop: Set this property to be explicit to whether or not StackView should - destroy the item when its popped off the stack. By default (if \a destroyOnPop is - not specified), StackView will destroy items pushed as components or URLs. Items - not destroyed will be reparented back to the original parents they had before being + \li \c destroyOnPop: set this property to specify if the item needs to be destroyed + when its popped off the stack. By default (if \a destroyOnPop is not specified), + StackView will destroy items pushed as components or URLs. Items + not destroyed will be re-parented to the original parents they had before being pushed onto the stack, and hidden. If you need to set this property, do it with care, so that items are not leaked. \endlist You can also push an array of items (property lists) if you need to push several items in one go. A transition will then only occur between the current item and the last - item in the list. The other items will be deferred loaded until needed. + item in the list. Loading the other items will be deferred until needed. Examples: \list @@ -524,8 +525,8 @@ Item { \li stackView.push([{item:anitem, immediate:true}, {item:aURL}]) \endlist - Note: If the only argument needed is "item", you can also, as a short-hand - notation, do: \c{stackView.push(anItem)}. + \note Note: if the only argument needed is "item", you can apply the following short- + hand notation: \c{stackView.push(anItem)}. Returns the item that became current. @@ -581,11 +582,11 @@ Item { /*! Pops one or more items off the stack. The function takes a property list as argument which can contain one or more of the following properties: \list - \li \c item: If specified, all items down to (but not including) \a item will be - popped off. if \a item is \c null, all items down to (but not including) the + \li \c item: if specified, all items down to (but not including) \a item will be + popped off. If \a item is \c null, all items down to (but not including) the first item will be popped. If not specified, only the current item will be popped. - \li \c immediate: Set this property to \c true to skip transition effects. + \li \c immediate: set this property to \c true to skip transition effects. \endlist Examples: @@ -596,8 +597,8 @@ Item { \li stackView.pop(null) \endlist - Note: If the only argument needed is "item", you can also, as a short-hand - notation, do: \c{stackView.pop(anItem)}. + \note Note: If the only argument needed is "item", you can apply the following short- + hand notation: \c{stackView.pop(anItem)}. Returns the item that was popped off \sa clear() @@ -668,7 +669,8 @@ Item { /*! Search for a specific item inside the stack. \a func will be called for each item in the stack (with the item as argument) - until the function returns true. Return value will be the item found. E.g: + until the function returns true. Return value will be the item found. For + example: find(function(item, index) { return item.isTheOne }) Set \a onlySearchLoadedItems to \c true to not load items that are not loaded into memory */ @@ -794,7 +796,7 @@ Item { element.destroyOnPop = true } } else { - // comp is already an Item, so just reparent it into the StackView: + // comp is already an Item, so just re-parent it into the StackView: element.item = comp element.originalParent = parent element.item.parent = root @@ -844,7 +846,7 @@ Item { /*! \internal */ function __cleanup(element) { // INVARIANT: element has been removed from JSArray. Destroy its - // item, or reparent it back to the parent it had before it was pushed: + // item, or re-parent it back to the parent it had before it was pushed: var item = element.item if (element.destroyOnPop) { item.destroy() @@ -871,7 +873,7 @@ Item { // Animate item in "outElement" out, and item in "inElement" in. Set a guard to protect // the user from pushing new items on signals that will fire while preparing for the transition // (e.g Stack.onCompleted, Stack.onStatusChanged, Stack.onIndexChanged etc). Otherwise, we will enter - // this function several times, which causes the items to be half-way updated. + // this function several times, which causes the items to be updated half-way. if (__currentTransition) __currentTransition.animation.complete() __loadElement(transition.inElement) -- cgit v1.2.1 From 3edcc79bcf9259c77732a8ad15bd8ed6919d4983 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Fri, 31 May 2013 16:07:00 +0200 Subject: Simplify example code by using QmlApplicationEngine Since QmlApplicationEngine does all the nasty bits including setting the incubation controller, we should use it in all of our examples. Task-number: QTBUG-31203 Change-Id: Ie4f2313b66ef1a460aa50559f5c0a6125d0c69f1 Reviewed-by: J-P Nurmi Reviewed-by: Caroline Chao Reviewed-by: Alan Alpert --- .../quick/controls/shared/qt_quick_controls_examplemain.h | 11 ++--------- examples/quick/controls/text/src/main.cpp | 14 ++------------ 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/examples/quick/controls/shared/qt_quick_controls_examplemain.h b/examples/quick/controls/shared/qt_quick_controls_examplemain.h index e3cae9a0..324d7110 100644 --- a/examples/quick/controls/shared/qt_quick_controls_examplemain.h +++ b/examples/quick/controls/shared/qt_quick_controls_examplemain.h @@ -64,20 +64,13 @@ QT_BEGIN_NAMESPACE int main(int argc, char *argv[]) \ { \ Application app(argc, argv); \ - QQmlEngine engine; \ - QQmlComponent component(&engine); \ - component.loadUrl(QUrl(#url)); \ - if ( !component.isReady() ) { \ - qWarning("%s", qPrintable(component.errorString())); \ - return -1; \ - } \ - QObject *topLevel = component.create(); \ + QQmlApplicationEngine engine(QUrl(#url)); \ + QObject *topLevel = engine.rootObjects().value(0); \ QQuickWindow *window = qobject_cast(topLevel); \ if ( !window ) { \ qWarning("Error: Your root item has to be a Window."); \ return -1; \ } \ - QObject::connect(&engine, SIGNAL(quit()), &app, SLOT(quit())); \ window->show(); \ return app.exec(); \ } diff --git a/examples/quick/controls/text/src/main.cpp b/examples/quick/controls/text/src/main.cpp index 0fc064dc..8d2b8dd0 100644 --- a/examples/quick/controls/text/src/main.cpp +++ b/examples/quick/controls/text/src/main.cpp @@ -49,24 +49,14 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); - QQmlEngine engine; - qmlRegisterType("org.qtproject.example", 1, 0, "DocumentHandler"); - - QQmlComponent component(&engine); - component.loadUrl(QUrl("qrc:/qml/main.qml")); - if ( !component.isReady() ) { - qWarning("%s", qPrintable(component.errorString())); - return -1; - } - QObject *topLevel = component.create(); + QQmlApplicationEngine engine(QUrl("qrc:/qml/main.qml")); + QObject *topLevel = engine.rootObjects().value(0); QQuickWindow *window = qobject_cast(topLevel); if ( !window ) { qWarning("Error: Your root item has to be a Window."); return -1; } - - QObject::connect(&engine, SIGNAL(quit()), &app, SLOT(quit())); window->show(); return app.exec(); } -- cgit v1.2.1 From 39ed137e71326411083c27c1d132769c33200df4 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Wed, 5 Jun 2013 13:23:24 +0200 Subject: Text example: Update example.html Remove references to QTextEdit and adapt it to match TextArea instead. Update the Qt logo. Change-Id: I6939bf7418fbad883e1d967bea3688d9ccfd4885 Reviewed-by: Hanne Linaae Reviewed-by: J-P Nurmi --- examples/quick/controls/text/example.html | 22 ++++----- examples/quick/controls/text/qml/images/logo32.png | Bin 1410 -> 0 bytes .../quick/controls/text/qml/images/qt-logo.png | Bin 0 -> 3960 bytes examples/quick/controls/text/resources.qrc | 52 ++++++++++----------- 4 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 examples/quick/controls/text/qml/images/logo32.png create mode 100644 examples/quick/controls/text/qml/images/qt-logo.png diff --git a/examples/quick/controls/text/example.html b/examples/quick/controls/text/example.html index 0560897b..52bb507a 100644 --- a/examples/quick/controls/text/example.html +++ b/examples/quick/controls/text/example.html @@ -1,11 +1,13 @@ -QTextEdit Example -

QTextEdit

-

The QTextEdit widget is an advanced editor that supports formatted rich text. It can be used to display HTML and other rich document formats. Internally, QTextEdit uses the QTextDocument class to describe both the high-level structure of each document and the low-level formatting of paragraphs.

-

If you are viewing this document in the textedit example, you can edit this document to explore Qt's rich text editing features. We have included some comments in each of the following sections to encourage you to experiment.

+

TextArea

+

The TextArea control is an advanced editor that supports formatted rich text. It can be used to display HTML and other rich document formats. Internally, TextArea uses the QQuickTextDocument class to describe both the high-level structure of each document and the low-level formatting of paragraphs.

+

If you are viewing this document in the Text Editor example, you can edit this document to explore Qt's rich text editing features. We have included some comments in each of the following sections to encourage you to experiment.

Font and Paragraph Styles

-

QTextEdit supports bold, italic, and underlined font styles, and can display multicolored text. Font families such as Times New Roman and Courier can also be used directly. If you place the cursor in a region of styled text, the controls in the tool bars will change to reflect the current style.

+

TextArea supports bold, italic, and underlined font styles, and can display multicolored + text. Font families such as Helvetica and + Courier can also be used directly. If you place the cursor in a region of styled text, the corresponding controls in the tool bar will change to reflect the current style, font size and color.

Paragraphs can be formatted so that the text is left-aligned, right-aligned, centered, or fully justified.

Try changing the alignment of some text and resize the editor to see how the text layout changes.

Lists

@@ -13,7 +15,7 @@ p, li { white-space: pre-wrap; }
  • Disc symbols are typically used for top-level list items.
  • Circle symbols can be used to distinguish between items in lower-level lists.
  • Square symbols provide a reasonable alternative to discs and circles.
-

Ordered lists can be created that can be used for tables of contents. Different characters can be used to enumerate items, and we can use both Roman and Arabic numerals in the same list structure:

+

Ordered lists can be used for tables of contents. Different characters can be used to enumerate items, and one can use both Roman and Arabic numerals in the same list structure:

  1. Introduction
  2. Qt Tools
  1. Qt Assistant
  2. @@ -26,9 +28,9 @@ p, li { white-space: pre-wrap; }

    Images

    Inline images are treated like ordinary ranges of characters in the text editor, so they flow with the surrounding text. Images can also be selected in the same way as text, making it easy to cut, copy, and paste them.

    -

    Try to select this image by clicking and dragging over it with the mouse, or use the text cursor to select it by holding down Shift and using the arrow keys. You can then cut or copy it, and paste it into different parts of this document.

    +

    Try to select this image by clicking and dragging over it with the mouse, or use the text cursor to select it by holding down Shift and using the arrow keys. You can then cut or copy it, and paste it into different parts of this document.

    Tables

    -

    QTextEdit can arrange and format tables, supporting features such as row and column spans, text formatting within cells, and size constraints for columns.

    +

    TextArea can arrange and format tables, supporting features such as row and column spans, text formatting within cells, and size constraints for columns.

    @@ -72,8 +74,6 @@ p, li { white-space: pre-wrap; }

    Try adding text to the cells in the table and experiment with the alignment of the paragraphs.

    -

    Hyperlinks

    -

    QTextEdit is designed to support hyperlinks between documents, and this feature is used extensively in Qt Assistant. Hyperlinks are automatically created when an HTML file is imported into an editor. Since the rich text framework supports hyperlinks natively, they can also be created programatically.

    Undo and Redo

    -

    Full support for undo and redo operations is built into QTextEdit and the underlying rich text framework. Operations on a document can be packaged together to make editing a more comfortable experience for the user.

    +

    Full support for undo and redo operations is built into TextArea and the underlying rich text framework. Operations on a document can be packaged together to make editing easier for the user.

    Try making changes to this document and press Ctrl+Z to undo them. You can always recover the original contents of the document.

    diff --git a/examples/quick/controls/text/qml/images/logo32.png b/examples/quick/controls/text/qml/images/logo32.png deleted file mode 100644 index 5f91e987..00000000 Binary files a/examples/quick/controls/text/qml/images/logo32.png and /dev/null differ diff --git a/examples/quick/controls/text/qml/images/qt-logo.png b/examples/quick/controls/text/qml/images/qt-logo.png new file mode 100644 index 00000000..6dedc8bf Binary files /dev/null and b/examples/quick/controls/text/qml/images/qt-logo.png differ diff --git a/examples/quick/controls/text/resources.qrc b/examples/quick/controls/text/resources.qrc index 4d137ff7..27c7b921 100644 --- a/examples/quick/controls/text/resources.qrc +++ b/examples/quick/controls/text/resources.qrc @@ -1,27 +1,27 @@ - - - qml/main.qml - qml/ToolBarSeparator.qml - qml/images/logo32.png - qml/images/editcopy.png - qml/images/editcut.png - qml/images/editpaste.png - qml/images/editredo.png - qml/images/editundo.png - qml/images/exportpdf.png - qml/images/filenew.png - qml/images/fileopen.png - qml/images/fileprint.png - qml/images/filesave.png - qml/images/textbold.png - qml/images/textcenter.png - qml/images/textitalic.png - qml/images/textjustify.png - qml/images/textleft.png - qml/images/textright.png - qml/images/textunder.png - qml/images/zoomin.png - qml/images/zoomout.png - example.html - + + + qml/main.qml + qml/ToolBarSeparator.qml + qml/images/editcopy.png + qml/images/editcut.png + qml/images/editpaste.png + qml/images/editredo.png + qml/images/editundo.png + qml/images/exportpdf.png + qml/images/filenew.png + qml/images/fileopen.png + qml/images/fileprint.png + qml/images/filesave.png + qml/images/textbold.png + qml/images/textcenter.png + qml/images/textitalic.png + qml/images/textjustify.png + qml/images/textleft.png + qml/images/textright.png + qml/images/textunder.png + qml/images/zoomin.png + qml/images/zoomout.png + example.html + qml/images/qt-logo.png + -- cgit v1.2.1 From e22a7ffb4355ae359344efe881e74edeb65a3d08 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 6 Jun 2013 15:20:51 +0200 Subject: Don't let tabs grab focus on press Tab buttons should never take focus when pressed, but only pass on focus to their child items. Tab focus should only get focus when they are tabbed into. Autotest is updated. Change-Id: I0edad4d893be7ed7066d3a3631ca340e9bf8cb53 Reviewed-by: Liang Qi Reviewed-by: Jens Bache-Wiig --- src/private/TabBar.qml | 2 -- tests/auto/controls/data/tst_tabview.qml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/private/TabBar.qml b/src/private/TabBar.qml index 6bcf795c..f51d60b2 100644 --- a/src/private/TabBar.qml +++ b/src/private/TabBar.qml @@ -183,8 +183,6 @@ FocusScope { var next = tabbar.nextItemInFocusChain(true); if (__isAncestorOf(tabView.getTab(currentIndex), next)) next.forceActiveFocus(); - else - tabitem.forceActiveFocus(); } Loader { diff --git a/tests/auto/controls/data/tst_tabview.qml b/tests/auto/controls/data/tst_tabview.qml index 85ad4346..8093ebc3 100644 --- a/tests/auto/controls/data/tst_tabview.qml +++ b/tests/auto/controls/data/tst_tabview.qml @@ -365,7 +365,7 @@ TestCase { waitForRendering(tab3) mouseClick(tab3, tab3.width/2, tab3.height/2) - verify(tab3.activeFocus) + verify(!tab3.activeFocus) verify(!textField.activeFocus) tabView.destroy() -- cgit v1.2.1 From c7df1ebf207f99c7889c8834d16bf62fc99db75e Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Tue, 28 May 2013 07:57:03 +0200 Subject: Add overview documentation for Qt Quick Layouts Change-Id: I79df2abca1de42496f75fc08a779203a406ce155 Reviewed-by: Nico Vertriest Reviewed-by: Jens Bache-Wiig --- src/layouts/doc/images/rowlayout-minimum.png | Bin 0 -> 5481 bytes src/layouts/doc/qtquicklayouts.qdocconf | 2 + src/layouts/doc/src/qtquicklayouts-index.qdoc | 10 ++ src/layouts/doc/src/qtquicklayouts-overview.qdoc | 128 +++++++++++++++++++++ src/layouts/doc/src/snippets/windowconstraints.qml | 89 ++++++++++++++ 5 files changed, 229 insertions(+) create mode 100644 src/layouts/doc/images/rowlayout-minimum.png create mode 100644 src/layouts/doc/src/qtquicklayouts-overview.qdoc create mode 100644 src/layouts/doc/src/snippets/windowconstraints.qml diff --git a/src/layouts/doc/images/rowlayout-minimum.png b/src/layouts/doc/images/rowlayout-minimum.png new file mode 100644 index 00000000..5875325c Binary files /dev/null and b/src/layouts/doc/images/rowlayout-minimum.png differ diff --git a/src/layouts/doc/qtquicklayouts.qdocconf b/src/layouts/doc/qtquicklayouts.qdocconf index ad33416f..a13066b8 100644 --- a/src/layouts/doc/qtquicklayouts.qdocconf +++ b/src/layouts/doc/qtquicklayouts.qdocconf @@ -26,6 +26,8 @@ qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.type = manual depends = qtqml qtquick qtwidgets qtdoc qtquickcontrols +exampledirs += src/snippets + headerdirs += .. sourcedirs += .. diff --git a/src/layouts/doc/src/qtquicklayouts-index.qdoc b/src/layouts/doc/src/qtquicklayouts-index.qdoc index c2280f5d..fb9c3898 100644 --- a/src/layouts/doc/src/qtquicklayouts-index.qdoc +++ b/src/layouts/doc/src/qtquicklayouts-index.qdoc @@ -52,6 +52,16 @@ \section1 Related information + \section2 Guides + \list + \li \l{Qt Quick Layouts Overview} + \endlist + + \section2 Examples + \list + \li \l{Qt Quick Controls - Basic Layouts Example} + \endlist + \section2 Reference \list \li \l{Qt Quick Layouts QML Types}{Qt Quick Layouts QML Types} diff --git a/src/layouts/doc/src/qtquicklayouts-overview.qdoc b/src/layouts/doc/src/qtquicklayouts-overview.qdoc new file mode 100644 index 00000000..b7302dad --- /dev/null +++ b/src/layouts/doc/src/qtquicklayouts-overview.qdoc @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** 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 Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page qtquicklayouts-overview.html + \title Qt Quick Layouts Overview + \brief A set of APIs for arranging QML items in a user interface. + + Qt Quick Layouts are items that are used to arrange items in a user interface. Since Qt Quick + Layouts also resize their items, they are well suited for resizable user interfaces. + + + \section1 Key Features + + + Some of the key features are: + + \list + \li \l{Layout::alignment}{Alignment} of items can be specified with the + \l{Layout::alignment}{Layout.alignment} property + \li \l{Layout::fillWidth}{Resizable items} can be specified with the + \l{Layout::fillWidth}{Layout.fillWidth} and \l{Layout::fillHeight}{Layout.fillHeight} + properties. + \li \l{Size constraints} can be specified with + \l{Layout::minimumWidth}{Layout.minimumWidth}, + \l{Layout::preferredWidth}{Layout.preferredWidth}, and + \l{Layout::maximumWidth}{Layout.maximumWidth} properties ("Width" can be replaced + with "Height" for specifying similar constraints to the height). + \li \l{RowLayout::spacing}{Spacings} can be specified with \l{RowLayout::spacing}{spacing}, + \l{GridLayout::rowSpacing}{rowSpacing} or \l{GridLayout::columnSpacing}{columnSpacing} + \endlist + + In addition to the above features, GridLayout adds these features: + \list + \li \l{Layout::row}{Grid coordinates} can be specified with the \l{Layout::row}{Layout.row} and + \l{Layout::column}{Layout.column}. + \li \l{GridLayout::flow}{Automatic grid coordinates} used together with the + \l{GridLayout::flow}{flow}, \l{GridLayout::rows}{rows}, and + \l{GridLayout::columns}{columns} properties. + \li \l{Layout::columnSpan}{Spans} across rows or columns can be specified with the + \l{Layout::rowSpan}{Layout.rowSpan} and \l{Layout::columnSpan}{Layout.columnSpan} + properties. + \endlist + + + + \section1 Size Constraints + Since an item can be resized by its layout, the layout needs to know the + \l{Layout::minimumWidth}{minimum}, \l{Layout::preferredWidth}{preferred}, + and \l{Layout::maximumWidth}{maximum} sizes of all items where \l{Layout::fillWidth}{Layout.fillWidth} or + \l{Layout::fillHeight}{Layout.fillHeight} is set to \c true. + For instance, the following will produce a layout with two rectangles lying side-by-side that + stretches horizontally. The azure rectangle can be resized from 50x150 to 300x150, and the plum + rectangle can be resized from 100x100 to ∞x100. + + \snippet windowconstraints.qml rowlayout + + \image rowlayout-minimum.png "RowLayout at its minimum" + + Combining each item's constraints will give these implicit constraints to the layout element: + + \table + \header + \li + \li minimum + \li preferred + \li maximum + \row + \li implicit constraints (width) + \li 156 + \li 306 + \li ∞ (\c Number.POSITIVE_INFINITY) + \row + \li implicit constraints (heights) + \li 150 + \li 150 + \li 150 + \endtable + + Thus, the layout cannot be narrower than 156 or be taller or shorter than 150 without breaking + any of the constraints of its child items. + + \section1 Connecting windows and layouts + You can just use normal anchoring concepts to ensure that the layout will follow the window + resizing. + + \snippet windowconstraints.qml anchoring + + The size constraints of layouts can be used to ensure that the window cannot be resized beyond + the layout constraints. You can take the size constraints from the layout and set these + constraints on the minimumWidth, minimumHeight, maximumWidth, and maximumHeight of the Window + element. The following code ensures that the window cannot be resized beyond the constraints of + the layout: + + \snippet windowconstraints.qml bindconstraints + + \note Since layout.Layout.maximumWidth is infinite in this case, we cannot bind that to the + maximumWidth property of Window, since that is an integer number. We therefore set a fixed + maximum width to 1000. + + Finally, you usually want the initial size of the window to be the layout's implicit size: + + \snippet windowconstraints.qml binddefaultsize +*/ diff --git a/src/layouts/doc/src/snippets/windowconstraints.qml b/src/layouts/doc/src/snippets/windowconstraints.qml new file mode 100644 index 00000000..673169a3 --- /dev/null +++ b/src/layouts/doc/src/snippets/windowconstraints.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation 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.0 +import QtQuick.Controls 1.0 +import QtQuick.Layouts 1.0 + +ApplicationWindow { + //! [binddefaultsize] + width: layout.implicitWidth + height: layout.implicitHeight + //! [binddefaultsize] + //! [bindconstraints] + minimumWidth: layout.Layout.minimumWidth + minimumHeight: layout.Layout.minimumHeight + maximumWidth: 1000 + maximumHeight: layout.Layout.maximumHeight + //! [bindconstraints] + + //! [rowlayout] + //! [anchoring] + RowLayout { + id: layout + anchors.fill: parent + //! [anchoring] + spacing: 6 + Rectangle { + color: 'azure' + Layout.fillWidth: true + Layout.minimumWidth: 50 + Layout.preferredWidth: 100 + Layout.maximumWidth: 300 + Layout.minimumHeight: 150 + Text { + anchors.centerIn: parent + text: parent.width + 'x' + parent.height + } + } + Rectangle { + color: 'plum' + Layout.fillWidth: true + Layout.minimumWidth: 100 + Layout.preferredWidth: 200 + Layout.preferredHeight: 100 + Text { + anchors.centerIn: parent + text: parent.width + 'x' + parent.height + } + } + } + //! [rowlayout] +} -- cgit v1.2.1 From 5303f814746606a78198fec5c02746c2f3090460 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 3 Jun 2013 12:47:40 +0200 Subject: Updated activation signals in TableView - Added row property to activated() - Added clicked(row) signal - Added doubleClicked(row) signal - We also fixed the behavior so that we do not emit activated if the user clicks outside of the available rows. - We fixed a problem where key events would not be seen outside of the control Change-Id: I13feba26e900daf85be7be88216f1a0a4a446c57 Reviewed-by: J-P Nurmi --- src/controls/TableView.qml | 76 +++++++++++++++++----- .../controls/data/tableview/table_activated.qml | 17 ++++- tests/auto/controls/data/tst_tableview.qml | 20 +++++- 3 files changed, 91 insertions(+), 22 deletions(-) diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index 17b2b186..44aecfc2 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -239,10 +239,30 @@ ScrollView { /*! \internal */ property alias __currentRowItem: listView.currentItem - /*! \qmlsignal TableView::activated() - Emitted when the user activates an item by single or double-clicking (depending on the platform). + /*! \qmlsignal TableView::activated(int row) + + Emitted when the user activates an item by mouse or keyboard interaction. + Mouse activation is triggered by single- or double-clicking, depending on the platform. + + \a row int provides access to the activated row index. + */ + signal activated(int row) + + /*! \qmlsignal TableView::clicked(int row) + + Emitted when the user clicks a valid row by single clicking + + \a row int provides access to the clicked row index. + */ + signal clicked(int row) + + /*! \qmlsignal TableView::doubleClicked(int row) + + Emitted when the user double clicks a valid row. + + \a row int provides access to the clicked row index. */ - signal activated + signal doubleClicked(int row) /*! \qmlmethod TableView::positionViewAtRow( int row, PositionMode mode ) @@ -447,28 +467,39 @@ ScrollView { autoincrement = false; autodecrement = false; } - var y = Math.min(listView.contentY + listView.height - 5, Math.max(mouseY + listView.contentY, listView.contentY)); - var newIndex = listView.indexAt(0, y); - if (newIndex >= 0) - listView.currentIndex = listView.indexAt(0, y); + + if (pressed) { + var newIndex = listView.indexAt(0, mouseY + listView.contentY) + if (newIndex >= 0) + listView.currentIndex = newIndex; + } } onClicked: { - if (root.__activateItemOnSingleClick) - root.activated() + var clickIndex = listView.indexAt(0, mouseY + listView.contentY) + if (clickIndex > -1) { + if (root.__activateItemOnSingleClick) + root.activated(clickIndex) + root.clicked(clickIndex) + } mouse.accepted = false } onPressed: { + var newIndex = listView.indexAt(0, mouseY + listView.contentY) listView.forceActiveFocus() - var x = Math.min(listView.contentWidth - 5, Math.max(mouseX + listView.contentX, 0)) - var y = Math.min(listView.contentHeight - 5, Math.max(mouseY + listView.contentY, 0)) - listView.currentIndex = listView.indexAt(x, y) + if (newIndex > -1) { + listView.currentIndex = newIndex + } } onDoubleClicked: { - if (!root.__activateItemOnSingleClick) - root.activated() + var clickIndex = listView.indexAt(0, mouseY + listView.contentY) + if (clickIndex > -1) { + if (!root.__activateItemOnSingleClick) + root.activated(clickIndex) + root.doubleClicked(clickIndex) + } } // Note: with boolean preventStealing we are keeping the flickable from @@ -511,8 +542,15 @@ ScrollView { highlightFollowsCurrentItem: true model: root.model - Keys.onUpPressed: root.__decrementCurrentIndex() - Keys.onDownPressed: root.__incrementCurrentIndex() + Keys.onUpPressed: { + event.accepted = false + root.__decrementCurrentIndex() + } + + Keys.onDownPressed: { + event.accepted = false + root.__incrementCurrentIndex() + } Keys.onPressed: { if (event.key === Qt.Key_PageUp) { @@ -521,7 +559,11 @@ ScrollView { verticalScrollBar.value = __verticalScrollBar.value + listView.height } - Keys.onReturnPressed: root.activated(); + Keys.onReturnPressed: { + event.accepted = false + if (currentRow > -1) + root.activated(currentRow); + } delegate: Item { id: rowitem diff --git a/tests/auto/controls/data/tableview/table_activated.qml b/tests/auto/controls/data/tableview/table_activated.qml index 52d420c4..227fbd88 100644 --- a/tests/auto/controls/data/tableview/table_activated.qml +++ b/tests/auto/controls/data/tableview/table_activated.qml @@ -42,11 +42,22 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 TableView { - height: 70 + height: 120 model: 10 - property bool test: false - onActivated: test = true + headerVisible: false + frameVisible: false + rowDelegate: Rectangle { + width: parent.width + height: 20 + } + + property int test: -1 + property int testClick: -1 + property int testDoubleClick: -1 + onActivated: test = row + onClicked: testClick = row + onDoubleClicked: testDoubleClick = row TableViewColumn { width: 100 diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml index 8763900e..6779990c 100644 --- a/tests/auto/controls/data/tst_tableview.qml +++ b/tests/auto/controls/data/tst_tableview.qml @@ -198,12 +198,27 @@ TestCase { var table = component.createObject(container); verify(table !== null, "table created is null") table.forceActiveFocus(); - compare(table.test, false) + compare(table.test, -1) + compare(table.testClick, table.currentRow) + + if (!table.__activateItemOnSingleClick) + mouseDoubleClick(table, 15 , 45, Qt.LeftButton) + else + mouseClick(table, 15, 45, Qt.LeftButton) + + compare(table.testDoubleClick, table.currentRow) + compare(table.test, table.currentRow) + compare(table.testClick, table.currentRow) + if (!table.__activateItemOnSingleClick) mouseDoubleClick(table, 15 , 15, Qt.LeftButton) else mouseClick(table, 15, 15, Qt.LeftButton) - compare(table.test, true) + + compare(table.testDoubleClick, table.currentRow) + compare(table.testClick, table.currentRow) + compare(table.test, table.currentRow) + table.destroy() } @@ -214,6 +229,7 @@ TestCase { verify(table !== null, "table created is null") table.forceActiveFocus(); compare(table.activatedTest, false) + waitForRendering(table) if (!table.__activateItemOnSingleClick) mouseDoubleClick(table, 15 , 50, Qt.LeftButton) else -- cgit v1.2.1 From 68abb104e902454b8daba23b108c1ad89e33d890 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 11 Jun 2013 09:21:05 +0200 Subject: Fix TableView::positionViewAtRow() Task-number: QTBUG-31631 Change-Id: Iaf5bd5c895f0fd94c7ffec19b571786ee9352782 Reviewed-by: Jens Bache-Wiig Reviewed-by: Caroline Chao --- src/controls/TableView.qml | 2 +- tests/auto/controls/data/tst_tableview.qml | 33 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index 44aecfc2..6f05d605 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -294,7 +294,7 @@ ScrollView { */ function positionViewAtRow(row, mode) { - listView.positionViewAtRow(row, mode) + listView.positionViewAtIndex(row, mode) } /*! diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml index 6779990c..a54bbdcb 100644 --- a/tests/auto/controls/data/tst_tableview.qml +++ b/tests/auto/controls/data/tst_tableview.qml @@ -395,6 +395,39 @@ TestCase { tableView.destroy() } + function test_positionViewAtRow() { + var test_instanceStr = + 'import QtQuick 2.1; \ + import QtQuick.Controls 1.0; \ + TableView { \ + TableViewColumn { \ + } \ + model: 1000; \ + headerVisible: false; \ + }' + + var table = Qt.createQmlObject(test_instanceStr, testCase, '') + waitForRendering(table) + + var beginPos = table.mapFromItem(table.viewport, 0, 0) + + table.positionViewAtRow(0, ListView.Beginning) + compare(table.rowAt(beginPos.x, beginPos.y), 0) + + table.positionViewAtRow(100, ListView.Beginning) + compare(table.rowAt(beginPos.x, beginPos.y), 100) + + var endPos = table.mapFromItem(table.viewport, 0, table.viewport.height - 1) + + table.positionViewAtRow(900, ListView.End) + compare(table.rowAt(endPos.x, endPos.y), 900) + + table.positionViewAtRow(999, ListView.End) + compare(table.rowAt(endPos.x, endPos.y), 999) + + table.destroy() + } + // In TableView, drawn text = table.__currentRowItem.children[1].children[1].itemAt(0).children[0].children[0].text function findAChild(item, name) -- cgit v1.2.1 From 3b10c17e34bd6da6278600f57a0ecafe5eb58431 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Mon, 10 Jun 2013 09:38:28 +0200 Subject: Move doc from the index to the overview page Cleanup the links. And doc fix in TableViewStyle.qml Change-Id: Id61fcff49af79f35f68696900142bb200ae18042 Reviewed-by: Jens Bache-Wiig Reviewed-by: Nico Vertriest --- src/controls/doc/src/qtquickcontrols-index.qdoc | 74 ++------------------ src/controls/doc/src/qtquickcontrols-overview.qdoc | 79 +++++++++++++++++++++- src/controls/qquickstack.cpp | 1 - src/layouts/doc/src/qtquicklayouts-index.qdoc | 19 +----- src/layouts/doc/src/qtquicklayouts-overview.qdoc | 7 ++ src/layouts/qquicklinearlayout.cpp | 6 ++ src/styles/Base/TableViewStyle.qml | 2 +- .../doc/src/qtquickcontrolsstyles-index.qdoc | 3 +- 8 files changed, 101 insertions(+), 90 deletions(-) diff --git a/src/controls/doc/src/qtquickcontrols-index.qdoc b/src/controls/doc/src/qtquickcontrols-index.qdoc index 5c22276e..96f2a670 100644 --- a/src/controls/doc/src/qtquickcontrols-index.qdoc +++ b/src/controls/doc/src/qtquickcontrols-index.qdoc @@ -36,56 +36,7 @@ The module is new in Qt 5.1 and requires \l{Qt Quick} 2.1. - \image qtquickcontrols-example-gallery.png - - \section1 Getting Started - - The QML types can be imported into your application using the following import statement in your \c {.qml} file. - - \code - import QtQuick.Controls 1.0 - \endcode - - A basic example of a QML file that makes use of controls is shown here: - - \code - import QtQuick.Controls 1.0 - - ApplicationWindow { - title: "My Application" - - Button { - text: "Push Me" - anchors.centerIn: parent - } - } - \endcode - - \section2 Setting Up Controls from C++ - - While we traditionally have used a QQuickView window to display QML files - in a C++ application, doing this means you can only set window properties from C++. - - With Qt Quick Controls, declare an ApplicationWindow as the root item of your application and launch it by using the - QQmlApplicationEngine instead. This ensures that you can control top level window properties from QML. - - A basic example of a source file that makes use of controls is shown here: - - \code - #include - #include - - int main(int argc, char *argv[]) - { - QApplication app(argc, argv); - QQmlApplicationEngine engine("main.qml"); - return app.exec(); - } - \endcode - - \note We are using QApplication and not QGuiApplication in this example. - Though you can use QGuiApplication instead, doing this will eliminate platform-dependent styling. - This is because it is relying on the widget module to provide the native look and feel. + Visit the \l{Qt Quick Controls Overview} page to get started. \section1 Application Window Components used to describe the basic window properties of an application. @@ -105,29 +56,12 @@ \section1 Related information - \section2 Guides \list + \li \l{Qt Quick} \li \l{Qt Quick Controls Overview} - \endlist - - \section2 Reference - \list \li \l{Qt Quick Controls QML Types}{Qt Quick Controls QML Types} - \endlist - - \section2 Examples - \list \li \l{Qt Quick Controls Examples} + \li \l{Qt Quick Controls Styles} + \li \l{Qt Quick Layouts} \endlist - - \section2 Styles - \list - \li \l {Qt Quick Controls Styles} - \endlist - - \section2 Layouts - \list - \li \l {Qt Quick Layouts} - \endlist - */ diff --git a/src/controls/doc/src/qtquickcontrols-overview.qdoc b/src/controls/doc/src/qtquickcontrols-overview.qdoc index 82da0b22..4eb6892f 100644 --- a/src/controls/doc/src/qtquickcontrols-overview.qdoc +++ b/src/controls/doc/src/qtquickcontrols-overview.qdoc @@ -28,5 +28,82 @@ /*! \page qtquickcontrols-overview.html \title Qt Quick Controls Overview - \brief A set of APIs for working with ... + \brief A set of UI controls to create user interfaces in Qt Quick + + The Qt Quick Controls provide a set of UI controls to create user interfaces + in Qt Quick. + + \section1 Getting Started + + The QML types can be imported into your application using the following import statement in your \c {.qml} file. + + \code + import QtQuick.Controls 1.0 + \endcode + + \section1 Creating a basic example + + A basic example of a QML file that makes use of controls is shown here: + + \code + import QtQuick.Controls 1.0 + + ApplicationWindow { + title: "My Application" + + Button { + text: "Push Me" + anchors.centerIn: parent + } + } + \endcode + + 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 + + \section1 Setting Up Controls from C++ + + Although we have traditionally used a QQuickView window to display QML files + in a C++ application, doing this means you can only set window properties from C++. + + With Qt Quick Controls, declare an ApplicationWindow as the root item of your application and launch it by using the + QQmlApplicationEngine instead. This ensures that you can control top level window properties from QML. + + A basic example of a source file that makes use of controls is shown here: + + \code + #include + #include + + int main(int argc, char *argv[]) + { + QApplication app(argc, argv); + QQmlApplicationEngine engine("main.qml"); + return app.exec(); + } + \endcode + + \note We are using QApplication and not QGuiApplication in this example. + Though you can use QGuiApplication instead, doing this will eliminate platform-dependent styling. + This is because it is relying on the widget module to provide the native look and feel. + + \section2 Using C++ Data From QML + + If you need to register a C++ class to use from QML, you can call, for example, + qmlRegisterType() before declaring your QQmlApplicationEngine. You can find the list + of all registering functions \l{QQmlEngine}{here}. + + If you need to expose data to QML components, you need to set them + to the context of the current QML engine. See QQmlContext for more + information. + + \section1 Related information + + \list + \li \l{Qt Quick} + \li \l{Qt Quick Controls} + \li \l{Qt Quick Controls Examples} + \endlist */ diff --git a/src/controls/qquickstack.cpp b/src/controls/qquickstack.cpp index ecf873d7..c949ffeb 100644 --- a/src/controls/qquickstack.cpp +++ b/src/controls/qquickstack.cpp @@ -47,7 +47,6 @@ QT_BEGIN_NAMESPACE \qmltype Stack \instantiates QQuickStack \inqmlmodule QtQuick.Controls 1.0 - \ingroup views \brief Provides attached properties for items pushed onto a StackView. The Stack type provides attached properties for items pushed onto a \l StackView. diff --git a/src/layouts/doc/src/qtquicklayouts-index.qdoc b/src/layouts/doc/src/qtquicklayouts-index.qdoc index fb9c3898..58d7fb8c 100644 --- a/src/layouts/doc/src/qtquicklayouts-index.qdoc +++ b/src/layouts/doc/src/qtquicklayouts-index.qdoc @@ -38,13 +38,7 @@ The module is new in Qt 5.1 and requires \l{Qt Quick} 2.1. - \section1 Getting started - - The QML types can be imported into your application using the following import statement in your \c {.qml} file. - - \code - import QtQuick.Layouts 1.0 - \endcode + Visit the \l{Qt Quick Layouts Overview} page to get started. \section1 Layouts @@ -52,18 +46,11 @@ \section1 Related information - \section2 Guides \list + \li \l{Qt Quick} + \li \l{Qt Quick Controls} \li \l{Qt Quick Layouts Overview} - \endlist - - \section2 Examples - \list \li \l{Qt Quick Controls - Basic Layouts Example} - \endlist - - \section2 Reference - \list \li \l{Qt Quick Layouts QML Types}{Qt Quick Layouts QML Types} \endlist */ diff --git a/src/layouts/doc/src/qtquicklayouts-overview.qdoc b/src/layouts/doc/src/qtquicklayouts-overview.qdoc index b7302dad..3eeb98d2 100644 --- a/src/layouts/doc/src/qtquicklayouts-overview.qdoc +++ b/src/layouts/doc/src/qtquicklayouts-overview.qdoc @@ -33,6 +33,13 @@ Qt Quick Layouts are items that are used to arrange items in a user interface. Since Qt Quick Layouts also resize their items, they are well suited for resizable user interfaces. + \section1 Getting started + + The QML types can be imported into your application using the following import statement in your \c {.qml} file. + + \code + import QtQuick.Layouts 1.0 + \endcode \section1 Key Features diff --git a/src/layouts/qquicklinearlayout.cpp b/src/layouts/qquicklinearlayout.cpp index 7c48248b..931bfed5 100644 --- a/src/layouts/qquicklinearlayout.cpp +++ b/src/layouts/qquicklinearlayout.cpp @@ -67,6 +67,8 @@ \li \l{Layout::fillHeight}{Layout.fillHeight} \li \l{Layout::alignment}{Layout.alignment} \endlist + + Read more about attached properties \l{QML Object Attributes}{here}. \sa ColumnLayout \sa GridLayout \sa Row @@ -95,6 +97,8 @@ \li \l{Layout::alignment}{Layout.alignment} \endlist + Read more about attached properties \l{QML Object Attributes}{here}. + \sa RowLayout \sa GridLayout \sa Column @@ -160,6 +164,8 @@ \li \l{Layout::alignment}{Layout.alignment} \endlist + Read more about attached properties \l{QML Object Attributes}{here}. + \sa RowLayout \sa ColumnLayout \sa Grid diff --git a/src/styles/Base/TableViewStyle.qml b/src/styles/Base/TableViewStyle.qml index 1a0605dc..ff7237b0 100644 --- a/src/styles/Base/TableViewStyle.qml +++ b/src/styles/Base/TableViewStyle.qml @@ -131,7 +131,7 @@ ScrollViewStyle { } } - /*! \qmlproperty Component TableViewStyle::rowDelegate + /*! \qmlproperty Component TableViewStyle::itemDelegate Delegate for item. This delegate is described in \l {TableView::itemDelegate} */ property Component itemDelegate: Item { diff --git a/src/styles/doc/src/qtquickcontrolsstyles-index.qdoc b/src/styles/doc/src/qtquickcontrolsstyles-index.qdoc index b2205bfc..ed4a0082 100644 --- a/src/styles/doc/src/qtquickcontrolsstyles-index.qdoc +++ b/src/styles/doc/src/qtquickcontrolsstyles-index.qdoc @@ -75,8 +75,9 @@ \section1 Related information - \section2 QML Types \list + \li \l{Qt Quick} + \li \l{Qt Quick Controls} \li \l{Qt Quick Controls Styles QML Types} \endlist -- cgit v1.2.1 From 41e13d3746c8b7b5cd550091c63fd8ab066422cf Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Tue, 11 Jun 2013 09:13:44 +0200 Subject: Add qml/js files in resource files To make deployment of Qt Quick Controls based applications easier. Task-number: QTBUG-31565 Change-Id: I0b8af2864ef0dc9121eed3189ced64712bdb3d20 Reviewed-by: Friedemann Kleint Reviewed-by: Jens Bache-Wiig --- examples/quick/controls/text/qml/main.qml | 1 + src/controls/Button.qml | 1 + src/controls/CheckBox.qml | 1 + src/controls/ComboBox.qml | 1 + src/controls/MenuBar.qml | 1 + src/controls/ProgressBar.qml | 1 + src/controls/RadioButton.qml | 1 + src/controls/Slider.qml | 1 + src/controls/SpinBox.qml | 1 + src/controls/StackView.qml | 2 +- src/controls/StatusBar.qml | 1 + src/controls/TabView.qml | 1 + src/controls/TextField.qml | 2 +- src/controls/ToolBar.qml | 1 + src/controls/ToolButton.qml | 1 + src/controls/controls.pro | 5 +- src/controls/plugin.cpp | 28 ++++++++++ src/controls/qmldir | 26 --------- src/controls/resources.qrc | 30 +++++++++++ src/private/FocusFrame.qml | 1 + src/private/plugin.cpp | 11 ++++ src/private/private.pro | 5 +- src/private/qmldir | 15 ++---- src/private/qquickcontrolsettings.cpp | 24 ++++++--- src/private/qquickcontrolsettings_p.h | 5 +- src/private/resources.qrc | 16 ++++++ src/src.pro | 3 +- src/styles/Base/MenuBarStyle.qml | 2 +- src/styles/Base/MenuStyle.qml | 2 +- src/styles/plugin.cpp | 78 +++++++++++++++++++++++++++ src/styles/private/private.pro | 3 -- src/styles/private/qmldir | 7 --- src/styles/qmldir | 11 +--- src/styles/resources.qrc | 61 +++++++++++++++++++++ src/styles/styles.pro | 18 +++++-- tests/auto/controls/data/tst_groupbox.qml | 2 +- tests/auto/controls/data/tst_styles.qml | 10 ++-- tests/manual/testbench/content/Components.qml | 2 +- 38 files changed, 298 insertions(+), 84 deletions(-) create mode 100644 src/controls/resources.qrc create mode 100644 src/private/resources.qrc create mode 100644 src/styles/plugin.cpp delete mode 100644 src/styles/private/private.pro delete mode 100644 src/styles/private/qmldir create mode 100644 src/styles/resources.qrc diff --git a/examples/quick/controls/text/qml/main.qml b/examples/quick/controls/text/qml/main.qml index d8f175ed..b2b863e2 100644 --- a/examples/quick/controls/text/qml/main.qml +++ b/examples/quick/controls/text/qml/main.qml @@ -319,6 +319,7 @@ ApplicationWindow { anchors.bottom: parent.bottom text: document.text textFormat: Qt.RichText + baseUrl: "qrc:/" Component.onCompleted: forceActiveFocus() } diff --git a/src/controls/Button.qml b/src/controls/Button.qml index 0a3cb131..efafe26b 100644 --- a/src/controls/Button.qml +++ b/src/controls/Button.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype Button diff --git a/src/controls/CheckBox.qml b/src/controls/CheckBox.qml index 48d5e8b2..9d6f5dfe 100644 --- a/src/controls/CheckBox.qml +++ b/src/controls/CheckBox.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype CheckBox diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index 9282c58d..b65e749a 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype ComboBox diff --git a/src/controls/MenuBar.qml b/src/controls/MenuBar.qml index 65af1c12..566c814f 100644 --- a/src/controls/MenuBar.qml +++ b/src/controls/MenuBar.qml @@ -42,6 +42,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype MenuBar diff --git a/src/controls/ProgressBar.qml b/src/controls/ProgressBar.qml index e472e66e..2270ff49 100644 --- a/src/controls/ProgressBar.qml +++ b/src/controls/ProgressBar.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype ProgressBar diff --git a/src/controls/RadioButton.qml b/src/controls/RadioButton.qml index fde08817..305e464c 100644 --- a/src/controls/RadioButton.qml +++ b/src/controls/RadioButton.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype RadioButton diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index 64dcfff1..9fee75e6 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype Slider diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index b1f87cec..06ec64ce 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype SpinBox diff --git a/src/controls/StackView.qml b/src/controls/StackView.qml index 9559ea87..623a1026 100644 --- a/src/controls/StackView.qml +++ b/src/controls/StackView.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Private/StackView.js" as JSArray +import "../private/StackView.js" as JSArray /*! \qmltype StackView diff --git a/src/controls/StatusBar.qml b/src/controls/StatusBar.qml index 85cc6681..62b81807 100644 --- a/src/controls/StatusBar.qml +++ b/src/controls/StatusBar.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype StatusBar diff --git a/src/controls/TabView.qml b/src/controls/TabView.qml index 6319d72c..503a203e 100644 --- a/src/controls/TabView.qml +++ b/src/controls/TabView.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype TabView diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index 32b2d4fb..b7e6996e 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "Styles" +import QtQuick.Controls.Styles 1.0 /*! \qmltype TextField diff --git a/src/controls/ToolBar.qml b/src/controls/ToolBar.qml index b73a6f3e..cadea5c7 100644 --- a/src/controls/ToolBar.qml +++ b/src/controls/ToolBar.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype ToolBar diff --git a/src/controls/ToolButton.qml b/src/controls/ToolButton.qml index 3c1eab1a..3cf32789 100644 --- a/src/controls/ToolButton.qml +++ b/src/controls/ToolButton.qml @@ -41,6 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype ToolButton diff --git a/src/controls/controls.pro b/src/controls/controls.pro index fbda88fc..fad8f2d9 100644 --- a/src/controls/controls.pro +++ b/src/controls/controls.pro @@ -5,7 +5,7 @@ QT += qml quick gui-private core-private QMAKE_DOCS = $$PWD/doc/qtquickcontrols.qdocconf -QML_FILES = \ +OTHER_FILES = \ ApplicationWindow.qml \ Button.qml \ CheckBox.qml \ @@ -37,3 +37,6 @@ include(plugin.pri) CONFIG += no_cxx_module load(qml_plugin) + +RESOURCES += \ + resources.qrc diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp index 1b255302..71cc3196 100644 --- a/src/controls/plugin.cpp +++ b/src/controls/plugin.cpp @@ -98,6 +98,34 @@ void QtQuickControlsPlugin::registerTypes(const char *uri) QLatin1String("Do not create objects of type MenuBase")); qmlRegisterUncreatableType(uri, 1, 0, "Stack", QLatin1String("Do not create objects of type Stack")); + + // Controls in resources file + qmlRegisterType(QUrl("qrc:/controls/ApplicationWindow.qml"), uri, 1, 0, "ApplicationWindow"); + qmlRegisterType(QUrl("qrc:/controls/Button.qml"), uri, 1, 0, "Button"); + qmlRegisterType(QUrl("qrc:/controls/CheckBox.qml"), uri, 1, 0, "CheckBox"); + qmlRegisterType(QUrl("qrc:/controls/ComboBox.qml"), uri, 1, 0, "ComboBox"); + qmlRegisterType(QUrl("qrc:/controls/GroupBox.qml"), uri, 1, 0, "GroupBox"); + qmlRegisterType(QUrl("qrc:/controls/Label.qml"), uri, 1, 0, "Label"); + qmlRegisterType(QUrl("qrc:/controls/Menu.qml"), uri, 1, 0, "Menu"); + qmlRegisterType(QUrl("qrc:/controls/MenuBar.qml"), uri, 1, 0, "MenuBar"); + qmlRegisterType(QUrl("qrc:/controls/ProgressBar.qml"), uri, 1, 0, "ProgressBar"); + qmlRegisterType(QUrl("qrc:/controls/RadioButton.qml"), uri, 1, 0, "RadioButton"); + qmlRegisterType(QUrl("qrc:/controls/ScrollView.qml"), uri, 1, 0, "ScrollView"); + qmlRegisterType(QUrl("qrc:/controls/Slider.qml"), uri, 1, 0, "Slider"); + qmlRegisterType(QUrl("qrc:/controls/SpinBox.qml"), uri, 1, 0, "SpinBox"); + qmlRegisterType(QUrl("qrc:/controls/SplitView.qml"), uri, 1, 0, "SplitView"); + qmlRegisterType(QUrl("qrc:/controls/StackView.qml"), uri, 1, 0, "StackView"); + qmlRegisterType(QUrl("qrc:/controls/StackViewDelegate.qml"), uri, 1, 0, "StackViewDelegate"); + qmlRegisterType(QUrl("qrc:/controls/StackViewTransition.qml"), uri, 1, 0, "StackViewTransition"); + qmlRegisterType(QUrl("qrc:/controls/StatusBar.qml"), uri, 1, 0, "StatusBar"); + qmlRegisterType(QUrl("qrc:/controls/Tab.qml"), uri, 1, 0, "Tab"); + qmlRegisterType(QUrl("qrc:/controls/TableView.qml"), uri, 1, 0, "TableView"); + qmlRegisterType(QUrl("qrc:/controls/TableViewColumn.qml"), uri, 1, 0, "TableViewColumn"); + qmlRegisterType(QUrl("qrc:/controls/TextField.qml"), uri, 1, 0, "TextField"); + qmlRegisterType(QUrl("qrc:/controls/TabView.qml"), uri, 1, 0, "TabView"); + qmlRegisterType(QUrl("qrc:/controls/TextArea.qml"), uri, 1, 0, "TextArea"); + qmlRegisterType(QUrl("qrc:/controls/ToolBar.qml"), uri, 1, 0, "ToolBar"); + qmlRegisterType(QUrl("qrc:/controls/ToolButton.qml"), uri, 1, 0, "ToolButton"); } void QtQuickControlsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) diff --git a/src/controls/qmldir b/src/controls/qmldir index c243360c..41d4d512 100644 --- a/src/controls/qmldir +++ b/src/controls/qmldir @@ -1,28 +1,2 @@ module QtQuick.Controls plugin qtquickcontrolsplugin -ApplicationWindow 1.0 ApplicationWindow.qml -Button 1.0 Button.qml -CheckBox 1.0 CheckBox.qml -ComboBox 1.0 ComboBox.qml -GroupBox 1.0 GroupBox.qml -Label 1.0 Label.qml -MenuBar 1.0 MenuBar.qml -Menu 1.0 Menu.qml -StackView 1.0 StackView.qml -ProgressBar 1.0 ProgressBar.qml -RadioButton 1.0 RadioButton.qml -ScrollView 1.0 ScrollView.qml -Slider 1.0 Slider.qml -SpinBox 1.0 SpinBox.qml -SplitView 1.0 SplitView.qml -StackViewDelegate 1.0 StackViewDelegate.qml -StackViewTransition 1.0 StackViewTransition.qml -StatusBar 1.0 StatusBar.qml -Tab 1.0 Tab.qml -TabView 1.0 TabView.qml -TableView 1.0 TableView.qml -TableViewColumn 1.0 TableViewColumn.qml -TextArea 1.0 TextArea.qml -TextField 1.0 TextField.qml -ToolBar 1.0 ToolBar.qml -ToolButton 1.0 ToolButton.qml diff --git a/src/controls/resources.qrc b/src/controls/resources.qrc new file mode 100644 index 00000000..5cf71c61 --- /dev/null +++ b/src/controls/resources.qrc @@ -0,0 +1,30 @@ + + + ApplicationWindow.qml + Button.qml + CheckBox.qml + ComboBox.qml + GroupBox.qml + Label.qml + Menu.qml + MenuBar.qml + ProgressBar.qml + RadioButton.qml + ScrollView.qml + Slider.qml + SpinBox.qml + SplitView.qml + StackView.qml + StackViewDelegate.qml + StackViewTransition.qml + StatusBar.qml + Tab.qml + TableView.qml + TableViewColumn.qml + TabView.qml + TextArea.qml + TextField.qml + ToolBar.qml + ToolButton.qml + + diff --git a/src/private/FocusFrame.qml b/src/private/FocusFrame.qml index 3a07701c..b734a4ff 100644 --- a/src/private/FocusFrame.qml +++ b/src/private/FocusFrame.qml @@ -40,6 +40,7 @@ import QtQuick 2.1 import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles 1.0 /*! \qmltype FocusFrame diff --git a/src/private/plugin.cpp b/src/private/plugin.cpp index e33c2d37..3ae91d35 100644 --- a/src/private/plugin.cpp +++ b/src/private/plugin.cpp @@ -91,6 +91,17 @@ void QtQuickControlsPrivatePlugin::registerTypes(const char *uri) #ifndef QT_NO_WIDGETS qmlRegisterType(uri, 1, 0, "StyleItem"); #endif + + qmlRegisterType(QUrl("qrc:/private/AbstractCheckable.qml"), uri, 1, 0, "AbstractCheckable"); + qmlRegisterType(QUrl("qrc:/private/BasicButton.qml"), uri, 1, 0, "BasicButton"); + qmlRegisterType(QUrl("qrc:/private/Control.qml"), uri, 1, 0, "Control"); + qmlRegisterType(QUrl("qrc:/private/FocusFrame.qml"), uri, 1, 0, "FocusFrame"); + qmlRegisterType(QUrl("qrc:/private/ModalPopupBehavior.qml"), uri, 1, 0, "ModalPopupBehavior"); + qmlRegisterType(QUrl("qrc:/private/ScrollBar.qml"), uri, 1, 0, "ScrollBar"); + qmlRegisterType(QUrl("qrc:/private/ScrollViewHelper.qml"), uri, 1, 0, "ScrollViewHelper"); + qmlRegisterType(QUrl("qrc:/private/StackViewSlideDelegate.qml"), uri, 1, 0, "StackViewSlideDelegate"); + qmlRegisterType(QUrl("qrc:/private/Style.qml"), uri, 1, 0, "Style"); + qmlRegisterType(QUrl("qrc:/private/TabBar.qml"), uri, 1, 0, "TabBar"); } QT_END_NAMESPACE diff --git a/src/private/private.pro b/src/private/private.pro index 803b703f..8e1767dd 100644 --- a/src/private/private.pro +++ b/src/private/private.pro @@ -23,7 +23,7 @@ SOURCES += \ $$PWD/qquickabstractstyle.cpp # private qml files -QML_FILES += \ +OTHER_FILES += \ AbstractCheckable.qml \ TabBar.qml \ BasicButton.qml \ @@ -50,3 +50,6 @@ mac { CONFIG += no_cxx_module load(qml_plugin) + +RESOURCES += \ + resources.qrc diff --git a/src/private/qmldir b/src/private/qmldir index 7f73028e..63919710 100644 --- a/src/private/qmldir +++ b/src/private/qmldir @@ -1,12 +1,7 @@ module QtQuick.Controls.Private plugin qtquickcontrolsprivateplugin -AbstractCheckable 1.0 AbstractCheckable.qml -Control 1.0 Control.qml -FocusFrame 1.0 FocusFrame.qml -Margins 1.0 Margins.qml -BasicButton 1.0 BasicButton.qml -ScrollBar 1.0 ScrollBar.qml -ScrollViewHelper 1.0 ScrollViewHelper.qml -Style 1.0 Style.qml -TabBar 1.0 TabBar.qml -StackViewSlideDelegate 1.0 StackViewSlideDelegate.qml +GroupBoxStyle 1.0 qrc:/Base/GroupBoxStyle.qml +SpinBoxStyle 1.0 qrc:/Base/SpinBoxStyle.qml +ToolBarStyle 1.0 qrc:/Base/ToolBarStyle.qml +StatusBarStyle 1.0 qrc:/Base/StatusBarStyle.qml +ToolButtonStyle 1.0 qrc:/Base/ToolButtonStyle.qml diff --git a/src/private/qquickcontrolsettings.cpp b/src/private/qquickcontrolsettings.cpp index e2daa17f..d2853982 100644 --- a/src/private/qquickcontrolsettings.cpp +++ b/src/private/qquickcontrolsettings.cpp @@ -63,18 +63,24 @@ static QString styleImportName() return QFileInfo(name).fileName(); } -static QString styleImportPath(QQmlEngine *engine, const QString &styleName) +static QString styleImportPath(QQmlEngine *engine, const QString &styleName, bool &fromResources) { QString path = qgetenv("QT_QUICK_CONTROLS_STYLE"); QFileInfo info(path); if (info.isRelative()) { + bool found = false; foreach (const QString &import, engine->importPathList()) { QDir dir(import + QLatin1String("/QtQuick/Controls/Styles")); if (dir.exists(styleName)) { + found = true; path = dir.absolutePath(); break; } } + if (!found) { + fromResources = true; + path = "qrc:"; + } } else { path = info.absolutePath(); } @@ -83,23 +89,27 @@ static QString styleImportPath(QQmlEngine *engine, const QString &styleName) QQuickControlSettings::QQuickControlSettings(QQmlEngine *engine) { + m_fromResources = false; m_name = styleImportName(); - m_path = styleImportPath(engine, m_name); + m_path = styleImportPath(engine, m_name, m_fromResources); - if (!QFile::exists(styleFilePath())) { + if (!m_fromResources && !QFile::exists(styleFilePath())) { QString unknownStyle = m_name; m_name = defaultStyleName(); - m_path = styleImportPath(engine, m_name); - qWarning() << "WARNING: Cannot find style" << unknownStyle << "- fallback:" << styleFilePath(); + m_path = styleImportPath(engine, m_name, m_fromResources); + qWarning() << "WARNING: Cannot find style" << unknownStyle << " locally - fallback:" << styleFilePath(); } connect(this, SIGNAL(styleNameChanged()), SIGNAL(styleChanged())); connect(this, SIGNAL(stylePathChanged()), SIGNAL(styleChanged())); } -QUrl QQuickControlSettings::style() const +QString QQuickControlSettings::style() const { - return QUrl::fromLocalFile(styleFilePath()); + if (m_fromResources) + return styleFilePath(); + else + return QUrl::fromLocalFile(styleFilePath()).toString(); } QString QQuickControlSettings::styleName() const diff --git a/src/private/qquickcontrolsettings_p.h b/src/private/qquickcontrolsettings_p.h index 8ff0ecbf..e9ba4186 100644 --- a/src/private/qquickcontrolsettings_p.h +++ b/src/private/qquickcontrolsettings_p.h @@ -52,7 +52,7 @@ class QQmlEngine; class QQuickControlSettings : public QObject { Q_OBJECT - Q_PROPERTY(QUrl style READ style NOTIFY styleChanged) + Q_PROPERTY(QString style READ style NOTIFY styleChanged) Q_PROPERTY(QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged) Q_PROPERTY(QString stylePath READ stylePath WRITE setStylePath NOTIFY stylePathChanged) Q_PROPERTY(qreal dpiScaleFactor READ dpiScaleFactor CONSTANT) @@ -60,7 +60,7 @@ class QQuickControlSettings : public QObject public: QQuickControlSettings(QQmlEngine *engine); - QUrl style() const; + QString style() const; QString styleName() const; void setStyleName(const QString &name); @@ -80,6 +80,7 @@ private: QString m_name; QString m_path; + bool m_fromResources; }; QT_END_NAMESPACE diff --git a/src/private/resources.qrc b/src/private/resources.qrc new file mode 100644 index 00000000..27ebfa13 --- /dev/null +++ b/src/private/resources.qrc @@ -0,0 +1,16 @@ + + + AbstractCheckable.qml + BasicButton.qml + Control.qml + FocusFrame.qml + ModalPopupBehavior.qml + ScrollBar.qml + ScrollViewHelper.qml + StackView.js + StackViewSlideDelegate.qml + style.js + Style.qml + TabBar.qml + + diff --git a/src/src.pro b/src/src.pro index 719a3c7b..2b70573c 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,5 +1,4 @@ TEMPLATE = subdirs -SUBDIRS += controls styles private styles/private - +SUBDIRS += controls styles private SUBDIRS += layouts diff --git a/src/styles/Base/MenuBarStyle.qml b/src/styles/Base/MenuBarStyle.qml index 4effd6ee..571ebe12 100644 --- a/src/styles/Base/MenuBarStyle.qml +++ b/src/styles/Base/MenuBarStyle.qml @@ -40,7 +40,7 @@ import QtQuick 2.1 import QtQuick.Controls.Private 1.0 -import "../../Private/style.js" as StyleHelpers +import "../private/style.js" as StyleHelpers /*! \qmltype MenuBarStyle diff --git a/src/styles/Base/MenuStyle.qml b/src/styles/Base/MenuStyle.qml index eab18f7d..e6fc49fb 100644 --- a/src/styles/Base/MenuStyle.qml +++ b/src/styles/Base/MenuStyle.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "../../Private/style.js" as StyleHelpers +import "../private/style.js" as StyleHelpers /*! \qmltype MenuStyle diff --git a/src/styles/plugin.cpp b/src/styles/plugin.cpp new file mode 100644 index 00000000..aedbfa5a --- /dev/null +++ b/src/styles/plugin.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include + +QT_BEGIN_NAMESPACE + +class QtQuickControlsStylesPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") + +public: + void registerTypes(const char *uri); + void initializeEngine(QQmlEngine *engine, const char *uri); +}; + +void QtQuickControlsStylesPlugin::registerTypes(const char *uri) +{ + qmlRegisterType(QUrl("qrc:/Base/ButtonStyle.qml"), uri, 1, 0, "ButtonStyle"); + qmlRegisterType(QUrl("qrc:/Base/CheckBoxStyle.qml"), uri, 1, 0, "CheckBoxStyle"); + qmlRegisterType(QUrl("qrc:/Base/ComboBoxStyle.qml"), uri, 1, 0, "ComboBoxStyle"); + qmlRegisterType(QUrl("qrc:/Base/ProgressBarStyle.qml"), uri, 1, 0, "ProgressBarStyle"); + qmlRegisterType(QUrl("qrc:/Base/RadioButtonStyle.qml"), uri, 1, 0, "RadioButtonStyle"); + qmlRegisterType(QUrl("qrc:/Base/ScrollViewStyle.qml"), uri, 1, 0, "ScrollViewStyle"); + qmlRegisterType(QUrl("qrc:/Base/SliderStyle.qml"), uri, 1, 0, "SliderStyle"); + qmlRegisterType(QUrl("qrc:/Base/TabViewStyle.qml"), uri, 1, 0, "TabViewStyle"); + qmlRegisterType(QUrl("qrc:/Base/TableViewStyle.qml"), uri, 1, 0, "TableViewStyle"); + qmlRegisterType(QUrl("qrc:/Base/TextFieldStyle.qml"), uri, 1, 0, "TextFieldStyle"); +} + +void QtQuickControlsStylesPlugin::initializeEngine(QQmlEngine *engine, const char *uri) +{ + Q_UNUSED(uri) + engine->addPluginPath("qrc:/Base"); +} + +QT_END_NAMESPACE + +#include "plugin.moc" diff --git a/src/styles/private/private.pro b/src/styles/private/private.pro deleted file mode 100644 index 9a5bcd1e..00000000 --- a/src/styles/private/private.pro +++ /dev/null @@ -1,3 +0,0 @@ -TARGETPATH = QtQuick/Controls/Styles/Private - -load(qml_module) diff --git a/src/styles/private/qmldir b/src/styles/private/qmldir deleted file mode 100644 index 4d1885d5..00000000 --- a/src/styles/private/qmldir +++ /dev/null @@ -1,7 +0,0 @@ -module QtQuick.Controls.Styles.Private - -GroupBoxStyle 1.0 ../Base/GroupBoxStyle.qml -SpinBoxStyle 1.0 ../Base/SpinBoxStyle.qml -ToolBarStyle 1.0 ../Base/ToolBarStyle.qml -StatusBarStyle 1.0 ../Base/StatusBarStyle.qml -ToolButtonStyle 1.0 ../Base/ToolButtonStyle.qml diff --git a/src/styles/qmldir b/src/styles/qmldir index 5077542a..43812858 100644 --- a/src/styles/qmldir +++ b/src/styles/qmldir @@ -1,11 +1,2 @@ module QtQuick.Controls.Styles -ButtonStyle 1.0 Base/ButtonStyle.qml -CheckBoxStyle 1.0 Base/CheckBoxStyle.qml -ComboBoxStyle 1.0 Base/ComboBoxStyle.qml -ProgressBarStyle 1.0 Base/ProgressBarStyle.qml -RadioButtonStyle 1.0 Base/RadioButtonStyle.qml -ScrollViewStyle 1.0 Base/ScrollViewStyle.qml -SliderStyle 1.0 Base/SliderStyle.qml -TabViewStyle 1.0 Base/TabViewStyle.qml -TableViewStyle 1.0 Base/TableViewStyle.qml -TextFieldStyle 1.0 Base/TextFieldStyle.qml +plugin qtquickcontrolsstylesplugin diff --git a/src/styles/resources.qrc b/src/styles/resources.qrc new file mode 100644 index 00000000..3eef2631 --- /dev/null +++ b/src/styles/resources.qrc @@ -0,0 +1,61 @@ + + + Base/images/arrow-down.png + Base/images/arrow-down@2x.png + Base/images/arrow-left.png + Base/images/arrow-left@2x.png + Base/images/arrow-right.png + Base/images/arrow-right@2x.png + Base/images/arrow-up.png + Base/images/arrow-up@2x.png + Base/images/button_down.png + Base/images/button.png + Base/images/editbox.png + Base/images/focusframe.png + Base/images/groupbox.png + Base/images/header.png + Base/images/progress-indeterminate.png + Base/images/scrollbar-handle-horizontal.png + Base/images/scrollbar-handle-vertical.png + Base/images/tab_selected.png + Base/images/tab.png + Base/ButtonStyle.qml + Base/CheckBoxStyle.qml + Base/ComboBoxStyle.qml + Base/FocusFrameStyle.qml + Base/GroupBoxStyle.qml + Base/MenuBarStyle.qml + Base/MenuStyle.qml + Base/ProgressBarStyle.qml + Base/RadioButtonStyle.qml + Base/ScrollViewStyle.qml + Base/SliderStyle.qml + Base/SpinBoxStyle.qml + Base/StatusBarStyle.qml + Base/TableViewStyle.qml + Base/TabViewStyle.qml + Base/TextFieldStyle.qml + Base/ToolBarStyle.qml + Base/ToolButtonStyle.qml + + + Desktop/ButtonStyle.qml + Desktop/CheckBoxStyle.qml + Desktop/ComboBoxStyle.qml + Desktop/FocusFrameStyle.qml + Desktop/GroupBoxStyle.qml + Desktop/MenuBarStyle.qml + Desktop/MenuStyle.qml + Desktop/ProgressBarStyle.qml + Desktop/RadioButtonStyle.qml + Desktop/ScrollViewStyle.qml + Desktop/SliderStyle.qml + Desktop/SpinBoxStyle.qml + Desktop/StatusBarStyle.qml + Desktop/TableViewStyle.qml + Desktop/TabViewStyle.qml + Desktop/TextFieldStyle.qml + Desktop/ToolBarStyle.qml + Desktop/ToolButtonStyle.qml + + diff --git a/src/styles/styles.pro b/src/styles/styles.pro index 158c1dd1..0e016ae0 100644 --- a/src/styles/styles.pro +++ b/src/styles/styles.pro @@ -1,9 +1,12 @@ +TARGET = qtquickcontrolsstylesplugin TARGETPATH = QtQuick/Controls/Styles +QT += qml quick gui-private core-private + QMAKE_DOCS = $$PWD/doc/qtquickcontrolsstyles.qdocconf # Base -QML_FILES = \ +OTHER_FILES = \ Base/ButtonStyle.qml \ Base/CheckBoxStyle.qml \ Base/ComboBoxStyle.qml \ @@ -24,7 +27,7 @@ QML_FILES = \ Base/ToolButtonStyle.qml # Desktop -QML_FILES += \ +OTHER_FILES += \ Desktop/ButtonStyle.qml \ Desktop/CheckBoxStyle.qml \ Desktop/ComboBoxStyle.qml \ @@ -45,7 +48,7 @@ QML_FILES += \ Desktop/ToolButtonStyle.qml # Images -QML_FILES += \ +OTHER_FILES += \ Base/images/button.png \ Base/images/button_down.png \ Base/images/tab.png \ @@ -66,4 +69,11 @@ QML_FILES += \ Base/images/arrow-right.png \ Base/images/arrow-right@2x.png -load(qml_module) +SOURCES += \ + $$PWD/plugin.cpp + +RESOURCES += \ + $$PWD/resources.qrc + +CONFIG += no_cxx_module +load(qml_plugin) diff --git a/tests/auto/controls/data/tst_groupbox.qml b/tests/auto/controls/data/tst_groupbox.qml index 6753868c..39f76a1e 100644 --- a/tests/auto/controls/data/tst_groupbox.qml +++ b/tests/auto/controls/data/tst_groupbox.qml @@ -91,7 +91,7 @@ TestCase { function test_dynamicSize() { - var groupbox = Qt.createQmlObject('import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0 ; GroupBox {style:GroupBoxStyle{}}', container, '') + var groupbox = Qt.createQmlObject('import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0 ; GroupBox {style:GroupBoxStyle{}}', container, '') compare(groupbox.width, 16) compare(groupbox.height, 16) diff --git a/tests/auto/controls/data/tst_styles.qml b/tests/auto/controls/data/tst_styles.qml index 233c4a2e..f6b53b72 100644 --- a/tests/auto/controls/data/tst_styles.qml +++ b/tests/auto/controls/data/tst_styles.qml @@ -62,7 +62,7 @@ Item { function test_createToolButtonStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: ToolButtonStyle {}}' , container, '') } @@ -111,21 +111,21 @@ Item { function test_createSpinBoxStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: SpinBoxStyle {}}' , container, '') } function test_createToolBarStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ 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.0; import QtQuick.Controls.Styles.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: StatusBarStyle {}}' , container, '') } @@ -146,7 +146,7 @@ Item { function test_createGroupBoxStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: GroupBoxStyle {}}' , container, '') } diff --git a/tests/manual/testbench/content/Components.qml b/tests/manual/testbench/content/Components.qml index b497230d..23527ccd 100644 --- a/tests/manual/testbench/content/Components.qml +++ b/tests/manual/testbench/content/Components.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.0 -import QtQuick.Controls.Styles.Private 1.0 +import QtQuick.Controls.Private 1.0 Item { property Component button: Button { text: "Push me"} -- cgit v1.2.1 From 45b5cfa643193d24f97122b8803efe11358de4ae Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Fri, 14 Jun 2013 15:39:33 +0200 Subject: Doc: Fixed Qt Quick Layouts listing in qch files. -should be lowercase in selectors variable Change-Id: Iab46d0d339a4a4ffe47fac2f7b9c6d6064e4d2aa Reviewed-by: Sergio Ahumada --- src/layouts/doc/qtquicklayouts.qdocconf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layouts/doc/qtquicklayouts.qdocconf b/src/layouts/doc/qtquicklayouts.qdocconf index a13066b8..8dd359e8 100644 --- a/src/layouts/doc/qtquicklayouts.qdocconf +++ b/src/layouts/doc/qtquicklayouts.qdocconf @@ -20,7 +20,7 @@ qhp.QtQuickLayouts.customFilters.Qt.filterAttributes = qtquicklayouts $QT_VERSIO qhp.QtQuickLayouts.subprojects = qtquicklayoutsqmltypes qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.title = QML Types qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.indexTitle = Qt Quick Layouts -qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.selectors = class fake:qmlClass +qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.selectors = class fake:qmlclass qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.sortPages = true qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.type = manual -- cgit v1.2.1 From 03c7e64ef5f3dfd10d61fd2473fb9f09b124c6e6 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Fri, 14 Jun 2013 15:01:34 +0200 Subject: Revert "Add qml/js files in resource files" We need to investigate more this solution. Deployment issue for Qt Quick Controls will be a known limitation in 5.1.0. This reverts commit 41e13d3746c8b7b5cd550091c63fd8ab066422cf. Change-Id: I501be7494bdbdfbb799d31c612d0c20e7f87ffc7 Reviewed-by: Friedemann Kleint Reviewed-by: Jens Bache-Wiig Reviewed-by: Liang Qi --- examples/quick/controls/text/qml/main.qml | 1 - src/controls/Button.qml | 1 - src/controls/CheckBox.qml | 1 - src/controls/ComboBox.qml | 1 - src/controls/MenuBar.qml | 1 - src/controls/ProgressBar.qml | 1 - src/controls/RadioButton.qml | 1 - src/controls/Slider.qml | 1 - src/controls/SpinBox.qml | 1 - src/controls/StackView.qml | 2 +- src/controls/StatusBar.qml | 1 - src/controls/TabView.qml | 1 - src/controls/TextField.qml | 2 +- src/controls/ToolBar.qml | 1 - src/controls/ToolButton.qml | 1 - src/controls/controls.pro | 5 +- src/controls/plugin.cpp | 28 ---------- src/controls/qmldir | 26 +++++++++ src/controls/resources.qrc | 30 ----------- src/private/FocusFrame.qml | 1 - src/private/plugin.cpp | 11 ---- src/private/private.pro | 5 +- src/private/qmldir | 15 ++++-- src/private/qquickcontrolsettings.cpp | 24 +++------ src/private/qquickcontrolsettings_p.h | 5 +- src/private/resources.qrc | 16 ------ src/src.pro | 3 +- src/styles/Base/MenuBarStyle.qml | 2 +- src/styles/Base/MenuStyle.qml | 2 +- src/styles/plugin.cpp | 78 --------------------------- src/styles/private/private.pro | 3 ++ src/styles/private/qmldir | 7 +++ src/styles/qmldir | 11 +++- src/styles/resources.qrc | 61 --------------------- src/styles/styles.pro | 18 ++----- tests/auto/controls/data/tst_groupbox.qml | 2 +- tests/auto/controls/data/tst_styles.qml | 10 ++-- tests/manual/testbench/content/Components.qml | 2 +- 38 files changed, 84 insertions(+), 298 deletions(-) delete mode 100644 src/controls/resources.qrc delete mode 100644 src/private/resources.qrc delete mode 100644 src/styles/plugin.cpp create mode 100644 src/styles/private/private.pro create mode 100644 src/styles/private/qmldir delete mode 100644 src/styles/resources.qrc diff --git a/examples/quick/controls/text/qml/main.qml b/examples/quick/controls/text/qml/main.qml index b2b863e2..d8f175ed 100644 --- a/examples/quick/controls/text/qml/main.qml +++ b/examples/quick/controls/text/qml/main.qml @@ -319,7 +319,6 @@ ApplicationWindow { anchors.bottom: parent.bottom text: document.text textFormat: Qt.RichText - baseUrl: "qrc:/" Component.onCompleted: forceActiveFocus() } diff --git a/src/controls/Button.qml b/src/controls/Button.qml index efafe26b..0a3cb131 100644 --- a/src/controls/Button.qml +++ b/src/controls/Button.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype Button diff --git a/src/controls/CheckBox.qml b/src/controls/CheckBox.qml index 9d6f5dfe..48d5e8b2 100644 --- a/src/controls/CheckBox.qml +++ b/src/controls/CheckBox.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype CheckBox diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index b65e749a..9282c58d 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype ComboBox diff --git a/src/controls/MenuBar.qml b/src/controls/MenuBar.qml index 566c814f..65af1c12 100644 --- a/src/controls/MenuBar.qml +++ b/src/controls/MenuBar.qml @@ -42,7 +42,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype MenuBar diff --git a/src/controls/ProgressBar.qml b/src/controls/ProgressBar.qml index 2270ff49..e472e66e 100644 --- a/src/controls/ProgressBar.qml +++ b/src/controls/ProgressBar.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype ProgressBar diff --git a/src/controls/RadioButton.qml b/src/controls/RadioButton.qml index 305e464c..fde08817 100644 --- a/src/controls/RadioButton.qml +++ b/src/controls/RadioButton.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype RadioButton diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index 9fee75e6..64dcfff1 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype Slider diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index 06ec64ce..b1f87cec 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype SpinBox diff --git a/src/controls/StackView.qml b/src/controls/StackView.qml index 623a1026..9559ea87 100644 --- a/src/controls/StackView.qml +++ b/src/controls/StackView.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "../private/StackView.js" as JSArray +import "Private/StackView.js" as JSArray /*! \qmltype StackView diff --git a/src/controls/StatusBar.qml b/src/controls/StatusBar.qml index 62b81807..85cc6681 100644 --- a/src/controls/StatusBar.qml +++ b/src/controls/StatusBar.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype StatusBar diff --git a/src/controls/TabView.qml b/src/controls/TabView.qml index 503a203e..6319d72c 100644 --- a/src/controls/TabView.qml +++ b/src/controls/TabView.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype TabView diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index b7e6996e..32b2d4fb 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 +import "Styles" /*! \qmltype TextField diff --git a/src/controls/ToolBar.qml b/src/controls/ToolBar.qml index cadea5c7..b73a6f3e 100644 --- a/src/controls/ToolBar.qml +++ b/src/controls/ToolBar.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype ToolBar diff --git a/src/controls/ToolButton.qml b/src/controls/ToolButton.qml index 3cf32789..3c1eab1a 100644 --- a/src/controls/ToolButton.qml +++ b/src/controls/ToolButton.qml @@ -41,7 +41,6 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype ToolButton diff --git a/src/controls/controls.pro b/src/controls/controls.pro index fad8f2d9..fbda88fc 100644 --- a/src/controls/controls.pro +++ b/src/controls/controls.pro @@ -5,7 +5,7 @@ QT += qml quick gui-private core-private QMAKE_DOCS = $$PWD/doc/qtquickcontrols.qdocconf -OTHER_FILES = \ +QML_FILES = \ ApplicationWindow.qml \ Button.qml \ CheckBox.qml \ @@ -37,6 +37,3 @@ include(plugin.pri) CONFIG += no_cxx_module load(qml_plugin) - -RESOURCES += \ - resources.qrc diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp index 71cc3196..1b255302 100644 --- a/src/controls/plugin.cpp +++ b/src/controls/plugin.cpp @@ -98,34 +98,6 @@ void QtQuickControlsPlugin::registerTypes(const char *uri) QLatin1String("Do not create objects of type MenuBase")); qmlRegisterUncreatableType(uri, 1, 0, "Stack", QLatin1String("Do not create objects of type Stack")); - - // Controls in resources file - qmlRegisterType(QUrl("qrc:/controls/ApplicationWindow.qml"), uri, 1, 0, "ApplicationWindow"); - qmlRegisterType(QUrl("qrc:/controls/Button.qml"), uri, 1, 0, "Button"); - qmlRegisterType(QUrl("qrc:/controls/CheckBox.qml"), uri, 1, 0, "CheckBox"); - qmlRegisterType(QUrl("qrc:/controls/ComboBox.qml"), uri, 1, 0, "ComboBox"); - qmlRegisterType(QUrl("qrc:/controls/GroupBox.qml"), uri, 1, 0, "GroupBox"); - qmlRegisterType(QUrl("qrc:/controls/Label.qml"), uri, 1, 0, "Label"); - qmlRegisterType(QUrl("qrc:/controls/Menu.qml"), uri, 1, 0, "Menu"); - qmlRegisterType(QUrl("qrc:/controls/MenuBar.qml"), uri, 1, 0, "MenuBar"); - qmlRegisterType(QUrl("qrc:/controls/ProgressBar.qml"), uri, 1, 0, "ProgressBar"); - qmlRegisterType(QUrl("qrc:/controls/RadioButton.qml"), uri, 1, 0, "RadioButton"); - qmlRegisterType(QUrl("qrc:/controls/ScrollView.qml"), uri, 1, 0, "ScrollView"); - qmlRegisterType(QUrl("qrc:/controls/Slider.qml"), uri, 1, 0, "Slider"); - qmlRegisterType(QUrl("qrc:/controls/SpinBox.qml"), uri, 1, 0, "SpinBox"); - qmlRegisterType(QUrl("qrc:/controls/SplitView.qml"), uri, 1, 0, "SplitView"); - qmlRegisterType(QUrl("qrc:/controls/StackView.qml"), uri, 1, 0, "StackView"); - qmlRegisterType(QUrl("qrc:/controls/StackViewDelegate.qml"), uri, 1, 0, "StackViewDelegate"); - qmlRegisterType(QUrl("qrc:/controls/StackViewTransition.qml"), uri, 1, 0, "StackViewTransition"); - qmlRegisterType(QUrl("qrc:/controls/StatusBar.qml"), uri, 1, 0, "StatusBar"); - qmlRegisterType(QUrl("qrc:/controls/Tab.qml"), uri, 1, 0, "Tab"); - qmlRegisterType(QUrl("qrc:/controls/TableView.qml"), uri, 1, 0, "TableView"); - qmlRegisterType(QUrl("qrc:/controls/TableViewColumn.qml"), uri, 1, 0, "TableViewColumn"); - qmlRegisterType(QUrl("qrc:/controls/TextField.qml"), uri, 1, 0, "TextField"); - qmlRegisterType(QUrl("qrc:/controls/TabView.qml"), uri, 1, 0, "TabView"); - qmlRegisterType(QUrl("qrc:/controls/TextArea.qml"), uri, 1, 0, "TextArea"); - qmlRegisterType(QUrl("qrc:/controls/ToolBar.qml"), uri, 1, 0, "ToolBar"); - qmlRegisterType(QUrl("qrc:/controls/ToolButton.qml"), uri, 1, 0, "ToolButton"); } void QtQuickControlsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) diff --git a/src/controls/qmldir b/src/controls/qmldir index 41d4d512..c243360c 100644 --- a/src/controls/qmldir +++ b/src/controls/qmldir @@ -1,2 +1,28 @@ module QtQuick.Controls plugin qtquickcontrolsplugin +ApplicationWindow 1.0 ApplicationWindow.qml +Button 1.0 Button.qml +CheckBox 1.0 CheckBox.qml +ComboBox 1.0 ComboBox.qml +GroupBox 1.0 GroupBox.qml +Label 1.0 Label.qml +MenuBar 1.0 MenuBar.qml +Menu 1.0 Menu.qml +StackView 1.0 StackView.qml +ProgressBar 1.0 ProgressBar.qml +RadioButton 1.0 RadioButton.qml +ScrollView 1.0 ScrollView.qml +Slider 1.0 Slider.qml +SpinBox 1.0 SpinBox.qml +SplitView 1.0 SplitView.qml +StackViewDelegate 1.0 StackViewDelegate.qml +StackViewTransition 1.0 StackViewTransition.qml +StatusBar 1.0 StatusBar.qml +Tab 1.0 Tab.qml +TabView 1.0 TabView.qml +TableView 1.0 TableView.qml +TableViewColumn 1.0 TableViewColumn.qml +TextArea 1.0 TextArea.qml +TextField 1.0 TextField.qml +ToolBar 1.0 ToolBar.qml +ToolButton 1.0 ToolButton.qml diff --git a/src/controls/resources.qrc b/src/controls/resources.qrc deleted file mode 100644 index 5cf71c61..00000000 --- a/src/controls/resources.qrc +++ /dev/null @@ -1,30 +0,0 @@ - - - ApplicationWindow.qml - Button.qml - CheckBox.qml - ComboBox.qml - GroupBox.qml - Label.qml - Menu.qml - MenuBar.qml - ProgressBar.qml - RadioButton.qml - ScrollView.qml - Slider.qml - SpinBox.qml - SplitView.qml - StackView.qml - StackViewDelegate.qml - StackViewTransition.qml - StatusBar.qml - Tab.qml - TableView.qml - TableViewColumn.qml - TabView.qml - TextArea.qml - TextField.qml - ToolBar.qml - ToolButton.qml - - diff --git a/src/private/FocusFrame.qml b/src/private/FocusFrame.qml index b734a4ff..3a07701c 100644 --- a/src/private/FocusFrame.qml +++ b/src/private/FocusFrame.qml @@ -40,7 +40,6 @@ import QtQuick 2.1 import QtQuick.Controls.Private 1.0 -import QtQuick.Controls.Styles 1.0 /*! \qmltype FocusFrame diff --git a/src/private/plugin.cpp b/src/private/plugin.cpp index 3ae91d35..e33c2d37 100644 --- a/src/private/plugin.cpp +++ b/src/private/plugin.cpp @@ -91,17 +91,6 @@ void QtQuickControlsPrivatePlugin::registerTypes(const char *uri) #ifndef QT_NO_WIDGETS qmlRegisterType(uri, 1, 0, "StyleItem"); #endif - - qmlRegisterType(QUrl("qrc:/private/AbstractCheckable.qml"), uri, 1, 0, "AbstractCheckable"); - qmlRegisterType(QUrl("qrc:/private/BasicButton.qml"), uri, 1, 0, "BasicButton"); - qmlRegisterType(QUrl("qrc:/private/Control.qml"), uri, 1, 0, "Control"); - qmlRegisterType(QUrl("qrc:/private/FocusFrame.qml"), uri, 1, 0, "FocusFrame"); - qmlRegisterType(QUrl("qrc:/private/ModalPopupBehavior.qml"), uri, 1, 0, "ModalPopupBehavior"); - qmlRegisterType(QUrl("qrc:/private/ScrollBar.qml"), uri, 1, 0, "ScrollBar"); - qmlRegisterType(QUrl("qrc:/private/ScrollViewHelper.qml"), uri, 1, 0, "ScrollViewHelper"); - qmlRegisterType(QUrl("qrc:/private/StackViewSlideDelegate.qml"), uri, 1, 0, "StackViewSlideDelegate"); - qmlRegisterType(QUrl("qrc:/private/Style.qml"), uri, 1, 0, "Style"); - qmlRegisterType(QUrl("qrc:/private/TabBar.qml"), uri, 1, 0, "TabBar"); } QT_END_NAMESPACE diff --git a/src/private/private.pro b/src/private/private.pro index 8e1767dd..803b703f 100644 --- a/src/private/private.pro +++ b/src/private/private.pro @@ -23,7 +23,7 @@ SOURCES += \ $$PWD/qquickabstractstyle.cpp # private qml files -OTHER_FILES += \ +QML_FILES += \ AbstractCheckable.qml \ TabBar.qml \ BasicButton.qml \ @@ -50,6 +50,3 @@ mac { CONFIG += no_cxx_module load(qml_plugin) - -RESOURCES += \ - resources.qrc diff --git a/src/private/qmldir b/src/private/qmldir index 63919710..7f73028e 100644 --- a/src/private/qmldir +++ b/src/private/qmldir @@ -1,7 +1,12 @@ module QtQuick.Controls.Private plugin qtquickcontrolsprivateplugin -GroupBoxStyle 1.0 qrc:/Base/GroupBoxStyle.qml -SpinBoxStyle 1.0 qrc:/Base/SpinBoxStyle.qml -ToolBarStyle 1.0 qrc:/Base/ToolBarStyle.qml -StatusBarStyle 1.0 qrc:/Base/StatusBarStyle.qml -ToolButtonStyle 1.0 qrc:/Base/ToolButtonStyle.qml +AbstractCheckable 1.0 AbstractCheckable.qml +Control 1.0 Control.qml +FocusFrame 1.0 FocusFrame.qml +Margins 1.0 Margins.qml +BasicButton 1.0 BasicButton.qml +ScrollBar 1.0 ScrollBar.qml +ScrollViewHelper 1.0 ScrollViewHelper.qml +Style 1.0 Style.qml +TabBar 1.0 TabBar.qml +StackViewSlideDelegate 1.0 StackViewSlideDelegate.qml diff --git a/src/private/qquickcontrolsettings.cpp b/src/private/qquickcontrolsettings.cpp index d2853982..e2daa17f 100644 --- a/src/private/qquickcontrolsettings.cpp +++ b/src/private/qquickcontrolsettings.cpp @@ -63,24 +63,18 @@ static QString styleImportName() return QFileInfo(name).fileName(); } -static QString styleImportPath(QQmlEngine *engine, const QString &styleName, bool &fromResources) +static QString styleImportPath(QQmlEngine *engine, const QString &styleName) { QString path = qgetenv("QT_QUICK_CONTROLS_STYLE"); QFileInfo info(path); if (info.isRelative()) { - bool found = false; foreach (const QString &import, engine->importPathList()) { QDir dir(import + QLatin1String("/QtQuick/Controls/Styles")); if (dir.exists(styleName)) { - found = true; path = dir.absolutePath(); break; } } - if (!found) { - fromResources = true; - path = "qrc:"; - } } else { path = info.absolutePath(); } @@ -89,27 +83,23 @@ static QString styleImportPath(QQmlEngine *engine, const QString &styleName, boo QQuickControlSettings::QQuickControlSettings(QQmlEngine *engine) { - m_fromResources = false; m_name = styleImportName(); - m_path = styleImportPath(engine, m_name, m_fromResources); + m_path = styleImportPath(engine, m_name); - if (!m_fromResources && !QFile::exists(styleFilePath())) { + if (!QFile::exists(styleFilePath())) { QString unknownStyle = m_name; m_name = defaultStyleName(); - m_path = styleImportPath(engine, m_name, m_fromResources); - qWarning() << "WARNING: Cannot find style" << unknownStyle << " locally - fallback:" << styleFilePath(); + m_path = styleImportPath(engine, m_name); + qWarning() << "WARNING: Cannot find style" << unknownStyle << "- fallback:" << styleFilePath(); } connect(this, SIGNAL(styleNameChanged()), SIGNAL(styleChanged())); connect(this, SIGNAL(stylePathChanged()), SIGNAL(styleChanged())); } -QString QQuickControlSettings::style() const +QUrl QQuickControlSettings::style() const { - if (m_fromResources) - return styleFilePath(); - else - return QUrl::fromLocalFile(styleFilePath()).toString(); + return QUrl::fromLocalFile(styleFilePath()); } QString QQuickControlSettings::styleName() const diff --git a/src/private/qquickcontrolsettings_p.h b/src/private/qquickcontrolsettings_p.h index e9ba4186..8ff0ecbf 100644 --- a/src/private/qquickcontrolsettings_p.h +++ b/src/private/qquickcontrolsettings_p.h @@ -52,7 +52,7 @@ class QQmlEngine; class QQuickControlSettings : public QObject { Q_OBJECT - Q_PROPERTY(QString style READ style NOTIFY styleChanged) + Q_PROPERTY(QUrl style READ style NOTIFY styleChanged) Q_PROPERTY(QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged) Q_PROPERTY(QString stylePath READ stylePath WRITE setStylePath NOTIFY stylePathChanged) Q_PROPERTY(qreal dpiScaleFactor READ dpiScaleFactor CONSTANT) @@ -60,7 +60,7 @@ class QQuickControlSettings : public QObject public: QQuickControlSettings(QQmlEngine *engine); - QString style() const; + QUrl style() const; QString styleName() const; void setStyleName(const QString &name); @@ -80,7 +80,6 @@ private: QString m_name; QString m_path; - bool m_fromResources; }; QT_END_NAMESPACE diff --git a/src/private/resources.qrc b/src/private/resources.qrc deleted file mode 100644 index 27ebfa13..00000000 --- a/src/private/resources.qrc +++ /dev/null @@ -1,16 +0,0 @@ - - - AbstractCheckable.qml - BasicButton.qml - Control.qml - FocusFrame.qml - ModalPopupBehavior.qml - ScrollBar.qml - ScrollViewHelper.qml - StackView.js - StackViewSlideDelegate.qml - style.js - Style.qml - TabBar.qml - - diff --git a/src/src.pro b/src/src.pro index 2b70573c..719a3c7b 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,4 +1,5 @@ TEMPLATE = subdirs -SUBDIRS += controls styles private +SUBDIRS += controls styles private styles/private + SUBDIRS += layouts diff --git a/src/styles/Base/MenuBarStyle.qml b/src/styles/Base/MenuBarStyle.qml index 571ebe12..4effd6ee 100644 --- a/src/styles/Base/MenuBarStyle.qml +++ b/src/styles/Base/MenuBarStyle.qml @@ -40,7 +40,7 @@ import QtQuick 2.1 import QtQuick.Controls.Private 1.0 -import "../private/style.js" as StyleHelpers +import "../../Private/style.js" as StyleHelpers /*! \qmltype MenuBarStyle diff --git a/src/styles/Base/MenuStyle.qml b/src/styles/Base/MenuStyle.qml index e6fc49fb..eab18f7d 100644 --- a/src/styles/Base/MenuStyle.qml +++ b/src/styles/Base/MenuStyle.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 -import "../private/style.js" as StyleHelpers +import "../../Private/style.js" as StyleHelpers /*! \qmltype MenuStyle diff --git a/src/styles/plugin.cpp b/src/styles/plugin.cpp deleted file mode 100644 index aedbfa5a..00000000 --- a/src/styles/plugin.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include - -QT_BEGIN_NAMESPACE - -class QtQuickControlsStylesPlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") - -public: - void registerTypes(const char *uri); - void initializeEngine(QQmlEngine *engine, const char *uri); -}; - -void QtQuickControlsStylesPlugin::registerTypes(const char *uri) -{ - qmlRegisterType(QUrl("qrc:/Base/ButtonStyle.qml"), uri, 1, 0, "ButtonStyle"); - qmlRegisterType(QUrl("qrc:/Base/CheckBoxStyle.qml"), uri, 1, 0, "CheckBoxStyle"); - qmlRegisterType(QUrl("qrc:/Base/ComboBoxStyle.qml"), uri, 1, 0, "ComboBoxStyle"); - qmlRegisterType(QUrl("qrc:/Base/ProgressBarStyle.qml"), uri, 1, 0, "ProgressBarStyle"); - qmlRegisterType(QUrl("qrc:/Base/RadioButtonStyle.qml"), uri, 1, 0, "RadioButtonStyle"); - qmlRegisterType(QUrl("qrc:/Base/ScrollViewStyle.qml"), uri, 1, 0, "ScrollViewStyle"); - qmlRegisterType(QUrl("qrc:/Base/SliderStyle.qml"), uri, 1, 0, "SliderStyle"); - qmlRegisterType(QUrl("qrc:/Base/TabViewStyle.qml"), uri, 1, 0, "TabViewStyle"); - qmlRegisterType(QUrl("qrc:/Base/TableViewStyle.qml"), uri, 1, 0, "TableViewStyle"); - qmlRegisterType(QUrl("qrc:/Base/TextFieldStyle.qml"), uri, 1, 0, "TextFieldStyle"); -} - -void QtQuickControlsStylesPlugin::initializeEngine(QQmlEngine *engine, const char *uri) -{ - Q_UNUSED(uri) - engine->addPluginPath("qrc:/Base"); -} - -QT_END_NAMESPACE - -#include "plugin.moc" diff --git a/src/styles/private/private.pro b/src/styles/private/private.pro new file mode 100644 index 00000000..9a5bcd1e --- /dev/null +++ b/src/styles/private/private.pro @@ -0,0 +1,3 @@ +TARGETPATH = QtQuick/Controls/Styles/Private + +load(qml_module) diff --git a/src/styles/private/qmldir b/src/styles/private/qmldir new file mode 100644 index 00000000..4d1885d5 --- /dev/null +++ b/src/styles/private/qmldir @@ -0,0 +1,7 @@ +module QtQuick.Controls.Styles.Private + +GroupBoxStyle 1.0 ../Base/GroupBoxStyle.qml +SpinBoxStyle 1.0 ../Base/SpinBoxStyle.qml +ToolBarStyle 1.0 ../Base/ToolBarStyle.qml +StatusBarStyle 1.0 ../Base/StatusBarStyle.qml +ToolButtonStyle 1.0 ../Base/ToolButtonStyle.qml diff --git a/src/styles/qmldir b/src/styles/qmldir index 43812858..5077542a 100644 --- a/src/styles/qmldir +++ b/src/styles/qmldir @@ -1,2 +1,11 @@ module QtQuick.Controls.Styles -plugin qtquickcontrolsstylesplugin +ButtonStyle 1.0 Base/ButtonStyle.qml +CheckBoxStyle 1.0 Base/CheckBoxStyle.qml +ComboBoxStyle 1.0 Base/ComboBoxStyle.qml +ProgressBarStyle 1.0 Base/ProgressBarStyle.qml +RadioButtonStyle 1.0 Base/RadioButtonStyle.qml +ScrollViewStyle 1.0 Base/ScrollViewStyle.qml +SliderStyle 1.0 Base/SliderStyle.qml +TabViewStyle 1.0 Base/TabViewStyle.qml +TableViewStyle 1.0 Base/TableViewStyle.qml +TextFieldStyle 1.0 Base/TextFieldStyle.qml diff --git a/src/styles/resources.qrc b/src/styles/resources.qrc deleted file mode 100644 index 3eef2631..00000000 --- a/src/styles/resources.qrc +++ /dev/null @@ -1,61 +0,0 @@ - - - Base/images/arrow-down.png - Base/images/arrow-down@2x.png - Base/images/arrow-left.png - Base/images/arrow-left@2x.png - Base/images/arrow-right.png - Base/images/arrow-right@2x.png - Base/images/arrow-up.png - Base/images/arrow-up@2x.png - Base/images/button_down.png - Base/images/button.png - Base/images/editbox.png - Base/images/focusframe.png - Base/images/groupbox.png - Base/images/header.png - Base/images/progress-indeterminate.png - Base/images/scrollbar-handle-horizontal.png - Base/images/scrollbar-handle-vertical.png - Base/images/tab_selected.png - Base/images/tab.png - Base/ButtonStyle.qml - Base/CheckBoxStyle.qml - Base/ComboBoxStyle.qml - Base/FocusFrameStyle.qml - Base/GroupBoxStyle.qml - Base/MenuBarStyle.qml - Base/MenuStyle.qml - Base/ProgressBarStyle.qml - Base/RadioButtonStyle.qml - Base/ScrollViewStyle.qml - Base/SliderStyle.qml - Base/SpinBoxStyle.qml - Base/StatusBarStyle.qml - Base/TableViewStyle.qml - Base/TabViewStyle.qml - Base/TextFieldStyle.qml - Base/ToolBarStyle.qml - Base/ToolButtonStyle.qml - - - Desktop/ButtonStyle.qml - Desktop/CheckBoxStyle.qml - Desktop/ComboBoxStyle.qml - Desktop/FocusFrameStyle.qml - Desktop/GroupBoxStyle.qml - Desktop/MenuBarStyle.qml - Desktop/MenuStyle.qml - Desktop/ProgressBarStyle.qml - Desktop/RadioButtonStyle.qml - Desktop/ScrollViewStyle.qml - Desktop/SliderStyle.qml - Desktop/SpinBoxStyle.qml - Desktop/StatusBarStyle.qml - Desktop/TableViewStyle.qml - Desktop/TabViewStyle.qml - Desktop/TextFieldStyle.qml - Desktop/ToolBarStyle.qml - Desktop/ToolButtonStyle.qml - - diff --git a/src/styles/styles.pro b/src/styles/styles.pro index 0e016ae0..158c1dd1 100644 --- a/src/styles/styles.pro +++ b/src/styles/styles.pro @@ -1,12 +1,9 @@ -TARGET = qtquickcontrolsstylesplugin TARGETPATH = QtQuick/Controls/Styles -QT += qml quick gui-private core-private - QMAKE_DOCS = $$PWD/doc/qtquickcontrolsstyles.qdocconf # Base -OTHER_FILES = \ +QML_FILES = \ Base/ButtonStyle.qml \ Base/CheckBoxStyle.qml \ Base/ComboBoxStyle.qml \ @@ -27,7 +24,7 @@ OTHER_FILES = \ Base/ToolButtonStyle.qml # Desktop -OTHER_FILES += \ +QML_FILES += \ Desktop/ButtonStyle.qml \ Desktop/CheckBoxStyle.qml \ Desktop/ComboBoxStyle.qml \ @@ -48,7 +45,7 @@ OTHER_FILES += \ Desktop/ToolButtonStyle.qml # Images -OTHER_FILES += \ +QML_FILES += \ Base/images/button.png \ Base/images/button_down.png \ Base/images/tab.png \ @@ -69,11 +66,4 @@ OTHER_FILES += \ Base/images/arrow-right.png \ Base/images/arrow-right@2x.png -SOURCES += \ - $$PWD/plugin.cpp - -RESOURCES += \ - $$PWD/resources.qrc - -CONFIG += no_cxx_module -load(qml_plugin) +load(qml_module) diff --git a/tests/auto/controls/data/tst_groupbox.qml b/tests/auto/controls/data/tst_groupbox.qml index 39f76a1e..6753868c 100644 --- a/tests/auto/controls/data/tst_groupbox.qml +++ b/tests/auto/controls/data/tst_groupbox.qml @@ -91,7 +91,7 @@ TestCase { function test_dynamicSize() { - var groupbox = Qt.createQmlObject('import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0 ; GroupBox {style:GroupBoxStyle{}}', container, '') + var groupbox = Qt.createQmlObject('import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0 ; GroupBox {style:GroupBoxStyle{}}', container, '') compare(groupbox.width, 16) compare(groupbox.height, 16) diff --git a/tests/auto/controls/data/tst_styles.qml b/tests/auto/controls/data/tst_styles.qml index f6b53b72..233c4a2e 100644 --- a/tests/auto/controls/data/tst_styles.qml +++ b/tests/auto/controls/data/tst_styles.qml @@ -62,7 +62,7 @@ Item { function test_createToolButtonStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: ToolButtonStyle {}}' , container, '') } @@ -111,21 +111,21 @@ Item { function test_createSpinBoxStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: SpinBoxStyle {}}' , container, '') } function test_createToolBarStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ 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.0; import QtQuick.Controls.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: StatusBarStyle {}}' , container, '') } @@ -146,7 +146,7 @@ Item { function test_createGroupBoxStyle() { var control = Qt.createQmlObject( - 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Private 1.0; \ + 'import QtQuick 2.1; import QtQuick.Controls 1.0; import QtQuick.Controls.Styles.Private 1.0; \ Rectangle { width: 50; height: 50; property Component style: GroupBoxStyle {}}' , container, '') } diff --git a/tests/manual/testbench/content/Components.qml b/tests/manual/testbench/content/Components.qml index 23527ccd..b497230d 100644 --- a/tests/manual/testbench/content/Components.qml +++ b/tests/manual/testbench/content/Components.qml @@ -41,7 +41,7 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.0 -import QtQuick.Controls.Private 1.0 +import QtQuick.Controls.Styles.Private 1.0 Item { property Component button: Button { text: "Push me"} -- cgit v1.2.1 From 64f464d7641384a98f894430a7e8b71a182aaaf7 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 17 Jun 2013 12:30:33 +0200 Subject: Doc: Fix QCH documentation structure for Qt Quick Layouts Remove 'type = manual' definition from the .qdocconf to prevent links on the module page from being added as subtopics. Also, fix the QML Types topic to point to the correct index page. Task-number: QTBUG-31778 Change-Id: I3df99e0fafff4bf807b952ad4bf976e2a481221d Reviewed-by: Jerome Pasion Reviewed-by: Shawn Rutledge --- src/layouts/doc/qtquicklayouts.qdocconf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/layouts/doc/qtquicklayouts.qdocconf b/src/layouts/doc/qtquicklayouts.qdocconf index 8dd359e8..85cb0a57 100644 --- a/src/layouts/doc/qtquicklayouts.qdocconf +++ b/src/layouts/doc/qtquicklayouts.qdocconf @@ -19,10 +19,9 @@ qhp.QtQuickLayouts.customFilters.Qt.filterAttributes = qtquicklayouts $QT_VERSIO qhp.QtQuickLayouts.subprojects = qtquicklayoutsqmltypes qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.title = QML Types -qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.indexTitle = Qt Quick Layouts +qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.indexTitle = Qt Quick Layouts QML Types qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.selectors = class fake:qmlclass qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.sortPages = true -qhp.QtQuickLayouts.subprojects.qtquicklayoutsqmltypes.type = manual depends = qtqml qtquick qtwidgets qtdoc qtquickcontrols -- cgit v1.2.1 From f5f818e3adfa9d39c4955ffe34443027427a7f74 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 17 Jun 2013 13:08:46 +0200 Subject: Doc: Fix QCH filter attributes for Qt Quick Controls/Styles Fix typos in filter attibutes, preventing filtering from working in Assistant. Task-number: QTBUG-31796 Change-Id: I21c91b43881cd73ae7df4203922085e7c9f93e8f Reviewed-by: Caroline Chao Reviewed-by: Jerome Pasion --- src/controls/doc/qtquickcontrols.qdocconf | 2 +- src/styles/doc/qtquickcontrolsstyles.qdocconf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controls/doc/qtquickcontrols.qdocconf b/src/controls/doc/qtquickcontrols.qdocconf index ab321a74..44fd86ca 100644 --- a/src/controls/doc/qtquickcontrols.qdocconf +++ b/src/controls/doc/qtquickcontrols.qdocconf @@ -14,7 +14,7 @@ qhp.QtQuickControls.indexTitle = Qt Quick Controls qhp.QtQuickControls.indexRoot = #qhp.QtQuickControls.extraFiles = style/qtquickcontrols.css -qhp.QtQuickControls.filterAttributes = qtcontrols $QT_VERSION qtrefdoc +qhp.QtQuickControls.filterAttributes = qtquickcontrols $QT_VERSION qtrefdoc qhp.QtQuickControls.customFilters.Qt.name = QtQuickControls $QT_VERSION qhp.QtQuickControls.customFilters.Qt.filterAttributes = qtquickcontrols $QT_VERSION diff --git a/src/styles/doc/qtquickcontrolsstyles.qdocconf b/src/styles/doc/qtquickcontrolsstyles.qdocconf index e559dcc4..6c1e51b1 100644 --- a/src/styles/doc/qtquickcontrolsstyles.qdocconf +++ b/src/styles/doc/qtquickcontrolsstyles.qdocconf @@ -14,7 +14,7 @@ qhp.QtQuickControlsStyles.indexTitle = Qt Quick Controls Styles qhp.QtQuickControlsStyles.indexRoot = #qhp.QtQuickControlsStyles.extraFiles = style/qtquickcontrolsstyles.css -qhp.QtQuickControlsStyles.filterAttributes = qtcontrolsstyles $QT_VERSION qtrefdoc +qhp.QtQuickControlsStyles.filterAttributes = qtquickcontrolsstyles $QT_VERSION qtrefdoc qhp.QtQuickControlsStyles.customFilters.Qt.name = QtQuickControlsStyles $QT_VERSION qhp.QtQuickControlsStyles.customFilters.Qt.filterAttributes = qtquickcontrolsstyles $QT_VERSION -- cgit v1.2.1 From f90d7eed222d65bd35730c2dd09fc68c3d67eea0 Mon Sep 17 00:00:00 2001 From: Caroline Chao Date: Mon, 24 Jun 2013 09:26:05 +0200 Subject: Doc: Small fix for SplitView SplitView items must set width/height and not Layout.preferredWidth/Layout.preferredHeight. Change-Id: Ice888d51c63cbdaf6e0e235c0c7569c4a8794b7d Reviewed-by: Richard Moe Gustavsen Reviewed-by: Jens Bache-Wiig --- src/controls/SplitView.qml | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml index ff44a03a..8214981a 100644 --- a/src/controls/SplitView.qml +++ b/src/controls/SplitView.qml @@ -76,8 +76,6 @@ import QtQuick.Controls.Private 1.0 as Private \list \li \l{Layout::minimumWidth}{Layout.minimumWidth} \li \l{Layout::minimumHeight}{Layout.minimumHeight} - \li \l{Layout::preferredWidth}{Layout.preferredWidth} - \li \l{Layout::preferredHeight}{Layout.preferredHeight} \li \l{Layout::maximumWidth}{Layout.maximumWidth} \li \l{Layout::maximumHeight}{Layout.maximumHeight} \li \l{Layout::fillWidth}{Layout.fillWidth} (\c true for only one child) -- cgit v1.2.1 From aa4ddfd8443f07badc0899d835027e46c6e0dfd8 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 24 Jun 2013 14:05:56 +0200 Subject: Adapt to Qt.platform.os rename ("mac" -> "osx") Change-Id: I089a01bee10b92f85dcdd338c695a3b796b0ecd1 Reviewed-by: Jens Bache-Wiig Reviewed-by: Jake Petroules --- examples/quick/controls/gallery/content/ModelView.qml | 2 +- examples/quick/controls/gallery/main.qml | 2 +- examples/quick/controls/tableview/main.qml | 2 +- src/controls/TableView.qml | 2 +- tests/auto/controls/data/tst_combobox.qml | 10 +++++----- tests/auto/controls/data/tst_shortcuts.qml | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/quick/controls/gallery/content/ModelView.qml b/examples/quick/controls/gallery/content/ModelView.qml index e6a6040f..483d99ee 100644 --- a/examples/quick/controls/gallery/content/ModelView.qml +++ b/examples/quick/controls/gallery/content/ModelView.qml @@ -51,7 +51,7 @@ Item { width: 600 height: 300 anchors.fill: parent - anchors.margins: Qt.platform.os === "mac" ? 12 : 6 + anchors.margins: Qt.platform.os === "osx" ? 12 : 6 // XmlListModel { // id: flickerModel diff --git a/examples/quick/controls/gallery/main.qml b/examples/quick/controls/gallery/main.qml index 8ea3cf9e..ec00627b 100644 --- a/examples/quick/controls/gallery/main.qml +++ b/examples/quick/controls/gallery/main.qml @@ -228,7 +228,7 @@ ApplicationWindow { enabled: enabledCheck.checked tabPosition: controlPage.item ? controlPage.item.tabPosition : Qt.TopEdge anchors.fill: parent - anchors.margins: Qt.platform.os === "mac" ? 12 : 2 + anchors.margins: Qt.platform.os === "osx" ? 12 : 2 Tab { id: controlPage diff --git a/examples/quick/controls/tableview/main.qml b/examples/quick/controls/tableview/main.qml index 3ecf5ddb..1a9246f8 100644 --- a/examples/quick/controls/tableview/main.qml +++ b/examples/quick/controls/tableview/main.qml @@ -129,7 +129,7 @@ Window { focus:true enabled: enabledCheck.checked - property int margins: Qt.platform.os === "mac" ? 16 : 0 + property int margins: Qt.platform.os === "osx" ? 16 : 0 height: parent.height - 34 anchors.right: parent.right diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index 6f05d605..b02a49c0 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -393,7 +393,7 @@ ScrollView { implicitHeight: 150 frameVisible: true - __scrollBarTopMargin: Qt.platform.os === "mac" ? headerrow.height : 0 + __scrollBarTopMargin: Qt.platform.os === "osx" ? headerrow.height : 0 __viewTopMargin: headerrow.height /*! \internal */ diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index c36218a3..4cb57351 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -217,20 +217,20 @@ TestCase { } function test_activeFocusOnPress(){ - if (Qt.platform.os === "mac") + if (Qt.platform.os === "osx") skip("When the menu pops up on OS X, it does not return and the test fails after time out") var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox { model: 4 }', container, ''); comboBox.activeFocusOnPress = false verify(!comboBox.activeFocus) - if (Qt.platform.os === "mac") // on mac when the menu open, the __popup function does not return + if (Qt.platform.os === "osx") // on mac when the menu open, the __popup function does not return timer.start() else // two mouse clicks to open and close the popup menu mouseClick(comboBox, comboBox.x + 1, comboBox.y + 1) mouseClick(comboBox, comboBox.x + 1, comboBox.y + 1) verify(!comboBox.activeFocus) comboBox.activeFocusOnPress = true - if (Qt.platform.os === "mac") // on mac when the menu open, the __popup function does not return + if (Qt.platform.os === "osx") // on mac when the menu open, the __popup function does not return timer.start() else // two mouse clicks to open and close the popup menu mouseClick(comboBox, comboBox.x + 1, comboBox.y + 1) @@ -240,7 +240,7 @@ TestCase { } function test_spaceKey(){ - if (Qt.platform.os === "mac") + if (Qt.platform.os === "osx") skip("When the menu pops up on OS X, it does not return and the test fails after time out") var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox { model: 4 }', container, ''); @@ -259,7 +259,7 @@ TestCase { } function test_currentIndexInMenu() { - if (Qt.platform.os === "mac") + if (Qt.platform.os === "osx") skip("When the menu pops up on OS X, it does not return and the test fails after time out") var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.0 ; ComboBox { model: 4 }', container, ''); diff --git a/tests/auto/controls/data/tst_shortcuts.qml b/tests/auto/controls/data/tst_shortcuts.qml index c0a668d4..b28d24a9 100644 --- a/tests/auto/controls/data/tst_shortcuts.qml +++ b/tests/auto/controls/data/tst_shortcuts.qml @@ -78,7 +78,7 @@ TestCase { { key: Qt.Key_D, modifier: Qt.AltModifier, expected: "alt d pressed" }, { key: Qt.Key_T, modifier: Qt.NoModifier, expected: "no key press" }, // on mac we don't have mnemonics - { key: Qt.Key_T, modifier: Qt.AltModifier, expected: Qt.platform.os === "mac" ? "no key press" : "alt t pressed" }, + { key: Qt.Key_T, modifier: Qt.AltModifier, expected: Qt.platform.os === "osx" ? "no key press" : "alt t pressed" }, ] } -- cgit v1.2.1