diff options
29 files changed, 118 insertions, 82 deletions
diff --git a/.qmake.conf b/.qmake.conf index 2f09a2ba..45d05b25 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,3 +1,3 @@ load(qt_build_config) -MODULE_VERSION = 5.2.0 +MODULE_VERSION = 5.2.1 diff --git a/examples/quick/controls/basiclayouts/basiclayouts.pro b/examples/quick/controls/basiclayouts/basiclayouts.pro index 144ad0fe..a5586fe6 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 fe573aa6..18883d9a 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 57ba57e3..a757f485 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/gallery.pro b/examples/quick/controls/gallery/gallery.pro index 09358658..68ed0c16 100644 --- a/examples/quick/controls/gallery/gallery.pro +++ b/examples/quick/controls/gallery/gallery.pro @@ -3,6 +3,7 @@ TARGET = gallery !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/gallery/main.qml b/examples/quick/controls/gallery/main.qml index 43b6776e..61e77ef8 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 diff --git a/examples/quick/controls/gallery/src/main.cpp b/examples/quick/controls/gallery/src/main.cpp index 57ba57e3..a757f485 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 index 7f73a6d1..171de6c6 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 00000000..8ca34737 --- /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 992607d6..395188ce 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 066e578c..11c55f74 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 57ba57e3..a757f485 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 d664e452..d15b6f65 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 57ba57e3..a757f485 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 f3d7d7e6..7238d007 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 50cbed56..89120094 100644 --- a/examples/quick/controls/texteditor/qml/main.qml +++ b/examples/quick/controls/texteditor/qml/main.qml @@ -46,6 +46,7 @@ import QtQuick.Window 2.1 import org.qtproject.example 1.0 ApplicationWindow { + visible: true width: 640 height: 480 minimumWidth: 400 diff --git a/examples/quick/controls/texteditor/src/main.cpp b/examples/quick/controls/texteditor/src/main.cpp index a096f70d..ea7d22de 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 d9b6c8a3..06e669d9 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 a6de8910..ab5d534f 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 57ba57e3..a757f485 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 1e5d12f3..6afca140 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/ComboBox.qml b/src/controls/ComboBox.qml index db39f579..d7a3d3d1 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -323,8 +323,9 @@ Control { 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/Styles/Base/SpinBoxStyle.qml b/src/controls/Styles/Base/SpinBoxStyle.qml index 9f1b565d..9cedf2b9 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 8b4494d1..4713130f 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/TableView.qml b/src/controls/TableView.qml index 586f1211..736ac6e3 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 0961430d..0bd4db1e 100644 --- a/src/controls/TextField.qml +++ b/src/controls/TextField.qml @@ -584,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 diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 802d23e4..256e213e 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 124ab881..176a70b5 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -343,6 +343,16 @@ 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; \ diff --git a/tests/auto/controls/data/tst_textfield.qml b/tests/auto/controls/data/tst_textfield.qml index a5dc2d87..a526d1f0 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; \ |