diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-11-18 12:28:07 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-11-18 12:28:07 +0100 |
commit | 4e63aafcb170cfba806696ac92ad1fe82f8859ae (patch) | |
tree | 95957b585fdca1d023807d5bbe8ee2498754e70e | |
parent | 8c2e3601d70b3bc7f004e15797c9fca61332ea5b (diff) | |
parent | 5b38d395a821967b48406faf18f638e252d627fa (diff) | |
download | qtquickcontrols-4e63aafcb170cfba806696ac92ad1fe82f8859ae.tar.gz |
Merge remote-tracking branch 'origin/release' into stable
Change-Id: Ifce0bd8b87bc58a4708b7e682a27aaeaba9fbd53
-rw-r--r-- | examples/quick/controls/gallery/content/AboutDialog.qml | 48 | ||||
-rw-r--r-- | examples/quick/controls/gallery/gallery.pro | 1 | ||||
-rw-r--r-- | examples/quick/controls/gallery/main.qml | 12 | ||||
-rw-r--r-- | examples/quick/controls/gallery/resources.qrc | 1 | ||||
-rw-r--r-- | examples/quick/controls/texteditor/qml/main.qml | 36 | ||||
-rw-r--r-- | src/controls/ApplicationWindow.qml | 3 | ||||
-rw-r--r-- | src/controls/SpinBox.qml | 5 | ||||
-rw-r--r-- | src/controls/plugins.qmltypes | 157 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_spinbox.qml | 70 |
9 files changed, 303 insertions, 30 deletions
diff --git a/examples/quick/controls/gallery/content/AboutDialog.qml b/examples/quick/controls/gallery/content/AboutDialog.qml new file mode 100644 index 00000000..aec7b604 --- /dev/null +++ b/examples/quick/controls/gallery/content/AboutDialog.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** 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.2 +import QtQuick.Dialogs 1.1 + +MessageDialog { + icon: StandardIcon.Information + text: "QtQuick.Controls gallery example" + detailedText: "This example demonstrates most of the available Qt Quick Controls." + title: "About Gallery" +} diff --git a/examples/quick/controls/gallery/gallery.pro b/examples/quick/controls/gallery/gallery.pro index b9a5d0e6..09358658 100644 --- a/examples/quick/controls/gallery/gallery.pro +++ b/examples/quick/controls/gallery/gallery.pro @@ -6,6 +6,7 @@ include(src/src.pri) OTHER_FILES += \ main.qml \ + content/AboutDialog.qml \ content/ChildWindow.qml \ content/Controls.qml \ content/ImageViewer.qml \ diff --git a/examples/quick/controls/gallery/main.qml b/examples/quick/controls/gallery/main.qml index cd8240f7..43b6776e 100644 --- a/examples/quick/controls/gallery/main.qml +++ b/examples/quick/controls/gallery/main.qml @@ -70,6 +70,8 @@ ApplicationWindow { onAccepted: imageViewer.open(fileUrl) } + AboutDialog { id: aboutDialog } + Action { id: openAction text: "&Open" @@ -106,6 +108,12 @@ ApplicationWindow { onTriggered: activeFocusItem.paste() } + Action { + id: aboutAction + text: "About" + onTriggered: aboutDialog.open() + } + ExclusiveGroup { id: textFormatGroup @@ -210,6 +218,10 @@ ApplicationWindow { visible: false } } + Menu { + title: "&Help" + MenuItem { action: aboutAction } + } } diff --git a/examples/quick/controls/gallery/resources.qrc b/examples/quick/controls/gallery/resources.qrc index 6f487274..ca9c6521 100644 --- a/examples/quick/controls/gallery/resources.qrc +++ b/examples/quick/controls/gallery/resources.qrc @@ -1,6 +1,7 @@ <RCC> <qresource prefix="/"> <file>main.qml</file> + <file>content/AboutDialog.qml</file> <file>content/ChildWindow.qml</file> <file>content/Controls.qml</file> <file>content/ImageViewer.qml</file> diff --git a/examples/quick/controls/texteditor/qml/main.qml b/examples/quick/controls/texteditor/qml/main.qml index 14bfa623..50cbed56 100644 --- a/examples/quick/controls/texteditor/qml/main.qml +++ b/examples/quick/controls/texteditor/qml/main.qml @@ -38,10 +38,10 @@ ** ****************************************************************************/ -import QtQuick 2.1 +import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.0 -import QtQuick.Dialogs 1.0 +import QtQuick.Dialogs 1.1 import QtQuick.Window 2.1 import org.qtproject.example 1.0 @@ -53,35 +53,11 @@ ApplicationWindow { title: document.documentTitle + " - Text Editor Example" - ApplicationWindow { + MessageDialog { 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 - } + text: "This is a basic text editor \nwritten with Qt Quick Controls" + icon: StandardIcon.Information } Action { @@ -231,7 +207,7 @@ ApplicationWindow { } Menu { title: "&Help" - MenuItem { text: "About..." ; onTriggered: aboutBox.show() } + MenuItem { text: "About..." ; onTriggered: aboutBox.open() } } } diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index 564e8d2a..3d3f8840 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -119,10 +119,13 @@ Window { onStatusBarChanged: { if (statusBar) { statusBar.parent = statusBarArea } } + onVisibleChanged: { if (visible && menuBar) { menuBar.__parentWindow = root } } + /*! \internal */ default property alias data: contentArea.data color: syspal.window + flags: Qt.Window | Qt.WindowFullscreenButtonHint SystemPalette {id: syspal} diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index 0cc2f5a7..bba4eae1 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -271,6 +271,7 @@ Control { MouseArea { id: mouseUp + objectName: "mouseUp" hoverEnabled: true property var upRect: __panel ? __panel.upRect : null @@ -285,6 +286,7 @@ Control { height: upRect ? upRect.height : 0 onClicked: __increment() + onPressed: if (activeFocusOnPress) input.forceActiveFocus() property bool autoincrement: false; onReleased: autoincrement = false @@ -296,9 +298,12 @@ Control { MouseArea { id: mouseDown + objectName: "mouseDown" hoverEnabled: true onClicked: __decrement() + onPressed: if (activeFocusOnPress) input.forceActiveFocus() + property var downRect: __panel ? __panel.downRect : null anchors.left: parent.left diff --git a/src/controls/plugins.qmltypes b/src/controls/plugins.qmltypes index e82b58a5..eadb72ef 100644 --- a/src/controls/plugins.qmltypes +++ b/src/controls/plugins.qmltypes @@ -948,7 +948,164 @@ Module { Property { name: "__style"; type: "QObject"; isReadonly: true; isPointer: true } } Component { + name: "QQuickText" + defaultProperty: "data" prototype: "QQuickImplicitSizeItem" + exports: ["QtQuick/Text 2.0"] + exportMetaObjectRevisions: [0] + Enum { + name: "HAlignment" + values: { + "AlignLeft": 1, + "AlignRight": 2, + "AlignHCenter": 4, + "AlignJustify": 8 + } + } + Enum { + name: "VAlignment" + values: { + "AlignTop": 32, + "AlignBottom": 64, + "AlignVCenter": 128 + } + } + Enum { + name: "TextStyle" + values: { + "Normal": 0, + "Outline": 1, + "Raised": 2, + "Sunken": 3 + } + } + Enum { + name: "TextFormat" + values: { + "PlainText": 0, + "RichText": 1, + "AutoText": 2, + "StyledText": 4 + } + } + Enum { + name: "TextElideMode" + values: { + "ElideLeft": 0, + "ElideRight": 1, + "ElideMiddle": 2, + "ElideNone": 3 + } + } + Enum { + name: "WrapMode" + values: { + "NoWrap": 0, + "WordWrap": 1, + "WrapAnywhere": 3, + "WrapAtWordBoundaryOrAnywhere": 4, + "Wrap": 4 + } + } + Enum { + name: "RenderType" + values: { + "QtRendering": 0, + "NativeRendering": 1 + } + } + Enum { + name: "LineHeightMode" + values: { + "ProportionalHeight": 0, + "FixedHeight": 1 + } + } + Enum { + name: "FontSizeMode" + values: { + "FixedSize": 0, + "HorizontalFit": 1, + "VerticalFit": 2, + "Fit": 3 + } + } + Property { name: "text"; type: "string" } + Property { name: "font"; type: "QFont" } + Property { name: "color"; type: "QColor" } + Property { name: "linkColor"; type: "QColor" } + Property { name: "style"; type: "TextStyle" } + Property { name: "styleColor"; type: "QColor" } + Property { name: "horizontalAlignment"; type: "HAlignment" } + Property { name: "effectiveHorizontalAlignment"; type: "HAlignment"; isReadonly: true } + Property { name: "verticalAlignment"; type: "VAlignment" } + Property { name: "wrapMode"; type: "WrapMode" } + Property { name: "lineCount"; type: "int"; isReadonly: true } + Property { name: "truncated"; type: "bool"; isReadonly: true } + Property { name: "maximumLineCount"; type: "int" } + Property { name: "textFormat"; type: "TextFormat" } + Property { name: "elide"; type: "TextElideMode" } + Property { name: "contentWidth"; type: "double"; isReadonly: true } + Property { name: "contentHeight"; type: "double"; isReadonly: true } + Property { name: "paintedWidth"; type: "double"; isReadonly: true } + Property { name: "paintedHeight"; type: "double"; isReadonly: true } + Property { name: "lineHeight"; type: "double" } + Property { name: "lineHeightMode"; type: "LineHeightMode" } + Property { name: "baseUrl"; type: "QUrl" } + Property { name: "minimumPixelSize"; type: "int" } + Property { name: "minimumPointSize"; type: "int" } + Property { name: "fontSizeMode"; type: "FontSizeMode" } + Property { name: "renderType"; type: "RenderType" } + Signal { + name: "textChanged" + Parameter { name: "text"; type: "string" } + } + Signal { + name: "linkActivated" + Parameter { name: "link"; type: "string" } + } + Signal { + name: "fontChanged" + Parameter { name: "font"; type: "QFont" } + } + Signal { + name: "styleChanged" + Parameter { name: "style"; type: "TextStyle" } + } + Signal { + name: "horizontalAlignmentChanged" + Parameter { name: "alignment"; type: "HAlignment" } + } + Signal { + name: "verticalAlignmentChanged" + Parameter { name: "alignment"; type: "VAlignment" } + } + Signal { + name: "textFormatChanged" + Parameter { name: "textFormat"; type: "TextFormat" } + } + Signal { + name: "elideModeChanged" + Parameter { name: "mode"; type: "TextElideMode" } + } + Signal { name: "contentSizeChanged" } + Signal { + name: "lineHeightChanged" + Parameter { name: "lineHeight"; type: "double" } + } + Signal { + name: "lineHeightModeChanged" + Parameter { name: "mode"; type: "LineHeightMode" } + } + Signal { + name: "lineLaidOut" + Parameter { name: "line"; type: "QQuickTextLine"; isPointer: true } + } + Method { name: "doLayout" } + } + + Component { + prototype: "QQuickText" name: "QtQuick.Controls/Label" exports: ["QtQuick.Controls/Label 1.0"] exportMetaObjectRevisions: [0] diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index 67dd3dba..9a68907c 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -343,6 +343,76 @@ Item { spinbox2.destroy() } + function test_get_active_focus_when_up_or_down_was_pressed(){ + var test_control = 'import QtQuick 2.1; \ + import QtQuick.Controls 1.1; \ + Column { \ + property alias spinbox: _spinbox; \ + property alias textfield: _textfield; \ + SpinBox { \ + id: _spinbox; \ + } \ + TextField { \ + id: _textfield; \ + text: "textfile"; \ + } \ + } ' + + var control = Qt.createQmlObject(test_control, container, '') + verify(control !== null) + + var spinbox = control.spinbox + var textfield = control.textfield + verify(spinbox !== null) + verify(textfield !== null) + + waitForRendering(control) + + var up = getMouseArea(spinbox, "mouseUp") + verify(up !== null) + var down = getMouseArea(spinbox, "mouseDown") + verify(down !== null) + + textfield.forceActiveFocus() + verify(!spinbox.activeFocus) + verify(textfield.activeFocus) + + mouseClick(up, up.width/2, up.height/2) + verify(spinbox.activeFocus) + verify(!textfield.activeFocus) + + textfield.forceActiveFocus() + verify(!spinbox.activeFocus) + verify(textfield.activeFocus) + + mouseClick(down, down.width/2, down.height/2) + verify(spinbox.activeFocus) + verify(!textfield.activeFocus) + + textfield.forceActiveFocus() + verify(!spinbox.activeFocus) + verify(textfield.activeFocus) + spinbox.activeFocusOnPress = false + + mouseClick(up, up.width/2, up.height/2) + verify(!spinbox.activeFocus) + verify(textfield.activeFocus) + + mouseClick(down, down.width/2, down.height/2) + verify(!spinbox.activeFocus) + verify(textfield.activeFocus) + + control.destroy() + } + + function getMouseArea(control, name) { + for (var i = 0; i < control.children.length; i++) { + if (control.children[i].objectName === name) + return control.children[i] + } + return null + } + function test_activeFocusOnPress(){ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.1; SpinBox {x: 20; y: 20; width: 100; height: 50}', container, '') spinbox.activeFocusOnPress = false |