diff --git a/examples/quick/controls/basiclayouts/basiclayouts.pro b/examples/quick/controls/basiclayouts/basiclayouts.pro index 144ad0fe4fec493d46c13c655b0be085427f5614..a5586fe62ffc6e8478f7572a6381c503b4be03f1 100644 --- a/examples/quick/controls/basiclayouts/basiclayouts.pro +++ b/examples/quick/controls/basiclayouts/basiclayouts.pro @@ -3,6 +3,7 @@ TARGET = basiclayouts !android: !ios: !blackberry: qtHaveModule(widgets): QT += widgets include(src/src.pri) +include(../shared/shared.pri) OTHER_FILES += \ main.qml diff --git a/examples/quick/controls/basiclayouts/main.qml b/examples/quick/controls/basiclayouts/main.qml index fe573aa6c98bcb6ed6cab041ba268926e2806201..18883d9a9fd9a6aa4e80e38b96fff4afa4505e4a 100644 --- a/examples/quick/controls/basiclayouts/main.qml +++ b/examples/quick/controls/basiclayouts/main.qml @@ -47,6 +47,7 @@ import QtQuick.Controls 1.1 import QtQuick.Layouts 1.0 ApplicationWindow { + visible: true title: "Basic layouts" property int margin: 11 width: mainLayout.implicitWidth + 2 * margin diff --git a/examples/quick/controls/basiclayouts/src/main.cpp b/examples/quick/controls/basiclayouts/src/main.cpp index 57ba57e3599d62d98f994b107bc6f5aacb60ad72..a757f4853bfbf9bcd6469529cfbc00854b38de47 100644 --- a/examples/quick/controls/basiclayouts/src/main.cpp +++ b/examples/quick/controls/basiclayouts/src/main.cpp @@ -38,5 +38,12 @@ ** ****************************************************************************/ -#include "../../shared/qt_quick_controls_examplemain.h" -QT_QUICK_CONTROLS_EXAMPLE_MAIN(qrc:/main.qml) +#include "qtquickcontrolsapplication.h" +#include <QtQml/QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QtQuickControlsApplication app(argc, argv); + QQmlApplicationEngine engine(QUrl("qrc:/main.qml")); + return app.exec(); +} diff --git a/examples/quick/controls/gallery/content/AboutDialog.qml b/examples/quick/controls/gallery/content/AboutDialog.qml new file mode 100644 index 0000000000000000000000000000000000000000..aec7b604392236f3a9370ce1bb819734bdd236ac --- /dev/null +++ b/examples/quick/controls/gallery/content/AboutDialog.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.2 +import QtQuick.Dialogs 1.1 + +MessageDialog { + icon: StandardIcon.Information + text: "QtQuick.Controls gallery example" + detailedText: "This example demonstrates most of the available Qt Quick Controls." + title: "About Gallery" +} diff --git a/examples/quick/controls/gallery/gallery.pro b/examples/quick/controls/gallery/gallery.pro index b9a5d0e66429c992d875755706b2fc1f213df0bc..68ed0c161e9b7cdc28958546cfff236f014a8ad2 100644 --- a/examples/quick/controls/gallery/gallery.pro +++ b/examples/quick/controls/gallery/gallery.pro @@ -3,9 +3,11 @@ TARGET = gallery !android: !ios: !blackberry: qtHaveModule(widgets): QT += widgets include(src/src.pri) +include(../shared/shared.pri) OTHER_FILES += \ main.qml \ + content/AboutDialog.qml \ content/ChildWindow.qml \ content/Controls.qml \ content/ImageViewer.qml \ diff --git a/examples/quick/controls/gallery/main.qml b/examples/quick/controls/gallery/main.qml index cd8240f7b6e99b1ea0b80bdf53d694e77b2c9eeb..61e77ef81e2f497043b212c56fb29732978afa77 100644 --- a/examples/quick/controls/gallery/main.qml +++ b/examples/quick/controls/gallery/main.qml @@ -49,6 +49,7 @@ import QtQuick.Dialogs 1.0 import "content" ApplicationWindow { + visible: true title: "Component Gallery" width: 640 @@ -70,6 +71,8 @@ ApplicationWindow { onAccepted: imageViewer.open(fileUrl) } + AboutDialog { id: aboutDialog } + Action { id: openAction text: "&Open" @@ -106,6 +109,12 @@ ApplicationWindow { onTriggered: activeFocusItem.paste() } + Action { + id: aboutAction + text: "About" + onTriggered: aboutDialog.open() + } + ExclusiveGroup { id: textFormatGroup @@ -210,6 +219,10 @@ ApplicationWindow { visible: false } } + Menu { + title: "&Help" + MenuItem { action: aboutAction } + } } diff --git a/examples/quick/controls/gallery/resources.qrc b/examples/quick/controls/gallery/resources.qrc index 6f48727404f8b4fe94346fd974f5f12cda4354bf..ca9c6521e04afdb09b8a051273f2f43ad5125f7b 100644 --- a/examples/quick/controls/gallery/resources.qrc +++ b/examples/quick/controls/gallery/resources.qrc @@ -1,6 +1,7 @@ <RCC> <qresource prefix="/"> <file>main.qml</file> + <file>content/AboutDialog.qml</file> <file>content/ChildWindow.qml</file> <file>content/Controls.qml</file> <file>content/ImageViewer.qml</file> diff --git a/examples/quick/controls/gallery/src/main.cpp b/examples/quick/controls/gallery/src/main.cpp index 57ba57e3599d62d98f994b107bc6f5aacb60ad72..a757f4853bfbf9bcd6469529cfbc00854b38de47 100644 --- a/examples/quick/controls/gallery/src/main.cpp +++ b/examples/quick/controls/gallery/src/main.cpp @@ -38,5 +38,12 @@ ** ****************************************************************************/ -#include "../../shared/qt_quick_controls_examplemain.h" -QT_QUICK_CONTROLS_EXAMPLE_MAIN(qrc:/main.qml) +#include "qtquickcontrolsapplication.h" +#include <QtQml/QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QtQuickControlsApplication app(argc, argv); + QQmlApplicationEngine engine(QUrl("qrc:/main.qml")); + return app.exec(); +} diff --git a/examples/quick/controls/shared/qt_quick_controls_examplemain.h b/examples/quick/controls/shared/qtquickcontrolsapplication.h similarity index 73% rename from examples/quick/controls/shared/qt_quick_controls_examplemain.h rename to examples/quick/controls/shared/qtquickcontrolsapplication.h index 7f73a6d182e6942565019a91f863c052680ad00f..171de6c671f8455b8bc1a3a81fcd8fb2cdbcea56 100644 --- a/examples/quick/controls/shared/qt_quick_controls_examplemain.h +++ b/examples/quick/controls/shared/qtquickcontrolsapplication.h @@ -39,12 +39,8 @@ ** ****************************************************************************/ -#ifndef QT_QUICK_CONTROLS_EXAMPLEMAIN_H -#define QT_QUICK_CONTROLS_EXAMPLEMAIN_H - -#include <QtQml> -#include <QtQuick/QQuickView> -#include <QtCore/QString> +#ifndef QTQUICKCONTROLSAPPLICATION_H +#define QTQUICKCONTROLSAPPLICATION_H #ifdef QT_WIDGETS_LIB #include <QtWidgets/QApplication> @@ -55,26 +51,11 @@ QT_BEGIN_NAMESPACE #ifdef QT_WIDGETS_LIB -#define Application QApplication +#define QtQuickControlsApplication QApplication #else -#define Application QGuiApplication +#define QtQuickControlsApplication QGuiApplication #endif -#define QT_QUICK_CONTROLS_EXAMPLE_MAIN(url) \ - int main(int argc, char *argv[]) \ - { \ - Application app(argc, argv); \ - QQmlApplicationEngine engine(QUrl(#url)); \ - QObject *topLevel = engine.rootObjects().value(0); \ - QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel); \ - if ( !window ) { \ - qWarning("Error: Your root item has to be a Window."); \ - return -1; \ - } \ - window->show(); \ - return app.exec(); \ - } - QT_END_NAMESPACE -#endif // QT_QUICK_CONTROLS_EXAMPLEMAIN_H +#endif // QTQUICKCONTROLSAPPLICATION_H diff --git a/examples/quick/controls/shared/shared.pri b/examples/quick/controls/shared/shared.pri new file mode 100644 index 0000000000000000000000000000000000000000..8ca347371def1dd256b14cf2fe0d5ef4615160e7 --- /dev/null +++ b/examples/quick/controls/shared/shared.pri @@ -0,0 +1,4 @@ +INCLUDEPATH += $$PWD + +SOURCES += \ + $$PWD/qtquickcontrolsapplication.h diff --git a/examples/quick/controls/splitview/main.qml b/examples/quick/controls/splitview/main.qml index 992607d622d04767791f7750c03c72081ee6f344..395188ce71a4c9f62476b0ed8af6657f292ccf04 100644 --- a/examples/quick/controls/splitview/main.qml +++ b/examples/quick/controls/splitview/main.qml @@ -47,6 +47,7 @@ import QtQuick.Controls 1.1 import QtQuick.Layouts 1.0 ApplicationWindow { + visible: true width: 600 height: 400 diff --git a/examples/quick/controls/splitview/splitview.pro b/examples/quick/controls/splitview/splitview.pro index 066e578c3f80d9ba461824650cfa4ea77e13381d..11c55f745d0e43e7cb8eb9c4c5657fb0db8847a1 100644 --- a/examples/quick/controls/splitview/splitview.pro +++ b/examples/quick/controls/splitview/splitview.pro @@ -3,6 +3,7 @@ TARGET = splitview !android: !ios: !blackberry: qtHaveModule(widgets): QT += widgets include(src/src.pri) +include(../shared/shared.pri) OTHER_FILES += \ main.qml diff --git a/examples/quick/controls/splitview/src/main.cpp b/examples/quick/controls/splitview/src/main.cpp index 57ba57e3599d62d98f994b107bc6f5aacb60ad72..a757f4853bfbf9bcd6469529cfbc00854b38de47 100644 --- a/examples/quick/controls/splitview/src/main.cpp +++ b/examples/quick/controls/splitview/src/main.cpp @@ -38,5 +38,12 @@ ** ****************************************************************************/ -#include "../../shared/qt_quick_controls_examplemain.h" -QT_QUICK_CONTROLS_EXAMPLE_MAIN(qrc:/main.qml) +#include "qtquickcontrolsapplication.h" +#include <QtQml/QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QtQuickControlsApplication app(argc, argv); + QQmlApplicationEngine engine(QUrl("qrc:/main.qml")); + return app.exec(); +} diff --git a/examples/quick/controls/tableview/main.qml b/examples/quick/controls/tableview/main.qml index 37ab383ee5f862602993f27f94140db78ef83d87..e613e42eccd260d5f55e2a5f8c4ceb103640264d 100644 --- a/examples/quick/controls/tableview/main.qml +++ b/examples/quick/controls/tableview/main.qml @@ -48,7 +48,7 @@ import QtQuick.Controls 1.1 import QtQuick.XmlListModel 2.0 Window { - + visible: true width: 538 + frame.margins * 2 height: 360 + frame.margins * 2 diff --git a/examples/quick/controls/tableview/src/main.cpp b/examples/quick/controls/tableview/src/main.cpp index 57ba57e3599d62d98f994b107bc6f5aacb60ad72..a757f4853bfbf9bcd6469529cfbc00854b38de47 100644 --- a/examples/quick/controls/tableview/src/main.cpp +++ b/examples/quick/controls/tableview/src/main.cpp @@ -38,5 +38,12 @@ ** ****************************************************************************/ -#include "../../shared/qt_quick_controls_examplemain.h" -QT_QUICK_CONTROLS_EXAMPLE_MAIN(qrc:/main.qml) +#include "qtquickcontrolsapplication.h" +#include <QtQml/QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QtQuickControlsApplication app(argc, argv); + QQmlApplicationEngine engine(QUrl("qrc:/main.qml")); + return app.exec(); +} diff --git a/examples/quick/controls/tableview/tableview.pro b/examples/quick/controls/tableview/tableview.pro index f3d7d7e6d37feb46178490fcd74d01a276354c2c..7238d007bd9ef713bebff5c627fef65db2512536 100644 --- a/examples/quick/controls/tableview/tableview.pro +++ b/examples/quick/controls/tableview/tableview.pro @@ -3,6 +3,7 @@ TARGET = tableview !android: !ios: !blackberry: qtHaveModule(widgets): QT += widgets include(src/src.pri) +include(../shared/shared.pri) OTHER_FILES += \ main.qml diff --git a/examples/quick/controls/texteditor/qml/main.qml b/examples/quick/controls/texteditor/qml/main.qml index 14bfa6234d79ad4bc3acc9a56a2d08d11066a2f2..89120094d24cb4975a46a96cb1474a939ddabc9d 100644 --- a/examples/quick/controls/texteditor/qml/main.qml +++ b/examples/quick/controls/texteditor/qml/main.qml @@ -38,14 +38,15 @@ ** ****************************************************************************/ -import QtQuick 2.1 +import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.0 -import QtQuick.Dialogs 1.0 +import QtQuick.Dialogs 1.1 import QtQuick.Window 2.1 import org.qtproject.example 1.0 ApplicationWindow { + visible: true width: 640 height: 480 minimumWidth: 400 @@ -53,35 +54,11 @@ ApplicationWindow { title: document.documentTitle + " - Text Editor Example" - ApplicationWindow { + MessageDialog { id: aboutBox - - width: 280 - height: 120 title: "About Text" - - ColumnLayout { - anchors.fill: parent - anchors.margins: 8 - Item { - Layout.fillWidth: true - Layout.fillHeight: true - Label { - anchors.centerIn: parent - horizontalAlignment: Text.AlignHCenter - text: "This is a basic text editor \nwritten with Qt Quick Controls" - } - } - Button { - text: "Ok" - isDefault: true - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - onClicked: aboutBox.close() - } - Keys.onReturnPressed: aboutBox.close() - focus: true - } + text: "This is a basic text editor \nwritten with Qt Quick Controls" + icon: StandardIcon.Information } Action { @@ -231,7 +208,7 @@ ApplicationWindow { } Menu { title: "&Help" - MenuItem { text: "About..." ; onTriggered: aboutBox.show() } + MenuItem { text: "About..." ; onTriggered: aboutBox.open() } } } diff --git a/examples/quick/controls/texteditor/src/main.cpp b/examples/quick/controls/texteditor/src/main.cpp index a096f70d1d72644029365064bf399ac2463cb65e..ea7d22de39fb87b3a63446ff17c1f6d67e6d009d 100644 --- a/examples/quick/controls/texteditor/src/main.cpp +++ b/examples/quick/controls/texteditor/src/main.cpp @@ -38,32 +38,14 @@ ** ****************************************************************************/ -#ifdef QT_WIDGETS_LIB -#include <QtWidgets/QApplication> -#else -#include <QtGui/QGuiApplication> -#endif -#include <QtQml> -#include <QtQuick/QQuickView> -#include <QtCore/QString> - +#include "qtquickcontrolsapplication.h" #include "documenthandler.h" +#include <QtQml/QQmlApplicationEngine> int main(int argc, char *argv[]) { -#ifdef QT_WIDGETS_LIB - QApplication app(argc, argv); -#else - QGuiApplication app(argc, argv); -#endif + QtQuickControlsApplication app(argc, argv); qmlRegisterType<DocumentHandler>("org.qtproject.example", 1, 0, "DocumentHandler"); QQmlApplicationEngine engine(QUrl("qrc:/qml/main.qml")); - QObject *topLevel = engine.rootObjects().value(0); - QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel); - if ( !window ) { - qWarning("Error: Your root item has to be a Window."); - return -1; - } - window->show(); return app.exec(); } diff --git a/examples/quick/controls/texteditor/texteditor.pro b/examples/quick/controls/texteditor/texteditor.pro index d9b6c8a33c1f8145af4cf261a89280538d2eee27..06e669d914f743918f43a8b76986c6f5fe3460a6 100644 --- a/examples/quick/controls/texteditor/texteditor.pro +++ b/examples/quick/controls/texteditor/texteditor.pro @@ -3,6 +3,7 @@ TARGET = texteditor !android: !ios: !blackberry: qtHaveModule(widgets): QT += widgets include(src/src.pri) +include(../shared/shared.pri) OTHER_FILES += \ qml/main.qml \ diff --git a/examples/quick/controls/touch/main.qml b/examples/quick/controls/touch/main.qml index a6de8910e4e73089f98197f9eaba046905d08771..ab5d534f7058a5ff87e1dddd159faf6e26c65ddc 100644 --- a/examples/quick/controls/touch/main.qml +++ b/examples/quick/controls/touch/main.qml @@ -43,6 +43,7 @@ import QtQuick.Controls 1.1 import "content" ApplicationWindow { + visible: true width: 800 height: 1280 diff --git a/examples/quick/controls/touch/src/main.cpp b/examples/quick/controls/touch/src/main.cpp index 57ba57e3599d62d98f994b107bc6f5aacb60ad72..a757f4853bfbf9bcd6469529cfbc00854b38de47 100644 --- a/examples/quick/controls/touch/src/main.cpp +++ b/examples/quick/controls/touch/src/main.cpp @@ -38,5 +38,12 @@ ** ****************************************************************************/ -#include "../../shared/qt_quick_controls_examplemain.h" -QT_QUICK_CONTROLS_EXAMPLE_MAIN(qrc:/main.qml) +#include "qtquickcontrolsapplication.h" +#include <QtQml/QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QtQuickControlsApplication app(argc, argv); + QQmlApplicationEngine engine(QUrl("qrc:/main.qml")); + return app.exec(); +} diff --git a/examples/quick/controls/touch/touch.pro b/examples/quick/controls/touch/touch.pro index 1e5d12f3c70fc03a0fbc32679d82fc233f65e4b1..6afca140455a2c8ee0517bc7ef7c6a7dc23e1875 100644 --- a/examples/quick/controls/touch/touch.pro +++ b/examples/quick/controls/touch/touch.pro @@ -3,6 +3,7 @@ TARGET = touch !android: !ios: !blackberry: qtHaveModule(widgets): QT += widgets include(src/src.pri) +include(../shared/shared.pri) OTHER_FILES += \ main.qml \ diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index 564e8d2af68b7c5d8200a33a56d00db685fd5cc6..6e0160df27c62a30d3c14ec356caeb6eca4eb8f6 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -119,11 +119,19 @@ Window { onStatusBarChanged: { if (statusBar) { statusBar.parent = statusBarArea } } + onVisibleChanged: { if (visible && menuBar) { menuBar.__parentWindow = root } } + /*! \internal */ default property alias data: contentArea.data color: syspal.window + flags: Qt.Window | Qt.WindowFullscreenButtonHint | + Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint | + Qt.WindowCloseButtonHint | Qt.WindowFullscreenButtonHint + // QTBUG-35049: Windows is removing features we didn't ask for, even though Qt::CustomizeWindowHint is not set + // Otherwise Qt.Window | Qt.WindowFullscreenButtonHint would be enough + SystemPalette {id: syspal} Item { diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index 8298a2d95f383c6103deed2fa84d34c40eab3e64..00842a40efee58117177ead8fe80eab51b1e6b06 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -323,8 +323,9 @@ Control { renderType: __style ? __style.renderType : Text.NativeRendering selectByMouse: true - selectionColor: syspal.highlight - selectedTextColor: syspal.highlightedText + color: __style.__syspal.text + selectionColor: __style.__syspal.highlight + selectedTextColor: __style.__syspal.highlightedText onAccepted: { var idx = input.find(editText) if (idx > -1) { @@ -340,8 +341,6 @@ Control { comboBox.accepted(); } - SystemPalette { id: syspal } - property bool blockUpdate: false property string prevText @@ -432,7 +431,7 @@ Control { property ExclusiveGroup eg: ExclusiveGroup { id: eg } - property bool __modelIsArray: popupItems.model ? popupItems.model.constructor === Array : false + property bool modelIsArray: false Instantiator { id: popupItems @@ -440,6 +439,7 @@ Control { property bool updatingModel: false onModelChanged: { + popup.modelIsArray = !!model ? model.constructor === Array : false if (active) { if (updatingModel && popup.__selectedIndex === 0) { // We still want to update the currentText @@ -449,12 +449,13 @@ Control { popup.__selectedIndex = 0 } } + popup.resolveTextValue(comboBox.textRole) } MenuItem { text: popup.textRole === '' ? modelData : - ((popup.__modelIsArray ? modelData[popup.textRole] : model[popup.textRole]) || '') + ((popup.modelIsArray ? modelData[popup.textRole] : model[popup.textRole]) || '') onTriggered: { if (index !== currentIndex) activated(index) @@ -479,7 +480,7 @@ Control { } var get = model['get']; - if (!get && popup.__modelIsArray) { + if (!get && popup.modelIsArray && !!model[0]) { if (model[0].constructor !== String && model[0].constructor !== Number) get = function(i) { return model[i]; } } diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp index a14a22d152b9328119e5e4fee37a2fe335f24bae..566a46f85ba03b7309c9b7865021b8303419ff46 100644 --- a/src/controls/Private/qquickstyleitem.cpp +++ b/src/controls/Private/qquickstyleitem.cpp @@ -112,7 +112,7 @@ public: } void initialize(QSGTexture *texture, - const QRectF &bounds, + const QRectF &bounds, qreal devicePixelRatio, int left, int top, int right, int bottom) { delete m_material.texture(); @@ -127,6 +127,9 @@ public: QRectF tc = texture->normalizedTextureSubRect(); QSize ts = texture->textureSize(); + ts.setHeight(ts.height() / devicePixelRatio); + ts.setWidth(ts.width() / devicePixelRatio); + qreal invtw = tc.width() / ts.width(); qreal invth = tc.height() / ts.height(); @@ -1661,6 +1664,7 @@ QSGNode *QQuickStyleItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *) styleNode->initialize(window()->createTextureFromImage(m_image, QQuickWindow::TextureCanUseAtlas), boundingRect(), + window()->devicePixelRatio(), m_border.left(), m_border.top(), m_border.right(), m_border.bottom()); return styleNode; } diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index 0cc2f5a7a6c0a939ab5c935611bea33c116c3b5d..c756566deca29d168ef0b22be852c49578e9ab65 100644 --- a/src/controls/SpinBox.qml +++ b/src/controls/SpinBox.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import QtQuick 2.1 +import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Controls.Private 1.0 @@ -164,6 +164,17 @@ Control { */ readonly property alias hovered: mouseArea.containsMouse + /*! + \qmlsignal SpinBox::editingFinished() + \since 5.2 + + This signal is emitted when the Return or Enter key is pressed or + the control loses focus. Note that if there is a validator + set on the control and enter/return is pressed, this signal will + only be emitted if the validator returns an acceptable state. + */ + signal editingFinished() + style: Qt.createComponent(Settings.style + "/SpinBoxStyle.qml", spinbox) /*! \internal */ @@ -255,6 +266,8 @@ Control { selectValue() } + onEditingFinished: spinbox.editingFinished() + color: __panel ? __panel.foregroundColor : "black" selectionColor: __panel ? __panel.selectionColor : "black" selectedTextColor: __panel ? __panel.selectedTextColor : "black" @@ -271,6 +284,7 @@ Control { MouseArea { id: mouseUp + objectName: "mouseUp" hoverEnabled: true property var upRect: __panel ? __panel.upRect : null @@ -285,6 +299,7 @@ Control { height: upRect ? upRect.height : 0 onClicked: __increment() + onPressed: if (activeFocusOnPress) input.forceActiveFocus() property bool autoincrement: false; onReleased: autoincrement = false @@ -296,9 +311,12 @@ Control { MouseArea { id: mouseDown + objectName: "mouseDown" hoverEnabled: true onClicked: __decrement() + onPressed: if (activeFocusOnPress) input.forceActiveFocus() + property var downRect: __panel ? __panel.downRect : null anchors.left: parent.left diff --git a/src/controls/Styles/Base/BusyIndicatorStyle.qml b/src/controls/Styles/Base/BusyIndicatorStyle.qml index 2a033024ea2908fcd9c963dd535e51dddf0268c9..d53ccb2925549232863133670d72016cc3e02a5e 100644 --- a/src/controls/Styles/Base/BusyIndicatorStyle.qml +++ b/src/controls/Styles/Base/BusyIndicatorStyle.qml @@ -37,7 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -import QtQuick 2.1 +import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Controls.Private 1.0 @@ -77,36 +77,25 @@ Style { /*! This defines the appearance of the busy indicator. */ property Component indicator: Item { - implicitWidth: 32 - implicitHeight: 32 + implicitWidth: 48 + implicitHeight: 48 opacity: control.running ? 1 : 0 - Behavior on opacity { NumberAnimation { duration: 250 } } + Behavior on opacity { OpacityAnimator { duration: 250 } } - Timer { - interval: 16 - running: control.running - repeat: true - onTriggered: { repeater.counter += 0.20 } - } - - Repeater { - id: repeater - model: 9 - anchors.fill: parent - property real counter: 0 - Rectangle { - width: repeater.width/6 + 2 - height: width - radius: width/2 - x: repeater.width/2 - transform: Rotation { origin.x: 0 ; origin.y: repeater.width/2 ; angle: 5 + (360/repeater.count) * index} - border.color: Qt.rgba(0, 0, 0, 0.24) - color: Qt.rgba(lum, lum, lum, lum/2 + 0.3) - property real lum: { - var idx = ((repeater.count-index) + repeater.counter) % repeater.count - return Math.max( 0.3, 1 - (idx/(repeater.count - 1))) - } + Image { + anchors.centerIn: parent + anchors.alignWhenCentered: true + width: Math.min(parent.width, parent.height) + height: width + source: width <= 32 ? "images/spinner_small.png" : + width >= 48 ? "images/spinner_large.png" : + "images/spinner_medium.png" + RotationAnimator on rotation { + duration: 800 + loops: Animation.Infinite + from: 0 + to: 360 } } } diff --git a/src/controls/Styles/Base/SpinBoxStyle.qml b/src/controls/Styles/Base/SpinBoxStyle.qml index 9f1b565d324719bc672da8aca469f55423f8de33..9cedf2b98ef2aae18dc32fd5bcbb6c1522c96e9d 100644 --- a/src/controls/Styles/Base/SpinBoxStyle.qml +++ b/src/controls/Styles/Base/SpinBoxStyle.qml @@ -76,8 +76,7 @@ Style { } /*! The content margins of the text field. */ - padding { top: 1 ; left: Math.round(TextSingleton.implicitHeight/2) ; right: Math.round(TextSingleton.implicitHeight) ; bottom: 0 } - + padding { top: 1 ; left: Math.round(styleData.contentHeight/2) ; right: Math.max(22, Math.round(styleData.contentHeight)) ; bottom: 0 } /*! \qmlproperty enumeration horizontalAlignment This property defines the default text aligment. @@ -141,8 +140,8 @@ Style { /*! The background of the SpinBox. */ property Component background: Item { - implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2)) - implicitWidth: styleData.contentWidth + 26 + implicitHeight: Math.max(25, Math.round(styleData.contentHeight * 1.2)) + implicitWidth: styleData.contentWidth + padding.left + padding.right Rectangle { anchors.fill: parent anchors.bottomMargin: -1 @@ -156,7 +155,7 @@ Style { GradientStop {color: "#fff" ; position: 0.1} GradientStop {color: "#fff" ; position: 1} } - radius: TextSingleton.implicitHeight * 0.16 + radius: control.font.pixelSize * 0.16 anchors.fill: parent border.color: control.activeFocus ? "#47b" : "#999" } diff --git a/src/controls/Styles/Base/TextFieldStyle.qml b/src/controls/Styles/Base/TextFieldStyle.qml index 8b4494d1864f9cd811b0b5cb9aa3b289e4eb8d91..4713130f35fc47da113ac5e76a6da8d4bf59f21b 100644 --- a/src/controls/Styles/Base/TextFieldStyle.qml +++ b/src/controls/Styles/Base/TextFieldStyle.qml @@ -77,7 +77,7 @@ Style { readonly property TextField control: __control /*! The content margins of the text field. */ - padding { top: 4 ; left: TextSingleton.implicitHeight/3 ; right: TextSingleton.implicitHeight/3 ; bottom:4 } + padding { top: 4 ; left: Math.round(control.__contentHeight/3) ; right: control.__contentHeight/3 ; bottom: 4 } /*! The current font. */ property font font @@ -93,6 +93,7 @@ Style { /*! \qmlproperty enumeration renderType + \since 5.2 Override the default rendering type for the control. @@ -113,8 +114,8 @@ Style { /*! The background of the text field. */ property Component background: Item { - implicitWidth: Math.round(TextSingleton.implicitHeight * 8) - implicitHeight: Math.max(25, Math.round(TextSingleton.implicitHeight * 1.2)) + implicitWidth: Math.round(control.__contentHeight * 8) + implicitHeight: Math.max(25, Math.round(control.__contentHeight * 1.2)) Rectangle { anchors.fill: parent anchors.bottomMargin: -1 @@ -128,7 +129,7 @@ Style { GradientStop {color: "#fff" ; position: 0.1} GradientStop {color: "#fff" ; position: 1} } - radius: TextSingleton.implicitHeight * 0.16 + radius: control.__contentHeight * 0.16 anchors.fill: parent border.color: control.activeFocus ? "#47b" : "#999" } diff --git a/src/controls/Styles/Base/images/spinner_large.png b/src/controls/Styles/Base/images/spinner_large.png new file mode 100644 index 0000000000000000000000000000000000000000..bfd1b6375a7a4bcfceb295cfc99ccf8b219c63ef Binary files /dev/null and b/src/controls/Styles/Base/images/spinner_large.png differ diff --git a/src/controls/Styles/Base/images/spinner_medium.png b/src/controls/Styles/Base/images/spinner_medium.png new file mode 100644 index 0000000000000000000000000000000000000000..41409d45ce676b98af9e5b2933f13e82e7ad4ca0 Binary files /dev/null and b/src/controls/Styles/Base/images/spinner_medium.png differ diff --git a/src/controls/Styles/Base/images/spinner_small.png b/src/controls/Styles/Base/images/spinner_small.png new file mode 100644 index 0000000000000000000000000000000000000000..2f6048e429bc372035071e15153ae1ee15b81634 Binary files /dev/null and b/src/controls/Styles/Base/images/spinner_small.png differ diff --git a/src/controls/Styles/styles.pri b/src/controls/Styles/styles.pri index 5a36767e31e1109fb86bbaf72645a033b62e7633..d695893a0e0e9cf60e3acc99d5576646c6c1f1fe 100644 --- a/src/controls/Styles/styles.pri +++ b/src/controls/Styles/styles.pri @@ -73,6 +73,9 @@ STYLES_QML_FILES += \ $$PWD/Base/images/arrow-left@2x.png \ $$PWD/Base/images/arrow-right.png \ $$PWD/Base/images/arrow-right@2x.png \ + $$PWD/Base/images/spinner_small.png \ + $$PWD/Base/images/spinner_medium.png \ + $$PWD/Base/images/spinner_large.png \ $$PWD/Base/images/check.png \ $$PWD/Base/images/check@2x.png diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index 586f1211dfcd9869cf991cc5b0e492c16834544e..736ac6e398d1c3bc84c9e720ee5e57f59933eaa3 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -830,7 +830,6 @@ ScrollView { } } } - onWidthChanged: listView.contentWidth = width } } @@ -991,6 +990,7 @@ ScrollView { } } } + onWidthChanged: listView.contentWidth = width } Loader { id: loader diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index c1e3ddab4ef547f8da6374bd90d406e2c58ed266..0bd4db1e80812a70896460c07b7c175d94b9298e 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -38,7 +38,7 @@ ** ****************************************************************************/ -import QtQuick 2.1 +import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Controls.Private 1.0 @@ -402,6 +402,18 @@ Control { */ signal accepted() + /*! + \qmlsignal TextField::editingFinished() + \since 5.2 + + This signal is emitted when the Return or Enter key is pressed or + the text field loses focus. Note that if there is a validator or + inputMask set on the text field and enter/return is pressed, this + signal will only be emitted if the input follows + the inputMask and the validator returns an acceptable state. + */ + signal editingFinished() + /*! \qmlmethod TextField::copy() @@ -572,7 +584,7 @@ Control { selectionColor: __panel ? __panel.selectionColor : "darkred" selectedTextColor: __panel ? __panel.selectedTextColor : "white" - font: __panel ? __panel.font : font + font: __panel ? __panel.font : undefined anchors.leftMargin: __panel ? __panel.leftMargin : 0 anchors.topMargin: __panel ? __panel.topMargin : 0 anchors.rightMargin: __panel ? __panel.rightMargin : 0 @@ -591,5 +603,7 @@ Control { Qt.inputMethod.hide() textfield.accepted() } + + onEditingFinished: textfield.editingFinished() } } diff --git a/src/controls/plugins.qmltypes b/src/controls/plugins.qmltypes index e82b58a58c8b978c0a637aab7f0e0a03a112e00b..eadb72efb7a612702cd098c3eafb38c4e92bda52 100644 --- a/src/controls/plugins.qmltypes +++ b/src/controls/plugins.qmltypes @@ -948,7 +948,164 @@ Module { Property { name: "__style"; type: "QObject"; isReadonly: true; isPointer: true } } Component { + name: "QQuickText" + defaultProperty: "data" prototype: "QQuickImplicitSizeItem" + exports: ["QtQuick/Text 2.0"] + exportMetaObjectRevisions: [0] + Enum { + name: "HAlignment" + values: { + "AlignLeft": 1, + "AlignRight": 2, + "AlignHCenter": 4, + "AlignJustify": 8 + } + } + Enum { + name: "VAlignment" + values: { + "AlignTop": 32, + "AlignBottom": 64, + "AlignVCenter": 128 + } + } + Enum { + name: "TextStyle" + values: { + "Normal": 0, + "Outline": 1, + "Raised": 2, + "Sunken": 3 + } + } + Enum { + name: "TextFormat" + values: { + "PlainText": 0, + "RichText": 1, + "AutoText": 2, + "StyledText": 4 + } + } + Enum { + name: "TextElideMode" + values: { + "ElideLeft": 0, + "ElideRight": 1, + "ElideMiddle": 2, + "ElideNone": 3 + } + } + Enum { + name: "WrapMode" + values: { + "NoWrap": 0, + "WordWrap": 1, + "WrapAnywhere": 3, + "WrapAtWordBoundaryOrAnywhere": 4, + "Wrap": 4 + } + } + Enum { + name: "RenderType" + values: { + "QtRendering": 0, + "NativeRendering": 1 + } + } + Enum { + name: "LineHeightMode" + values: { + "ProportionalHeight": 0, + "FixedHeight": 1 + } + } + Enum { + name: "FontSizeMode" + values: { + "FixedSize": 0, + "HorizontalFit": 1, + "VerticalFit": 2, + "Fit": 3 + } + } + Property { name: "text"; type: "string" } + Property { name: "font"; type: "QFont" } + Property { name: "color"; type: "QColor" } + Property { name: "linkColor"; type: "QColor" } + Property { name: "style"; type: "TextStyle" } + Property { name: "styleColor"; type: "QColor" } + Property { name: "horizontalAlignment"; type: "HAlignment" } + Property { name: "effectiveHorizontalAlignment"; type: "HAlignment"; isReadonly: true } + Property { name: "verticalAlignment"; type: "VAlignment" } + Property { name: "wrapMode"; type: "WrapMode" } + Property { name: "lineCount"; type: "int"; isReadonly: true } + Property { name: "truncated"; type: "bool"; isReadonly: true } + Property { name: "maximumLineCount"; type: "int" } + Property { name: "textFormat"; type: "TextFormat" } + Property { name: "elide"; type: "TextElideMode" } + Property { name: "contentWidth"; type: "double"; isReadonly: true } + Property { name: "contentHeight"; type: "double"; isReadonly: true } + Property { name: "paintedWidth"; type: "double"; isReadonly: true } + Property { name: "paintedHeight"; type: "double"; isReadonly: true } + Property { name: "lineHeight"; type: "double" } + Property { name: "lineHeightMode"; type: "LineHeightMode" } + Property { name: "baseUrl"; type: "QUrl" } + Property { name: "minimumPixelSize"; type: "int" } + Property { name: "minimumPointSize"; type: "int" } + Property { name: "fontSizeMode"; type: "FontSizeMode" } + Property { name: "renderType"; type: "RenderType" } + Signal { + name: "textChanged" + Parameter { name: "text"; type: "string" } + } + Signal { + name: "linkActivated" + Parameter { name: "link"; type: "string" } + } + Signal { + name: "fontChanged" + Parameter { name: "font"; type: "QFont" } + } + Signal { + name: "styleChanged" + Parameter { name: "style"; type: "TextStyle" } + } + Signal { + name: "horizontalAlignmentChanged" + Parameter { name: "alignment"; type: "HAlignment" } + } + Signal { + name: "verticalAlignmentChanged" + Parameter { name: "alignment"; type: "VAlignment" } + } + Signal { + name: "textFormatChanged" + Parameter { name: "textFormat"; type: "TextFormat" } + } + Signal { + name: "elideModeChanged" + Parameter { name: "mode"; type: "TextElideMode" } + } + Signal { name: "contentSizeChanged" } + Signal { + name: "lineHeightChanged" + Parameter { name: "lineHeight"; type: "double" } + } + Signal { + name: "lineHeightModeChanged" + Parameter { name: "mode"; type: "LineHeightMode" } + } + Signal { + name: "lineLaidOut" + Parameter { name: "line"; type: "QQuickTextLine"; isPointer: true } + } + Method { name: "doLayout" } + } + + Component { + prototype: "QQuickText" name: "QtQuick.Controls/Label" exports: ["QtQuick.Controls/Label 1.0"] exportMetaObjectRevisions: [0] diff --git a/tests/auto/controls/data/spinbox/sp_editingfinished.qml b/tests/auto/controls/data/spinbox/sp_editingfinished.qml new file mode 100644 index 0000000000000000000000000000000000000000..d85e6eae3355c6a222db25e8d142690ad9f3dd7e --- /dev/null +++ b/tests/auto/controls/data/spinbox/sp_editingfinished.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Quick Controls module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 +import QtQuick.Controls 1.1 + +Row { + width: 100 + height: 50 + spacing: 10 + + property alias control1: _control1 + property alias control2: _control2 + SpinBox { + id: _control1 + property bool myeditingfinished: false + onEditingFinished: myeditingfinished = true + } + SpinBox { + id: _control2 + property bool myeditingfinished: false + onEditingFinished: myeditingfinished = true + } +} diff --git a/tests/auto/controls/data/textfield/tf_editingfinished.qml b/tests/auto/controls/data/textfield/tf_editingfinished.qml new file mode 100644 index 0000000000000000000000000000000000000000..d38423a430092b61130a39635689d8168a01f335 --- /dev/null +++ b/tests/auto/controls/data/textfield/tf_editingfinished.qml @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** 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.1 + +Row { + width: 100 + height: 50 + spacing: 10 + + property alias control1: _control1 + property alias control2: _control2 + TextField { + id: _control1 + text: 'A' + property bool myeditingfinished: false + onEditingFinished: myeditingfinished = true + } + TextField { + id: _control2 + text: 'B' + property bool myeditingfinished: false + onEditingFinished: myeditingfinished = true + } +} diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 802d23e429ed7e5f74f62ef26aa7610d8f8b8aec..256e213e02d0f620c51f633830218b52b262e6ea 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -118,13 +118,15 @@ TestCase { } function test_arraymodelwithtextrole() { - // FIXME The use-case before this change should work. - var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.1 ; \ - ComboBox { \ - model: [ { "text": "Banana", "color": "Yellow"}, \ - { "text": "Apple", "color": "Green"}, \ - { "text": "Coconut", "color": "Brown"} ]; \ - textRole: "text" }', testCase, ''); + var arrayModel = [ + {text: 'Banana', color: 'Yellow'}, + {text: 'Apple', color: 'Green'}, + {text: 'Coconut', color: 'Brown'} + ]; + + var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.1 ; ComboBox { }', testCase, ''); + comboBox.textRole = "text" + comboBox.model = arrayModel compare(comboBox.currentIndex, 0) compare(comboBox.currentText, "Banana") comboBox.textRole = "color" diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index 67dd3dba9804ff39f764cb6e504ddd703c86a008..176a70b5e715ce8fe5806a72956180db309917e0 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -343,6 +343,86 @@ Item { spinbox2.destroy() } + function test_setFontsize(){ + var control = Qt.createQmlObject('import QtQuick.Controls 1.1; import QtQuick.Controls.Styles 1.1; SpinBox {style: SpinBoxStyle{}}', container, '') + var width = control.width; + var height = control.height; + control.font.pixelSize = 40 + verify(control.width > width) // ensure that the text field resizes + verify(control.height > height) + control.destroy() + } + + function test_get_active_focus_when_up_or_down_was_pressed(){ + var test_control = 'import QtQuick 2.1; \ + import QtQuick.Controls 1.1; \ + Column { \ + property alias spinbox: _spinbox; \ + property alias textfield: _textfield; \ + SpinBox { \ + id: _spinbox; \ + } \ + TextField { \ + id: _textfield; \ + text: "textfile"; \ + } \ + } ' + + var control = Qt.createQmlObject(test_control, container, '') + verify(control !== null) + + var spinbox = control.spinbox + var textfield = control.textfield + verify(spinbox !== null) + verify(textfield !== null) + + waitForRendering(control) + + var up = getMouseArea(spinbox, "mouseUp") + verify(up !== null) + var down = getMouseArea(spinbox, "mouseDown") + verify(down !== null) + + textfield.forceActiveFocus() + verify(!spinbox.activeFocus) + verify(textfield.activeFocus) + + mouseClick(up, up.width/2, up.height/2) + verify(spinbox.activeFocus) + verify(!textfield.activeFocus) + + textfield.forceActiveFocus() + verify(!spinbox.activeFocus) + verify(textfield.activeFocus) + + mouseClick(down, down.width/2, down.height/2) + verify(spinbox.activeFocus) + verify(!textfield.activeFocus) + + textfield.forceActiveFocus() + verify(!spinbox.activeFocus) + verify(textfield.activeFocus) + spinbox.activeFocusOnPress = false + + mouseClick(up, up.width/2, up.height/2) + verify(!spinbox.activeFocus) + verify(textfield.activeFocus) + + mouseClick(down, down.width/2, down.height/2) + verify(!spinbox.activeFocus) + verify(textfield.activeFocus) + + control.destroy() + } + + function getMouseArea(control, name) { + for (var i = 0; i < control.children.length; i++) { + if (control.children[i].objectName === name) + return control.children[i] + } + return null + } + function test_activeFocusOnPress(){ var spinbox = Qt.createQmlObject('import QtQuick.Controls 1.1; SpinBox {x: 20; y: 20; width: 100; height: 50}', container, '') spinbox.activeFocusOnPress = false @@ -476,6 +556,36 @@ Item { spinbox.destroy() } + function test_editingFinished() { + var component = Qt.createComponent("spinbox/sp_editingfinished.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 = test.control2 + verify(control2 !== null) + + control1.forceActiveFocus() + verify(control1.activeFocus) + verify(!control2.activeFocus) + + verify(control1.myeditingfinished === false) + verify(control2.myeditingfinished === false) + + keyPress(Qt.Key_Tab) + verify(!control1.activeFocus) + verify(control2.activeFocus) + verify(control1.myeditingfinished === true) + + keyPress(Qt.Key_Enter) + verify(!control1.activeFocus) + verify(control2.activeFocus) + verify(control2.myeditingfinished === true) + + test.destroy() + } + function test_construction() { // onValueChanged should not be emitted during construction. var root = Qt.createQmlObject(" diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml index 6a1769974732ed7394eb41360669519ebf8c76c3..a526d1f0e966066e1aa3c38f7d8e5e5bf2861991 100644 --- a/tests/auto/controls/data/tst_textfield.qml +++ b/tests/auto/controls/data/tst_textfield.qml @@ -280,6 +280,16 @@ TestCase { control.destroy() } + function test_setFontsize(){ + var control = Qt.createQmlObject('import QtQuick.Controls 1.1; import QtQuick.Controls.Styles 1.1; TextField {style:TextFieldStyle{}}', container, '') + var width = control.width; + var height = control.height; + control.font.pixelSize = 40 + verify(control.width > width) // ensure that the text field resizes + verify(control.height > height) + control.destroy() + } + function test_activeFocusOnTab() { // Set TextField readonly so the tab/backtab can be tested toward the navigation var test_control = 'import QtQuick 2.1; \ @@ -356,5 +366,35 @@ TestCase { verify(!control.control3.activeFocus) control.destroy() } + + function test_editingFinished() { + var component = Qt.createComponent("textfield/tf_editingfinished.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 = test.control2 + verify(control2 !== null) + + control1.forceActiveFocus() + verify(control1.activeFocus) + verify(!control2.activeFocus) + + verify(control1.myeditingfinished === false) + verify(control2.myeditingfinished === false) + + keyPress(Qt.Key_Tab) + verify(!control1.activeFocus) + verify(control2.activeFocus) + verify(control1.myeditingfinished === true) + + keyPress(Qt.Key_Enter) + verify(!control1.activeFocus) + verify(control2.activeFocus) + verify(control2.myeditingfinished === true) + + test.destroy() + } } }