diff options
| author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-01-16 13:47:50 +0100 |
|---|---|---|
| committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-01-16 13:48:15 +0100 |
| commit | 7497dc48e674ee155aeebf0986be5a929ce15877 (patch) | |
| tree | 87f575b7ce612b7130b91fd4c9b4e3dc437ff612 | |
| parent | 46d983e08cdece92a62833dc74f37e2f11a66324 (diff) | |
| parent | 5abfd7c00bc7ebfec2f059adc9bc22eb989ae10d (diff) | |
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
.qmake.conf
tests/auto/controls/data/tst_stackview.qml
Change-Id: I54b55d51452e812315f97bcdfd1a8e361a427f56
179 files changed, 2848 insertions, 1256 deletions
diff --git a/.gitignore b/.gitignore index 1c265ad31..7c2ec2739 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ /examples/quick/controls/basiclayouts/basiclayouts /examples/quick/controls/calendar/calendar /examples/quick/controls/gallery/gallery -/examples/quick/controls/splitview/splitview /examples/quick/controls/styles/styles /examples/quick/controls/tableview/tableview /examples/quick/controls/touch/touch @@ -111,7 +110,8 @@ qtc-debugging-helper # linux shared libraries *.so* -# windows shared libraries +# windows binaries +*.exe *.dll # osx shared libraries diff --git a/dist/changes-5.4.0 b/dist/changes-5.4.0 new file mode 100644 index 000000000..abbd52818 --- /dev/null +++ b/dist/changes-5.4.0 @@ -0,0 +1,191 @@ +Qt 5.4 introduces many new features and improvements as well as bugfixes +over the 5.3.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + + http://qt-project.org/doc/qt-5.4 + +The Qt version 5.4 series is binary compatible with the 5.3.x series. +Applications compiled for 5.3 will continue to run with 5.4. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + http://bugreports.qt-project.org/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* General * +**************************************************************************** + + - Introduced a native Android style + - Added text selection handles to all editable controls on Android and iOS + - Added translation support to dialogs + - Made all controls and dialogs use native text rendering on mobile + platforms + +**************************************************************************** +* Examples * +**************************************************************************** + + - Revised the Qt Quick Controls Gallery and Table View examples to be more + mobile friendly + - Removed the Split View example - a similar snippet is available in the + detailed description section of SplitView documentation + - Made the Styles tab of the former Gallery example a standalone example + +**************************************************************************** +* Controls * +**************************************************************************** + + - ApplicationWindow: + * Introduced ApplicationWindowStyle for styling the window background + + - Button: + * Added support for mnemonics + + - Calendar: + * Added navigationBarVisible property + * Added pressAndHold(date) signal + + - CheckBox: + * Added support for mnemonics + + - ComboBox: + * Added inputMethodComposing property + + - Menu: + * Fixed key navigation on Windows + + - RadioButton: + * Added support for mnemonics + + - ScrollView: + * Added horizontalScrollBarPolicy and verticalScrollBarPolicy properties + + - Slider: + * [QTBUG-39099] Fixed the step size used on increase/decrease key press + * Made the hovered property follow the hovered state of the handle + instead of the whole groove + + - SpinBox: + * Added inputMethodComposing property + + - SplitView: + * [QTBUG-35281] Added addItem() method + + - StackView: + * Changed the linear slide with a smooth animation + + - Switch: + * Added pressed property + * Added clicked() signal + + - TableView: + * Added pressAndHold(int row) signal + * Fixed support for Keys-attached property + * [QTBUG-41444] Fixed leaking of key events + * Made focused and selected rows to be raised above other rows + + - TabView: + * [QTBUG-38425] Added contentItem property + + - TextArea: + * [QTBUG-38324] Added contentWidth and contentHeight properties + * Added cursorRectangle property + * Added inputMethodComposing property + * Made selection persistent + + - TextField: + * Added cursorRectangle property + * Added selectByMouse property + * Added inputMethodComposing property + * [QTBUG-38282] Added support for sticky VKB with Qt.ImhMultiLine + + - ToolButton: + * Added support for mnemonics + +**************************************************************************** +* Dialogs * +**************************************************************************** + + - Fixed deployment dependencies + - [QTBUG-41844] Fixed centering of dialogs over parent windows + - [QTBUG-41734] Fixed several sizing problems + - [QTBUG-38578] Fixed dynamically created dialogs + + - I18n: + * Added translation support + + - ColorDialog: + * Fixed rendering on non-windowing platforms + + - FileDialog: + * Fixed array key navigation to always navigate the file list + * Replaced icons with scalable ones from an icon font + * [QTBUG-39231] Added sideBarVisible property and button + * [QTBUG-39435] Fixed Save As and directory-choosing scenarios + + - FontDialog: + * [QTBUG-39365] Added support for key navigation + + - Dialog: + * Focus is given to the contentItem automatically + +**************************************************************************** +* Layouts * +**************************************************************************** + + - Increased the default spacing on mobile platforms + - [QTBUG-39045] Fixed a crash when removing children from hidden layouts + +**************************************************************************** +* Styles * +**************************************************************************** + + - Introduced ApplicationWindowStyle + + - ComboBoxStyle: + * Added font property + * Added textColor, selectionColor and selectedTextColor properties + + - MenuBarStyle: + * Added font property + + - MenuStyle: + * Added font property + * Added styleData.pressed context property + + - SpinBoxStyle: + * Added font property + + - TableViewStyle: + * Added styleData.pressed context property for itemDelegate & rowDelegate + * Added styleData.hasActiveFocus context property for itemDelegate + + - TabViewStyle: + * Added styleData.pressed context property for tab + + - ToolBarStyle: + * Added menuButton property + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + +Android +------- + - Introduced a native Android style + - [QTBUG-38934] Added text selection handles to all editable controls + +iOS +--- + - [QTBUG-38934] Added text selection handles to all editable controls + - Made ComboBox open a native selection menu + - Added edit menu (cut, copy, paste) support to all editable controls + - Added text cursor and scroll bar styling + +Windows +------- + - Fixed Menu key navigation diff --git a/examples/quick/controls/controls.pro b/examples/quick/controls/controls.pro index 134a25e35..f6696bc53 100644 --- a/examples/quick/controls/controls.pro +++ b/examples/quick/controls/controls.pro @@ -2,7 +2,6 @@ TEMPLATE = subdirs SUBDIRS += \ gallery \ - splitview \ tableview \ touch \ basiclayouts \ diff --git a/examples/quick/controls/gallery/gallery.pro b/examples/quick/controls/gallery/gallery.pro index 992dd8911..f13f42135 100644 --- a/examples/quick/controls/gallery/gallery.pro +++ b/examples/quick/controls/gallery/gallery.pro @@ -1,17 +1,20 @@ -QT += qml quick +TEMPLATE = app TARGET = gallery -!no_desktop: QT += widgets -include(src/src.pri) -include(../shared/shared.pri) +SOURCES += \ + main.cpp + +RESOURCES += \ + gallery.qrc OTHER_FILES += \ main.qml \ - content/AboutDialog.qml \ - content/Controls.qml \ - content/ImageViewer.qml \ - content/ModelView.qml \ - content/Styles.qml + qml/ButtonPage.qml \ + qml/InputPage.qml \ + qml/ProgressPage.qml \ + qml/UI.js \ + qml/+android/UI.js \ + qml/+ios/UI.js \ + qml/+osx/UI.js -RESOURCES += \ - resources.qrc +include(../shared/shared.pri) diff --git a/examples/quick/controls/gallery/gallery.qmlproject b/examples/quick/controls/gallery/gallery.qmlproject deleted file mode 100644 index e5a8bf02c..000000000 --- a/examples/quick/controls/gallery/gallery.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/quick/controls/gallery/gallery.qrc b/examples/quick/controls/gallery/gallery.qrc new file mode 100644 index 000000000..873c8b5ca --- /dev/null +++ b/examples/quick/controls/gallery/gallery.qrc @@ -0,0 +1,12 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>qml/ButtonPage.qml</file> + <file>qml/InputPage.qml</file> + <file>qml/ProgressPage.qml</file> + <file>qml/UI.js</file> + <file>qml/+android/UI.js</file> + <file>qml/+ios/UI.js</file> + <file>qml/+osx/UI.js</file> + </qresource> +</RCC> diff --git a/examples/quick/controls/gallery/src/main.cpp b/examples/quick/controls/gallery/main.cpp index 8971aa153..c456e1cb6 100644 --- a/examples/quick/controls/gallery/src/main.cpp +++ b/examples/quick/controls/gallery/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -41,7 +41,6 @@ #include "qtquickcontrolsapplication.h" #include <QtQml/QQmlApplicationEngine> #include <QtGui/QSurfaceFormat> -#include <QtQuick/QQuickWindow> int main(int argc, char *argv[]) { diff --git a/examples/quick/controls/gallery/main.qml b/examples/quick/controls/gallery/main.qml index 4d013c8b8..2de810d8d 100644 --- a/examples/quick/controls/gallery/main.qml +++ b/examples/quick/controls/gallery/main.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -39,37 +39,22 @@ ****************************************************************************/ import QtQuick 2.2 +import QtQuick.Layouts 1.1 +import QtQuick.Dialogs 1.1 import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.0 -import QtQuick.Dialogs 1.0 -import "content" +import "qml/UI.js" as UI +import "qml" ApplicationWindow { visible: true title: "Qt Quick Controls Gallery" - width: 640 - height: 420 - minimumHeight: 400 - minimumWidth: 600 - - ImageViewer { id: imageViewer } - - FileDialog { - id: fileDialog - nameFilters: [ "Image files (*.png *.jpg)" ] - onAccepted: imageViewer.open(fileUrl) - } - - AboutDialog { id: aboutDialog } - - Action { - id: openAction - text: "&Open" - shortcut: StandardKey.Open - iconSource: "images/document-open.png" - onTriggered: fileDialog.open() - tooltip: "Open an image" + MessageDialog { + id: aboutDialog + icon: StandardIcon.Information + title: "About" + text: "Qt Quick Controls Gallery" + informativeText: "This example demonstrates most of the available Qt Quick Controls." } Action { @@ -100,20 +85,15 @@ ApplicationWindow { } toolBar: ToolBar { - id: toolbar RowLayout { - id: toolbarLayout - spacing: 0 anchors.fill: parent - ToolButton { action: openAction } - ToolButton { - Accessible.name: "Save as" - iconSource: "images/document-save-as.png" - tooltip: "(Pretend to) Save as..." + anchors.margins: spacing + Label { + text: UI.label } Item { Layout.fillWidth: true } CheckBox { - id: enabledCheck + id: enabler text: "Enabled" checked: true } @@ -123,7 +103,6 @@ ApplicationWindow { menuBar: MenuBar { Menu { title: "&File" - MenuItem { action: openAction } MenuItem { text: "E&xit" shortcut: StandardKey.Quit @@ -132,6 +111,7 @@ ApplicationWindow { } Menu { title: "&Edit" + visible: tabView.currentIndex == 2 MenuItem { action: cutAction } MenuItem { action: copyAction } MenuItem { action: pasteAction } @@ -146,24 +126,34 @@ ApplicationWindow { } TabView { - id:frame - enabled: enabledCheck.checked - tabPosition: controlPage.item ? controlPage.item.tabPosition : Qt.TopEdge + id: tabView + anchors.fill: parent - anchors.margins: Qt.platform.os === "osx" ? 12 : 2 + anchors.margins: UI.margin + tabPosition: UI.tabPosition + + Layout.minimumWidth: 360 + Layout.minimumHeight: 360 + Layout.preferredWidth: 480 + Layout.preferredHeight: 640 Tab { - id: controlPage - title: "Controls" - Controls { } + title: "Buttons" + ButtonPage { + enabled: enabler.checked + } } Tab { - title: "Itemviews" - ModelView { } + title: "Progress" + ProgressPage { + enabled: enabler.checked + } } Tab { - title: "Styles" - Styles { anchors.fill: parent } + title: "Input" + InputPage { + enabled: enabler.checked + } } } } diff --git a/examples/quick/controls/splitview/src/main.cpp b/examples/quick/controls/gallery/qml/+android/UI.js index a757f4853..6050d16ec 100644 --- a/examples/quick/controls/splitview/src/main.cpp +++ b/examples/quick/controls/gallery/qml/+android/UI.js @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -38,12 +38,8 @@ ** ****************************************************************************/ -#include "qtquickcontrolsapplication.h" -#include <QtQml/QQmlApplicationEngine> +.pragma library -int main(int argc, char *argv[]) -{ - QtQuickControlsApplication app(argc, argv); - QQmlApplicationEngine engine(QUrl("qrc:/main.qml")); - return app.exec(); -} +var margin = 0 +var tabPosition = Qt.BottomEdge +var label = "Gallery" diff --git a/examples/quick/controls/gallery/qml/+ios/UI.js b/examples/quick/controls/gallery/qml/+ios/UI.js new file mode 100644 index 000000000..6050d16ec --- /dev/null +++ b/examples/quick/controls/gallery/qml/+ios/UI.js @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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$ +** +****************************************************************************/ + +.pragma library + +var margin = 0 +var tabPosition = Qt.BottomEdge +var label = "Gallery" diff --git a/examples/quick/controls/gallery/qml/+osx/UI.js b/examples/quick/controls/gallery/qml/+osx/UI.js new file mode 100644 index 000000000..2f078ea7f --- /dev/null +++ b/examples/quick/controls/gallery/qml/+osx/UI.js @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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$ +** +****************************************************************************/ + +.pragma library + +var margin = 12 +var tabPosition = Qt.TopEdge +var label = "" diff --git a/examples/quick/controls/gallery/qml/ButtonPage.qml b/examples/quick/controls/gallery/qml/ButtonPage.qml new file mode 100644 index 000000000..0ed7e2d6a --- /dev/null +++ b/examples/quick/controls/gallery/qml/ButtonPage.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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.Layouts 1.1 +import QtQuick.Controls 1.2 + +ScrollView { + id: page + + horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff + + Item { + id: content + + width: Math.max(page.viewport.width, grid.implicitWidth + 2 * grid.rowSpacing) + height: Math.max(page.viewport.height, grid.implicitHeight + 2 * grid.columnSpacing) + + GridLayout { + id: grid + + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: grid.rowSpacing + anchors.rightMargin: grid.rowSpacing + anchors.topMargin: grid.columnSpacing + + columns: page.width < page.height ? 1 : 2 + + GroupBox { + title: "Button" + Layout.fillWidth: true + Layout.columnSpan: grid.columns + RowLayout { + anchors.fill: parent + Button { text: "OK"; isDefault: true } + Button { text: "Cancel" } + Item { Layout.fillWidth: true } + Button { + text: "Attach" + menu: Menu { + MenuItem { text: "Image" } + MenuItem { text: "Document" } + } + } + } + } + + GroupBox { + title: "CheckBox" + Layout.fillWidth: true + ColumnLayout { + anchors.fill: parent + CheckBox { text: "E-mail"; checked: true } + CheckBox { text: "Calendar"; checked: true } + CheckBox { text: "Contacts" } + } + } + + GroupBox { + title: "RadioButton" + Layout.fillWidth: true + ColumnLayout { + anchors.fill: parent + ExclusiveGroup { id: radioGroup } + RadioButton { text: "Portrait"; exclusiveGroup: radioGroup } + RadioButton { text: "Landscape"; exclusiveGroup: radioGroup } + RadioButton { text: "Automatic"; exclusiveGroup: radioGroup; checked: true } + } + } + + GroupBox { + title: "Switch" + Layout.fillWidth: true + Layout.columnSpan: grid.columns + ColumnLayout { + anchors.fill: parent + RowLayout { + Label { text: "Wi-Fi"; Layout.fillWidth: true } + Switch { checked: true } + } + RowLayout { + Label { text: "Bluetooth"; Layout.fillWidth: true } + Switch { checked: false } + } + } + } + } + } +} diff --git a/examples/quick/controls/gallery/qml/InputPage.qml b/examples/quick/controls/gallery/qml/InputPage.qml new file mode 100644 index 000000000..cb1878d02 --- /dev/null +++ b/examples/quick/controls/gallery/qml/InputPage.qml @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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.Layouts 1.1 +import QtQuick.Controls 1.2 + +ScrollView { + id: page + + horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff + + Item { + id: content + + width: Math.max(page.viewport.width, column.implicitWidth + 2 * column.spacing) + height: Math.max(page.viewport.height, column.implicitHeight + 2 * column.spacing) + + ColumnLayout { + id: column + + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: column.spacing + + GroupBox { + title: "TextField" + Layout.fillWidth: true + ColumnLayout { + anchors.fill: parent + TextField { placeholderText: "..."; Layout.fillWidth: true; z: 1 } + TextField { placeholderText: "Password"; echoMode: TextInput.Password; Layout.fillWidth: true } + } + } + + GroupBox { + title: "ComboBox" + Layout.fillWidth: true + ColumnLayout { + anchors.fill: parent + ComboBox { + model: Qt.fontFamilies() + Layout.fillWidth: true + } + ComboBox { + editable: true + model: ListModel { + id: listModel + ListElement { text: "Apple" } + ListElement { text: "Banana" } + ListElement { text: "Coconut" } + ListElement { text: "Orange" } + } + onAccepted: { + if (find(currentText) === -1) { + listModel.append({text: editText}) + currentIndex = find(editText) + } + } + Layout.fillWidth: true + } + } + } + + GroupBox { + title: "SpinBox" + Layout.fillWidth: true + ColumnLayout { + anchors.fill: parent + SpinBox { value: 99; Layout.fillWidth: true; z: 1 } + SpinBox { decimals: 2; Layout.fillWidth: true } + } + } + } + } +} diff --git a/examples/quick/controls/gallery/qml/ProgressPage.qml b/examples/quick/controls/gallery/qml/ProgressPage.qml new file mode 100644 index 000000000..a1fa596f7 --- /dev/null +++ b/examples/quick/controls/gallery/qml/ProgressPage.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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.Layouts 1.1 +import QtQuick.Controls 1.2 + +ScrollView { + id: page + + horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff + + Item { + id: content + + width: Math.max(page.viewport.width, column.implicitWidth + 2 * column.spacing) + height: Math.max(page.viewport.height, column.implicitHeight + 2 * column.spacing) + + ColumnLayout { + id: column + + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: column.spacing + + GroupBox { + title: "ProgressBar" + Layout.fillWidth: true + ColumnLayout { + anchors.fill: parent + ProgressBar { indeterminate: true; Layout.fillWidth: true } + ProgressBar { value: slider.value; Layout.fillWidth: true } + } + } + + GroupBox { + title: "Slider" + Layout.fillWidth: true + ColumnLayout { + anchors.fill: parent + Slider { id: slider; value: 0.5; Layout.fillWidth: true } + } + } + + GroupBox { + title: "BusyIndicator" + Layout.fillWidth: true + BusyIndicator { running: true } + } + } + } +} diff --git a/examples/quick/controls/gallery/qml/UI.js b/examples/quick/controls/gallery/qml/UI.js new file mode 100644 index 000000000..0286ac56a --- /dev/null +++ b/examples/quick/controls/gallery/qml/UI.js @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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$ +** +****************************************************************************/ + +.pragma library + +var margin = 2 +var tabPosition = Qt.TopEdge +var label = "" diff --git a/examples/quick/controls/shared/shared.pri b/examples/quick/controls/shared/shared.pri index 8ca347371..1d9e0592f 100644 --- a/examples/quick/controls/shared/shared.pri +++ b/examples/quick/controls/shared/shared.pri @@ -1,3 +1,6 @@ +QT += quick +!no_desktop: QT += widgets + INCLUDEPATH += $$PWD SOURCES += \ diff --git a/examples/quick/controls/splitview/splitview.pro b/examples/quick/controls/splitview/splitview.pro deleted file mode 100644 index 40adf3d11..000000000 --- a/examples/quick/controls/splitview/splitview.pro +++ /dev/null @@ -1,12 +0,0 @@ -QT += qml quick -TARGET = splitview -!no_desktop: QT += widgets - -include(src/src.pri) -include(../shared/shared.pri) - -OTHER_FILES += \ - main.qml - -RESOURCES += \ - resources.qrc diff --git a/examples/quick/controls/splitview/splitview.qmlproject b/examples/quick/controls/splitview/splitview.qmlproject deleted file mode 100644 index e5a8bf02c..000000000 --- a/examples/quick/controls/splitview/splitview.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/quick/controls/splitview/src/src.pri b/examples/quick/controls/splitview/src/src.pri deleted file mode 100644 index 66d903eac..000000000 --- a/examples/quick/controls/splitview/src/src.pri +++ /dev/null @@ -1,2 +0,0 @@ -SOURCES += \ - $$PWD/main.cpp diff --git a/examples/quick/controls/tableview/images/header.png b/examples/quick/controls/tableview/images/header.png Binary files differdeleted file mode 100644 index dba664609..000000000 --- a/examples/quick/controls/tableview/images/header.png +++ /dev/null diff --git a/examples/quick/controls/tableview/images/selectedrow.png b/examples/quick/controls/tableview/images/selectedrow.png Binary files differdeleted file mode 100644 index 71192ea4e..000000000 --- a/examples/quick/controls/tableview/images/selectedrow.png +++ /dev/null diff --git a/examples/quick/controls/tableview/images/sort-up.png b/examples/quick/controls/tableview/images/sort-up.png Binary files differdeleted file mode 100644 index 27fcb1915..000000000 --- a/examples/quick/controls/tableview/images/sort-up.png +++ /dev/null diff --git a/examples/quick/controls/tableview/main.qml b/examples/quick/controls/tableview/main.qml index b85f2d1d9..49386289d 100644 --- a/examples/quick/controls/tableview/main.qml +++ b/examples/quick/controls/tableview/main.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -38,385 +38,150 @@ ** ****************************************************************************/ - - - - import QtQuick 2.2 -import QtQuick.Window 2.1 +import QtQuick.Layouts 1.1 import QtQuick.Controls 1.2 -import QtQuick.XmlListModel 2.0 +import org.qtproject.example 1.0 -Window { +ApplicationWindow { + id: window visible: true - width: 538 + frame.margins * 2 - height: 360 + frame.margins * 2 - - ToolBar { - id: toolbar - width: parent.width + title: "Table View Example" - ListModel { - id: delegatemenu - ListElement { text: "Shiny delegate" } - ListElement { text: "Scale selected" } - ListElement { text: "Editable items" } - } + toolBar: ToolBar { + TextField { + id: searchBox - ComboBox { - id: delegateChooser - enabled: frame.currentIndex === 3 ? 1 : 0 - model: delegatemenu - width: 150 - anchors.left: parent.left - anchors.leftMargin: 8 - anchors.verticalCenter: parent.verticalCenter - } + placeholderText: "Search..." + inputMethodHints: Qt.ImhNoPredictiveText - CheckBox { - id: enabledCheck - text: "Enabled" - checked: true + width: window.width / 5 * 2 anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter } } - SystemPalette {id: syspal} - color: syspal.window - - XmlListModel { - id: flickerModel - source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2&tags=" + "Qt" - query: "/rss/channel/item" - namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";" - XmlRole { name: "title"; query: "title/string()" } - XmlRole { name: "imagesource"; query: "media:thumbnail/@url/string()" } - XmlRole { name: "credit"; query: "media:credit/string()" } - } - - ListModel { - id: nestedModel - ListElement{content: ListElement { description: "Core" ; color:"#ffaacc"}} - ListElement{content: ListElement { description: "Second" ; color:"#ffccaa"}} - ListElement{content: ListElement { description: "Third" ; color:"#ffffaa"}} - } + TableView { + id: tableView - ListModel { - id: largeModel - Component.onCompleted: { - for (var i=0 ; i< 500 ; ++i) - largeModel.append({"name":"Person "+i , "age": Math.round(Math.random()*100), "gender": Math.random()>0.5 ? "Male" : "Female"}) - } - } + frameVisible: false + sortIndicatorVisible: true - Column { - anchors.top: toolbar.bottom - anchors.right: parent.right - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.margins: 8 + anchors.fill: parent - TabView { - id:frame - focus:true - enabled: enabledCheck.checked + Layout.minimumWidth: 400 + Layout.minimumHeight: 240 + Layout.preferredWidth: 600 + Layout.preferredHeight: 400 - property int margins: Qt.platform.os === "osx" ? 16 : 0 + TableViewColumn { + id: titleColumn + title: "Title" + role: "title" + movable: false + resizable: false + width: tableView.viewport.width - authorColumn.width + } - height: parent.height - 34 - anchors.right: parent.right - anchors.left: parent.left - anchors.margins: margins + TableViewColumn { + id: authorColumn + title: "Author" + role: "author" + movable: false + resizable: false + width: tableView.viewport.width / 3 + } - Tab { - title: "XmlListModel" + model: SortFilterProxyModel { + id: proxyModel + source: sourceModel.count > 0 ? sourceModel : null - TableView { - model: flickerModel - anchors.fill: parent - anchors.margins: 12 + sortOrder: tableView.sortIndicatorOrder + sortCaseSensitivity: Qt.CaseInsensitive + sortRole: sourceModel.count > 0 ? tableView.getColumn(tableView.sortIndicatorColumn).role : "" - TableViewColumn { - role: "title" - title: "Title" - width: 120 - } - TableViewColumn { - role: "credit" - title: "Credit" - width: 120 - } - TableViewColumn { - role: "imagesource" - title: "Image source" - width: 200 - visible: true - } + filterString: "*" + searchBox.text + "*" + filterSyntax: SortFilterProxyModel.Wildcard + filterCaseSensitivity: Qt.CaseInsensitive + } - frameVisible: frameCheckbox.checked - headerVisible: headerCheckbox.checked - sortIndicatorVisible: sortableCheckbox.checked - alternatingRowColors: alternateCheckbox.checked - } + ListModel { + id: sourceModel + ListElement { + title: "Moby-Dick" + author: "Herman Melville" } - Tab { - title: "Multivalue" - - TableView { - model: nestedModel - anchors.fill: parent - anchors.margins: 12 - - TableViewColumn { - role: "content" - title: "Text and Color" - width: 220 - } - - itemDelegate: Item { - Rectangle{ - color: styleData.value.get(0).color - anchors.top:parent.top - anchors.right:parent.right - anchors.bottom:parent.bottom - anchors.margins: 4 - width:32 - border.color:"#666" - } - Text { - width: parent.width - anchors.margins: 4 - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - elide: styleData.elideMode - text: styleData.value.get(0).description - color: styleData.textColor - } - } - - frameVisible: frameCheckbox.checked - headerVisible: headerCheckbox.checked - sortIndicatorVisible: sortableCheckbox.checked - alternatingRowColors: alternateCheckbox.checked - } + ListElement { + title: "The Adventures of Tom Sawyer" + author: "Mark Twain" } - Tab { - title: "Generated" - - TableView { - model: largeModel - anchors.margins: 12 - anchors.fill: parent - TableViewColumn { - role: "name" - title: "Name" - width: 120 - } - TableViewColumn { - role: "age" - title: "Age" - width: 120 - } - TableViewColumn { - role: "gender" - title: "Gender" - width: 120 - } - frameVisible: frameCheckbox.checked - headerVisible: headerCheckbox.checked - sortIndicatorVisible: sortableCheckbox.checked - alternatingRowColors: alternateCheckbox.checked - } + ListElement { + title: "Cat’s Cradle" + author: "Kurt Vonnegut" } - - Tab { - title: "Delegates" - Item { - anchors.fill: parent - - Component { - id: delegate1 - Item { - clip: true - 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 - } - } - } - - Component { - id: delegate2 - 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 - } - } - - Component { - id: editableDelegate - Item { - - 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 - visible: !styleData.selected - } - Loader { // Initialize text editor lazily to improve performance - id: loaderEditor - anchors.fill: parent - anchors.margins: 4 - Connections { - target: loaderEditor.item - onAccepted: { - if (typeof styleData.value === 'number') - largeModel.setProperty(styleData.row, styleData.role, Number(parseFloat(loaderEditor.item.text).toFixed(0))) - else - largeModel.setProperty(styleData.row, styleData.role, loaderEditor.item.text) - } - } - sourceComponent: styleData.selected ? editor : null - Component { - id: editor - TextInput { - id: textinput - color: styleData.textColor - text: styleData.value - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - onClicked: textinput.forceActiveFocus() - } - } - } - } - } - } - TableView { - id: delegatesView - model: largeModel - anchors.margins: 12 - anchors.fill:parent - frameVisible: frameCheckbox.checked - headerVisible: headerCheckbox.checked - sortIndicatorVisible: sortableCheckbox.checked - alternatingRowColors: alternateCheckbox.checked - - TableViewColumn { - role: "name" - title: "Name" - width: 120 - } - TableViewColumn { - role: "age" - title: "Age" - width: 120 - } - TableViewColumn { - role: "gender" - title: "Gender" - width: 120 - } - - headerDelegate: BorderImage{ - source: "images/header.png" - border{left:2;right:2;top:2;bottom:2} - Text { - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.right: indicator.visible ? indicator.left : parent.right - anchors.margins: 6 - text: styleData.value - elide: Text.ElideRight - color:"#333" - } - // Sort indicator - Image { - id: indicator - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: 6 - source: "images/sort-up.png" - visible: delegatesView.sortIndicatorVisible && - styleData.column === delegatesView.sortIndicatorColumn - rotation: delegatesView.sortIndicatorOrder === Qt.AscendingOrder ? 180 : 0 - Behavior on rotation { NumberAnimation { } } - } - - } - - rowDelegate: Rectangle { - 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: styleData.selected - border{left:2; right:2; top:2; bottom:2} - SequentialAnimation { - running: true; loops: Animation.Infinite - NumberAnimation { target:selected; property: "opacity"; to: 1.0; duration: 900} - NumberAnimation { target:selected; property: "opacity"; to: 0.5; duration: 900} - } - } - } - - itemDelegate: { - if (delegateChooser.currentIndex == 2) - return editableDelegate; - else - return delegate1; - } - } - } + ListElement { + title: "Farenheit 451" + author: "Ray Bradbury" } - } - Row{ - x: 12 - height: 34 - CheckBox{ - id: alternateCheckbox - checked: true - text: "Alternate" - anchors.verticalCenter: parent.verticalCenter + ListElement { + title: "It" + author: "Stephen King" + } + ListElement { + title: "On the Road" + author: "Jack Kerouac" + } + ListElement { + title: "Of Mice and Men" + author: "John Steinbeck" + } + ListElement { + title: "Do Androids Dream of Electric Sheep?" + author: "Philip K. Dick" + } + ListElement { + title: "Uncle Tom’s Cabin" + author: "Harriet Beecher Stowe" + } + ListElement { + title: "The Call of the Wild" + author: "Jack London" + } + ListElement { + title: "The Old Man and the Sea" + author: "Ernest Hemingway" + } + ListElement { + title: "A Streetcar Named Desire" + author: "Tennessee Williams" + } + ListElement { + title: "Catch-22" + author: "Joseph Heller" + } + ListElement { + title: "One Flew Over the Cuckoo’s Nest" + author: "Ken Kesey" + } + ListElement { + title: "The Murders in the Rue Morgue" + author: "Edgar Allan Poe" + } + ListElement { + title: "Breakfast at Tiffany’s" + author: "Truman Capote" } - CheckBox{ - id: sortableCheckbox - checked: false - text: "Sort indicator" - anchors.verticalCenter: parent.verticalCenter + ListElement { + title: "Death of a Salesman" + author: "Arthur Miller" } - CheckBox{ - id: frameCheckbox - checked: true - text: "Frame" - anchors.verticalCenter: parent.verticalCenter + ListElement { + title: "Post Office" + author: "Charles Bukowski" } - CheckBox{ - id: headerCheckbox - checked: true - text: "Headers" - anchors.verticalCenter: parent.verticalCenter + ListElement { + title: "Herbert West—Reanimator" + author: "H. P. Lovecraft" } } } diff --git a/examples/quick/controls/tableview/resources.qrc b/examples/quick/controls/tableview/resources.qrc deleted file mode 100644 index 83d3f6a76..000000000 --- a/examples/quick/controls/tableview/resources.qrc +++ /dev/null @@ -1,8 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="/"> - <file>main.qml</file> - <file>images/selectedrow.png</file> - <file>images/header.png</file> - <file>images/sort-up.png</file> -</qresource> -</RCC> diff --git a/examples/quick/controls/tableview/src/main.cpp b/examples/quick/controls/tableview/src/main.cpp index a757f4853..1406b84ce 100644 --- a/examples/quick/controls/tableview/src/main.cpp +++ b/examples/quick/controls/tableview/src/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -39,11 +39,21 @@ ****************************************************************************/ #include "qtquickcontrolsapplication.h" -#include <QtQml/QQmlApplicationEngine> +#include "sortfilterproxymodel.h" +#include <QtQml/qqmlapplicationengine.h> +#include <QtGui/qsurfaceformat.h> +#include <QtQml/qqml.h> int main(int argc, char *argv[]) { QtQuickControlsApplication app(argc, argv); + if (QCoreApplication::arguments().contains(QLatin1String("--coreprofile"))) { + QSurfaceFormat fmt; + fmt.setVersion(4, 4); + fmt.setProfile(QSurfaceFormat::CoreProfile); + QSurfaceFormat::setDefaultFormat(fmt); + } + qmlRegisterType<SortFilterProxyModel>("org.qtproject.example", 1, 0, "SortFilterProxyModel"); QQmlApplicationEngine engine(QUrl("qrc:/main.qml")); return app.exec(); } diff --git a/examples/quick/controls/tableview/src/sortfilterproxymodel.cpp b/examples/quick/controls/tableview/src/sortfilterproxymodel.cpp new file mode 100644 index 000000000..7b999470f --- /dev/null +++ b/examples/quick/controls/tableview/src/sortfilterproxymodel.cpp @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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$ +** +****************************************************************************/ + +#include "sortfilterproxymodel.h" +#include <QtDebug> +#include <QtQml> + +SortFilterProxyModel::SortFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent), m_complete(false) +{ + connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(countChanged())); + connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(countChanged())); +} + +int SortFilterProxyModel::count() const +{ + return rowCount(); +} + +QObject *SortFilterProxyModel::source() const +{ + return sourceModel(); +} + +void SortFilterProxyModel::setSource(QObject *source) +{ + setSourceModel(qobject_cast<QAbstractItemModel *>(source)); +} + +QByteArray SortFilterProxyModel::sortRole() const +{ + return m_sortRole; +} + +void SortFilterProxyModel::setSortRole(const QByteArray &role) +{ + if (m_sortRole != role) { + m_sortRole = role; + if (m_complete) + QSortFilterProxyModel::setSortRole(roleKey(role)); + } +} + +void SortFilterProxyModel::setSortOrder(Qt::SortOrder order) +{ + QSortFilterProxyModel::sort(0, order); +} + +QByteArray SortFilterProxyModel::filterRole() const +{ + return m_filterRole; +} + +void SortFilterProxyModel::setFilterRole(const QByteArray &role) +{ + if (m_filterRole != role) { + m_filterRole = role; + if (m_complete) + QSortFilterProxyModel::setFilterRole(roleKey(role)); + } +} + +QString SortFilterProxyModel::filterString() const +{ + return filterRegExp().pattern(); +} + +void SortFilterProxyModel::setFilterString(const QString &filter) +{ + setFilterRegExp(QRegExp(filter, filterCaseSensitivity(), static_cast<QRegExp::PatternSyntax>(filterSyntax()))); +} + +SortFilterProxyModel::FilterSyntax SortFilterProxyModel::filterSyntax() const +{ + return static_cast<FilterSyntax>(filterRegExp().patternSyntax()); +} + +void SortFilterProxyModel::setFilterSyntax(SortFilterProxyModel::FilterSyntax syntax) +{ + setFilterRegExp(QRegExp(filterString(), filterCaseSensitivity(), static_cast<QRegExp::PatternSyntax>(syntax))); +} + +QJSValue SortFilterProxyModel::get(int idx) const +{ + QJSEngine *engine = qmlEngine(this); + QJSValue value = engine->newObject(); + if (idx >= 0 && idx < count()) { + QHash<int, QByteArray> roles = roleNames(); + QHashIterator<int, QByteArray> it(roles); + while (it.hasNext()) { + it.next(); + value.setProperty(QString::fromUtf8(it.value()), data(index(idx, 0), it.key()).toString()); + } + } + return value; +} + +void SortFilterProxyModel::classBegin() +{ +} + +void SortFilterProxyModel::componentComplete() +{ + m_complete = true; + if (!m_sortRole.isEmpty()) + QSortFilterProxyModel::setSortRole(roleKey(m_sortRole)); + if (!m_filterRole.isEmpty()) + QSortFilterProxyModel::setFilterRole(roleKey(m_filterRole)); +} + +int SortFilterProxyModel::roleKey(const QByteArray &role) const +{ + QHash<int, QByteArray> roles = roleNames(); + QHashIterator<int, QByteArray> it(roles); + while (it.hasNext()) { + it.next(); + if (it.value() == role) + return it.key(); + } + return -1; +} + +QHash<int, QByteArray> SortFilterProxyModel::roleNames() const +{ + if (QAbstractItemModel *source = sourceModel()) + return source->roleNames(); + return QHash<int, QByteArray>(); +} + +bool SortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const +{ + QRegExp rx = filterRegExp(); + if (rx.isEmpty()) + return true; + QAbstractItemModel *model = sourceModel(); + if (filterRole().isEmpty()) { + QHash<int, QByteArray> roles = roleNames(); + QHashIterator<int, QByteArray> it(roles); + while (it.hasNext()) { + it.next(); + QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent); + QString key = model->data(sourceIndex, it.key()).toString(); + if (key.contains(rx)) + return true; + } + return false; + } + QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent); + if (!sourceIndex.isValid()) + return true; + QString key = model->data(sourceIndex, roleKey(filterRole())).toString(); + return key.contains(rx); +} diff --git a/examples/quick/controls/tableview/src/sortfilterproxymodel.h b/examples/quick/controls/tableview/src/sortfilterproxymodel.h new file mode 100644 index 000000000..026b5d124 --- /dev/null +++ b/examples/quick/controls/tableview/src/sortfilterproxymodel.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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$ +** +****************************************************************************/ + +#ifndef SORTFILTERPROXYMODEL_H +#define SORTFILTERPROXYMODEL_H + +#include <QtCore/qsortfilterproxymodel.h> +#include <QtQml/qqmlparserstatus.h> +#include <QtQml/qjsvalue.h> + +class SortFilterProxyModel : public QSortFilterProxyModel, public QQmlParserStatus +{ + Q_OBJECT + Q_INTERFACES(QQmlParserStatus) + + Q_PROPERTY(int count READ count NOTIFY countChanged) + Q_PROPERTY(QObject *source READ source WRITE setSource) + + Q_PROPERTY(QByteArray sortRole READ sortRole WRITE setSortRole) + Q_PROPERTY(Qt::SortOrder sortOrder READ sortOrder WRITE setSortOrder) + + Q_PROPERTY(QByteArray filterRole READ filterRole WRITE setFilterRole) + Q_PROPERTY(QString filterString READ filterString WRITE setFilterString) + Q_PROPERTY(FilterSyntax filterSyntax READ filterSyntax WRITE setFilterSyntax) + + Q_ENUMS(FilterSyntax) + +public: + explicit SortFilterProxyModel(QObject *parent = 0); + + QObject *source() const; + void setSource(QObject *source); + + QByteArray sortRole() const; + void setSortRole(const QByteArray &role); + + void setSortOrder(Qt::SortOrder order); + + QByteArray filterRole() const; + void setFilterRole(const QByteArray &role); + + QString filterString() const; + void setFilterString(const QString &filter); + + enum FilterSyntax { + RegExp, + Wildcard, + FixedString + }; + + FilterSyntax filterSyntax() const; + void setFilterSyntax(FilterSyntax syntax); + + int count() const; + Q_INVOKABLE QJSValue get(int index) const; + + void classBegin(); + void componentComplete(); + +signals: + void countChanged(); + +protected: + int roleKey(const QByteArray &role) const; + QHash<int, QByteArray> roleNames() const; + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + +private: + bool m_complete; + QByteArray m_sortRole; + QByteArray m_filterRole; +}; + +#endif // SORTFILTERPROXYMODEL_H diff --git a/examples/quick/controls/tableview/src/src.pri b/examples/quick/controls/tableview/src/src.pri index 66d903eac..491f851c9 100644 --- a/examples/quick/controls/tableview/src/src.pri +++ b/examples/quick/controls/tableview/src/src.pri @@ -1,2 +1,8 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/sortfilterproxymodel.h + SOURCES += \ - $$PWD/main.cpp + $$PWD/main.cpp \ + $$PWD/sortfilterproxymodel.cpp diff --git a/examples/quick/controls/tableview/tableview.pro b/examples/quick/controls/tableview/tableview.pro index c982ac203..c0ed1a2f9 100644 --- a/examples/quick/controls/tableview/tableview.pro +++ b/examples/quick/controls/tableview/tableview.pro @@ -1,12 +1,11 @@ -QT += qml quick +TEMPLATE = app TARGET = tableview -!no_desktop: QT += widgets -include(src/src.pri) -include(../shared/shared.pri) +RESOURCES += \ + tableview.qrc OTHER_FILES += \ main.qml -RESOURCES += \ - resources.qrc +include(src/src.pri) +include(../shared/shared.pri) diff --git a/examples/quick/controls/tableview/tableview.qmlproject b/examples/quick/controls/tableview/tableview.qmlproject deleted file mode 100644 index e5a8bf02c..000000000 --- a/examples/quick/controls/tableview/tableview.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "main.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/quick/controls/splitview/resources.qrc b/examples/quick/controls/tableview/tableview.qrc index 3b111a907..3b111a907 100644 --- a/examples/quick/controls/splitview/resources.qrc +++ b/examples/quick/controls/tableview/tableview.qrc diff --git a/examples/quick/dialogs/systemdialogs/ColorDialogs.qml b/examples/quick/dialogs/systemdialogs/ColorDialogs.qml index c44284df1..8b26e081a 100644 --- a/examples/quick/dialogs/systemdialogs/ColorDialogs.qml +++ b/examples/quick/dialogs/systemdialogs/ColorDialogs.qml @@ -65,7 +65,7 @@ Item { anchors.fill: parent anchors.margins: 12 spacing: 8 - Text { + Label { font.bold: true text: "Color dialog properties:" } @@ -99,9 +99,8 @@ Item { onClicked: colorDialog.open() } } - Text { + Label { id: colorLabel - color: palette.windowText text: "<b>current color:</b> " + colorDialog.color anchors.verticalCenter: parent.verticalCenter } diff --git a/examples/quick/dialogs/systemdialogs/CustomDialogs.qml b/examples/quick/dialogs/systemdialogs/CustomDialogs.qml index 405dece3b..90d012e1e 100644 --- a/examples/quick/dialogs/systemdialogs/CustomDialogs.qml +++ b/examples/quick/dialogs/systemdialogs/CustomDialogs.qml @@ -67,7 +67,7 @@ Item { onApply: lastChosen.text = "Apply" onReset: lastChosen.text = "Reset" - Text { + Label { text: "Hello world!" } } @@ -91,9 +91,8 @@ Item { ColumnLayout { id: column width: parent ? parent.width : 100 - Text { + Label { text: "<b>What</b> is the average airspeed velocity of an unladen European swallow?" - textFormat: Text.StyledText Layout.columnSpan: 2 Layout.fillWidth: true wrapMode: Text.WordWrap @@ -104,7 +103,7 @@ Item { id: answer onEditingFinished: spinboxDialog.click(StandardButton.Ok) } - Text { + Label { text: "m/s" Layout.alignment: Qt.AlignBaseline | Qt.AlignLeft } @@ -123,6 +122,7 @@ Item { else lastChosen.text = (clickedButton == StandardButton.Retry ? "(Retry)" : "(Ignore)") } + onRejected: lastChosen.text = "Rejected" Calendar { id: calendar @@ -135,26 +135,31 @@ Item { id: filledDialog modality: dialogModal.checked ? Qt.WindowModal : Qt.NonModal title: customizeTitle.checked ? windowTitleField.text : "Customized content" + onRejected: lastChosen.text = "Rejected" + onAccepted: lastChosen.text = "Accepted " + + (clickedButton === StandardButton.Retry ? "(Retry)" : "(OK)") + onButtonClicked: if (clickedButton === StandardButton.Retry) lastChosen.text = "Retry" contentItem: Rectangle { color: "lightskyblue" implicitWidth: 400 implicitHeight: 100 - Text { + Label { text: "Hello blue sky!" color: "navy" anchors.centerIn: parent } - focus: true - Keys.onEscapePressed: filledDialog.close() + Keys.onPressed: if (event.key === Qt.Key_R && (event.modifiers & Qt.ControlModifier)) filledDialog.click(StandardButton.Retry) + Keys.onEnterPressed: filledDialog.accept() + Keys.onEscapePressed: filledDialog.reject() + Keys.onBackPressed: filledDialog.reject() // especially necessary on Android } } - Column { + ColumnLayout { anchors.fill: parent anchors.margins: 12 spacing: 8 - Text { - color: palette.windowText + Label { font.bold: true text: "Message dialog properties:" } @@ -163,22 +168,26 @@ Item { text: "Modal" Binding on checked { value: helloDialog.modality != Qt.NonModal } } - CheckBox { - id: customizeTitle - text: "Window Title" - checked: true - width: parent.width + RowLayout { + CheckBox { + id: customizeTitle + text: "Window Title" + Layout.alignment: Qt.AlignBaseline + checked: true + } TextField { id: windowTitleField - anchors.right: parent.right + Layout.alignment: Qt.AlignBaseline + Layout.fillWidth: true text: "Custom Dialog" - width: root.width - customizeTitle.implicitWidth - 30 } } - + Label { + text: "Buttons:" + } Flow { spacing: 8 - width: parent.width + Layout.fillWidth: true property bool updating: false function updateButtons(button, checked) { if (updating) return @@ -256,6 +265,24 @@ Item { } CheckBox { + text: "Apply" + property int button: StandardButton.Apply + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { + text: "Reset" + property int button: StandardButton.Reset + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { + text: "Restore Defaults" + property int button: StandardButton.RestoreDefaults + onCheckedChanged: parent.updateButtons(button, checked) + } + + CheckBox { text: "OK" checked: true property int button: StandardButton.Ok @@ -264,12 +291,14 @@ Item { Component.onCompleted: updateButtons() } - Text { + Label { id: lastChosen } + Item { Layout.fillHeight: true } } Rectangle { + id: bottomBar anchors { left: parent.left right: parent.right @@ -286,22 +315,22 @@ Item { anchors.leftMargin: 12 width: parent.width Button { - text: "Hello World dialog" + text: "Hello World" anchors.verticalCenter: parent.verticalCenter onClicked: helloDialog.open() } Button { - text: "Input dialog" + text: "Input" anchors.verticalCenter: parent.verticalCenter onClicked: spinboxDialog.open() } Button { - text: "Date picker" + text: "Date" anchors.verticalCenter: parent.verticalCenter onClicked: dateDialog.open() } Button { - text: "Buttonless marginless dialog" + text: "No buttons or margins" anchors.verticalCenter: parent.verticalCenter onClicked: filledDialog.open() } diff --git a/examples/quick/dialogs/systemdialogs/FileDialogs.qml b/examples/quick/dialogs/systemdialogs/FileDialogs.qml index 79a58b982..9f50abcd4 100644 --- a/examples/quick/dialogs/systemdialogs/FileDialogs.qml +++ b/examples/quick/dialogs/systemdialogs/FileDialogs.qml @@ -41,6 +41,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Dialogs 1.1 +import QtQuick.Layouts 1.1 import QtQuick.Window 2.0 Item { @@ -72,83 +73,79 @@ Item { } //! [filedialog] - Column { - anchors.fill: parent - anchors.margins: 12 - spacing: 8 - Text { - color: palette.windowText - font.bold: true - text: "File dialog properties:" - } - CheckBox { - id: fileDialogModal - text: "Modal" - checked: true - Binding on checked { value: fileDialog.modality != Qt.NonModal } - } - CheckBox { - id: fileDialogSelectFolder - text: "Select Folder" - Binding on checked { value: fileDialog.selectFolder } - } - CheckBox { - id: fileDialogSelectExisting - text: "Select Existing Files" - checked: true - Binding on checked { value: fileDialog.selectExisting } - } - CheckBox { - id: fileDialogSelectMultiple - text: "Select Multiple Files" - Binding on checked { value: fileDialog.selectMultiple } - } - CheckBox { - id: fileDialogOpenFiles - text: "Open Files After Accepting" - } - CheckBox { - id: fileDialogSidebarVisible - text: "Show Sidebar" - checked: fileDialog.sidebarVisible - Binding on checked { value: fileDialog.sidebarVisible } - } - CheckBox { - id: fileDialogVisible - text: "Visible" - Binding on checked { value: fileDialog.visible } - } - Text { - color: palette.windowText - text: "<b>current view folder:</b> " + fileDialog.folder - } - Text { - color: palette.windowText - text: "<b>name filters:</b> {" + fileDialog.nameFilters + "}" - width: parent.width - wrapMode: Text.Wrap - } - Text { - color: palette.windowText - text: "<b>current filter:</b>" + fileDialog.selectedNameFilter - width: parent.width - wrapMode: Text.Wrap - } - Text { - color: palette.windowText - text: "<b>chosen files:</b> " + fileDialog.fileUrls - width: parent.width - wrapMode: Text.Wrap - } - Text { - color: palette.windowText - text: "<b>chosen single path:</b> " + fileDialog.fileUrl - width: parent.width - wrapMode: Text.Wrap + ScrollView { + id: scrollView + anchors { + left: parent.left + right: parent.right + top: parent.top + bottom: bottomBar.top + leftMargin: 12 + } + ColumnLayout { + spacing: 8 + Item { Layout.preferredHeight: 4 } // padding + Label { + font.bold: true + text: "File dialog properties:" + } + CheckBox { + id: fileDialogModal + text: "Modal" + checked: true + Binding on checked { value: fileDialog.modality != Qt.NonModal } + } + CheckBox { + id: fileDialogSelectFolder + text: "Select Folder" + Binding on checked { value: fileDialog.selectFolder } + } + CheckBox { + id: fileDialogSelectExisting + text: "Select Existing Files" + checked: true + Binding on checked { value: fileDialog.selectExisting } + } + CheckBox { + id: fileDialogSelectMultiple + text: "Select Multiple Files" + Binding on checked { value: fileDialog.selectMultiple } + } + CheckBox { + id: fileDialogOpenFiles + text: "Open Files After Accepting" + } + CheckBox { + id: fileDialogSidebarVisible + text: "Show Sidebar" + checked: fileDialog.sidebarVisible + Binding on checked { value: fileDialog.sidebarVisible } + } + CheckBox { + id: fileDialogVisible + text: "Visible" + Binding on checked { value: fileDialog.visible } + } + Label { + text: "<b>current view folder:</b> " + fileDialog.folder + } + Label { + text: "<b>name filters:</b> {" + fileDialog.nameFilters + "}" + } + Label { + text: "<b>current filter:</b>" + fileDialog.selectedNameFilter + } + Label { + text: "<b>chosen files:</b> " + fileDialog.fileUrls + } + Label { + text: "<b>chosen single path:</b> " + fileDialog.fileUrl + } } } Rectangle { + id: bottomBar anchors { left: parent.left right: parent.right diff --git a/examples/quick/dialogs/systemdialogs/FontDialogs.qml b/examples/quick/dialogs/systemdialogs/FontDialogs.qml index dc8f245bc..3b6f86f7c 100644 --- a/examples/quick/dialogs/systemdialogs/FontDialogs.qml +++ b/examples/quick/dialogs/systemdialogs/FontDialogs.qml @@ -42,12 +42,11 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Dialogs 1.1 -Rectangle { +Item { width: 320 height: 360 SystemPalette { id: palette } clip: true - color: palette.window FontDialog { id: fontDialog @@ -70,7 +69,7 @@ Rectangle { anchors.fill: parent anchors.margins: 12 spacing: 8 - Text { + Label { font.bold: true text: "Font dialog properties:" } @@ -105,12 +104,11 @@ Rectangle { text: "Visible" Binding on checked { value: fontDialog.visible } } - Text { + Label { text: "Current font:" } - Text { + Label { id: fontLabel - color: palette.windowText text: "<b>" + fontDialog.font.family + " - " + fontDialog.font.pointSize + "</b>" MouseArea { anchors.fill: parent diff --git a/examples/quick/dialogs/systemdialogs/MessageDialogs.qml b/examples/quick/dialogs/systemdialogs/MessageDialogs.qml index 1bc9a4b66..208a69d46 100644 --- a/examples/quick/dialogs/systemdialogs/MessageDialogs.qml +++ b/examples/quick/dialogs/systemdialogs/MessageDialogs.qml @@ -41,6 +41,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Dialogs 1.1 +import QtQuick.Layouts 1.1 import QtQuick.Window 2.0 Item { @@ -72,211 +73,229 @@ Item { } //! [messagedialog] - Column { - anchors.fill: parent - anchors.margins: 12 - spacing: 8 - Text { - color: palette.windowText - font.bold: true - text: "Message dialog properties:" - } - CheckBox { - id: messageDialogModal - text: "Modal" - checked: true - Binding on checked { value: messageDialog.modality != Qt.NonModal } - } - CheckBox { - id: customizeTitle - text: "Window Title" - checked: true - width: parent.width - TextField { - id: windowTitleField - anchors.right: parent.right - width: informativeTextField.width - text: "Alert" - } + ScrollView { + id: scrollView + anchors { + left: parent.left + right: parent.right + top: parent.top + bottom: bottomBar.top + leftMargin: 12 } - Row { + ColumnLayout { spacing: 8 - property bool updating: false - function updateIcon(icon, checked) { - if (updating) return - updating = true - messageDialog.icon = (checked ? icon : StandardIcon.NoIcon) - for (var i = 0; i < children.length; ++i) - if (children[i].icon !== icon) - children[i].checked = false - updating = false + Item { Layout.preferredHeight: 4 } // padding + Label { + font.bold: true + text: "Message dialog properties:" } - CheckBox { - id: iconInformation - text: "Information" - property int icon: StandardIcon.Information - onCheckedChanged: parent.updateIcon(icon, checked) - } - - CheckBox { - id: iconWarning - text: "Warning" + id: messageDialogModal + text: "Modal" checked: true - property int icon: StandardIcon.Warning - onCheckedChanged: parent.updateIcon(icon, checked) - Component.onCompleted: parent.updateIcon(icon, true) + Binding on checked { value: messageDialog.modality != Qt.NonModal } } - - CheckBox { - id: iconCritical - text: "Critical" - property int icon: StandardIcon.Critical - onCheckedChanged: parent.updateIcon(icon, checked) + RowLayout { + CheckBox { + id: customizeTitle + text: "Window Title" + Layout.alignment: Qt.AlignBaseline + checked: true + } + TextField { + id: windowTitleField + Layout.alignment: Qt.AlignBaseline + Layout.fillWidth: true + text: "Alert" + } } + Label { text: "Icon:" } + Flow { + spacing: 8 + Layout.fillWidth: true + property bool updating: false + function updateIcon(icon, checked) { + if (updating) return + updating = true + messageDialog.icon = (checked ? icon : StandardIcon.NoIcon) + for (var i = 0; i < children.length; ++i) + if (children[i].icon !== icon) + children[i].checked = false + updating = false + } - CheckBox { - id: iconQuestion - text: "Question" - property int icon: StandardIcon.Question - onCheckedChanged: parent.updateIcon(icon, checked) - } - } + CheckBox { + id: iconInformation + text: "Information" + property int icon: StandardIcon.Information + onCheckedChanged: parent.updateIcon(icon, checked) + } - CheckBox { - id: customizeText - text: "Primary Text" - checked: true - width: parent.width - TextField { - id: textField - anchors.right: parent.right - width: informativeTextField.width - text: "Attention Please" + CheckBox { + id: iconWarning + text: "Warning" + checked: true + property int icon: StandardIcon.Warning + onCheckedChanged: parent.updateIcon(icon, checked) + Component.onCompleted: parent.updateIcon(icon, true) + } + + CheckBox { + id: iconCritical + text: "Critical" + property int icon: StandardIcon.Critical + onCheckedChanged: parent.updateIcon(icon, checked) + } + + CheckBox { + id: iconQuestion + text: "Question" + property int icon: StandardIcon.Question + onCheckedChanged: parent.updateIcon(icon, checked) + } } - } - CheckBox { - id: customizeInformativeText - text: "Informative Text" - checked: true - width: parent.width - TextField { - id: informativeTextField - anchors.right: parent.right - width: root.width - customizeInformativeText.implicitWidth - 20 - text: "Be alert!" + + RowLayout { + CheckBox { + id: customizeText + text: "Primary Text" + Layout.alignment: Qt.AlignBaseline + checked: true + } + TextField { + id: textField + Layout.alignment: Qt.AlignBaseline + Layout.fillWidth: true + text: "Attention Please" + } } - } - Text { - text: "Buttons:" - } - Flow { - spacing: 8 - width: parent.width - property bool updating: false - function updateButtons(button, checked) { - if (updating) return - updating = true - var buttons = 0 - for (var i = 0; i < children.length; ++i) - if (children[i].checked) - buttons |= children[i].button - if (!buttons) - buttons = StandardButton.Ok - messageDialog.standardButtons = buttons - updating = false + RowLayout { + CheckBox { + id: customizeInformativeText + text: "Informative Text" + Layout.alignment: Qt.AlignBaseline + checked: true + } + TextField { + id: informativeTextField + Layout.alignment: Qt.AlignBaseline + Layout.fillWidth: true + text: "Be alert!" + } } + Label { text: "Buttons:" } + Flow { + spacing: 8 + Layout.fillWidth: true + Layout.preferredWidth: root.width - 30 + property bool updating: false + function updateButtons(button, checked) { + if (updating) return + updating = true + var buttons = 0 + for (var i = 0; i < children.length; ++i) + if (children[i].checked) + buttons |= children[i].button + if (!buttons) + buttons = StandardButton.Ok + messageDialog.standardButtons = buttons + updating = false + } - CheckBox { - text: "Help" - property int button: StandardButton.Help - onCheckedChanged: parent.updateButtons(button, checked) - } + CheckBox { + text: "Help" + property int button: StandardButton.Help + onCheckedChanged: parent.updateButtons(button, checked) + } - CheckBox { - text: "Abort" - property int button: StandardButton.Abort - onCheckedChanged: parent.updateButtons(button, checked) - } + CheckBox { + text: "Abort" + property int button: StandardButton.Abort + onCheckedChanged: parent.updateButtons(button, checked) + } - CheckBox { - text: "Close" - property int button: StandardButton.Close - onCheckedChanged: parent.updateButtons(button, checked) - } + CheckBox { + text: "Close" + property int button: StandardButton.Close + onCheckedChanged: parent.updateButtons(button, checked) + } - CheckBox { - text: "Cancel" - property int button: StandardButton.Cancel - onCheckedChanged: parent.updateButtons(button, checked) - } + CheckBox { + text: "Cancel" + property int button: StandardButton.Cancel + onCheckedChanged: parent.updateButtons(button, checked) + } - CheckBox { - text: "NoToAll" - property int button: StandardButton.NoToAll - onCheckedChanged: parent.updateButtons(button, checked) - } + CheckBox { + text: "NoToAll" + property int button: StandardButton.NoToAll + onCheckedChanged: parent.updateButtons(button, checked) + } - CheckBox { - text: "No" - property int button: StandardButton.No - onCheckedChanged: parent.updateButtons(button, checked) - } + CheckBox { + text: "No" + property int button: StandardButton.No + onCheckedChanged: parent.updateButtons(button, checked) + } - CheckBox { - text: "YesToAll" - property int button: StandardButton.YesToAll - onCheckedChanged: parent.updateButtons(button, checked) - } + CheckBox { + text: "YesToAll" + property int button: StandardButton.YesToAll + onCheckedChanged: parent.updateButtons(button, checked) + } - CheckBox { - text: "Yes" - property int button: StandardButton.Yes - onCheckedChanged: parent.updateButtons(button, checked) - } + CheckBox { + text: "Yes" + property int button: StandardButton.Yes + onCheckedChanged: parent.updateButtons(button, checked) + } - CheckBox { - text: "Ignore" - property int button: StandardButton.Ignore - onCheckedChanged: parent.updateButtons(button, checked) - } + CheckBox { + text: "Ignore" + property int button: StandardButton.Ignore + onCheckedChanged: parent.updateButtons(button, checked) + } - CheckBox { - text: "Retry" - property int button: StandardButton.Retry - onCheckedChanged: parent.updateButtons(button, checked) - } + CheckBox { + text: "Retry" + property int button: StandardButton.Retry + onCheckedChanged: parent.updateButtons(button, checked) + } + CheckBox { + text: "OK" + checked: true + property int button: StandardButton.Ok + onCheckedChanged: parent.updateButtons(button, checked) + } + } + RowLayout { + CheckBox { + id: customizeDetailedText + text: "Detailed Text" + Layout.alignment: Qt.AlignBaseline + checked: true + } + TextField { + id: detailedTextField + Layout.alignment: Qt.AlignBaseline + Layout.fillWidth: true + text: "The world needs more lerts." + } + } CheckBox { - text: "OK" - checked: true - property int button: StandardButton.Ok - onCheckedChanged: parent.updateButtons(button, checked) + id: messageDialogVisible + text: "Visible" + Binding on checked { value: messageDialog.visible } } - } - CheckBox { - id: customizeDetailedText - text: "Detailed Text" - checked: true - width: parent.width - TextField { - id: detailedTextField - anchors.right: parent.right - width: informativeTextField.width - text: "The world needs more lerts." + Label { + id: lastChosen } } - CheckBox { - id: messageDialogVisible - text: "Visible" - Binding on checked { value: messageDialog.visible } - } - Text { - id: lastChosen - } } Rectangle { + id: bottomBar anchors { left: parent.left right: parent.right diff --git a/examples/quick/dialogs/systemdialogs/systemdialogs.qml b/examples/quick/dialogs/systemdialogs/systemdialogs.qml index 0c30d9e59..5e8cb7864 100644 --- a/examples/quick/dialogs/systemdialogs/systemdialogs.qml +++ b/examples/quick/dialogs/systemdialogs/systemdialogs.qml @@ -52,23 +52,23 @@ ApplicationWindow { anchors.margins: 8 Tab { id: controlPage - title: "File Dialog" + title: "File" FileDialogs { } } Tab { - title: "Color Dialog" + title: "Color" ColorDialogs { } } Tab { - title: "Font Dialog" + title: "Font" FontDialogs { anchors.fill: parent } } Tab { - title: "Message Dialog" + title: "Message" MessageDialogs { anchors.fill:parent } } Tab { - title: "Custom Dialogs" + title: "Custom" CustomDialogs { anchors.fill:parent } } } diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index c13fdb6e1..888b0aec2 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -125,7 +125,7 @@ Window { property Item statusBar // The below documentation was supposed to be written as a grouped property, but qdoc would - // not render it correctly due to a bug (https://bugreports.qt-project.org/browse/QTBUG-34206) + // not render it correctly due to a bug (QTBUG-34206) /*! \qmlproperty ContentItem ApplicationWindow::contentItem diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index 68429483c..f2f37a0a5 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -401,8 +401,8 @@ Control { clip: contentWidth > width control: comboBox - cursorHandle: __style ? __style.cursorHandle : undefined - selectionHandle: __style ? __style.selectionHandle : undefined + cursorHandle: __style ? __style.__cursorHandle : undefined + selectionHandle: __style ? __style.__selectionHandle : undefined anchors.fill: parent anchors.leftMargin: __style ? __style.padding.left : 0 diff --git a/src/controls/Private/AbstractCheckable.qml b/src/controls/Private/AbstractCheckable.qml index 1909e05c2..f1dbe9621 100644 --- a/src/controls/Private/AbstractCheckable.qml +++ b/src/controls/Private/AbstractCheckable.qml @@ -148,4 +148,14 @@ Control { clicked(); } } + + Action { + // handle mnemonic + text: abstractCheckable.text + onTriggered: { + if (!abstractCheckable.exclusiveGroup || !abstractCheckable.checked) + abstractCheckable.__cycleStatesHandler(); + abstractCheckable.clicked(); + } + } } diff --git a/src/controls/Private/BasicButton.qml b/src/controls/Private/BasicButton.qml index f482ad72f..f0c9c63ea 100644 --- a/src/controls/Private/BasicButton.qml +++ b/src/controls/Private/BasicButton.qml @@ -152,6 +152,10 @@ Control { id: ownAction iconSource: !button.action || __iconOverriden ? button.iconSource : "" iconName: !button.action || __iconOverriden ? button.iconName : "" + + // let ownAction handle mnemonic if and only if the button does + // not already have an action assigned to avoid ambiguous shortcuts + text: button.action ? "" : button.text } Connections { diff --git a/src/controls/Private/EditMenu.qml b/src/controls/Private/EditMenu.qml index f4d80bd5f..70b6b9b24 100644 --- a/src/controls/Private/EditMenu.qml +++ b/src/controls/Private/EditMenu.qml @@ -49,6 +49,7 @@ Loader { property Flickable flickable property Component defaultMenu: item && item.defaultMenu ? item.defaultMenu : null property Menu menuInstance: null + property MouseArea mouseArea Connections { target: control @@ -69,5 +70,6 @@ Loader { return menuInstance; } - source: Qt.resolvedUrl("EditMenu_" + (Qt.platform.os === "ios" ? "ios" : "base") + ".qml") + source: Qt.resolvedUrl(Qt.platform.os === "ios" ? "EditMenu_ios.qml" + : Qt.platform.os === "android" ? "" : "EditMenu_base.qml") } diff --git a/src/controls/Private/EditMenu_base.qml b/src/controls/Private/EditMenu_base.qml index 597541bc2..3745d9f48 100644 --- a/src/controls/Private/EditMenu_base.qml +++ b/src/controls/Private/EditMenu_base.qml @@ -90,10 +90,8 @@ Item { MenuItem { action: pasteAction.createObject(editMenuBase) } } - MouseArea { - id: mouseArea - anchors.fill: parent - acceptedButtons: Qt.RightButton + Connections { + target: mouseArea onClicked: { if (input.selectionStart === input.selectionEnd) { diff --git a/src/controls/Private/EditMenu_ios.qml b/src/controls/Private/EditMenu_ios.qml index aeb21b03f..44ff7709f 100644 --- a/src/controls/Private/EditMenu_ios.qml +++ b/src/controls/Private/EditMenu_ios.qml @@ -75,7 +75,7 @@ Item { } MenuItem { text: "select" - visible: selectionStart === selectionEnd + visible: selectionStart === selectionEnd && input.length > 0 onTriggered: selectWord(); } MenuItem { @@ -85,9 +85,8 @@ Item { } } - MouseArea { - id: mouseArea - anchors.fill: parent + Connections { + target: mouseArea function clearFocusFromOtherItems() { @@ -115,7 +114,8 @@ Item { onPressAndHold: { var pos = input.positionAt(mouseArea.mouseX, mouseArea.mouseY); input.select(pos, pos); - if (!control.menu || !input.activeFocus || (selectionStart != selectionEnd)) { + var hasSelection = selectionStart != selectionEnd; + if (!control.menu || (input.length > 0 && (!input.activeFocus || hasSelection))) { selectWord(); } else { // We don't select anything at this point, the @@ -170,6 +170,7 @@ Item { return; if ((__showMenuFromTouchAndHold || selectionStart !== selectionEnd) + && control.activeFocus && (!cursorHandle.pressed && !selectionHandle.pressed) && (!flickable || !flickable.moving) && (cursorHandle.delegate)) { diff --git a/src/controls/Private/ScrollBar.qml b/src/controls/Private/ScrollBar.qml index 827504121..3bd0a1640 100644 --- a/src/controls/Private/ScrollBar.qml +++ b/src/controls/Private/ScrollBar.qml @@ -102,7 +102,7 @@ Item { onExited: if (!pressed) __panel.activeControl = "none" onMouseXChanged: if (!pressed) __panel.activeControl = __panel.hitTest(mouseX, mouseY) hoverEnabled: !Settings.hasTouchScreen - enabled: !Settings.hasTouchScreen // TODO: touch on desktop? + enabled: !Settings.isMobile || !Settings.hasTouchScreen // ### Not ideal, but will usually behave as expected... preventStealing: true property var pressedX property var pressedY diff --git a/src/controls/Private/TextHandle.qml b/src/controls/Private/TextHandle.qml index 19fc19a6d..8656dcfd8 100644 --- a/src/controls/Private/TextHandle.qml +++ b/src/controls/Private/TextHandle.qml @@ -75,7 +75,7 @@ Loader { MouseArea { id: mouse anchors.fill: item - enabled: handle.active + enabled: item && item.visible preventStealing: true property real pressX property point offset diff --git a/src/controls/Private/TextInputWithHandles.qml b/src/controls/Private/TextInputWithHandles.qml index f33487743..75ca947f7 100644 --- a/src/controls/Private/TextInputWithHandles.qml +++ b/src/controls/Private/TextInputWithHandles.qml @@ -52,9 +52,9 @@ TextInput { readonly property int selectionPosition: selectionStart !== cursorPosition ? selectionStart : selectionEnd readonly property alias containsMouse: mouseArea.containsMouse property alias editMenu: editMenu - cursorDelegate: __style && __style.cursorDelegate ? __style.cursorDelegate : null + cursorDelegate: __style && __style.__cursorDelegate ? __style.__cursorDelegate : null - selectByMouse: control.selectByMouse && (!cursorHandle.delegate || !selectionHandle.delegate) + selectByMouse: control.selectByMouse && (!Settings.isMobile || !cursorHandle.delegate || !selectionHandle.delegate) // force re-evaluation when selection moves: // - cursorRectangle changes => content scrolled @@ -104,13 +104,17 @@ TextInput { anchors.fill: parent hoverEnabled: true cursorShape: Qt.IBeamCursor - acceptedButtons: input.selectByMouse ? Qt.NoButton : Qt.LeftButton + acceptedButtons: (input.selectByMouse ? Qt.NoButton : Qt.LeftButton) | (control.menu ? Qt.RightButton : Qt.NoButton) onClicked: { + if (editMenu.item) + return; var pos = input.positionAt(mouse.x, mouse.y) input.moveHandles(pos, pos) input.activate() } onPressAndHold: { + if (editMenu.item) + return; var pos = input.positionAt(mouse.x, mouse.y) input.moveHandles(pos, control.selectByMouse ? -1 : pos) input.activate() @@ -120,6 +124,7 @@ TextInput { EditMenu { id: editMenu input: parent + mouseArea: mouseArea control: parent.control cursorHandle: cursorHandle selectionHandle: selectionHandle @@ -132,7 +137,7 @@ TextInput { editor: input parent: control control: input.control - active: control.selectByMouse + active: control.selectByMouse && Settings.isMobile maximum: cursorHandle.position - 1 property var mappedPos: parent.mapFromItem(editor, editor.selectionRectangle.x, editor.selectionRectangle.y) @@ -158,15 +163,14 @@ TextInput { editor: input parent: control control: input.control - active: control.selectByMouse - delegate: style.cursorHandle + active: control.selectByMouse && Settings.isMobile minimum: input.hasSelection ? selectionHandle.position + 1 : -1 property var mappedPos: parent.mapFromItem(editor, editor.cursorRectangle.x, editor.cursorRectangle.y) x: mappedPos.x y: mappedPos.y - visible: pressed || (input.hasSelection && handleX + handleWidth >= -1 && handleX <= control.width + 1) + visible: pressed || ((input.cursorVisible || input.hasSelection) && handleX + handleWidth >= -1 && handleX <= control.width + 1) onPositionChanged: { if (!input.blockRecursion) { diff --git a/src/controls/Private/qquickcontrolsettings.cpp b/src/controls/Private/qquickcontrolsettings.cpp index bd02b87d8..b73a7d43a 100644 --- a/src/controls/Private/qquickcontrolsettings.cpp +++ b/src/controls/Private/qquickcontrolsettings.cpp @@ -35,10 +35,14 @@ #include <qquickitem.h> #include <qcoreapplication.h> #include <qqmlengine.h> +#include <qlibrary.h> #include <qdir.h> #include <QTouchDevice> #include <QGuiApplication> #include <QStyleHints> +#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) +#include <private/qjnihelpers_p.h> +#endif QT_BEGIN_NAMESPACE @@ -49,7 +53,8 @@ static QString defaultStyleName() if (QCoreApplication::instance()->inherits("QApplication")) return QLatin1String("Desktop"); #elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK) - return QLatin1String("Android"); + if (QtAndroidPrivate::androidSdkVersion() >= 11) + return QLatin1String("Android"); #elif defined(Q_OS_IOS) return QLatin1String("iOS"); #elif defined(Q_OS_WINRT) @@ -126,11 +131,29 @@ QQuickControlSettings::QQuickControlSettings(QQmlEngine *engine) QString path = styleFilePath(); - if (!QDir(path).exists()) { + QDir dir(path); + if (!dir.exists()) { QString unknownStyle = m_name; m_name = defaultStyleName(); m_path = styleImportPath(engine, m_name); qWarning() << "WARNING: Cannot find style" << unknownStyle << "- fallback:" << styleFilePath(); + } else { + typedef bool (*StyleInitFunc)(); + typedef const char *(*StylePathFunc)(); + + foreach (const QString &fileName, dir.entryList()) { + if (QLibrary::isLibrary(fileName)) { + QLibrary lib(dir.absoluteFilePath(fileName)); + StyleInitFunc initFunc = (StyleInitFunc) lib.resolve("qt_quick_controls_style_init"); + if (initFunc) + initFunc(); + StylePathFunc pathFunc = (StylePathFunc) lib.resolve("qt_quick_controls_style_path"); + if (pathFunc) + m_path = QString::fromLocal8Bit(pathFunc()); + if (initFunc || pathFunc) + break; + } + } } connect(this, SIGNAL(styleNameChanged()), SIGNAL(styleChanged())); diff --git a/src/controls/Private/qquickspinboxvalidator.cpp b/src/controls/Private/qquickspinboxvalidator.cpp index afbc866c8..2fec79e82 100644 --- a/src/controls/Private/qquickspinboxvalidator.cpp +++ b/src/controls/Private/qquickspinboxvalidator.cpp @@ -200,7 +200,9 @@ QValidator::State QQuickSpinBoxValidator::validate(QString &input, int &pos) con bool ok = false; qreal val = locale().toDouble(value, &ok); if (ok) { - if (state == QValidator::Acceptable) { + if (state == QValidator::Acceptable || + (state == QValidator::Intermediate && val >= 0 && val <= m_validator.top()) || + (state == QValidator::Intermediate && val < 0 && val >= m_validator.bottom())) { const_cast<QQuickSpinBoxValidator *>(this)->setValue(val); if (input != textFromValue(val)) state = QValidator::Intermediate; diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp index edb33212e..fb49e6e3f 100644 --- a/src/controls/Private/qquickstyleitem.cpp +++ b/src/controls/Private/qquickstyleitem.cpp @@ -354,6 +354,8 @@ void QQuickStyleItem::initStyleOption() opt->features = QStyleOptionViewItem::HasDisplay; opt->text = text(); opt->textElideMode = Qt::ElideRight; + opt->displayAlignment = Qt::AlignLeft | Qt::AlignVCenter; + opt->decorationAlignment = Qt::AlignCenter; resolvePalette(); needsResolvePalette = false; QPalette pal = m_styleoption->palette; diff --git a/src/controls/Private/qquicktooltip.cpp b/src/controls/Private/qquicktooltip.cpp index b93b4a534..6f81b5b82 100644 --- a/src/controls/Private/qquicktooltip.cpp +++ b/src/controls/Private/qquicktooltip.cpp @@ -36,7 +36,7 @@ #include <qquickitem.h> #include <private/qguiapplication_p.h> #include <qpa/qplatformintegration.h> -#include <QtQuick/private/qquickrendercontrol_p.h> +#include <QtQuick/QQuickRenderControl> #ifdef QT_WIDGETS_LIB #include <qtooltip.h> diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml index 94653bf82..d0644b4cc 100644 --- a/src/controls/Slider.qml +++ b/src/controls/Slider.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -61,7 +61,7 @@ import QtQuick.Controls.Private 1.0 } \endcode - The Slider value is by default in the range [0, 1]. If integer values are + The slider value is by default in the range [0, 1]. If integer values are needed, you can set the \l stepSize. You can create a custom appearance for a Slider by @@ -82,7 +82,7 @@ Control { /*! \qmlproperty real Slider::minimumValue - This property holds the minimum value of the Slider. + This property holds the minimum value of the slider. The default value is \c{0.0}. */ property alias minimumValue: range.minimumValue @@ -90,7 +90,7 @@ Control { /*! \qmlproperty real Slider::maximumValue - This property holds the maximum value of the Slider + This property holds the maximum value of the slider. The default value is \c{1.0}. */ property alias maximumValue: range.maximumValue @@ -117,9 +117,9 @@ Control { /*! \qmlproperty bool Slider::hovered - This property indicates whether the control is being hovered. + This property indicates whether the slider handle is being hovered. */ - readonly property alias hovered: mouseArea.containsMouse + readonly property alias hovered: mouseArea.handleHovered /*! \qmlproperty real Slider::stepSize @@ -146,7 +146,7 @@ Control { /*! \qmlproperty real Slider::value - This property holds the current value of the Slider. + This property holds the current value of the slider. The default value is \c{0.0}. */ property alias value: range.value @@ -154,7 +154,7 @@ Control { /*! \qmlproperty bool Slider::activeFocusOnPress - This property indicates whether the Slider should receive active focus when + This property indicates whether the slider should receive active focus when pressed. */ property bool activeFocusOnPress: false @@ -162,11 +162,13 @@ Control { /*! \qmlproperty bool Slider::tickmarksEnabled - This property indicates whether the Slider should display tickmarks + This property indicates whether the slider should display tickmarks at step intervals. Tick mark spacing is calculated based on the \l stepSize property. The default value is \c false. + + \note This property may be ignored on some platforms when using the native style (e.g. Android). */ property bool tickmarksEnabled: false @@ -231,46 +233,54 @@ Control { property int clickOffset: 0 property real pressX: 0 property real pressY: 0 + property bool handleHovered: false function clamp ( val ) { return Math.max(range.positionAtMinimum, Math.min(range.positionAtMaximum, val)) } - onMouseXChanged: { - if (pressed && __horizontal) { - var pos = clamp (mouse.x + clickOffset - fakeHandle.width/2) - var overThreshold = Math.abs(mouse.x - pressX) >= Settings.dragThreshold + function updateHandlePosition(mouse, force) { + var pos, overThreshold + if (__horizontal) { + pos = clamp (mouse.x + clickOffset - fakeHandle.width/2) + overThreshold = Math.abs(mouse.x - pressX) >= Settings.dragThreshold if (overThreshold) preventStealing = true - if (overThreshold || !Settings.hasTouchScreen) + if (overThreshold || force) fakeHandle.x = pos - } - } - - onMouseYChanged: { - if (pressed && !__horizontal) { - var pos = clamp (mouse.y + clickOffset- fakeHandle.height/2) - var overThreshold = Math.abs(mouse.y - pressY) >= Settings.dragThreshold + } else if (!__horizontal) { + pos = clamp (mouse.y + clickOffset- fakeHandle.height/2) + overThreshold = Math.abs(mouse.y - pressY) >= Settings.dragThreshold if (overThreshold) preventStealing = true - if (overThreshold || !Settings.hasTouchScreen) + if (overThreshold || force) fakeHandle.y = pos } } + onPositionChanged: { + if (pressed) + updateHandlePosition(mouse, preventStealing) + + var point = mouseArea.mapToItem(fakeHandle, mouse.x, mouse.y) + handleHovered = fakeHandle.contains(Qt.point(point.x, point.y)) + } + onPressed: { if (slider.activeFocusOnPress) slider.forceActiveFocus(); - var point = mouseArea.mapToItem(fakeHandle, mouse.x, mouse.y) - if (fakeHandle.contains(Qt.point(point.x, point.y))) { + if (handleHovered) { + var point = mouseArea.mapToItem(fakeHandle, mouse.x, mouse.y) clickOffset = __horizontal ? fakeHandle.width/2 - point.x : fakeHandle.height/2 - point.y } pressX = mouse.x pressY = mouse.y + updateHandlePosition(mouse, !Settings.hasTouchScreen) } onReleased: { + updateHandlePosition(mouse, Settings.hasTouchScreen) // If we don't update while dragging, this is the only // moment that the range is updated. if (!slider.updateValueWhileDragging) @@ -278,6 +288,8 @@ Control { clickOffset = 0 preventStealing = false } + + onExited: handleHovered = false } diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index f13e81dc4..66a210274 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -291,8 +291,8 @@ Control { anchors.bottomMargin: __style ? __style.padding.bottom: 0 control: spinbox - cursorHandle: __style ? __style.cursorHandle : undefined - selectionHandle: __style ? __style.selectionHandle : undefined + cursorHandle: __style ? __style.__cursorHandle : undefined + selectionHandle: __style ? __style.__selectionHandle : undefined focus: true activeFocusOnPress: spinbox.activeFocusOnPress diff --git a/src/controls/StackView.qml b/src/controls/StackView.qml index 4423a02ff..f6608ecaa 100644 --- a/src/controls/StackView.qml +++ b/src/controls/StackView.qml @@ -473,7 +473,7 @@ import QtQuick.Controls.Private 1.0 \endlist */ -Item { +FocusScope { id: root /*! \qmlproperty int StackView::depth diff --git a/src/controls/Styles/Android/ButtonStyle.qml b/src/controls/Styles/Android/ButtonStyle.qml index 2a1080513..7157affe0 100644 --- a/src/controls/Styles/Android/ButtonStyle.qml +++ b/src/controls/Styles/Android/ButtonStyle.qml @@ -93,7 +93,7 @@ Style { LabelStyle { id: label visible: !!text - text: control.text + text: StyleHelpers.removeMnemonics(control.text) pressed: control.pressed focused: control.activeFocus selected: control.checked diff --git a/src/controls/Styles/Android/CheckBoxStyle.qml b/src/controls/Styles/Android/CheckBoxStyle.qml index 908665d01..3983a868e 100644 --- a/src/controls/Styles/Android/CheckBoxStyle.qml +++ b/src/controls/Styles/Android/CheckBoxStyle.qml @@ -70,7 +70,7 @@ Style { LabelStyle { id: label - text: control.text + text: StyleHelpers.removeMnemonics(control.text) pressed: control.pressed focused: control.activeFocus selected: control.checked diff --git a/src/controls/Styles/Android/ComboBoxStyle.qml b/src/controls/Styles/Android/ComboBoxStyle.qml index 715dd9f69..366deed56 100644 --- a/src/controls/Styles/Android/ComboBoxStyle.qml +++ b/src/controls/Styles/Android/ComboBoxStyle.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.2 +import QtQuick 2.4 import QtQuick.Window 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Private 1.0 @@ -70,7 +70,7 @@ Style { readonly property real minWidth: styleDef.View_minWidth || 0 readonly property real minHeight: styleDef.View_minHeight || 0 - readonly property real labelWidth: label.implicitWidth + paddingStart + paddingEnd + readonly property real labelWidth: Math.max(label.implicitWidth, metrics.width) + paddingStart + paddingEnd readonly property real labelHeight: label.implicitHeight + bg.padding.top + bg.padding.bottom implicitWidth: Math.max(minWidth, Math.max(bg.implicitWidth, labelWidth)) @@ -85,6 +85,11 @@ Style { styleDef: panel.styleDef.View_background } + TextMetrics { + id: metrics + text: "12345678901234567890" + } + LabelStyle { id: label text: control.currentText @@ -105,11 +110,11 @@ Style { property Component __popupStyle: null property Component __dropDownStyle: null - property Component selectionHandle: DrawableLoader { + property Component __selectionHandle: DrawableLoader { styleDef: AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandleLeft x: -width / 4 * 3 y: styleData.lineHeight } - property Component cursorHandle: CursorHandleStyle { } + property Component __cursorHandle: CursorHandleStyle { } } diff --git a/src/controls/Styles/Android/CursorHandleStyle.qml b/src/controls/Styles/Android/CursorHandleStyle.qml index 97b9fe857..e9d08f8e6 100644 --- a/src/controls/Styles/Android/CursorHandleStyle.qml +++ b/src/controls/Styles/Android/CursorHandleStyle.qml @@ -45,66 +45,51 @@ import "drawables" DrawableLoader { id: delegate - property bool active: false + + property bool hasText: !!editor.text || !!editor.displayText + styleDef: styleData.hasSelection ? AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandleRight : AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandle x: styleData.hasSelection ? -width / 4 : -width / 2 y: styleData.lineHeight - opacity: 1.0 pressed: styleData.pressed focused: control.activeFocus window_focused: focused && control.Window.active - Connections { - target: editor - ignoreUnknownSignals: true - onDisplayTextChanged: { - delegate.state = "hidden" - } + opacity: hasText && (styleData.hasSelection || styleData.pressed || idle.running) ? 1.0 : 0.0 + + Timer { + id: idle + repeat: false + interval: 4000 } Connections { target: styleData - onActivated: { - if (editor.text) { - delegate.active = true - delegate.opacity = 1.0 - delegate.state = "" - if (!styleData.hasSelection) - delegate.state = "idle" - } + onActivated: idle.restart() + onPressedChanged: { + if (!styleData.pressed) + idle.restart() } } - state: "hidden" - - states: [ - State { - name: "hidden" - when: editor.inputMethodComposing && !delegate.active && !editor.text - }, - State { - name: "idle" - when: !styleData.hasSelection && !styleData.pressed - } - ] + // Hide the cursor handle on textual changes, unless the signals are + // indirectly triggered by activating/tapping/moving the handle. When + // text prediction is enabled, the textual content may change when the + // cursor moves and the predicted text is committed. + Connections { + target: editor + ignoreUnknownSignals: true + onTextChanged: if (!ignore.running) idle.stop() + onDisplayTextChanged: if (!ignore.running) idle.stop() + onInputMethodComposing: if (!ignore.running) idle.stop() + } - transitions: [ - Transition { - to: "hidden" - SequentialAnimation { - PauseAnimation { duration: 100 } - PropertyAction { target: delegate; property: "opacity"; value: 0.0 } - } - }, - Transition { - to: "idle" - SequentialAnimation { - PauseAnimation { duration: 4000 } - NumberAnimation { target: delegate; property: "opacity"; to: 0.0 } - PropertyAction { target: delegate; property: "active"; value: false } - } - } - ] + Timer { + id: ignore + repeat: false + interval: 250 + running: idle.running + } } diff --git a/src/controls/Styles/Android/GroupBoxStyle.qml b/src/controls/Styles/Android/GroupBoxStyle.qml index b7346ea43..d8f1127b6 100644 --- a/src/controls/Styles/Android/GroupBoxStyle.qml +++ b/src/controls/Styles/Android/GroupBoxStyle.qml @@ -53,7 +53,7 @@ GroupBoxStyle { readonly property var styleDef: AndroidStyle.styleDef.checkboxStyle readonly property real contentMargin: label.implicitHeight / 3 - readonly property real topMargin: indicator.height + readonly property real topMargin: control.checkable ? indicator.height : label.height Binding { target: root; property: "padding.top"; value: topMargin + contentMargin } Binding { target: root; property: "padding.left"; value: contentMargin } Binding { target: root; property: "padding.right"; value: contentMargin } @@ -95,14 +95,15 @@ GroupBoxStyle { DrawableLoader { id: indicator - visible: control.checkable + active: control.checkable checked: control.checked pressed: check.pressed focused: check.activeFocus window_focused: control.Window.active styleDef: AndroidStyle.styleDef.checkboxStyle.CompoundButton_button - anchors.verticalCenter: label.verticalCenter width: control.checkable ? item.implicitWidth : 0 + anchors.verticalCenter: parent.top + anchors.verticalCenterOffset: topMargin / 2 } LabelStyle { @@ -114,9 +115,10 @@ GroupBoxStyle { window_focused: control.Window.active styleDef: AndroidStyle.styleDef.checkboxStyle - anchors.top: parent.top anchors.left: indicator.right anchors.right: parent.right + anchors.verticalCenter: parent.top + anchors.verticalCenterOffset: topMargin / 2 } } } diff --git a/src/controls/Styles/Android/RadioButtonStyle.qml b/src/controls/Styles/Android/RadioButtonStyle.qml index 76b2c9b7c..678fcdc3d 100644 --- a/src/controls/Styles/Android/RadioButtonStyle.qml +++ b/src/controls/Styles/Android/RadioButtonStyle.qml @@ -70,7 +70,7 @@ Style { LabelStyle { id: label - text: control.text + text: StyleHelpers.removeMnemonics(control.text) pressed: control.pressed focused: control.activeFocus selected: control.checked diff --git a/src/controls/Styles/Android/SpinBoxStyle.qml b/src/controls/Styles/Android/SpinBoxStyle.qml index 86fce0349..0e5df3fd0 100644 --- a/src/controls/Styles/Android/SpinBoxStyle.qml +++ b/src/controls/Styles/Android/SpinBoxStyle.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.2 +import QtQuick 2.4 import QtQuick.Window 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Private 1.0 @@ -58,7 +58,7 @@ Style { readonly property real contentWidth: Math.max(styleDef.View_minWidth || 0, styleData.contentWidth) readonly property real contentHeight: Math.max(styleDef.View_minHeight || 0, styleData.contentHeight) - readonly property real labelWidth: label.implicitWidth + bg.padding.left + bg.padding.right + readonly property real labelWidth: Math.max(label.implicitWidth, metrics.width) + bg.padding.left + bg.padding.right readonly property real labelHeight: label.implicitHeight + bg.padding.top + bg.padding.bottom implicitWidth: Math.max(contentWidth, Math.max(bg.implicitWidth, labelWidth)) @@ -88,6 +88,11 @@ Style { readonly property int horizontalAlignment: Qt.AlignLeft readonly property int verticalAlignment: Qt.AlignVCenter + TextMetrics { + id: metrics + text: "12345678901234567890" + } + LabelStyle { id: label visible: false @@ -98,11 +103,11 @@ Style { } } - property Component selectionHandle: DrawableLoader { + property Component __selectionHandle: DrawableLoader { styleDef: AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandleLeft x: -width / 4 * 3 y: styleData.lineHeight } - property Component cursorHandle: CursorHandleStyle { } + property Component __cursorHandle: CursorHandleStyle { } } diff --git a/src/controls/Styles/Android/SwitchStyle.qml b/src/controls/Styles/Android/SwitchStyle.qml index 4c36c918e..6e9260c35 100644 --- a/src/controls/Styles/Android/SwitchStyle.qml +++ b/src/controls/Styles/Android/SwitchStyle.qml @@ -79,18 +79,26 @@ SwitchStyle { Item { id: thumb + readonly property bool hideText: AndroidStyle.styleDef.switchStyle.Switch_showText === false + x: control.checked ? max : min - FontMetrics { - id: metrics + TextMetrics { + id: onMetrics + font: label.font + text: panel.styleDef.Switch_textOn + } + + TextMetrics { + id: offMetrics font: label.font + text: panel.styleDef.Switch_textOff } - readonly property real maxTextWidth: Math.max(metrics.boundingRect(panel.styleDef.Switch_textOn).width, - metrics.boundingRect(panel.styleDef.Switch_textOff).width) + readonly property real maxTextWidth: Math.max(onMetrics.width, offMetrics.width) implicitWidth: Math.max(loader.implicitWidth, maxTextWidth + 2 * panel.styleDef.Switch_thumbTextPadding) - implicitHeight: Math.max(loader.implicitHeight, metrics.height) + implicitHeight: Math.max(loader.implicitHeight, onMetrics.height, offMetrics.height) anchors.top: parent.top anchors.bottom: parent.bottom @@ -120,6 +128,7 @@ SwitchStyle { LabelStyle { id: label + visible: !thumb.hideText text: control.checked ? panel.styleDef.Switch_textOn : panel.styleDef.Switch_textOff pressed: control.pressed diff --git a/src/controls/Styles/Android/TextAreaStyle.qml b/src/controls/Styles/Android/TextAreaStyle.qml index 61ea9fb85..85950efa0 100644 --- a/src/controls/Styles/Android/TextAreaStyle.qml +++ b/src/controls/Styles/Android/TextAreaStyle.qml @@ -72,11 +72,11 @@ ScrollViewStyle { styleDef: style.styleDef } - property Component selectionHandle: DrawableLoader { + property Component __selectionHandle: DrawableLoader { styleDef: AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandleLeft x: -width / 4 * 3 y: styleData.lineHeight } - property Component cursorHandle: CursorHandleStyle { } + property Component __cursorHandle: CursorHandleStyle { } } diff --git a/src/controls/Styles/Android/TextFieldStyle.qml b/src/controls/Styles/Android/TextFieldStyle.qml index e7eec32c6..0edc5c90b 100644 --- a/src/controls/Styles/Android/TextFieldStyle.qml +++ b/src/controls/Styles/Android/TextFieldStyle.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.2 +import QtQuick 2.4 import QtQuick.Window 2.2 import QtQuick.Controls 1.2 import QtQuick.Controls.Private 1.0 @@ -56,7 +56,7 @@ Style { readonly property real minWidth: styleDef.View_minWidth || 0 readonly property real minHeight: styleDef.View_minHeight || 0 - readonly property real labelWidth: label.implicitWidth + bg.padding.left + bg.padding.right + readonly property real labelWidth: Math.max(label.implicitWidth, metrics.width) + bg.padding.left + bg.padding.right readonly property real labelHeight: label.implicitHeight + bg.padding.top + bg.padding.bottom implicitWidth: Math.max(minWidth, Math.max(bg.implicitWidth, labelWidth)) @@ -81,21 +81,26 @@ Style { readonly property alias selectionColor: label.selectionColor readonly property color selectedTextColor: label.selectedTextColor + TextMetrics { + id: metrics + text: "12345678901234567890" + } + LabelStyle { id: label visible: false - text: control.text + text: control.text || control.placeholderText focused: control.activeFocus window_focused: focused && control.Window.active styleDef: panel.styleDef } } - property Component selectionHandle: DrawableLoader { + property Component __selectionHandle: DrawableLoader { styleDef: AndroidStyle.styleDef.textViewStyle.TextView_textSelectHandleLeft x: -width / 4 * 3 y: styleData.lineHeight } - property Component cursorHandle: CursorHandleStyle { } + property Component __cursorHandle: CursorHandleStyle { } } diff --git a/src/controls/Styles/Android/ToolButtonStyle.qml b/src/controls/Styles/Android/ToolButtonStyle.qml index 33d922207..9dbe60f77 100644 --- a/src/controls/Styles/Android/ToolButtonStyle.qml +++ b/src/controls/Styles/Android/ToolButtonStyle.qml @@ -95,7 +95,7 @@ Style { LabelStyle { id: label visible: !!text - text: control.text + text: StyleHelpers.removeMnemonics(control.text) pressed: control.pressed focused: control.activeFocus selected: control.checked diff --git a/src/controls/Styles/Android/drawables/AnimationDrawable.qml b/src/controls/Styles/Android/drawables/AnimationDrawable.qml index a522bfa7c..12d576ff4 100644 --- a/src/controls/Styles/Android/drawables/AnimationDrawable.qml +++ b/src/controls/Styles/Android/drawables/AnimationDrawable.qml @@ -49,14 +49,17 @@ Drawable { property int currentFrame: 0 readonly property int frameCount: styleDef.frames ? styleDef.frames.length : 0 readonly property var frameDef: styleDef.frames ? styleDef.frames[currentFrame] : undefined + readonly property alias running: timer.running + property bool oneshot: styleDef.oneshot Timer { + id: timer repeat: true running: root.frameCount && root.visible && Qt.application.active interval: root.frameDef ? root.frameDef.duration : 0 onTriggered: { var frame = root.currentFrame + 1 - repeat = !root.styleDef.oneshot || frame < root.frameCount - 1 + repeat = !root.oneshot || frame < root.frameCount - 1 root.currentFrame = frame % root.frameCount } } diff --git a/src/controls/Styles/Android/drawables/ImageDrawable.qml b/src/controls/Styles/Android/drawables/ImageDrawable.qml index 1e71a389a..4b41b2f21 100644 --- a/src/controls/Styles/Android/drawables/ImageDrawable.qml +++ b/src/controls/Styles/Android/drawables/ImageDrawable.qml @@ -52,5 +52,33 @@ Drawable { anchors.fill: parent fillMode: Image.TileHorizontally source: AndroidStyle.filePath(styleDef.path) + + layer.enabled: !!styleDef && !!styleDef.tintList + layer.effect: ShaderEffect { + property variant source: image + property color color: AndroidStyle.colorValue(styleDef.tintList[state]) + state: { + var states = [] + if (pressed) states.push("PRESSED") + if (enabled) states.push("ENABLED") + if (focused) states.push("FOCUSED") + if (selected) states.push("SELECTED") + if (window_focused) states.push("WINDOW_FOCUSED") + if (!states.length) + states.push("EMPTY") + return states.join("_") + "_STATE_SET" + } + // QtGraphicalEffects/ColorOverlay: + fragmentShader: " + varying mediump vec2 qt_TexCoord0; + uniform highp float qt_Opacity; + uniform lowp sampler2D source; + uniform highp vec4 color; + void main() { + highp vec4 pixelColor = texture2D(source, qt_TexCoord0); + gl_FragColor = vec4(mix(pixelColor.rgb/max(pixelColor.a, 0.00390625), color.rgb/max(color.a, 0.00390625), color.a) * pixelColor.a, pixelColor.a) * qt_Opacity; + } + " + } } } diff --git a/src/controls/Styles/Android/drawables/StateDrawable.qml b/src/controls/Styles/Android/drawables/StateDrawable.qml index d446542d9..862ab9ae6 100644 --- a/src/controls/Styles/Android/drawables/StateDrawable.qml +++ b/src/controls/Styles/Android/drawables/StateDrawable.qml @@ -46,10 +46,12 @@ Drawable { implicitWidth: Math.max(loader.implicitWidth, styleDef.width || 0) implicitHeight: Math.max(loader.implicitHeight, styleDef.height || 0) + property int prevMatch: 0 + DrawableLoader { id: loader anchors.fill: parent - styleDef: bestStateMatch() + visible: !animation.active focused: root.focused pressed: root.pressed checked: root.checked @@ -65,17 +67,70 @@ Drawable { clippables: root.clippables } - function bestStateMatch () { + Loader { + id: animation + property var animDef + active: false + anchors.fill: parent + sourceComponent: AnimationDrawable { + anchors.fill: parent + styleDef: animDef + focused: root.focused + pressed: root.pressed + checked: root.checked + selected: root.selected + accelerated: root.accelerated + window_focused: root.window_focused + index: root.index + level: root.level + levelId: root.levelId + orientations: root.orientations + duration: root.duration + excludes: root.excludes + clippables: root.clippables + + oneshot: true + onRunningChanged: if (!running) animation.active = false + } + } + + onStyleDefChanged: resolveState() + Component.onCompleted: resolveState() + + // In order to be able to find appropriate transition paths between + // various states, the following states must be allowed to change in + // batches. For example, button-like controls could have a transition + // path from pressed+checked to unpressed+unchecked. We must let both + // properties change before we try to find the transition path. + onEnabledChanged: resolver.start() + onFocusedChanged: resolver.start() + onPressedChanged: resolver.start() + onCheckedChanged: resolver.start() + onSelectedChanged: resolver.start() + onAcceleratedChanged: resolver.start() + onWindow_focusedChanged: resolver.start() + + Timer { + id: resolver + interval: 15 + onTriggered: resolveState() + } + + function resolveState () { if (styleDef && styleDef.stateslist) { var bestMatch = 0 var highestScore = -1 var stateslist = styleDef.stateslist + var transitions = [] for (var i = 0; i < stateslist.length; ++i) { var score = 0 var state = stateslist[i] + if (state.transition) + transitions.push(i) + for (var s in state.states) { if (s === "pressed") score += (pressed === state.states[s]) ? 1 : -10 @@ -98,8 +153,21 @@ Drawable { highestScore = score } } - return stateslist[bestMatch].drawable + + if (prevMatch != bestMatch) { + for (var t = 0; t < transitions.length; ++t) { + var transition = stateslist[transitions[t]].transition + if ((transition.from == prevMatch && transition.to == bestMatch) || + (transition.reverse && transition.from == bestMatch && transition.to == prevMatch)) { + animation.animDef = stateslist[transitions[t]].drawable + animation.active = true + break + } + } + prevMatch = bestMatch + } + + loader.styleDef = stateslist[bestMatch].drawable } - return undefined } } diff --git a/src/controls/Styles/Base/ButtonStyle.qml b/src/controls/Styles/Base/ButtonStyle.qml index 54576b7fd..9b55d26d7 100644 --- a/src/controls/Styles/Base/ButtonStyle.qml +++ b/src/controls/Styles/Base/ButtonStyle.qml @@ -143,7 +143,7 @@ Style { id: text renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering anchors.verticalCenter: parent.verticalCenter - text: control.text + text: StyleHelpers.stylizeMnemonics(control.text) color: SystemPaletteSingleton.buttonText(control.enabled) } } diff --git a/src/controls/Styles/Base/CheckBoxStyle.qml b/src/controls/Styles/Base/CheckBoxStyle.qml index a23c77210..6fbdaede6 100644 --- a/src/controls/Styles/Base/CheckBoxStyle.qml +++ b/src/controls/Styles/Base/CheckBoxStyle.qml @@ -98,7 +98,7 @@ Style { } Text { id: text - text: control.text + text: StyleHelpers.stylizeMnemonics(control.text) anchors.centerIn: parent color: SystemPaletteSingleton.text(control.enabled) renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering diff --git a/src/controls/Styles/Base/ComboBoxStyle.qml b/src/controls/Styles/Base/ComboBoxStyle.qml index 77d2e91e1..1a810772a 100644 --- a/src/controls/Styles/Base/ComboBoxStyle.qml +++ b/src/controls/Styles/Base/ComboBoxStyle.qml @@ -280,7 +280,8 @@ Style { property Component __scrollerStyle: null } - /*! The cursor handle. + /*! \internal + The cursor handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -297,9 +298,10 @@ Style { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component cursorHandle + property Component __cursorHandle - /*! The selection handle. + /*! \internal + The selection handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -316,10 +318,11 @@ Style { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component selectionHandle + property Component __selectionHandle - /*! The cursor delegate. + /*! \internal + The cursor delegate. \since QtQuick.Controls.Styles 1.3 */ - property Component cursorDelegate + property Component __cursorDelegate } diff --git a/src/controls/Styles/Base/RadioButtonStyle.qml b/src/controls/Styles/Base/RadioButtonStyle.qml index 8f70d854c..7975de701 100644 --- a/src/controls/Styles/Base/RadioButtonStyle.qml +++ b/src/controls/Styles/Base/RadioButtonStyle.qml @@ -97,7 +97,7 @@ Style { } Text { id: text - text: control.text + text: StyleHelpers.stylizeMnemonics(control.text) anchors.centerIn: parent color: SystemPaletteSingleton.text(control.enabled) renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering diff --git a/src/controls/Styles/Base/SpinBoxStyle.qml b/src/controls/Styles/Base/SpinBoxStyle.qml index 1bcb6b5cf..d821940a5 100644 --- a/src/controls/Styles/Base/SpinBoxStyle.qml +++ b/src/controls/Styles/Base/SpinBoxStyle.qml @@ -210,7 +210,8 @@ Style { } } - /*! The cursor handle. + /*! \internal + The cursor handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -227,9 +228,10 @@ Style { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component cursorHandle + property Component __cursorHandle - /*! The selection handle. + /*! \internal + The selection handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -246,10 +248,11 @@ Style { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component selectionHandle + property Component __selectionHandle - /*! The cursor delegate. + /*! \internal + The cursor delegate. \since QtQuick.Controls.Styles 1.3 */ - property Component cursorDelegate + property Component __cursorDelegate } diff --git a/src/controls/Styles/Base/TableViewStyle.qml b/src/controls/Styles/Base/TableViewStyle.qml index ca4cc4288..e5e6db2fd 100644 --- a/src/controls/Styles/Base/TableViewStyle.qml +++ b/src/controls/Styles/Base/TableViewStyle.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -110,7 +110,7 @@ ScrollViewStyle { */ property Component rowDelegate: Rectangle { height: Math.round(TextSingleton.implicitHeight * 1.2) - property color selectedColor: styleData.hasActiveFocus ? "#07c" : "#999" + property color selectedColor: control.activeFocus ? "#07c" : "#999" color: styleData.selected ? selectedColor : !styleData.alternate ? alternateBackgroundColor : backgroundColor } diff --git a/src/controls/Styles/Base/TextAreaStyle.qml b/src/controls/Styles/Base/TextAreaStyle.qml index bd3ed31ea..56a1ec58f 100644 --- a/src/controls/Styles/Base/TextAreaStyle.qml +++ b/src/controls/Styles/Base/TextAreaStyle.qml @@ -104,7 +104,8 @@ ScrollViewStyle { \sa TextArea::textMargin */ property real textMargin: 4 - /*! The cursor handle. + /*! \internal + The cursor handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -121,9 +122,10 @@ ScrollViewStyle { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component cursorHandle + property Component __cursorHandle - /*! The selection handle. + /*! \internal + The selection handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -140,10 +142,11 @@ ScrollViewStyle { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component selectionHandle + property Component __selectionHandle - /*! The cursor delegate. + /*! \internal + The cursor delegate. \since QtQuick.Controls.Styles 1.3 */ - property Component cursorDelegate + property Component __cursorDelegate } diff --git a/src/controls/Styles/Base/TextFieldStyle.qml b/src/controls/Styles/Base/TextFieldStyle.qml index c1e7a69f6..4d0a66eba 100644 --- a/src/controls/Styles/Base/TextFieldStyle.qml +++ b/src/controls/Styles/Base/TextFieldStyle.qml @@ -157,7 +157,8 @@ Style { } } - /*! The cursor handle. + /*! \internal + The cursor handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -174,9 +175,10 @@ Style { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component cursorHandle + property Component __cursorHandle - /*! The selection handle. + /*! \internal + The selection handle. \since QtQuick.Controls.Styles 1.3 The parent of the handle is positioned to the top left corner of @@ -193,10 +195,11 @@ Style { \row \li \b {styleData.hasSelection} : bool \li Whether the editor has selected text. \endtable */ - property Component selectionHandle + property Component __selectionHandle - /*! The cursor delegate. + /*! \internal + The cursor delegate. \since QtQuick.Controls.Styles 1.3 */ - property Component cursorDelegate + property Component __cursorDelegate } diff --git a/src/controls/Styles/Base/ToolButtonStyle.qml b/src/controls/Styles/Base/ToolButtonStyle.qml index 364b1b31e..7183623fd 100644 --- a/src/controls/Styles/Base/ToolButtonStyle.qml +++ b/src/controls/Styles/Base/ToolButtonStyle.qml @@ -74,7 +74,7 @@ Style { id: label visible: !hasIcon anchors.centerIn: parent - text: control.text + text: StyleHelpers.stylizeMnemonics(control.text) renderType: Settings.isMobile ? Text.QtRendering : Text.NativeRendering } Image { diff --git a/src/controls/Styles/Desktop/ComboBoxStyle.qml b/src/controls/Styles/Desktop/ComboBoxStyle.qml index d897a2a45..758518edc 100644 --- a/src/controls/Styles/Desktop/ComboBoxStyle.qml +++ b/src/controls/Styles/Desktop/ComboBoxStyle.qml @@ -109,8 +109,8 @@ Style { elementType: "itemrow" selected: styleData.selected - implicitWidth: textItem.contentWidth - implicitHeight: textItem.contentHeight + implicitWidth: textItem.implicitWidth + implicitHeight: textItem.implicitHeight StyleItem { id: textItem diff --git a/src/controls/Styles/Desktop/MenuStyle.qml b/src/controls/Styles/Desktop/MenuStyle.qml index ecd898cfc..1c21f8c41 100644 --- a/src/controls/Styles/Desktop/MenuStyle.qml +++ b/src/controls/Styles/Desktop/MenuStyle.qml @@ -100,7 +100,7 @@ Style { selected: styleData.selected on: styleData.checkable && styleData.checked - hints: { "showUnderlined": styleData.underlineMnemonics } + hints: { "showUnderlined": styleData.underlineMnemonic } properties: { "checkable": styleData.checkable, diff --git a/src/controls/Styles/Desktop/TableViewStyle.qml b/src/controls/Styles/Desktop/TableViewStyle.qml index 605c62d63..11f8ed54c 100644 --- a/src/controls/Styles/Desktop/TableViewStyle.qml +++ b/src/controls/Styles/Desktop/TableViewStyle.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -82,7 +82,7 @@ ScrollViewStyle { visible: styleData.selected || styleData.alternate source: "image://__tablerow/" + (styleData.alternate ? "alternate_" : "") + (styleData.selected ? "selected_" : "") - + (styleData.hasActiveFocus ? "active" : "") + + (control.activeFocus ? "active" : "") height: Math.max(16, RowItemSingleton.implicitHeight) border.left: 4 ; border.right: 4 } diff --git a/src/controls/Styles/iOS/ComboBoxStyle.qml b/src/controls/Styles/iOS/ComboBoxStyle.qml index 147fd7fdb..ba657298e 100644 --- a/src/controls/Styles/iOS/ComboBoxStyle.qml +++ b/src/controls/Styles/iOS/ComboBoxStyle.qml @@ -42,7 +42,7 @@ import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.3 ComboBoxStyle { - selectionHandle: SelectionHandleStyle{} - cursorHandle: CursorHandleStyle{} - cursorDelegate: CursorDelegate{} + __selectionHandle: SelectionHandleStyle{} + __cursorHandle: CursorHandleStyle{} + __cursorDelegate: CursorDelegate{} } diff --git a/src/controls/Styles/iOS/CursorHandleStyle.qml b/src/controls/Styles/iOS/CursorHandleStyle.qml index 26ab97282..408a7bf46 100644 --- a/src/controls/Styles/iOS/CursorHandleStyle.qml +++ b/src/controls/Styles/iOS/CursorHandleStyle.qml @@ -45,6 +45,7 @@ Item { y: -20 width: 80 height: knob.height + knobLine.height + 60 + visible: styleData.hasSelection Rectangle { id: knob diff --git a/src/controls/Styles/iOS/SpinBoxStyle.qml b/src/controls/Styles/iOS/SpinBoxStyle.qml index a764cb79d..c898e5e9f 100644 --- a/src/controls/Styles/iOS/SpinBoxStyle.qml +++ b/src/controls/Styles/iOS/SpinBoxStyle.qml @@ -42,7 +42,7 @@ import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.3 SpinBoxStyle { - selectionHandle: SelectionHandleStyle{} - cursorHandle: CursorHandleStyle{} - cursorDelegate: CursorDelegate{} + __selectionHandle: SelectionHandleStyle{} + __cursorHandle: CursorHandleStyle{} + __cursorDelegate: CursorDelegate{} } diff --git a/src/controls/Styles/iOS/TextAreaStyle.qml b/src/controls/Styles/iOS/TextAreaStyle.qml index 6b8a18003..6be12be68 100644 --- a/src/controls/Styles/iOS/TextAreaStyle.qml +++ b/src/controls/Styles/iOS/TextAreaStyle.qml @@ -51,7 +51,7 @@ ScrollViewStyle { property color selectedTextColor: SystemPaletteSingleton.highlightedText(control.enabled) property color backgroundColor: control.backgroundVisible ? SystemPaletteSingleton.base(control.enabled) : "transparent" property int renderType: Text.QtRendering - property Component selectionHandle: SelectionHandleStyle{} - property Component cursorHandle: CursorHandleStyle{} - property Component cursorDelegate: CursorDelegate{} + property Component __selectionHandle: SelectionHandleStyle{} + property Component __cursorHandle: CursorHandleStyle{} + property Component __cursorDelegate: CursorDelegate{} } diff --git a/src/controls/Styles/iOS/TextFieldStyle.qml b/src/controls/Styles/iOS/TextFieldStyle.qml index 28ad692ff..ca237a0a2 100644 --- a/src/controls/Styles/iOS/TextFieldStyle.qml +++ b/src/controls/Styles/iOS/TextFieldStyle.qml @@ -42,7 +42,7 @@ import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.3 TextFieldStyle { - selectionHandle: SelectionHandleStyle{} - cursorHandle: CursorHandleStyle{} - cursorDelegate: CursorDelegate{} + __selectionHandle: SelectionHandleStyle{} + __cursorHandle: CursorHandleStyle{} + __cursorDelegate: CursorDelegate{} } diff --git a/src/controls/Styles/iOS/ToolButtonStyle.qml b/src/controls/Styles/iOS/ToolButtonStyle.qml index c2d2db9c3..3e4cbd2e5 100644 --- a/src/controls/Styles/iOS/ToolButtonStyle.qml +++ b/src/controls/Styles/iOS/ToolButtonStyle.qml @@ -38,5 +38,6 @@ ** ****************************************************************************/ import QtQuick.Controls.Styles 1.3 +import QtQuick.Controls.Private 1.0 ToolButtonStyle { } diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index 11b0662aa..fb940c444 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -56,25 +56,42 @@ import QtQuick.Window 2.1 A TableView is similar to \l ListView, and adds scroll bars, selection, and resizable header sections. As with \l ListView, data for each row is provided through a \l model: - \code - ListModel { - id: libraryModel - ListElement{ title: "A Masterpiece" ; author: "Gabriel" } - ListElement{ title: "Brilliance" ; author: "Jens" } - ListElement{ title: "Outstanding" ; author: "Frederik" } - } - \endcode + \code + ListModel { + id: libraryModel + ListElement { + title: "A Masterpiece" + author: "Gabriel" + } + ListElement { + title: "Brilliance" + author: "Jens" + } + ListElement { + title: "Outstanding" + author: "Frederik" + } + } + \endcode You provide title and size of a column header by adding a \l TableViewColumn as demonstrated below. - \code - TableView { - TableViewColumn{ role: "title" ; title: "Title" ; width: 100 } - TableViewColumn{ role: "author" ; title: "Author" ; width: 200 } - model: libraryModel - } - \endcode + \code + TableView { + TableViewColumn { + role: "title" + title: "Title" + width: 100 + } + TableViewColumn { + role: "author" + title: "Author" + width: 200 + } + model: libraryModel + } + \endcode The header sections are attached to values in the \l model by defining the model role they attach to. Each property in the model will @@ -149,6 +166,7 @@ ScrollView { \li styleData.elideMode - the elide mode of the column \li styleData.textAlignment - the horizontal text alignment of the column \li styleData.pressed - true when the item is pressed (since QtQuick.Controls 1.3) + \li styleData.hasActiveFocus - true when the row has focus (since QtQuick.Controls 1.3) \endlist Example: @@ -165,9 +183,9 @@ ScrollView { \note For performance reasons, created delegates can be recycled across multiple table rows. This implies that when you make use of implicit - properties such as \c styledata.row or \c model, these values can change also - after the delegate has been constructed. In practice this means you should not assume - that content is fixed when \c Component.onCompleted happens, but instead rely on + properties such as \c styleData.row or \c model, these values can change + after the delegate has been constructed. This means that you should not assume + that content is fixed when \c Component.onCompleted is called, but instead rely on bindings to such properties. */ property Component itemDelegate: __style ? __style.itemDelegate : null @@ -179,14 +197,15 @@ ScrollView { \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 + \li styleData.hasActiveFocus - true when the row has focus \li styleData.pressed - true when the row is pressed (since QtQuick.Controls 1.3) \endlist \note For performance reasons, created delegates can be recycled across multiple table rows. This implies that when you make use of implicit - properties such as \c styledata.row or \c model, these values can change also - after the delegate has been constructed. In practice this means you should not assume - that content is fixed when \c Component.onCompleted happens, but instead rely on + properties such as \c styleData.row or \c model, these values can change + after the delegate has been constructed. This means that you should not assume + that content is fixed when \c Component.onCompleted is called, but instead rely on bindings to such properties. */ property Component rowDelegate: __style ? __style.rowDelegate : null @@ -761,7 +780,7 @@ ScrollView { 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 bool hasActiveFocus: false readonly property bool pressed: false } readonly property var model: listView.model @@ -790,19 +809,23 @@ ScrollView { Keys.forwardTo: root Keys.onUpPressed: { - event.accepted = false + var oldIndex = listView.currentIndex __scroller.blockUpdates = true; listView.decrementCurrentIndex(); __scroller.blockUpdates = false; + if (oldIndex === listView.currentIndex) + event.accepted = false if (selectionMode) keySelect(event.modifiers & Qt.ShiftModifier, currentRow) } Keys.onDownPressed: { - event.accepted = false + var oldIndex = listView.currentIndex __scroller.blockUpdates = true; listView.incrementCurrentIndex(); __scroller.blockUpdates = false; + if (oldIndex === listView.currentIndex) + event.accepted = false if (selectionMode) keySelect(event.modifiers & Qt.ShiftModifier, currentRow) } @@ -829,15 +852,17 @@ ScrollView { } Keys.onReturnPressed: { - event.accepted = false if (currentRow > -1) root.activated(currentRow); + else + event.accepted = false } delegate: FocusScope { id: rowItemContainer activeFocusOnTab: false + z: rowItem.activeFocus ? 0.7 : rowItem.itemSelected ? 0.5 : 0 property Item rowItem // We recycle instantiated row items to speed up list scrolling @@ -918,7 +943,7 @@ ScrollView { 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 bool hasActiveFocus: rowitem.activeFocus readonly property bool pressed: rowitem.rowIndex === mousearea.pressedRow } readonly property var model: listView.model @@ -949,6 +974,7 @@ ScrollView { readonly property int elideMode: columnItem.elideMode readonly property int textAlignment: columnItem.horizontalAlignment readonly property bool selected: rowitem.itemSelected + readonly property bool hasActiveFocus: rowitem.activeFocus readonly property bool pressed: row === mousearea.pressedRow && column === mousearea.pressedColumn readonly property color textColor: rowitem.itemTextColor readonly property string role: columnItem.role diff --git a/src/controls/TextArea.qml b/src/controls/TextArea.qml index 5e8387db6..1c19a300f 100644 --- a/src/controls/TextArea.qml +++ b/src/controls/TextArea.qml @@ -718,7 +718,8 @@ ScrollView { TextEdit { id: edit focus: true - cursorDelegate: __style && __style.cursorDelegate ? __style.cursorDelegate : null + cursorDelegate: __style && __style.__cursorDelegate ? __style.__cursorDelegate : null + persistentSelection: true Rectangle { id: colorRect @@ -769,7 +770,7 @@ ScrollView { wrapMode: TextEdit.WordWrap textMargin: __style && __style.textMargin !== undefined ? __style.textMargin : 4 - selectByMouse: area.selectByMouse && (!cursorHandle.delegate || !selectionHandle.delegate) + selectByMouse: area.selectByMouse && (!Settings.isMobile || !cursorHandle.delegate || !selectionHandle.delegate) readOnly: false Keys.forwardTo: area @@ -846,15 +847,20 @@ ScrollView { } MouseArea { + id: mouseArea anchors.fill: parent cursorShape: edit.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor - acceptedButtons: edit.selectByMouse ? Qt.NoButton : Qt.LeftButton + acceptedButtons: (edit.selectByMouse ? Qt.NoButton : Qt.LeftButton) | (area.menu ? Qt.RightButton : Qt.NoButton) onClicked: { + if (editMenu.item) + return; var pos = edit.positionAt(mouse.x, mouse.y) edit.moveHandles(pos, pos) edit.activate() } onPressAndHold: { + if (editMenu.item) + return; var pos = edit.positionAt(mouse.x, mouse.y) edit.moveHandles(pos, area.selectByMouse ? -1 : pos) edit.activate() @@ -865,6 +871,7 @@ ScrollView { id: editMenu control: area input: edit + mouseArea: mouseArea cursorHandle: cursorHandle selectionHandle: selectionHandle flickable: flickable @@ -878,8 +885,8 @@ ScrollView { control: area z: 1 // above scrollbars parent: Qt.platform.os === "ios" ? editor : __scroller // no clip - active: area.selectByMouse - delegate: __style.selectionHandle + active: area.selectByMouse && Settings.isMobile + delegate: __style.__selectionHandle maximum: cursorHandle.position - 1 // Mention contentX and contentY in the mappedPos binding to force re-evaluation if they change @@ -888,8 +895,13 @@ ScrollView { x: mappedPos.x y: mappedPos.y - visible: pressed || (edit.hasSelection && handleY + handleHeight >= -1 && handleY <= viewport.height + 1 - && handleX + handleWidth >= -1 && handleX <= viewport.width + 1) + property var posInViewport: flickableItem.contentX !== flickableItem.contentY !== Number.MAX_VALUE ? + parent.mapToItem(viewport, handleX, handleY) : -1 + visible: pressed || (edit.hasSelection + && posInViewport.y + handleHeight >= -1 + && posInViewport.y <= viewport.height + 1 + && posInViewport.x + handleWidth >= -1 + && posInViewport.x <= viewport.width + 1) onPositionChanged: { if (!edit.blockRecursion) { @@ -909,8 +921,8 @@ ScrollView { control: area z: 1 // above scrollbars parent: Qt.platform.os === "ios" ? editor : __scroller // no clip - active: area.selectByMouse - delegate: __style.cursorHandle + active: area.selectByMouse && Settings.isMobile + delegate: __style.__cursorHandle minimum: edit.hasSelection ? selectionHandle.position + 1 : -1 // Mention contentX and contentY in the mappedPos binding to force re-evaluation if they change @@ -919,8 +931,13 @@ ScrollView { x: mappedPos.x y: mappedPos.y - visible: pressed || (edit.hasSelection && handleY + handleHeight >= -1 && handleY <= viewport.height + 1 - && handleX + handleWidth >= -1 && handleX <= viewport.width + 1) + property var posInViewport: flickableItem.contentX !== flickableItem.contentY !== Number.MAX_VALUE ? + parent.mapToItem(viewport, handleX, handleY) : -1 + visible: pressed || ((edit.cursorVisible || edit.hasSelection) + && posInViewport.y + handleHeight >= -1 + && posInViewport.y <= viewport.height + 1 + && posInViewport.x + handleWidth >= -1 + && posInViewport.x <= viewport.width + 1) onPositionChanged: { if (!edit.blockRecursion) { diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index 2e940bdb1..8a544a694 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -629,7 +629,7 @@ Control { font: textInput.font horizontalAlignment: textInput.horizontalAlignment verticalAlignment: textInput.verticalAlignment - opacity: !textInput.text.length && !textInput.inputMethodComposing ? 1 : 0 + opacity: textInput.displayText.length ? 0.0 : 1.0 color: __panel ? __panel.placeholderTextColor : "darkgray" clip: contentWidth > width; elide: Text.ElideRight @@ -643,8 +643,8 @@ Control { selectedTextColor: __panel ? __panel.selectedTextColor : "white" control: textfield - cursorHandle: __style ? __style.cursorHandle : undefined - selectionHandle: __style ? __style.selectionHandle : undefined + cursorHandle: __style ? __style.__cursorHandle : undefined + selectionHandle: __style ? __style.__selectionHandle : undefined font: __panel ? __panel.font : TextSingleton.font anchors.leftMargin: __panel ? __panel.leftMargin : 0 @@ -662,12 +662,7 @@ Control { Keys.forwardTo: textfield - onAccepted: { - Qt.inputMethod.commit() - if (!(textInput.inputMethodHints & Qt.ImhMultiLine)) - Qt.inputMethod.hide() - textfield.accepted() - } + onAccepted: textfield.accepted() onEditingFinished: textfield.editingFinished() } diff --git a/src/controls/ToolBar.qml b/src/controls/ToolBar.qml index cc07fd5cb..b79e0ade8 100644 --- a/src/controls/ToolBar.qml +++ b/src/controls/ToolBar.qml @@ -151,7 +151,7 @@ FocusScope { anchors.topMargin: topMargin anchors.leftMargin: leftMargin - anchors.rightMargin: rightMargin + (buttonLoader.active ? buttonLoader.width : 0) + anchors.rightMargin: rightMargin + (buttonLoader.active ? buttonLoader.width + rightMargin : 0) anchors.bottomMargin: bottomMargin property int topMargin: __style ? __style.padding.top : 0 diff --git a/src/controls/doc/images/qtquickcontrols-android.png b/src/controls/doc/images/qtquickcontrols-android.png Binary files differdeleted file mode 100644 index 8877c09cd..000000000 --- a/src/controls/doc/images/qtquickcontrols-android.png +++ /dev/null diff --git a/src/controls/doc/images/qtquickcontrols-example-gallery-android-dark.png b/src/controls/doc/images/qtquickcontrols-example-gallery-android-dark.png Binary files differnew file mode 100644 index 000000000..7e27b466b --- /dev/null +++ b/src/controls/doc/images/qtquickcontrols-example-gallery-android-dark.png diff --git a/src/controls/doc/images/qtquickcontrols-example-gallery-android.png b/src/controls/doc/images/qtquickcontrols-example-gallery-android.png Binary files differnew file mode 100644 index 000000000..11ba2cc0c --- /dev/null +++ b/src/controls/doc/images/qtquickcontrols-example-gallery-android.png diff --git a/src/controls/doc/images/qtquickcontrols-example-gallery-osx.png b/src/controls/doc/images/qtquickcontrols-example-gallery-osx.png Binary files differnew file mode 100644 index 000000000..492dc36e5 --- /dev/null +++ b/src/controls/doc/images/qtquickcontrols-example-gallery-osx.png diff --git a/src/controls/doc/images/qtquickcontrols-example-gallery.png b/src/controls/doc/images/qtquickcontrols-example-gallery.png Binary files differdeleted file mode 100644 index a88eab793..000000000 --- a/src/controls/doc/images/qtquickcontrols-example-gallery.png +++ /dev/null diff --git a/src/controls/doc/images/qtquickcontrols-example-splitview.png b/src/controls/doc/images/qtquickcontrols-example-splitview.png Binary files differdeleted file mode 100644 index a82017b49..000000000 --- a/src/controls/doc/images/qtquickcontrols-example-splitview.png +++ /dev/null diff --git a/src/controls/doc/images/qtquickcontrols-example-tableview.png b/src/controls/doc/images/qtquickcontrols-example-tableview.png Binary files differindex b9dc67c31..c4ab8d997 100644 --- a/src/controls/doc/images/qtquickcontrols-example-tableview.png +++ b/src/controls/doc/images/qtquickcontrols-example-tableview.png diff --git a/src/controls/doc/src/applicationwindow.qdoc b/src/controls/doc/src/applicationwindow.qdoc index f9e2d97fe..45b66e30b 100644 --- a/src/controls/doc/src/applicationwindow.qdoc +++ b/src/controls/doc/src/applicationwindow.qdoc @@ -27,5 +27,6 @@ /*! \group applicationwindow + \brief A window adding convenience for positioning items. \title Application Window */ diff --git a/src/controls/doc/src/controls.qdoc b/src/controls/doc/src/controls.qdoc index d1e4d0524..fa2a800ca 100644 --- a/src/controls/doc/src/controls.qdoc +++ b/src/controls/doc/src/controls.qdoc @@ -27,5 +27,6 @@ /*! \group controls + \brief Buttons and UI Controls. \title Buttons and Controls */ diff --git a/src/controls/doc/src/menus.qdoc b/src/controls/doc/src/menus.qdoc index 75f5ba2c6..8a6a8032c 100644 --- a/src/controls/doc/src/menus.qdoc +++ b/src/controls/doc/src/menus.qdoc @@ -27,5 +27,6 @@ /*! \group menus + \brief How to create a menu bar. \title Menus */ diff --git a/src/controls/doc/src/qtquickcontrols-examples.qdoc b/src/controls/doc/src/qtquickcontrols-examples.qdoc index 8b8c14699..29c8d2b55 100644 --- a/src/controls/doc/src/qtquickcontrols-examples.qdoc +++ b/src/controls/doc/src/qtquickcontrols-examples.qdoc @@ -40,7 +40,22 @@ \title Qt Quick Controls - Gallery \ingroup qtquickcontrols_examples \brief A collection of components for a classic desktop-style UI. - \image qtquickcontrols-example-gallery.png + + \raw HTML + <div class="table"><table style="background:transparent; border:0px"> + <tr><td style="border:0px"> + \endraw + \image qtquickcontrols-example-gallery-osx.png + \caption OS X + \raw HTML + </td><td style="border:0px"> + \endraw + \image qtquickcontrols-example-gallery-android.png + \caption Android - Nexus 5 + \raw HTML + </td></tr> + </table></div> + \endraw This example project demonstrates the various UI components provided by \l{Qt Quick Controls}. @@ -63,30 +78,40 @@ */ /*! - \example splitview - \title Qt Quick Controls - Split View Example - \ingroup qtquickcontrols_examples - \brief An example for the SplitView UI control. - \image qtquickcontrols-example-splitview.png - - This example project demonstrates the usage of \l {SplitView} from - \l{Qt Quick Controls} - a control that lays out items horizontally or - vertically with a draggable splitter between each item. - - \include examples-run.qdocinc -*/ - -/*! \example tableview \title Qt Quick Controls - Table View Example \ingroup qtquickcontrols_examples \brief An example for the TableView control. \image qtquickcontrols-example-tableview.png - This example shows how a \l{TableView} from \l{Qt Quick Controls} - can be used together with different types of data models to display - lists of information with support for scroll bars, selections and - resizable header sections. + This example project demonstrates the usage of \l {TableView} from + \l{Qt Quick Controls} - a control to display one or more columns of + information from a data list model. The example includes a model + that supports sorting and filtering. + + The C++ class, SortFilterProxyModel, is registered as a QML type + under the namespace, "\c{org.qtproject.example 1.0}". + + The following snippets show how the type is registered under + a namespace and later imported by \e main.qml. + + QML type registration: + + \code + #include <QtQml/qqml.h> + ... + qmlRegisterType<SortFilterProxyModel>("org.qtproject.example", 1, 0, "SortFilterProxyModel"); + ... + \endcode + + QML namespace import: + + \qml + import org.qtproject.example 1.0 + \endqml + + For more information about registering C++ classses as QML types, see + \l {Defining QML Types from C++}. \include examples-run.qdocinc */ diff --git a/src/controls/doc/src/qtquickcontrols-overview.qdoc b/src/controls/doc/src/qtquickcontrols-overview.qdoc index 09f5318d0..651edc66d 100644 --- a/src/controls/doc/src/qtquickcontrols-overview.qdoc +++ b/src/controls/doc/src/qtquickcontrols-overview.qdoc @@ -61,7 +61,7 @@ For an overview of the controls provided by \l{Qt Quick Controls}, you can look at the \l{Qt Quick Controls - Gallery}{Gallery} example. - \image qtquickcontrols-example-gallery.png + \image qtquickcontrols-example-gallery-osx.png \section1 Setting Up Controls from C++ diff --git a/src/controls/doc/src/qtquickcontrols-platformnotes.qdoc b/src/controls/doc/src/qtquickcontrols-platformnotes.qdoc index 70f1a1bb5..8c6c5c198 100644 --- a/src/controls/doc/src/qtquickcontrols-platformnotes.qdoc +++ b/src/controls/doc/src/qtquickcontrols-platformnotes.qdoc @@ -33,19 +33,37 @@ This page contains platform specific notes for creating applications that use \l{Qt Quick Controls}. - \section1 Android + \section1 Android Style Qt 5.4 introduced a native Android style for Qt Quick Controls. - \image qtquickcontrols-android.png + \image qtquickcontrols-example-gallery-android.png \note The Android style requires Android 3.0 (API level 11) or later. - No special actions are required to use the Android style. It is - automatically selected and deployed on Android. See \l{Getting Started + The style is automatically selected and deployed on Android. See \l{Getting Started with Qt for Android} and \l{Deploying an Application on Android} for more details on the Android essentials. + \section2 Android Themes + + Applications may choose a specific \l{http://developer.android.com/design/style/themes.html} + {Android theme} by specifying it in \l{AndroidManifest.xml}. + + \image qtquickcontrols-example-gallery-android-dark.png + + The following example sets a dark Holo theme, and the result can be + seen in the screenshot above. + + \code + <manifest ...> + <application ... android:theme="@android:style/Theme.Holo"> + ... + </application> + ... + </manifest> + \endcode + \section2 Action Bar The \l{http://developer.android.com/guide/topics/ui/actionbar.html} @@ -62,8 +80,8 @@ items declared in QML. Just to name a few possibilities: \list \li ToolButton actions, - \li A TextField as a search field, - \li A ComboBox for navigation, and - \li A ProgressBar for displaying progress. + \li a TextField as a search field, + \li a ComboBox for navigation, and + \li a ProgressBar for displaying progress. \endlist */ diff --git a/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc b/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc index 74c750a5a..7548d7429 100644 --- a/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc +++ b/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc @@ -40,6 +40,7 @@ /*! \group controlsstyling + \brief Provides custom styling for Buttons and UI Controls. \title Styling Controls */ diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp index faa9b1d1d..1a125135c 100644 --- a/src/controls/qquickmenu.cpp +++ b/src/controls/qquickmenu.cpp @@ -43,7 +43,7 @@ #include <QtGui/qpa/qplatformtheme.h> #include <QtGui/qpa/qplatformmenu.h> #include <qquickitem.h> -#include <QtQuick/private/qquickrendercontrol_p.h> +#include <QtQuick/QQuickRenderControl> QT_BEGIN_NAMESPACE @@ -367,7 +367,10 @@ QQuickWindow *QQuickMenu::findParentWindow() void QQuickMenu::popup() { - QQuickWindow *parentWindow = findParentWindow(); + QQuickWindow *quickWindow = findParentWindow(); + QPoint renderOffset; + QWindow *renderWindow = QQuickRenderControl::renderWindowFor(quickWindow, &renderOffset); + QWindow *parentWindow = renderWindow ? renderWindow : quickWindow; QScreen *screen = parentWindow ? parentWindow->screen() : qGuiApp->primaryScreen(); QPoint mousePos = QCursor::pos(screen); @@ -379,7 +382,7 @@ void QQuickMenu::popup() if (parentWindow) mousePos = parentWindow->mapFromGlobal(mousePos); - __popup(QRectF(mousePos.x(), mousePos.y(), 0, 0)); + __popup(QRectF(mousePos.x() - renderOffset.x(), mousePos.y() - renderOffset.y(), 0, 0)); } void QQuickMenu::__popup(const QRectF &targetRect, int atItemIndex, MenuType menuType) @@ -397,10 +400,10 @@ void QQuickMenu::__popup(const QRectF &targetRect, int atItemIndex, MenuType men QQuickMenuBase *atItem = menuItemAtIndex(atItemIndex); QQuickWindow *quickWindow = findParentWindow(); - QWindow *parentWindow = quickWindow; - QWindow *renderWindow = QQuickRenderControl::renderWindowFor(static_cast<QQuickWindow *>(parentWindow)); - if (renderWindow) - parentWindow = renderWindow; // may not be a QQuickWindow anymore (happens when using QQuickWidget) + QPoint renderOffset; + QWindow *renderWindow = QQuickRenderControl::renderWindowFor(quickWindow, &renderOffset); + QWindow *parentWindow = renderWindow ? renderWindow : quickWindow; + // parentWindow may not be a QQuickWindow (happens when using QQuickWidget) if (m_platformMenu) { QRectF globalTargetRect = targetRect.translated(m_xOffset, m_yOffset); @@ -411,6 +414,7 @@ void QQuickMenu::__popup(const QRectF &targetRect, int atItemIndex, MenuType men } globalTargetRect = visualItem()->mapRectToScene(globalTargetRect); } + globalTargetRect.translate(renderOffset); m_platformMenu->setMenuType(QPlatformMenu::MenuType(menuType)); m_platformMenu->showPopup(parentWindow, globalTargetRect.toRect(), atItem ? atItem->platformItem() : 0); } else { @@ -425,7 +429,8 @@ void QQuickMenu::__popup(const QRectF &targetRect, int atItemIndex, MenuType men connect(m_popupWindow, SIGNAL(visibleChanged(bool)), this, SLOT(windowVisibleChanged(bool))); connect(m_popupWindow, SIGNAL(geometryChanged()), this, SIGNAL(__popupGeometryChanged())); - m_popupWindow->setPosition(targetRect.x() + m_xOffset, targetRect.y() + targetRect.height() + m_yOffset); + m_popupWindow->setPosition(targetRect.x() + m_xOffset + renderOffset.x(), + targetRect.y() + targetRect.height() + m_yOffset + renderOffset.y()); m_popupWindow->show(); } } diff --git a/src/controls/qquickmenupopupwindow.cpp b/src/controls/qquickmenupopupwindow.cpp index 52ce72195..787896d8d 100644 --- a/src/controls/qquickmenupopupwindow.cpp +++ b/src/controls/qquickmenupopupwindow.cpp @@ -37,7 +37,7 @@ #include <qpa/qwindowsysteminterface.h> #include <qquickitem.h> #include <QtGui/QScreen> -#include <QtQuick/private/qquickrendercontrol_p.h> +#include <QtQuick/QQuickRenderControl> QT_BEGIN_NAMESPACE diff --git a/src/controls/qquickpopupwindow.cpp b/src/controls/qquickpopupwindow.cpp index e10e6ae04..fa7ebee1e 100644 --- a/src/controls/qquickpopupwindow.cpp +++ b/src/controls/qquickpopupwindow.cpp @@ -36,7 +36,7 @@ #include <qguiapplication.h> #include <qpa/qwindowsysteminterface.h> #include <QtQuick/qquickitem.h> -#include <QtQuick/private/qquickrendercontrol_p.h> +#include <QtQuick/QQuickRenderControl> QT_BEGIN_NAMESPACE @@ -180,7 +180,8 @@ void QQuickPopupWindow::forwardEventToTransientParent(QMouseEvent *e) || e->type() == QEvent::MouseButtonPress)) { // Clicked outside any popup dismissPopup(); - } else if (transientParent()) { + } + if (transientParent()) { QPoint parentPos = transientParent()->mapFromGlobal(mapToGlobal(e->pos())); QMouseEvent pe = QMouseEvent(e->type(), parentPos, e->button(), e->buttons(), e->modifiers()); QGuiApplication::sendEvent(transientParent(), &pe); @@ -191,11 +192,11 @@ void QQuickPopupWindow::exposeEvent(QExposeEvent *e) { if (isExposed() && m_needsActivatedEvent) { m_needsActivatedEvent = false; - QWindowSystemInterface::handleWindowActivated(this, Qt::PopupFocusReason); + QWindowSystemInterface::handleWindowActivated(this); } else if (!isExposed() && !m_needsActivatedEvent) { m_needsActivatedEvent = true; if (QWindow *tp = transientParent()) - QWindowSystemInterface::handleWindowActivated(tp, Qt::PopupFocusReason); + QWindowSystemInterface::handleWindowActivated(tp); } QQuickWindow::exposeEvent(e); } @@ -204,7 +205,7 @@ void QQuickPopupWindow::hideEvent(QHideEvent *e) { if (QWindow *tp = !m_needsActivatedEvent ? transientParent() : 0) { m_needsActivatedEvent = true; - QWindowSystemInterface::handleWindowActivated(tp, Qt::PopupFocusReason); + QWindowSystemInterface::handleWindowActivated(tp); } QQuickWindow::hideEvent(e); diff --git a/src/dialogs/DefaultColorDialog.qml b/src/dialogs/DefaultColorDialog.qml index 6cd1eda9f..7188010ea 100644 --- a/src/dialogs/DefaultColorDialog.qml +++ b/src/dialogs/DefaultColorDialog.qml @@ -40,6 +40,7 @@ import QtQuick 2.4 import QtQuick.Controls 1.2 +import QtQuick.Controls.Private 1.0 import QtQuick.Dialogs 1.0 import QtQuick.Window 2.1 import "qml" @@ -61,9 +62,8 @@ AbstractColorDialog { Rectangle { id: content - property int maxSize: 0.9 * Math.min(Screen.desktopAvailableWidth, Screen.desktopAvailableHeight) - implicitHeight: Math.min(maxSize, Screen.pixelDensity * (usePaletteMap ? 100 : 50)) - implicitWidth: usePaletteMap ? implicitHeight - bottomMinHeight : implicitHeight * 1.5 + implicitHeight: Math.min(root.__maximumDimension, Screen.pixelDensity * (usePaletteMap ? 120 : 50)) + implicitWidth: Math.min(root.__maximumDimension, usePaletteMap ? Screen.pixelDensity * (usePaletteMap ? 100 : 50) : implicitHeight * 1.5) color: palette.window focus: root.visible property real bottomMinHeight: sliders.height + buttonRow.height + outerSpacing * 3 @@ -99,9 +99,6 @@ AbstractColorDialog { } } - // set the preferred width based on height, to avoid "letterboxing" the paletteMap - onHeightChanged: implicitHeight = Math.max((usePaletteMap ? 480 : bottomMinHeight), height) - SystemPalette { id: palette } Item { @@ -276,7 +273,6 @@ AbstractColorDialog { right: parent.right margins: content.outerSpacing } - spacing: content.spacing ColorSlider { id: hueSlider @@ -371,7 +367,8 @@ AbstractColorDialog { } Row { spacing: content.spacing - height: parent.height + height: visible ? parent.height : 0 + visible: !Settings.isMobile TextField { id: colorField text: root.currentColor.toString() diff --git a/src/dialogs/DefaultDialogWrapper.qml b/src/dialogs/DefaultDialogWrapper.qml index a10249001..014c38a7b 100644 --- a/src/dialogs/DefaultDialogWrapper.qml +++ b/src/dialogs/DefaultDialogWrapper.qml @@ -48,6 +48,7 @@ import "qml" AbstractDialog { id: root default property alias data: defaultContentItem.data + onVisibilityChanged: if (visible && contentItem) contentItem.forceActiveFocus() Rectangle { id: content @@ -58,10 +59,9 @@ AbstractDialog { property real minimumHeight: implicitHeight property real minimumWidth: Screen.pixelDensity * 50 implicitHeight: defaultContentItem.implicitHeight + spacing + outerSpacing * 2 + buttonsRight.implicitHeight - implicitWidth: Math.min(Screen.desktopAvailableWidth * 0.9, Math.max( + implicitWidth: Math.min(root.__maximumDimension, Math.max( defaultContentItem.implicitWidth, buttonsRowImplicitWidth, Screen.pixelDensity * 50) + outerSpacing * 2); color: palette.window - focus: root.visible Keys.onPressed: { event.accepted = true switch (event.key) { diff --git a/src/dialogs/DefaultFileDialog.qml b/src/dialogs/DefaultFileDialog.qml index feb31c4df..7cd87bc99 100644 --- a/src/dialogs/DefaultFileDialog.qml +++ b/src/dialogs/DefaultFileDialog.qml @@ -120,10 +120,9 @@ AbstractFileDialog { } Rectangle { - property int maxSize: Math.min(Screen.desktopAvailableWidth, Screen.desktopAvailableHeight) - implicitWidth: Math.min(maxSize, Math.max(Screen.pixelDensity * 100, splitter.implicitWidth)) - implicitHeight: Math.min(maxSize, Screen.pixelDensity * 80) id: window + implicitWidth: Math.min(root.__maximumDimension, Math.max(Screen.pixelDensity * 100, splitter.implicitWidth)) + implicitHeight: Math.min(root.__maximumDimension, Screen.pixelDensity * 80) color: root.palette.window Binding { @@ -317,13 +316,14 @@ AbstractFileDialog { sortReversed: view.sortIndicatorOrder === Qt.DescendingOrder } - onActivated: { - if (view.model.isFolder(row)) { + onActivated: if (view.focus) { + if (view.selection.count > 0 && view.model.isFolder(row)) { dirDown(view.model.get(row, "filePath")) } else { root.acceptSelection() } } + onClicked: currentPathField.text = view.model.get(row, "filePath") TableViewColumn { @@ -399,13 +399,14 @@ AbstractFileDialog { TextField { id: currentPathField Layout.fillWidth: true - onAccepted: { + function doAccept() { root.clearSelection() if (root.addSelection(root.pathToUrl(text))) root.accept() else root.folder = root.pathFolder(text) } + onAccepted: doAccept() } } } @@ -455,6 +456,8 @@ AbstractFileDialog { onClicked: { if (view.model.isFolder(view.currentIndex) && !selectFolder) dirDown(view.model.get(view.currentIndex, "filePath")) + else if (!(root.selectExisting)) + currentPathField.doAccept() else root.acceptSelection() } diff --git a/src/dialogs/DefaultFontDialog.qml b/src/dialogs/DefaultFontDialog.qml index 4bd4a1bef..d5c4570ac 100644 --- a/src/dialogs/DefaultFontDialog.qml +++ b/src/dialogs/DefaultFontDialog.qml @@ -58,9 +58,8 @@ AbstractFontDialog { id: content SystemPalette { id: palette } - property int maxSize: Math.min(Screen.desktopAvailableWidth, Screen.desktopAvailableHeight) - implicitWidth: Math.min(maxSize, Math.max(Screen.pixelDensity * 60, mainLayout.implicitWidth + outerSpacing * 2)) - implicitHeight: Math.min(maxSize, Math.max(Screen.pixelDensity * 40, mainLayout.implicitHeight + outerSpacing * 2)) + implicitWidth: Math.min(root.__maximumDimension, Math.max(Screen.pixelDensity * 100, mainLayout.implicitWidth + outerSpacing * 2)) + implicitHeight: Math.min(root.__maximumDimension, Math.max(Screen.pixelDensity * 60, mainLayout.implicitHeight + outerSpacing * 2)) property real spacing: 6 property real outerSpacing: 12 color: palette.window @@ -127,7 +126,7 @@ AbstractFontDialog { focus: true Layout.fillWidth: true Layout.fillHeight: true - Layout.minimumWidth: fontColumn.width + Layout.preferredWidth: fontColumn.width headerVisible: false function reset() { fontModel.findIndex() @@ -201,7 +200,7 @@ AbstractFontDialog { function reset() { weightModel.findIndex() } - TableViewColumn{ id: weightColumn; role: "name"; title: qsTr("Weight") } + TableViewColumn { id: weightColumn; role: "name"; title: qsTr("Weight") } model: ListModel { id: weightModel ListElement { @@ -340,28 +339,6 @@ AbstractFontDialog { } Item { Layout.fillHeight: true; } //spacer Label { id: writingSystemLabel; text: qsTr("Writing System"); font.bold: true } - ComboBox { - id: wsComboBox - function reset() { - if (wsModel.count > 0) { - currentIndex = 0 - } - } - textRole: "name" - model: WritingSystemListModel { - id: wsModel - Component.onCompleted: wsComboBox.reset() - } - onCurrentIndexChanged: { - if (currentIndex == -1) - return - - content.writingSystem = wsModel.get(currentIndex).name - fontModel.writingSystem = content.writingSystem - content.writingSystemSample = wsModel.get(currentIndex).sample - fontListView.reset() - } - } } ColumnLayout { @@ -398,6 +375,28 @@ AbstractFontDialog { id: buttonRow Layout.columnSpan: 3 spacing: content.spacing + ComboBox { + id: wsComboBox + function reset() { + if (wsModel.count > 0) { + currentIndex = 0 + } + } + textRole: "name" + model: WritingSystemListModel { + id: wsModel + Component.onCompleted: wsComboBox.reset() + } + onCurrentIndexChanged: { + if (currentIndex == -1) + return + + content.writingSystem = wsModel.get(currentIndex).name + fontModel.writingSystem = content.writingSystem + content.writingSystemSample = wsModel.get(currentIndex).sample + fontListView.reset() + } + } Item { Layout.fillWidth: true; } //spacer Button { text: qsTr("Cancel") diff --git a/src/dialogs/DefaultMessageDialog.qml b/src/dialogs/DefaultMessageDialog.qml index 609d060c5..0e6e3a6af 100644 --- a/src/dialogs/DefaultMessageDialog.qml +++ b/src/dialogs/DefaultMessageDialog.qml @@ -55,7 +55,7 @@ AbstractMessageDialog { property real buttonsRowImplicitWidth: Screen.pixelDensity * 50 implicitHeight: contentColumn.implicitHeight + outerSpacing * 2 onImplicitHeightChanged: root.height = implicitHeight - implicitWidth: Math.min(Screen.desktopAvailableWidth * 0.9, Math.max( + implicitWidth: Math.min(root.__maximumDimension, Math.max( mainText.implicitWidth, buttonsRowImplicitWidth) + outerSpacing * 2); onImplicitWidthChanged: root.width = implicitWidth color: palette.window @@ -89,12 +89,9 @@ AbstractMessageDialog { Column { id: contentColumn spacing: content.spacing - anchors { - top: parent.top - left: parent.left - right: parent.right - margins: content.outerSpacing - } + x: content.outerSpacing + y: content.outerSpacing + width: content.width - content.outerSpacing * 2 SystemPalette { id: palette } diff --git a/src/dialogs/dialogs.pro b/src/dialogs/dialogs.pro index fd85dcba9..93db78f40 100644 --- a/src/dialogs/dialogs.pro +++ b/src/dialogs/dialogs.pro @@ -39,15 +39,17 @@ HEADERS += \ qquickabstractdialog_p.h \ qquickdialog_p.h +WIDGET_DIALOGS_QML_FILES = \ + WidgetMessageDialog.qml \ + WidgetFileDialog.qml \ + WidgetColorDialog.qml \ + WidgetFontDialog.qml + DIALOGS_QML_FILES += \ DefaultMessageDialog.qml \ - WidgetMessageDialog.qml \ DefaultFileDialog.qml \ - WidgetFileDialog.qml \ DefaultColorDialog.qml \ - WidgetColorDialog.qml \ DefaultFontDialog.qml \ - WidgetFontDialog.qml \ DefaultDialogWrapper.qml \ qml/ColorSlider.qml \ qml/DefaultWindowDecoration.qml \ @@ -65,7 +67,12 @@ DIALOGS_QML_FILES += \ images/crosshairs.png \ images/slider_handle.png \ images/sunken_frame.png \ - images/window_border.png + images/window_border.png \ + $$WIDGET_DIALOGS_QML_FILES + +ios|android|blackberry|winrt { + DIALOGS_QML_FILES -= $$WIDGET_DIALOGS_QML_FILES +} QT += quick-private gui gui-private core core-private qml qml-private diff --git a/src/dialogs/doc/src/qtquickdialogs-index.qdoc b/src/dialogs/doc/src/qtquickdialogs-index.qdoc index 5a1223b04..ab0bc31a1 100644 --- a/src/dialogs/doc/src/qtquickdialogs-index.qdoc +++ b/src/dialogs/doc/src/qtquickdialogs-index.qdoc @@ -27,6 +27,7 @@ /*! \group dialogs + \brief Dialog components \title Dialogs */ diff --git a/src/dialogs/plugin.cpp b/src/dialogs/plugin.cpp index b8ddf35b9..be71ffe89 100644 --- a/src/dialogs/plugin.cpp +++ b/src/dialogs/plugin.cpp @@ -50,9 +50,11 @@ #include "qquickdialog_p.h" #include <private/qguiapplication_p.h> #include <qpa/qplatformintegration.h> +#include <QTouchDevice> //#define PURE_QML_ONLY -//#define DEBUG_REGISTRATION + +Q_LOGGING_CATEGORY(lcRegistration, "qt.quick.dialogs.registration") static void initResources() { @@ -85,11 +87,7 @@ public: QtQuick2DialogsPlugin() : QQmlExtensionPlugin(), m_useResources(true) { } virtual void initializeEngine(QQmlEngine *engine, const char * uri) { -#ifdef DEBUG_REGISTRATION - qDebug() << Q_FUNC_INFO << uri << m_decorationComponentUrl; -#else - Q_UNUSED(uri) -#endif + qCDebug(lcRegistration) << uri << m_decorationComponentUrl; QQuickAbstractDialog::m_decorationComponent = new QQmlComponent(engine, m_decorationComponentUrl, QQmlComponent::Asynchronous); } @@ -97,12 +95,10 @@ public: virtual void registerTypes(const char *uri) { initResources(); -#ifdef DEBUG_REGISTRATION - qDebug() << Q_FUNC_INFO << uri; -#endif Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.Dialogs")); bool hasTopLevelWindows = QGuiApplicationPrivate::platformIntegration()-> hasCapability(QPlatformIntegration::MultipleWindows); + qCDebug(lcRegistration) << uri << "can use top-level windows?" << hasTopLevelWindows; QDir qmlDir(baseUrl().toLocalFile()); QDir widgetsDir(baseUrl().toLocalFile()); widgetsDir.cd("../PrivateWidgets"); @@ -164,9 +160,7 @@ public: QUrl dialogQmlPath = m_useResources ? QUrl("qrc:/QtQuick/Dialogs/DefaultDialogWrapper.qml") : QUrl::fromLocalFile(qmlDir.filePath("DefaultDialogWrapper.qml")); -#ifdef DEBUG_REGISTRATION - qDebug() << " registering DefaultDialogWrapper.qml as Dialog; success?" << -#endif + qCDebug(lcRegistration) << " registering" << dialogQmlPath << "as Dialog"; qmlRegisterType(dialogQmlPath, uri, 1, 2, "Dialog"); } } @@ -175,29 +169,35 @@ protected: template <class WrapperType> void registerWidgetOrQmlImplementation(QDir widgetsDir, QDir qmlDir, const char *qmlName, const char *uri, bool hasTopLevelWindows, int versionMajor, int versionMinor) { - // qDebug() << "QtQuick2DialogsPlugin::registerWidgetOrQmlImplementation" << uri << qmlName << ": QML in" << qmlDir.absolutePath() - // << "using resources?" << m_useResources << "; widgets in" << widgetsDir.absolutePath(); -#ifdef DEBUG_REGISTRATION - qDebug() << Q_FUNC_INFO << qmlDir << qmlName << uri; -#endif + qCDebug(lcRegistration) << qmlName << uri << ": QML in" << qmlDir.absolutePath() + << "using resources?" << m_useResources << "; widgets in" << widgetsDir.absolutePath(); bool needQmlImplementation = true; #ifdef PURE_QML_ONLY Q_UNUSED(widgetsDir) Q_UNUSED(hasTopLevelWindows) #else + bool mobileTouchPlatform = false; +#if defined(Q_OS_IOS) + mobileTouchPlatform = true; +#elif defined(Q_OS_ANDROID) || defined(Q_OS_BLACKBERRY) || defined(Q_OS_QNX) || defined(Q_OS_WINRT) + foreach (const QTouchDevice *dev, QTouchDevice::devices()) + if (dev->type() == QTouchDevice::TouchScreen) + mobileTouchPlatform = true; +#endif // If there is a qmldir and we have a QApplication instance (as opposed to a - // widget-free QGuiApplication), assume that the widget-based dialog will work. - if (hasTopLevelWindows && widgetsDir.exists("qmldir") && + // widget-free QGuiApplication), and this isn't a mobile touch-based platform, + // assume that the widget-based dialog will work. Otherwise an application developer + // can ensure that widgets are omitted from the deployment to ensure that the widget + // dialogs won't be used. + if (!mobileTouchPlatform && hasTopLevelWindows && widgetsDir.exists("qmldir") && QCoreApplication::instance()->inherits("QApplication")) { QUrl dialogQmlPath = m_useResources ? QUrl(QString("qrc:/QtQuick/Dialogs/Widget%1.qml").arg(qmlName)) : QUrl::fromLocalFile(qmlDir.filePath(QString("Widget%1.qml").arg(qmlName))); if (qmlRegisterType(dialogQmlPath, uri, versionMajor, versionMinor, qmlName) >= 0) { needQmlImplementation = false; -#ifdef DEBUG_REGISTRATION - qDebug() << " registering" << qmlName << " as " << dialogQmlPath << "success?" << !needQmlImplementation; -#endif + qCDebug(lcRegistration) << " registering" << qmlName << " as " << dialogQmlPath << "success?" << !needQmlImplementation; } } #endif @@ -207,9 +207,7 @@ protected: QUrl dialogQmlPath = m_useResources ? QUrl(QString("qrc:/QtQuick/Dialogs/Default%1.qml").arg(qmlName)) : QUrl::fromLocalFile(qmlDir.filePath(QString("Default%1.qml").arg(qmlName))); -#ifdef DEBUG_REGISTRATION - qDebug() << " registering" << qmlName << " as " << dialogQmlPath << "success?" << -#endif + qCDebug(lcRegistration) << " registering" << qmlName << " as " << dialogQmlPath; qmlRegisterType(dialogQmlPath, uri, versionMajor, versionMinor, qmlName); } } diff --git a/src/dialogs/qml/DefaultWindowDecoration.qml b/src/dialogs/qml/DefaultWindowDecoration.qml index 9b0066980..15512669d 100644 --- a/src/dialogs/qml/DefaultWindowDecoration.qml +++ b/src/dialogs/qml/DefaultWindowDecoration.qml @@ -58,8 +58,8 @@ Rectangle { width: content ? content.width + 15 : 0 height: content ? content.height + 15 : 0 - onWidthChanged: content.x = 5 - onHeightChanged: content.y = 5 + onWidthChanged: if (content) content.x = 5 + onHeightChanged: if (content) content.y = 5 border { left: 10; top: 10; right: 10; bottom: 10 } clip: true source: "../images/window_border.png" diff --git a/src/dialogs/qmldir b/src/dialogs/qmldir index 37e1efff7..df0d402be 100644 --- a/src/dialogs/qmldir +++ b/src/dialogs/qmldir @@ -4,3 +4,4 @@ classname QtQuick2DialogsPlugin typeinfo plugins.qmltypes depends Qt.labs.folderlistmodel 1.0 depends Qt.labs.settings 1.0 +depends QtQuick.Dialogs.Private 1.0 diff --git a/src/dialogs/qquickabstractdialog.cpp b/src/dialogs/qquickabstractdialog.cpp index 41aa1bdcc..92fd04f4e 100644 --- a/src/dialogs/qquickabstractdialog.cpp +++ b/src/dialogs/qquickabstractdialog.cpp @@ -35,6 +35,8 @@ #include "qquickitem.h" #include <private/qguiapplication_p.h> +#include <private/qqmlglobal_p.h> +#include <QLoggingCategory> #include <QWindow> #include <QQmlComponent> #include <QQuickWindow> @@ -42,6 +44,8 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcWindow, "qt.quick.dialogs.window") + QQmlComponent *QQuickAbstractDialog::m_decorationComponent(0); QQuickAbstractDialog::QQuickAbstractDialog(QObject *parent) @@ -70,6 +74,7 @@ void QQuickAbstractDialog::setVisible(bool v) if (m_visible == v) return; m_visible = v; if (helper()) { + qCDebug(lcWindow) << "via helper" << helper(); if (v) { Qt::WindowFlags flags = Qt::Dialog; if (!title().isEmpty()) @@ -88,6 +93,7 @@ void QQuickAbstractDialog::setVisible(bool v) if (!m_dialogWindow && m_hasNativeWindows) { QQuickWindow *win = new QQuickWindow; ((QObject *)win)->setParent(this); // memory management only + win->setFlags(Qt::Dialog); m_dialogWindow = win; m_contentItem->setParentItem(win->contentItem()); QSize minSize = QSize(m_contentItem->implicitWidth(), m_contentItem->implicitHeight()); @@ -106,33 +112,43 @@ void QQuickAbstractDialog::setVisible(bool v) m_dialogWindow->setMinimumSize(minSize); connect(win, SIGNAL(widthChanged(int)), this, SLOT(windowGeometryChanged())); connect(win, SIGNAL(heightChanged(int)), this, SLOT(windowGeometryChanged())); + qCDebug(lcWindow) << "created window" << win; } - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - - // If the platform does not support multiple windows, but the dialog is - // implemented as an Item, then try to decorate it as a fake window and make it visible. - if (parentItem && !m_dialogWindow && !m_windowDecoration) { - if (m_decorationComponent) { - if (m_decorationComponent->isLoading()) - connect(m_decorationComponent, SIGNAL(statusChanged(QQmlComponent::Status)), - this, SLOT(decorationLoaded())); - else - decorationLoaded(); + if (!m_dialogWindow) { + if (Q_UNLIKELY(!parentWindow())) { + qWarning("cannot set dialog visible: no window"); + return; } - // Window decoration wasn't possible, so just reparent it into the scene - else { - m_contentItem->setParentItem(parentItem); - m_contentItem->setZ(10000); + m_dialogWindow = parentWindow(); + + // If the platform does not support multiple windows, but the dialog is + // implemented as an Item, then try to decorate it as a fake window and make it visible. + if (!m_windowDecoration) { + if (m_decorationComponent) { + if (m_decorationComponent->isLoading()) + connect(m_decorationComponent, SIGNAL(statusChanged(QQmlComponent::Status)), + this, SLOT(decorationLoaded())); + else + decorationLoaded(); // do the reparenting of contentItem on top of it + } + // Window decoration wasn't possible, so just reparent it into the scene + else { + qCDebug(lcWindow) << "no window and no decoration"; + m_contentItem->setParentItem(parentWindow()->contentItem()); + m_contentItem->setZ(10000); + } } } } if (m_dialogWindow) { // "grow up" to the size and position expected to achieve if (!m_sizeAspiration.isNull()) { - if (m_hasAspiredPosition) + if (m_hasAspiredPosition) { + qCDebug(lcWindow) << "geometry aspiration" << m_sizeAspiration; m_dialogWindow->setGeometry(m_sizeAspiration); - else { + } else { + qCDebug(lcWindow) << "size aspiration" << m_sizeAspiration.size(); if (m_sizeAspiration.width() > 0) m_dialogWindow->setWidth(m_sizeAspiration.width()); if (m_sizeAspiration.height() > 0) @@ -142,6 +158,7 @@ void QQuickAbstractDialog::setVisible(bool v) connect(m_dialogWindow, SIGNAL(yChanged(int)), this, SLOT(setY(int))); connect(m_dialogWindow, SIGNAL(widthChanged(int)), this, SLOT(setWidth(int))); connect(m_dialogWindow, SIGNAL(heightChanged(int)), this, SLOT(setHeight(int))); + connect(m_contentItem, SIGNAL(implicitHeightChanged()), this, SLOT(implicitHeightChanged())); } if (!m_visibleChangedConnected) { connect(m_dialogWindow, SIGNAL(visibleChanged(bool)), this, SLOT(visibleChanged(bool))); @@ -166,9 +183,9 @@ void QQuickAbstractDialog::setVisible(bool v) void QQuickAbstractDialog::decorationLoaded() { bool ok = false; - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - while (parentItem->parentItem() && !parentItem->parentItem()->inherits("QQuickRootItem")) - parentItem = parentItem->parentItem(); + Q_ASSERT(parentWindow()); + QQuickItem *parentItem = parentWindow()->contentItem(); + Q_ASSERT(parentItem); if (m_decorationComponent->isError()) { qWarning() << m_decorationComponent->errors(); } else { @@ -182,6 +199,7 @@ void QQuickAbstractDialog::decorationLoaded() m_windowDecoration->setProperty("content", contentVariant); connect(m_windowDecoration, SIGNAL(dismissed()), this, SLOT(reject())); ok = true; + qCDebug(lcWindow) << "using synthetic window decoration" << m_windowDecoration; } else { qWarning() << m_decorationComponent->url() << "cannot be used as a window decoration because it's not an Item"; @@ -194,12 +212,14 @@ void QQuickAbstractDialog::decorationLoaded() if (!ok) { m_contentItem->setParentItem(parentItem); m_contentItem->setZ(10000); + qCDebug(lcWindow) << "no decoration"; } } void QQuickAbstractDialog::setModality(Qt::WindowModality m) { if (m_modality == m) return; + qCDebug(lcWindow) << "modality" << m; m_modality = m; emit modalityChanged(); } @@ -219,12 +239,14 @@ void QQuickAbstractDialog::reject() void QQuickAbstractDialog::visibleChanged(bool v) { m_visible = v; + qCDebug(lcWindow) << "visible" << v; emit visibilityChanged(); } void QQuickAbstractDialog::windowGeometryChanged() { if (m_dialogWindow && m_contentItem) { + qCDebug(lcWindow) << m_dialogWindow->geometry(); m_contentItem->setWidth(m_dialogWindow->width()); m_contentItem->setHeight(m_dialogWindow->height()); } @@ -232,27 +254,42 @@ void QQuickAbstractDialog::windowGeometryChanged() void QQuickAbstractDialog::minimumWidthChanged() { - m_dialogWindow->setMinimumWidth(qMax(m_contentItem->implicitWidth(), - m_contentItem->property("minimumWidth").toReal())); + qreal min = m_contentItem->property("minimumWidth").toReal(); + qCDebug(lcWindow) << "content implicitWidth" << m_contentItem->implicitWidth() << "minimumWidth" << min; + m_dialogWindow->setMinimumWidth(qMax(m_contentItem->implicitWidth(), min)); } void QQuickAbstractDialog::minimumHeightChanged() { + qreal min = m_contentItem->property("minimumHeight").toReal(); + qCDebug(lcWindow) << "content implicitHeight" << m_contentItem->implicitHeight() << "minimumHeight" << min; m_dialogWindow->setMinimumHeight(qMax(m_contentItem->implicitHeight(), m_contentItem->property("minimumHeight").toReal())); } +void QQuickAbstractDialog::implicitHeightChanged() +{ + qCDebug(lcWindow) << "content implicitHeight" << m_contentItem->implicitHeight() + << "window minimumHeight" << m_dialogWindow->minimumHeight(); + if (m_contentItem->implicitHeight() < m_dialogWindow->minimumHeight()) + m_dialogWindow->setMinimumHeight(m_contentItem->implicitHeight()); +} + QQuickWindow *QQuickAbstractDialog::parentWindow() { - QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); - if (parentItem) - m_parentWindow = parentItem->window(); + if (!m_parentWindow) { + // Usually a dialog is declared inside an Item; but if its QObject parent + // is a Window, that's the window we are interested in. (QTBUG-38578) + QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); + m_parentWindow = (parentItem ? parentItem->window() : qmlobject_cast<QQuickWindow *>(parent())); + } return m_parentWindow; } void QQuickAbstractDialog::setContentItem(QQuickItem *obj) { m_contentItem = obj; + qCDebug(lcWindow) << obj; if (m_dialogWindow) { disconnect(this, SLOT(visibleChanged(bool))); // Can't necessarily delete because m_dialogWindow might have been provided by the QML. @@ -288,6 +325,25 @@ int QQuickAbstractDialog::height() const return m_sizeAspiration.height(); } +/* + A non-fullscreen dialog is not allowed to be too large + to fit on the screen in either orientation (portrait or landscape). + That way on platforms which can do rotation, the dialog does not + change its size when the screen is rotated. So the value returned + here is the maximum for both width and height. We need to know + at init time, not wait until the dialog's content item is shown in + a window so that the desktopAvailableWidth and Height will be valid + in the Screen attached property. And to allow space for window borders, + the max is further reduced by 10%. +*/ +int QQuickAbstractDialog::__maximumDimension() const +{ + QScreen *screen = QGuiApplication::primaryScreen(); + return (screen ? + qMin(screen->availableVirtualGeometry().width(), screen->availableVirtualGeometry().height()) : + 480) * 9 / 10; +} + void QQuickAbstractDialog::setX(int arg) { m_hasAspiredPosition = true; @@ -300,6 +356,7 @@ void QQuickAbstractDialog::setX(int arg) } else if (m_contentItem) { m_contentItem->setX(arg); } + qCDebug(lcWindow) << arg; emit geometryChanged(); } @@ -315,6 +372,7 @@ void QQuickAbstractDialog::setY(int arg) } else if (m_contentItem) { m_contentItem->setY(arg); } + qCDebug(lcWindow) << arg; emit geometryChanged(); } @@ -329,6 +387,7 @@ void QQuickAbstractDialog::setWidth(int arg) } else if (m_contentItem) { m_contentItem->setWidth(arg); } + qCDebug(lcWindow) << arg; emit geometryChanged(); } @@ -343,6 +402,7 @@ void QQuickAbstractDialog::setHeight(int arg) } else if (m_contentItem) { m_contentItem->setHeight(arg); } + qCDebug(lcWindow) << arg; emit geometryChanged(); } diff --git a/src/dialogs/qquickabstractdialog_p.h b/src/dialogs/qquickabstractdialog_p.h index a74c539ba..164168fe0 100644 --- a/src/dialogs/qquickabstractdialog_p.h +++ b/src/dialogs/qquickabstractdialog_p.h @@ -66,6 +66,7 @@ class QQuickAbstractDialog : public QObject Q_PROPERTY(int y READ y WRITE setY NOTIFY geometryChanged) Q_PROPERTY(int width READ width WRITE setWidth NOTIFY geometryChanged) Q_PROPERTY(int height READ height WRITE setHeight NOTIFY geometryChanged) + Q_PROPERTY(int __maximumDimension READ __maximumDimension CONSTANT) public: QQuickAbstractDialog(QObject *parent = 0); @@ -80,6 +81,7 @@ public: int y() const; int width() const; int height() const; + int __maximumDimension() const; virtual void setVisible(bool v); virtual void setModality(Qt::WindowModality m); @@ -135,6 +137,7 @@ protected Q_SLOTS: void windowGeometryChanged(); void minimumWidthChanged(); void minimumHeightChanged(); + void implicitHeightChanged(); protected: virtual QPlatformDialogHelper *helper() = 0; diff --git a/src/dialogs/qquickcolordialog.cpp b/src/dialogs/qquickcolordialog.cpp index 514b275e0..d4f41f2bd 100644 --- a/src/dialogs/qquickcolordialog.cpp +++ b/src/dialogs/qquickcolordialog.cpp @@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype AbstractColorDialog \instantiates QQuickColorDialog - \inqmlmodule QtQuick.Dialogs 1 + \inqmlmodule QtQuick.Dialogs \ingroup qtquick-visual \brief API wrapper for QML file dialog implementations \since 5.1 diff --git a/src/dialogs/qquickfiledialog.cpp b/src/dialogs/qquickfiledialog.cpp index 576778e10..132131bcb 100644 --- a/src/dialogs/qquickfiledialog.cpp +++ b/src/dialogs/qquickfiledialog.cpp @@ -44,7 +44,7 @@ using namespace QV4; /*! \qmltype AbstractFileDialog \instantiates QQuickFileDialog - \inqmlmodule QtQuick.Dialogs 1 + \inqmlmodule QtQuick.Dialogs \ingroup qtquick-visual \brief API wrapper for QML file dialog implementations \since 5.1 @@ -176,14 +176,15 @@ void QQuickFileDialog::clearSelection() bool QQuickFileDialog::addSelection(const QUrl &path) { QFileInfo info(path.toLocalFile()); - if (info.exists() && ((info.isDir() && m_selectFolder) || !info.isDir())) { - if (m_selectFolder) - m_selections.append(pathFolder(path.toLocalFile())); - else - m_selections.append(path); - return true; - } - return false; + if (selectExisting() && !info.exists()) + return false; + if (selectFolder() != info.isDir()) + return false; + if (selectFolder()) + m_selections.append(pathFolder(path.toLocalFile())); + else + m_selections.append(path); + return true; } /*! diff --git a/src/dialogs/qquickfontdialog.cpp b/src/dialogs/qquickfontdialog.cpp index 9e8ee28ec..260ad710f 100644 --- a/src/dialogs/qquickfontdialog.cpp +++ b/src/dialogs/qquickfontdialog.cpp @@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype AbstractFontDialog \instantiates QQuickFontDialog - \inqmlmodule QtQuick.Dialogs 1 + \inqmlmodule QtQuick.Dialogs \ingroup qtquick-visual \brief API wrapper for QML font dialog implementations \since 5.2 diff --git a/src/dialogs/qquickmessagedialog.cpp b/src/dialogs/qquickmessagedialog.cpp index 55caad6aa..1a6ee470a 100644 --- a/src/dialogs/qquickmessagedialog.cpp +++ b/src/dialogs/qquickmessagedialog.cpp @@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype AbstractMessageDialog \instantiates QQuickMessageDialog - \inqmlmodule QtQuick.Dialogs 1 + \inqmlmodule QtQuick.Dialogs \ingroup qtquick-visual \brief API wrapper for QML message dialog implementations \since 5.2 diff --git a/src/dialogs/qquickplatformcolordialog.cpp b/src/dialogs/qquickplatformcolordialog.cpp index f48c4ab75..59ad97057 100644 --- a/src/dialogs/qquickplatformcolordialog.cpp +++ b/src/dialogs/qquickplatformcolordialog.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype ColorDialog \instantiates QQuickPlatformColorDialog - \inqmlmodule QtQuick.Dialogs 1 + \inqmlmodule QtQuick.Dialogs \ingroup dialogs \brief Dialog component for choosing a color. \since 5.1 diff --git a/src/dialogs/qquickplatformfiledialog.cpp b/src/dialogs/qquickplatformfiledialog.cpp index 7ed4e3fbc..b8f75ddc9 100644 --- a/src/dialogs/qquickplatformfiledialog.cpp +++ b/src/dialogs/qquickplatformfiledialog.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype FileDialog \instantiates QQuickPlatformFileDialog - \inqmlmodule QtQuick.Dialogs 1 + \inqmlmodule QtQuick.Dialogs \ingroup dialogs \brief Dialog component for choosing files from a local filesystem. \since 5.1 @@ -172,6 +172,21 @@ QQuickPlatformFileDialog::~QQuickPlatformFileDialog() delete m_dlgHelper; } +void QQuickPlatformFileDialog::setModality(Qt::WindowModality m) +{ +#ifdef Q_OS_WIN + // A non-modal native file dialog is not possible on Windows, so + // be stubborn about it. Emit modalityChanged() whether it changed + // or not, to ensure that anything which depends on the property + // will re-read the actual current value. + if (m != Qt::ApplicationModal) + m = Qt::ApplicationModal; + if (m == m_modality) + emit modalityChanged(); +#endif + QQuickAbstractFileDialog::setModality(m); +} + QPlatformFileDialogHelper *QQuickPlatformFileDialog::helper() { QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent()); diff --git a/src/dialogs/qquickplatformfiledialog_p.h b/src/dialogs/qquickplatformfiledialog_p.h index 411a78242..f21d01406 100644 --- a/src/dialogs/qquickplatformfiledialog_p.h +++ b/src/dialogs/qquickplatformfiledialog_p.h @@ -56,6 +56,7 @@ class QQuickPlatformFileDialog : public QQuickAbstractFileDialog public: QQuickPlatformFileDialog(QObject *parent = 0); virtual ~QQuickPlatformFileDialog(); + virtual void setModality(Qt::WindowModality m) Q_DECL_OVERRIDE; protected: QPlatformFileDialogHelper *helper(); diff --git a/src/dialogs/qquickplatformfontdialog.cpp b/src/dialogs/qquickplatformfontdialog.cpp index 1744cb846..37a1dad3f 100644 --- a/src/dialogs/qquickplatformfontdialog.cpp +++ b/src/dialogs/qquickplatformfontdialog.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype FontDialog \instantiates QQuickPlatformFontDialog - \inqmlmodule QtQuick.Dialogs 1 + \inqmlmodule QtQuick.Dialogs \ingroup qtquick-visual \ingroup dialogs \brief Dialog component for choosing a font. diff --git a/src/dialogs/qquickplatformmessagedialog.cpp b/src/dialogs/qquickplatformmessagedialog.cpp index c7b13c7ce..e27c5eba7 100644 --- a/src/dialogs/qquickplatformmessagedialog.cpp +++ b/src/dialogs/qquickplatformmessagedialog.cpp @@ -44,7 +44,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype MessageDialog \instantiates QQuickPlatformMessageDialog - \inqmlmodule QtQuick.Dialogs 1 + \inqmlmodule QtQuick.Dialogs \ingroup dialogs \brief Dialog component for displaying popup messages. \since 5.2 diff --git a/src/layouts/qquicklayoutstyleinfo.cpp b/src/layouts/qquicklayoutstyleinfo.cpp index 1b9f2f577..144b14f00 100644 --- a/src/layouts/qquicklayoutstyleinfo.cpp +++ b/src/layouts/qquicklayoutstyleinfo.cpp @@ -44,11 +44,18 @@ QQuickLayoutStyleInfo::QQuickLayoutStyleInfo() qreal QQuickLayoutStyleInfo::spacing(Qt::Orientation /*orientation*/) const { +#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) || defined(Q_OS_BLACKBERRY) || defined(Q_OS_QNX) || defined(Q_OS_WINRT) + // On Android and iOS the default spacing between each UI element is 8dp + qreal spacing = 8.0; +#else qreal spacing = 5.0; -#ifndef Q_OS_MAC - // On mac the DPI is always 72 so we should not scale it +#endif + +#ifndef Q_OS_OSX + // On OS X the DPI is always 72 so we should not scale it spacing = qRound(spacing * (qreal(qt_defaultDpiX()) / 96.0)); #endif + return spacing; } diff --git a/src/widgets/qquickqcolordialog.cpp b/src/widgets/qquickqcolordialog.cpp index 79ae51428..e72975c26 100644 --- a/src/widgets/qquickqcolordialog.cpp +++ b/src/widgets/qquickqcolordialog.cpp @@ -81,7 +81,7 @@ private: /*! \qmltype QtColorDialog \instantiates QQuickQColorDialog - \inqmlmodule QtQuick.PrivateWidgets 1 + \inqmlmodule QtQuick.PrivateWidgets \ingroup qtquick-visual \brief Dialog component for choosing a color. \since 5.1 diff --git a/src/widgets/qquickqfiledialog.cpp b/src/widgets/qquickqfiledialog.cpp index cae23622c..81e8aa531 100644 --- a/src/widgets/qquickqfiledialog.cpp +++ b/src/widgets/qquickqfiledialog.cpp @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype QtFileDialog \instantiates QQuickQFileDialog - \inqmlmodule QtQuick.PrivateWidgets 1 + \inqmlmodule QtQuick.PrivateWidgets \ingroup qtquick-visual \brief Dialog component for choosing files from a local filesystem. \since 5.1 diff --git a/src/widgets/qquickqfontdialog.cpp b/src/widgets/qquickqfontdialog.cpp index 635c80dcb..8fb93b3e3 100644 --- a/src/widgets/qquickqfontdialog.cpp +++ b/src/widgets/qquickqfontdialog.cpp @@ -83,7 +83,7 @@ private: /*! \qmltype QtFontDialog \instantiates QQuickQFontDialog - \inqmlmodule QtQuick.PrivateWidgets 1 + \inqmlmodule QtQuick.PrivateWidgets \ingroup qtquick-visual \brief Dialog component for choosing files from a local filesystem. \since 5.2 diff --git a/src/widgets/qquickqmessagebox.cpp b/src/widgets/qquickqmessagebox.cpp index 0b267158d..261239e94 100644 --- a/src/widgets/qquickqmessagebox.cpp +++ b/src/widgets/qquickqmessagebox.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE /*! \qmltype QtMessageDialog \instantiates QQuickQMessageBox - \inqmlmodule QtQuick.PrivateWidgets 1 + \inqmlmodule QtQuick.PrivateWidgets \ingroup qtquick-visual \brief Dialog component for choosing a color. \since 5.2 diff --git a/tests/auto/controls/controls.pro b/tests/auto/controls/controls.pro index 956113c6e..40fa77cdc 100644 --- a/tests/auto/controls/controls.pro +++ b/tests/auto/controls/controls.pro @@ -35,6 +35,8 @@ OTHER_FILES += \ $$PWD/data/tst_rowlayout.qml \ $$PWD/data/tst_gridlayout.qml \ $$PWD/data/tst_slider.qml \ + $$PWD/data/tst_stack.qml \ + $$PWD/data/tst_stackview.qml \ $$PWD/data/tst_statusbar.qml \ $$PWD/data/tst_switch.qml \ $$PWD/data/tst_tab.qml \ diff --git a/tests/auto/controls/data/rangemodel/bindings.qml b/tests/auto/controls/data/rangemodel/bindings.qml new file mode 100644 index 000000000..7ecdada8c --- /dev/null +++ b/tests/auto/controls/data/rangemodel/bindings.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** 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.Controls 1.2 +import QtQuick.Controls.Private 1.0 + +Item { + property alias range1: range1 + property alias range2: range2 + property alias range3: range3 + RangeModel { + id: range1 + value: 50 + minimumValue: 25 + maximumValue: 75 + } + RangeModel { + id: range2 + value: range1.value + minimumValue: range1.minimumValue + maximumValue: range1.maximumValue + } + RangeModel { + id: range3 + value: range2.value + minimumValue: range2.minimumValue + maximumValue: range2.maximumValue + } +} diff --git a/tests/auto/controls/data/shortcut/shortcuts.qml b/tests/auto/controls/data/shortcut/shortcuts.qml index 97a575e7f..eac6786ee 100644 --- a/tests/auto/controls/data/shortcut/shortcuts.qml +++ b/tests/auto/controls/data/shortcut/shortcuts.qml @@ -100,4 +100,38 @@ Rectangle { text: "&test" onTriggered: text.text = "alt t pressed" } + + CheckBox { + text: "&checkbox" + onClicked: text.text = "alt c pressed" + } + + RadioButton { + text: "&radiobutton" + onClicked: text.text = "alt r pressed" + } + + Button { + text: "button&1" + onClicked: text.text = "alt 1 pressed" + } + + Button { + action: Action { + text: "button&2" + } + onClicked: text.text = "alt 2 pressed" + } + + ToolButton { + text: "toolbutton&3" + onClicked: text.text = "alt 3 pressed" + } + + ToolButton { + action: Action { + text: "toolbutton&4" + } + onClicked: text.text = "alt 4 pressed" + } } diff --git a/examples/quick/controls/splitview/main.qml b/tests/auto/controls/data/tableview/tv_keys_2.qml index 8707b6cc8..06eba0efd 100644 --- a/examples/quick/controls/splitview/main.qml +++ b/tests/auto/controls/data/tableview/tv_keys_2.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -38,44 +38,37 @@ ** ****************************************************************************/ - - - - import QtQuick 2.2 import QtQuick.Controls 1.2 -import QtQuick.Layouts 1.0 - -ApplicationWindow { - visible: true - width: 600 - height: 400 - SplitView { - anchors.fill: parent +Row { + width: 100 + height: 200 + spacing: 10 + property alias control1: _control1 + ListModel { + id: libraryModel + ListElement{ title: "A Masterpiece" ; author: "Gabriel" } + ListElement{ title: "Brilliance" ; author: "Jens" } + ListElement{ title: "Outstanding" ; author: "Frederik" } + } - Rectangle { - id: column - width: 200 - Layout.minimumWidth: 100 - Layout.maximumWidth: 300 - color: "lightsteelblue" + FocusScope { + focus: true + id: _control1 + property alias control2: _control2 + property bool gotit: false + TableView { + id: _control2 + TableViewColumn{ role: "title" ; title: "Title" ; width: 100 } + TableViewColumn{ role: "author" ; title: "Author" ; width: 200 } + model: libraryModel } - - SplitView { - orientation: Qt.Vertical - Layout.fillWidth: true - - Rectangle { - id: row1 - height: 200 - color: "lightblue" - Layout.minimumHeight: 1 - } - - Rectangle { - id: row2 - color: "lightgray" + Keys.onPressed: { + if ((!gotit) && (event.key === Qt.Key_Up || event.key === Qt.Key_Down)) { + gotit = true; + event.accepted = true; + return; } } } diff --git a/tests/auto/controls/data/tst_rangemodel.qml b/tests/auto/controls/data/tst_rangemodel.qml index bbb0e3bfb..b29a67492 100644 --- a/tests/auto/controls/data/tst_rangemodel.qml +++ b/tests/auto/controls/data/tst_rangemodel.qml @@ -164,4 +164,23 @@ TestCase { compare(spy.count, 2) compare(range.position, 100) } + + function test_bindings() { + var component = Qt.createComponent("rangemodel/bindings.qml") + compare(component.status, Component.Ready) + var object = component.createObject(testCase) + verify(object !== null, "created object is null") + + compare(object.range1.value, 50) + compare(object.range1.minimumValue, 25) + compare(object.range1.maximumValue, 75) + + compare(object.range2.value, 50) + compare(object.range2.minimumValue, 25) + compare(object.range2.maximumValue, 75) + + compare(object.range3.value, 50) + compare(object.range3.minimumValue, 25) + compare(object.range3.maximumValue, 75) + } } diff --git a/tests/auto/controls/data/tst_shortcuts.qml b/tests/auto/controls/data/tst_shortcuts.qml index 385314bc5..7f32b045c 100644 --- a/tests/auto/controls/data/tst_shortcuts.qml +++ b/tests/auto/controls/data/tst_shortcuts.qml @@ -80,6 +80,12 @@ TestCase { { tag: "nokey_pressed3", key: Qt.Key_T, modifier: Qt.NoModifier, expected: "no key press" }, // on mac we don't have mnemonics { tag: "mnemonics", key: Qt.Key_T, modifier: Qt.AltModifier, expected: Qt.platform.os === "osx" ? "no key press" : "alt t pressed" }, + { tag: "checkbox", key: Qt.Key_C, modifier: Qt.AltModifier, expected: Qt.platform.os === "osx" ? "no key press" : "alt c pressed" }, + { tag: "radiobutton", key: Qt.Key_R, modifier: Qt.AltModifier, expected: Qt.platform.os === "osx" ? "no key press" : "alt r pressed" }, + { tag: "button", key: Qt.Key_1, modifier: Qt.AltModifier, expected: Qt.platform.os === "osx" ? "no key press" : "alt 1 pressed" }, + { tag: "button+action", key: Qt.Key_2, modifier: Qt.AltModifier, expected: Qt.platform.os === "osx" ? "no key press" : "alt 2 pressed" }, + { tag: "toolbutton", key: Qt.Key_3, modifier: Qt.AltModifier, expected: Qt.platform.os === "osx" ? "no key press" : "alt 3 pressed" }, + { tag: "toolbutton+action", key: Qt.Key_4, modifier: Qt.AltModifier, expected: Qt.platform.os === "osx" ? "no key press" : "alt 4 pressed" }, ] } diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index 3836fdde4..2541b1c58 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -41,6 +41,8 @@ import QtQuick 2.2 import QtTest 1.0 import QtQuickControlsTests 1.0 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Private 1.0 Item { id: container @@ -280,12 +282,16 @@ Item { function test_sliderOffset() { var control = Qt.createQmlObject('import QtQuick.Controls 1.2; Slider {x: 20; y: 20; width: 100; height: 50}', container, '') // Don't move slider value if mouse is inside handle regtion + mouseMove(control, control.width/2, control.height/2) mouseClick(control, control.width/2, control.height/2) compare(control.value, 0.5) + mouseMove(control, control.width/2 + 5, control.height/2) mouseClick(control, control.width/2 + 5, control.height/2) compare(control.value, 0.5) + mouseMove(control, control.width/2 - 5, control.height/2) mouseClick(control, control.width/2 - 5, control.height/2) compare(control.value, 0.5) + mouseMove(control, control.width/2 + 25, control.height/2) mouseClick(control, control.width/2 + 25, control.height/2) verify(control.value > 0.5) control.destroy() @@ -301,5 +307,28 @@ Item { compare(slider.__handlePos, 50) slider.destroy() } + + function test_dragThreshold() { + var control = Qt.createQmlObject('import QtQuick.Controls 1.2; Slider {x: 20; y: 20; width: 100; height: 50}', container, '') + + var pt = { x: control.width/2, y: control.height/2 } + + mousePress(control, pt.x, pt.y) + compare(control.value, 0.5) + + // drag less than the threshold distance + mouseMove(control, pt.x + Settings.dragThreshold - 1, pt.y) + compare(control.value, 0.5) + + // drag over the threshold + mouseMove(control, pt.x + Settings.dragThreshold + 1, pt.y) + verify(control.value > 0.5) + + // move back close to the original press point, less than the threshold distance away + mouseMove(control, pt.x - Settings.dragThreshold / 2, pt.y) + verify(control.value < 0.5) + + control.destroy() + } } } diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index f74386c94..71132ca9f 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -132,7 +132,10 @@ Item { {tag: "-20", input: [Qt.Key_Minus, Qt.Key_2, Qt.Key_0, Qt.Key_Return], value: -2, minimumValue: -10}, {tag: "-200", input: [Qt.Key_Minus, Qt.Key_2, Qt.Key_0, Qt.Key_0, Qt.Key_Return], value: -20, minimumValue: -100}, {tag: "-2000", input: [Qt.Key_Minus, Qt.Key_2, Qt.Key_0, Qt.Key_0, Qt.Key_0, Qt.Key_Return], value: -200, minimumValue: -1000}, - {tag: "-0123", input: [Qt.Key_Minus, Qt.Key_0, Qt.Key_1, Qt.Key_2, Qt.Key_3, Qt.Key_Return], value: -123, minimumValue: -150} + {tag: "-0123", input: [Qt.Key_Minus, Qt.Key_0, Qt.Key_1, Qt.Key_2, Qt.Key_3, Qt.Key_Return], value: -123, minimumValue: -150}, + + {tag: "5", input: [Qt.Key_2, Qt.Key_0, Qt.Key_Return], value: 20, minimumValue: 10, maximumValue: 99}, + {tag: "-5", input: [Qt.Key_Minus, Qt.Key_2, Qt.Key_0, Qt.Key_Return], value: -20, minimumValue: -99, maximumValue: -10}, ] } diff --git a/tests/auto/controls/data/tst_stackview.qml b/tests/auto/controls/data/tst_stackview.qml index 9bbe5f4b4..eaa8d14f2 100644 --- a/tests/auto/controls/data/tst_stackview.qml +++ b/tests/auto/controls/data/tst_stackview.qml @@ -46,10 +46,12 @@ TestCase { id: testCase name: "Tests_StackView" when: windowShown + visible: true width: 400 height: 400 Item { id: anItem } + TextField { id: textField } Component { id: pageComponent Item {} @@ -57,7 +59,7 @@ TestCase { Component { id: stackComponent - StackView {} + StackView { } } function test_stackview() { @@ -77,5 +79,28 @@ TestCase { var w = stack.width testCase.width = w + 333 compare(stack.width, w) + + stack.destroy() + } + + function test_focus() { + var stack = stackComponent.createObject(testCase, {initialItem: anItem, width: testCase.width, height: testCase.height}) + verify (stack !== null, "stackview created is null") + compare(stack.currentItem, anItem) + + stack.forceActiveFocus() + verify(stack.activeFocus) + + stack.push({item: textField, immediate: true}) + compare(stack.currentItem, textField) + textField.forceActiveFocus() + verify(textField.activeFocus) + + stack.pop({immediate: true}) + compare(stack.currentItem, anItem) + verify(stack.activeFocus) + verify(!textField.activeFocus) + + stack.destroy() } } diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml index 9e37f45e6..71f92a3f7 100644 --- a/tests/auto/controls/data/tst_tableview.qml +++ b/tests/auto/controls/data/tst_tableview.qml @@ -210,6 +210,55 @@ TestCase { test.destroy() } + function test_keys_2() { + var component = Qt.createComponent("tableview/tv_keys_2.qml") + compare(component.status, Component.Ready) + var test = component.createObject(container); + verify(test !== null, "test control created is null") + var control1 = test.control1 + verify(control1 !== null) + var control2 = control1.control2 + verify(control2 !== null) + + control2.forceActiveFocus() + verify(control2.activeFocus) + + control2.currentRow = 1 + control2.selection.select(1, 1) + + verify(control1.gotit === false) + verify(control2.currentRow === 1) + + keyClick(Qt.Key_Up); + verify(control1.activeFocus) + verify(control1.gotit === false) + verify(control2.currentRow === 0) + + keyClick(Qt.Key_Up); + verify(control1.activeFocus) + verify(control1.gotit === true) + verify(control2.currentRow === 0) + + control2.currentRow = 1 + control2.selection.select(1, 1) + control1.gotit = false + + verify(control1.gotit === false) + verify(control2.currentRow === 1) + + keyClick(Qt.Key_Down); + verify(control1.activeFocus) + verify(control1.gotit === false) + verify(control2.currentRow === 2) + + keyClick(Qt.Key_Down); + verify(control1.activeFocus) + verify(control1.gotit === true) + verify(control2.currentRow === 2) + + test.destroy() + } + function test_selection() { var component = Qt.createComponent("tableview/table2_qabstractitemmodel.qml") diff --git a/tests/auto/dialogs/tst_dialogs.cpp b/tests/auto/dialogs/tst_dialogs.cpp index 34af7e0c0..acf04c5c1 100644 --- a/tests/auto/dialogs/tst_dialogs.cpp +++ b/tests/auto/dialogs/tst_dialogs.cpp @@ -124,7 +124,11 @@ void tst_dialogs::fileDialogNonModal() QTest::mouseClick(window, Qt::LeftButton, 0, QPoint(1000, 100)); // hide QTRY_VERIFY(spyVisibilityChanged.count() > visibilityChangedCount); QCOMPARE(dlg->property("visible").toBool(), false); +#ifdef Q_OS_WIN + QCOMPARE(dlg->property("modality").toInt(), (int)Qt::ApplicationModal); +#else QCOMPARE(dlg->property("modality").toInt(), (int)Qt::NonModal); +#endif } void tst_dialogs::fileDialogNameFilters() diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/main.qml index 65e663796..479637ee0 100644 --- a/tests/manual/testbench/main.qml +++ b/tests/manual/testbench/main.qml @@ -51,7 +51,7 @@ ApplicationWindow { property bool ignoreUpdate: false onPropertyChanged: container.resetSize() - property var propertyMap: [] + property var propertyMap: ({}) property SpinBox widthControl property SpinBox heightControl @@ -175,8 +175,8 @@ ApplicationWindow { customStyle.checked = false if (status == Loader.Ready) { - propertyMap = [] - var arr = new Array + propertyMap = {} + var arr = {} for (var prop in item) { @@ -391,9 +391,9 @@ ApplicationWindow { arr[typeName].push({name: prop , result: val, typeString: typeName, layoutComponent: layout, enumModel: enumModelData}) } } - propertyMap = arr; - container.resetSize(); } + propertyMap = arr; + container.resetSize(); } } diff --git a/tests/manual/texthandles/main.qml b/tests/manual/texthandles/main.qml index ab10b861b..5a520d170 100644 --- a/tests/manual/texthandles/main.qml +++ b/tests/manual/texthandles/main.qml @@ -105,8 +105,8 @@ ApplicationWindow { selectByMouse: selectBox.checked style: TextFieldStyle { - cursorHandle: handleBox.checked ? cursorDelegate : null - selectionHandle: handleBox.checked ? selectionDelegate : null + __cursorHandle: handleBox.checked ? cursorDelegate : null + __selectionHandle: handleBox.checked ? selectionDelegate : null } } @@ -121,8 +121,8 @@ ApplicationWindow { horizontalAlignment: Qt.AlignHCenter style: SpinBoxStyle { - cursorHandle: handleBox.checked ? cursorDelegate : null - selectionHandle: handleBox.checked ? selectionDelegate : null + __cursorHandle: handleBox.checked ? cursorDelegate : null + __selectionHandle: handleBox.checked ? selectionDelegate : null } } @@ -148,8 +148,8 @@ ApplicationWindow { } style: ComboBoxStyle { - cursorHandle: handleBox.checked ? cursorDelegate : null - selectionHandle: handleBox.checked ? selectionDelegate : null + __cursorHandle: handleBox.checked ? cursorDelegate : null + __selectionHandle: handleBox.checked ? selectionDelegate : null } } @@ -164,8 +164,8 @@ ApplicationWindow { text: loremIpsum + "<p>" + loremIpsum + "<p>" + loremIpsum + "<p>" + loremIpsum style: TextAreaStyle { - cursorHandle: handleBox.checked ? cursorDelegate : null - selectionHandle: handleBox.checked ? selectionDelegate : null + __cursorHandle: handleBox.checked ? cursorDelegate : null + __selectionHandle: handleBox.checked ? selectionDelegate : null } } } diff --git a/examples/quick/controls/gallery/content/AboutDialog.qml b/tests/manual/workshop/content/AboutDialog.qml index e4837ff76..c4d87ee03 100644 --- a/examples/quick/controls/gallery/content/AboutDialog.qml +++ b/tests/manual/workshop/content/AboutDialog.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -43,7 +43,7 @@ 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" + title: "Qt Quick Controls Workshop" + text: "Qt Quick Controls Workshop" + detailedText: "A manual test for most of the available Qt Quick Controls" } diff --git a/examples/quick/controls/gallery/content/Controls.qml b/tests/manual/workshop/content/Controls.qml index 54ee99b9d..1abd57e4c 100644 --- a/examples/quick/controls/gallery/content/Controls.qml +++ b/tests/manual/workshop/content/Controls.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. diff --git a/examples/quick/controls/gallery/content/ImageViewer.qml b/tests/manual/workshop/content/ImageViewer.qml index dfac2e006..26d2da173 100644 --- a/examples/quick/controls/gallery/content/ImageViewer.qml +++ b/tests/manual/workshop/content/ImageViewer.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. diff --git a/examples/quick/controls/gallery/content/ModelView.qml b/tests/manual/workshop/content/ModelView.qml index a5d07d155..eb9f720d3 100644 --- a/examples/quick/controls/gallery/content/ModelView.qml +++ b/tests/manual/workshop/content/ModelView.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. diff --git a/examples/quick/controls/gallery/content/Styles.qml b/tests/manual/workshop/content/Styles.qml index 03be93fd1..d490e2b5e 100644 --- a/examples/quick/controls/gallery/content/Styles.qml +++ b/tests/manual/workshop/content/Styles.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. diff --git a/examples/quick/controls/gallery/images/bubble.png b/tests/manual/workshop/images/bubble.png Binary files differindex 62aa1efe5..62aa1efe5 100644 --- a/examples/quick/controls/gallery/images/bubble.png +++ b/tests/manual/workshop/images/bubble.png diff --git a/examples/quick/controls/gallery/images/button-pressed.png b/tests/manual/workshop/images/button-pressed.png Binary files differindex d64cdaa78..d64cdaa78 100644 --- a/examples/quick/controls/gallery/images/button-pressed.png +++ b/tests/manual/workshop/images/button-pressed.png diff --git a/examples/quick/controls/gallery/images/button.png b/tests/manual/workshop/images/button.png Binary files differindex 8ab41cc80..8ab41cc80 100644 --- a/examples/quick/controls/gallery/images/button.png +++ b/tests/manual/workshop/images/button.png diff --git a/examples/quick/controls/gallery/images/document-open.png b/tests/manual/workshop/images/document-open.png Binary files differindex f35f25835..f35f25835 100644 --- a/examples/quick/controls/gallery/images/document-open.png +++ b/tests/manual/workshop/images/document-open.png diff --git a/examples/quick/controls/gallery/images/document-open@2x.png b/tests/manual/workshop/images/document-open@2x.png Binary files differindex 9fdbb6657..9fdbb6657 100644 --- a/examples/quick/controls/gallery/images/document-open@2x.png +++ b/tests/manual/workshop/images/document-open@2x.png diff --git a/examples/quick/controls/gallery/images/document-save-as.png b/tests/manual/workshop/images/document-save-as.png Binary files differindex 5c9f6b343..5c9f6b343 100644 --- a/examples/quick/controls/gallery/images/document-save-as.png +++ b/tests/manual/workshop/images/document-save-as.png diff --git a/examples/quick/controls/gallery/images/document-save-as@2x.png b/tests/manual/workshop/images/document-save-as@2x.png Binary files differindex a15e34c92..a15e34c92 100644 --- a/examples/quick/controls/gallery/images/document-save-as@2x.png +++ b/tests/manual/workshop/images/document-save-as@2x.png diff --git a/examples/quick/controls/gallery/images/folder_new.png b/tests/manual/workshop/images/folder_new.png Binary files differindex 8d8bb9bd7..8d8bb9bd7 100644 --- a/examples/quick/controls/gallery/images/folder_new.png +++ b/tests/manual/workshop/images/folder_new.png diff --git a/examples/quick/controls/gallery/images/go-next.png b/tests/manual/workshop/images/go-next.png Binary files differindex a68e2db77..a68e2db77 100644 --- a/examples/quick/controls/gallery/images/go-next.png +++ b/tests/manual/workshop/images/go-next.png diff --git a/examples/quick/controls/gallery/images/go-previous.png b/tests/manual/workshop/images/go-previous.png Binary files differindex c37bc0414..c37bc0414 100644 --- a/examples/quick/controls/gallery/images/go-previous.png +++ b/tests/manual/workshop/images/go-previous.png diff --git a/examples/quick/controls/gallery/images/preferences-system.png b/tests/manual/workshop/images/preferences-system.png Binary files differindex 6e52db7cf..6e52db7cf 100644 --- a/examples/quick/controls/gallery/images/preferences-system.png +++ b/tests/manual/workshop/images/preferences-system.png diff --git a/examples/quick/controls/gallery/images/process-stop.png b/tests/manual/workshop/images/process-stop.png Binary files differindex e7a8d1722..e7a8d1722 100644 --- a/examples/quick/controls/gallery/images/process-stop.png +++ b/tests/manual/workshop/images/process-stop.png diff --git a/examples/quick/controls/gallery/images/progress-background.png b/tests/manual/workshop/images/progress-background.png Binary files differindex 55a069dfc..55a069dfc 100644 --- a/examples/quick/controls/gallery/images/progress-background.png +++ b/tests/manual/workshop/images/progress-background.png diff --git a/examples/quick/controls/gallery/images/progress-fill.png b/tests/manual/workshop/images/progress-fill.png Binary files differindex b588c9586..b588c9586 100644 --- a/examples/quick/controls/gallery/images/progress-fill.png +++ b/tests/manual/workshop/images/progress-fill.png diff --git a/examples/quick/controls/gallery/images/slider-handle.png b/tests/manual/workshop/images/slider-handle.png Binary files differindex ac4d4a0d9..ac4d4a0d9 100644 --- a/examples/quick/controls/gallery/images/slider-handle.png +++ b/tests/manual/workshop/images/slider-handle.png diff --git a/examples/quick/controls/gallery/images/tab.png b/tests/manual/workshop/images/tab.png Binary files differindex 74fefab78..74fefab78 100644 --- a/examples/quick/controls/gallery/images/tab.png +++ b/tests/manual/workshop/images/tab.png diff --git a/examples/quick/controls/gallery/images/tab_selected.png b/tests/manual/workshop/images/tab_selected.png Binary files differindex 665400ccf..665400ccf 100644 --- a/examples/quick/controls/gallery/images/tab_selected.png +++ b/tests/manual/workshop/images/tab_selected.png diff --git a/examples/quick/controls/gallery/images/textfield.png b/tests/manual/workshop/images/textfield.png Binary files differindex 1d4a38ab3..1d4a38ab3 100644 --- a/examples/quick/controls/gallery/images/textfield.png +++ b/tests/manual/workshop/images/textfield.png diff --git a/examples/quick/controls/gallery/images/toplevel_window.png b/tests/manual/workshop/images/toplevel_window.png Binary files differindex 4dc6a8cee..4dc6a8cee 100644 --- a/examples/quick/controls/gallery/images/toplevel_window.png +++ b/tests/manual/workshop/images/toplevel_window.png diff --git a/examples/quick/controls/gallery/images/view-refresh.png b/tests/manual/workshop/images/view-refresh.png Binary files differindex 606ea9eba..606ea9eba 100644 --- a/examples/quick/controls/gallery/images/view-refresh.png +++ b/tests/manual/workshop/images/view-refresh.png diff --git a/examples/quick/controls/gallery/images/window-new@2x.png b/tests/manual/workshop/images/window-new@2x.png Binary files differindex 36503018e..36503018e 100644 --- a/examples/quick/controls/gallery/images/window-new@2x.png +++ b/tests/manual/workshop/images/window-new@2x.png diff --git a/tests/manual/workshop/main.qml b/tests/manual/workshop/main.qml new file mode 100644 index 000000000..723a8886b --- /dev/null +++ b/tests/manual/workshop/main.qml @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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.Controls 1.2 +import QtQuick.Layouts 1.0 +import QtQuick.Dialogs 1.0 +import "content" + +ApplicationWindow { + visible: true + title: "Qt Quick Controls Workshop" + + width: 640 + height: 420 + minimumHeight: 400 + minimumWidth: 600 + + ImageViewer { id: imageViewer } + + FileDialog { + id: fileDialog + nameFilters: [ "Image files (*.png *.jpg)" ] + onAccepted: imageViewer.open(fileUrl) + } + + AboutDialog { id: aboutDialog } + + Action { + id: openAction + text: "&Open" + shortcut: StandardKey.Open + iconSource: "images/document-open.png" + onTriggered: fileDialog.open() + tooltip: "Open an image" + } + + Action { + id: copyAction + text: "&Copy" + shortcut: StandardKey.Copy + iconName: "edit-copy" + enabled: (!!activeFocusItem && !!activeFocusItem["copy"]) + onTriggered: activeFocusItem.copy() + } + + Action { + id: cutAction + text: "Cu&t" + shortcut: StandardKey.Cut + iconName: "edit-cut" + enabled: (!!activeFocusItem && !!activeFocusItem["cut"]) + onTriggered: activeFocusItem.cut() + } + + Action { + id: pasteAction + text: "&Paste" + shortcut: StandardKey.Paste + iconName: "edit-paste" + enabled: (!!activeFocusItem && !!activeFocusItem["paste"]) + onTriggered: activeFocusItem.paste() + } + + toolBar: ToolBar { + id: toolbar + RowLayout { + id: toolbarLayout + spacing: 0 + anchors.fill: parent + ToolButton { action: openAction } + ToolButton { + Accessible.name: "Save as" + iconSource: "images/document-save-as.png" + tooltip: "(Pretend to) Save as..." + } + Item { Layout.fillWidth: true } + CheckBox { + id: enabledCheck + text: "Enabled" + checked: true + } + } + } + + menuBar: MenuBar { + Menu { + title: "&File" + MenuItem { action: openAction } + MenuItem { + text: "E&xit" + shortcut: StandardKey.Quit + onTriggered: Qt.quit() + } + } + Menu { + title: "&Edit" + MenuItem { action: cutAction } + MenuItem { action: copyAction } + MenuItem { action: pasteAction } + } + Menu { + title: "&Help" + MenuItem { + text: "About..." + onTriggered: aboutDialog.open() + } + } + } + + TabView { + id:frame + enabled: enabledCheck.checked + tabPosition: controlPage.item ? controlPage.item.tabPosition : Qt.TopEdge + anchors.fill: parent + anchors.margins: Qt.platform.os === "osx" ? 12 : 2 + + Tab { + id: controlPage + title: "Controls" + Controls { } + } + Tab { + title: "Itemviews" + ModelView { } + } + Tab { + title: "Styles" + Styles { anchors.fill: parent } + } + } +} diff --git a/tests/manual/workshop/src/main.cpp b/tests/manual/workshop/src/main.cpp new file mode 100644 index 000000000..d8b3665ca --- /dev/null +++ b/tests/manual/workshop/src/main.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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$ +** +****************************************************************************/ + +#include "qt_quick_controls_testapp.h" +#include <QtQml/QQmlApplicationEngine> +#include <QtGui/QSurfaceFormat> +#include <QtQuick/QQuickWindow> + +int main(int argc, char *argv[]) +{ + QtQuickControlsTestApp app(argc, argv); + if (QCoreApplication::arguments().contains(QLatin1String("--coreprofile"))) { + QSurfaceFormat fmt; + fmt.setVersion(4, 4); + fmt.setProfile(QSurfaceFormat::CoreProfile); + QSurfaceFormat::setDefaultFormat(fmt); + } + QQmlApplicationEngine engine(QUrl("qrc:/main.qml")); + return app.exec(); +} diff --git a/examples/quick/controls/gallery/src/src.pri b/tests/manual/workshop/src/src.pri index 66d903eac..66d903eac 100644 --- a/examples/quick/controls/gallery/src/src.pri +++ b/tests/manual/workshop/src/src.pri diff --git a/tests/manual/workshop/workshop.pro b/tests/manual/workshop/workshop.pro new file mode 100644 index 000000000..c3abc14ce --- /dev/null +++ b/tests/manual/workshop/workshop.pro @@ -0,0 +1,18 @@ +QT += qml quick +TARGET = workshop +!no_desktop: QT += widgets + +include(src/src.pri) + +INCLUDEPATH += ../../shared + +OTHER_FILES += \ + main.qml \ + content/AboutDialog.qml \ + content/Controls.qml \ + content/ImageViewer.qml \ + content/ModelView.qml \ + content/Styles.qml + +RESOURCES += \ + workshop.qrc diff --git a/examples/quick/controls/gallery/resources.qrc b/tests/manual/workshop/workshop.qrc index 57d803b22..57d803b22 100644 --- a/examples/quick/controls/gallery/resources.qrc +++ b/tests/manual/workshop/workshop.qrc diff --git a/tests/shared/qt_quick_controls_quicktest.h b/tests/shared/qt_quick_controls_quicktest.h index 67dffa92a..cbbd5a258 100644 --- a/tests/shared/qt_quick_controls_quicktest.h +++ b/tests/shared/qt_quick_controls_quicktest.h @@ -34,14 +34,9 @@ #ifndef QT_QUICK_CONTROLS_QUICKTEST_H #define QT_QUICK_CONTROLS_QUICKTEST_H +#include "qt_quick_controls_testapp.h" #include <QtQuickTest/quicktestglobal.h> -#ifdef QT_WIDGETS_LIB -#include <QtWidgets/QApplication> -#else -#include <QtGui/QGuiApplication> -#endif - QT_BEGIN_NAMESPACE #ifdef QUICK_TEST_SOURCE_DIR @@ -50,18 +45,12 @@ QT_BEGIN_NAMESPACE #define QT_QUICK_CONTROLS_TEST_MAIN_VAR 0 #endif -#ifdef QT_WIDGETS_LIB -#define Application QApplication -#else -#define Application QGuiApplication -#endif - #define QT_QUICK_CONTROLS_TEST_MAIN(name) \ int main(int argc, char **argv) \ { \ - Application* app = 0; \ + QtQuickControlsTestApp* app = 0; \ if (!QCoreApplication::instance()) \ - app = new Application(argc, argv); \ + app = new QtQuickControlsTestApp(argc, argv); \ int i = quick_test_main(argc, argv, #name, QT_QUICK_CONTROLS_TEST_MAIN_VAR); \ delete app; \ return i; \ diff --git a/tests/shared/qt_quick_controls_testapp.h b/tests/shared/qt_quick_controls_testapp.h new file mode 100644 index 000000000..a57a4c5be --- /dev/null +++ b/tests/shared/qt_quick_controls_testapp.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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:LGPL21$ +** 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 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** 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. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT_QUICK_CONTROLS_TESTAPP_H +#define QT_QUICK_CONTROLS_TESTAPP_H + +#ifdef QT_WIDGETS_LIB +#include <QtWidgets/QApplication> +#else +#include <QtGui/QGuiApplication> +#endif + +QT_BEGIN_NAMESPACE + +#ifdef QT_WIDGETS_LIB +#define QtQuickControlsTestApp QApplication +#else +#define QtQuickControlsTestApp QGuiApplication +#endif + +QT_END_NAMESPACE + +#endif // QT_QUICK_CONTROLS_TESTAPP_H |
