From 692211670b377014c4dcf7b6819723bbeb2ffa66 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 18 Nov 2013 16:20:34 +0100 Subject: Fix retina rendering issues with Qt Quick Controls We need to scale the texture size since it has twice the pixel count on retina macs. Task-number: QTBUG-34922 Change-Id: I38ff316016ccb1e609037598f7107d62b3ba4295 Reviewed-by: Gunnar Sletta --- src/controls/Private/qquickstyleitem.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp index a14a22d1..566a46f8 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; } -- cgit v1.2.1 From 20db3ac1e11d528ab2a924fd10764d903e8c1b4b Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Thu, 14 Nov 2013 10:35:13 +0100 Subject: TextField: add editingFinished signal Autotest is included. Task-number: QTBUG-34780 Change-Id: I19e73ca0c988a9d294aca52f9c0eabb9274f40d7 Reviewed-by: J-P Nurmi --- src/controls/TextField.qml | 16 +++++- .../controls/data/textfield/tf_editingfinished.qml | 63 ++++++++++++++++++++++ tests/auto/controls/data/tst_textfield.qml | 30 +++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 tests/auto/controls/data/textfield/tf_editingfinished.qml diff --git a/src/controls/TextField.qml b/src/controls/TextField.qml index c1e3ddab..0961430d 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() @@ -591,5 +603,7 @@ Control { Qt.inputMethod.hide() textfield.accepted() } + + onEditingFinished: textfield.editingFinished() } } 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 00000000..d38423a4 --- /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_textfield.qml b/tests/auto/controls/data/tst_textfield.qml index 6a176997..a5dc2d87 100644 --- a/tests/auto/controls/data/tst_textfield.qml +++ b/tests/auto/controls/data/tst_textfield.qml @@ -356,5 +356,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() + } } } -- cgit v1.2.1 From 3be9c4bca30acf109cda87a9c53849ba328c45db Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 19 Nov 2013 15:14:50 +0100 Subject: SpinBox: add editingFinished signal Autotest is included. Task-number: QTBUG-34780 Change-Id: I2da9d57b409c24cbf1d90ce42da9b4071dd6dac8 Reviewed-by: J-P Nurmi --- src/controls/SpinBox.qml | 15 +++++- .../controls/data/spinbox/sp_editingfinished.qml | 61 ++++++++++++++++++++++ tests/auto/controls/data/tst_spinbox.qml | 30 +++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 tests/auto/controls/data/spinbox/sp_editingfinished.qml diff --git a/src/controls/SpinBox.qml b/src/controls/SpinBox.qml index bba4eae1..c756566d 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" 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 00000000..d85e6eae --- /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/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index 9a68907c..124ab881 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -546,6 +546,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(" -- cgit v1.2.1 From bc477d4dee3f22a284694b8ab45e6346dcd1ef27 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Fri, 22 Nov 2013 13:03:19 +0100 Subject: Revert "ApplicationWindow has the WindowFullscreenButtonHint flag by default" This reverts commit 29d1b0d209ebb267c5a6ac8402c33892c09b8de6. This patch caused a regression resulting in QTBUG-35049 and should be reverted until we have a better fix. Change-Id: I76f9fa9859742a63f33757456c64f70183c76178 Reviewed-by: Gabriel de Dietrich --- src/controls/ApplicationWindow.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index 3d3f8840..850212fa 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -125,7 +125,6 @@ Window { default property alias data: contentArea.data color: syspal.window - flags: Qt.Window | Qt.WindowFullscreenButtonHint SystemPalette {id: syspal} -- cgit v1.2.1 From 34523bb83651ae009d28748d64697eb8ade9a639 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 22 Nov 2013 13:28:22 +0100 Subject: Set more window flags to keep Windows from omitting titlebar & buttons This should not be necessary, but Windows does not treat the missing Qt::CustomizeWindowHint the same as the other platforms do. Task-number: QTBUG-35049 Change-Id: I81dc645dc1acf29b6ff4d5fc04f5dd3db94b0133 Reviewed-by: Friedemann Kleint --- src/controls/ApplicationWindow.qml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index 850212fa..6e0160df 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -126,6 +126,12 @@ Window { 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 { -- cgit v1.2.1