From f0f66c1aa001c630a6b246e312bef7f8e83958d2 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 3 Nov 2017 18:26:22 +0100 Subject: Qt.labs.platform: declare and register enums to the meta system To make them correctly available in QML so that they also work as signal arguments. Task-number: QTBUG-64259 Change-Id: I5fa00871f96357d924661c4b8af323a0f1748c9d Reviewed-by: Liang Qi --- src/imports/platform/qquickplatformmenu_p.h | 1 + src/imports/platform/qquickplatformstandardpaths_p.h | 2 ++ src/imports/platform/qquickplatformsystemtrayicon_p.h | 2 ++ src/imports/platform/qtlabsplatformplugin.cpp | 6 +++--- 4 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/imports/platform/qquickplatformmenu_p.h b/src/imports/platform/qquickplatformmenu_p.h index 7456c660..b5c23b61 100644 --- a/src/imports/platform/qquickplatformmenu_p.h +++ b/src/imports/platform/qquickplatformmenu_p.h @@ -209,5 +209,6 @@ private: QT_END_NAMESPACE QML_DECLARE_TYPE(QQuickPlatformMenu) +Q_DECLARE_METATYPE(QPlatformMenu::MenuType) #endif // QQUICKPLATFORMMENU_P_H diff --git a/src/imports/platform/qquickplatformstandardpaths_p.h b/src/imports/platform/qquickplatformstandardpaths_p.h index c3d879b0..e2f4e11e 100644 --- a/src/imports/platform/qquickplatformstandardpaths_p.h +++ b/src/imports/platform/qquickplatformstandardpaths_p.h @@ -86,5 +86,7 @@ private: QT_END_NAMESPACE QML_DECLARE_TYPE(QQuickPlatformStandardPaths) +Q_DECLARE_METATYPE(QStandardPaths::StandardLocation) +Q_DECLARE_METATYPE(QStandardPaths::LocateOptions) #endif // QQUICKPLATFORMSTANDARDPATHS_P_H diff --git a/src/imports/platform/qquickplatformsystemtrayicon_p.h b/src/imports/platform/qquickplatformsystemtrayicon_p.h index 7aa07512..77a78f30 100644 --- a/src/imports/platform/qquickplatformsystemtrayicon_p.h +++ b/src/imports/platform/qquickplatformsystemtrayicon_p.h @@ -137,5 +137,7 @@ private: QT_END_NAMESPACE QML_DECLARE_TYPE(QQuickPlatformSystemTrayIcon) +Q_DECLARE_METATYPE(QPlatformSystemTrayIcon::ActivationReason) +Q_DECLARE_METATYPE(QPlatformSystemTrayIcon::MessageIcon) #endif // QQUICKPLATFORMSYSTEMTRAYICON_P_H diff --git a/src/imports/platform/qtlabsplatformplugin.cpp b/src/imports/platform/qtlabsplatformplugin.cpp index bcb9ac98..1eac7d80 100644 --- a/src/imports/platform/qtlabsplatformplugin.cpp +++ b/src/imports/platform/qtlabsplatformplugin.cpp @@ -56,9 +56,6 @@ # include "qquickplatformsystemtrayicon_p.h" #endif -Q_DECLARE_METATYPE(QStandardPaths::StandardLocation) -Q_DECLARE_METATYPE(QStandardPaths::LocateOptions) - static inline void initResources() { #ifdef QT_STATIC @@ -102,6 +99,7 @@ void QtLabsPlatformPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 1, 0, "MenuItem"); qmlRegisterType(uri, 1, 0, "MenuItemGroup"); qmlRegisterType(uri, 1, 0, "MenuSeparator"); + qRegisterMetaType(); qmlRegisterUncreatableType(uri, 1, 0, "StandardButton", QQuickPlatformDialog::tr("Cannot create an instance of StandardButton")); qmlRegisterSingletonType(uri, 1, 0, "StandardPaths", QQuickPlatformStandardPaths::create); @@ -110,6 +108,8 @@ void QtLabsPlatformPlugin::registerTypes(const char *uri) #if QT_CONFIG(systemtrayicon) qmlRegisterType(uri, 1, 0, "SystemTrayIcon"); + qRegisterMetaType(); + qRegisterMetaType(); #endif } -- cgit v1.2.3 From f46776cc68f88a8cbc518cacf6c63f31f11d73b0 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 6 Nov 2017 13:53:03 +0100 Subject: Fix QQuickSlider::valueAt() Task-number: QTBUG-64065 Change-Id: Id77a85ce5b88c20795e9f7fe9d2ece974f46a315 Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquickslider.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index 4d3cbe3e..da2f402f 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -513,10 +513,10 @@ void QQuickSlider::setHandle(QQuickItem *handle) qreal QQuickSlider::valueAt(qreal position) const { Q_D(const QQuickSlider); - const qreal value = d->from + (d->to - d->from) * position; + const qreal value = (d->to - d->from) * position; if (qFuzzyIsNull(d->stepSize)) - return value; - return qRound(value / d->stepSize) * d->stepSize; + return d->from + value; + return d->from + qRound(value / d->stepSize) * d->stepSize; } /*! -- cgit v1.2.3 From a0559ea88be32e19e83b2131cb26e61e873dc817 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 3 Nov 2017 11:13:44 +0400 Subject: DialogButtonBox: micro optimization for resizeContent() Change-Id: Ie72671fb92108dfaf5aaae4ea3ffb279e14b2f1a Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquickdialogbuttonbox.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp index 1b50346c..5f7f488e 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox.cpp +++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp @@ -172,13 +172,13 @@ static QRectF alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment qreal w = size.width(); qreal h = size.height(); if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter) - y += rectangle.size().height() / 2 - h / 2; + y += (rectangle.size().height() - h) / 2; else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom) y += rectangle.size().height() - h; if ((alignment & Qt::AlignRight) == Qt::AlignRight) x += rectangle.size().width() - w; else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter) - x += rectangle.size().width() / 2 - w / 2; + x += (rectangle.size().width() - w) / 2; return QRectF(x, y, w, h); } @@ -188,15 +188,12 @@ void QQuickDialogButtonBoxPrivate::resizeContent() if (!contentItem) return; - const int halign = alignment & Qt::AlignHorizontal_Mask; - const int valign = alignment & Qt::AlignVertical_Mask; - - const qreal cw = !halign ? q->availableWidth() : contentItem->implicitWidth(); - const qreal ch = !valign ? q->availableHeight() : contentItem->implicitHeight(); - QRectF geometry = q->boundingRect().adjusted(q->leftPadding(), q->topPadding(), -q->rightPadding(), -q->bottomPadding()); - if (halign || valign) + if (alignment != 0) { + qreal cw = (alignment & Qt::AlignHorizontal_Mask) == 0 ? q->availableWidth() : contentItem->implicitWidth(); + qreal ch = (alignment & Qt::AlignVertical_Mask) == 0 ? q->availableHeight() : contentItem->implicitHeight(); geometry = alignedRect(q->isMirrored() ? Qt::RightToLeft : Qt::LeftToRight, alignment, QSizeF(cw, ch), geometry); + } contentItem->setPosition(geometry.topLeft()); contentItem->setSize(geometry.size()); -- cgit v1.2.3 From cbf8342526c071bc77c3764e7a28c3cfe587bb80 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Thu, 16 Nov 2017 08:57:19 +0100 Subject: Fix outdated FDL license header Change-Id: I969a911c3e66aff502188ff9a103f16dc6544ba5 Reviewed-by: Kai Koehne --- .../controls/doc/snippets/qtquickcontrols2-button-icononly.qml | 8 ++++---- .../doc/snippets/qtquickcontrols2-button-textbesideicon.qml | 8 ++++---- .../controls/doc/snippets/qtquickcontrols2-button-textonly.qml | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-button-icononly.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-button-icononly.qml index 43110494..32b0797a 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-button-icononly.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-button-icononly.qml @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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 The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Free Documentation License Usage ** Alternatively, this file may be used under the terms of the GNU Free @@ -20,7 +20,7 @@ ** Foundation and appearing in the file included in the packaging of ** this file. Please review the following information to ensure ** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-button-textbesideicon.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-button-textbesideicon.qml index e3be7a4b..870da262 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-button-textbesideicon.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-button-textbesideicon.qml @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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 The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Free Documentation License Usage ** Alternatively, this file may be used under the terms of the GNU Free @@ -20,7 +20,7 @@ ** Foundation and appearing in the file included in the packaging of ** this file. Please review the following information to ensure ** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-button-textonly.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-button-textonly.qml index 883340dc..fe871639 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-button-textonly.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-button-textonly.qml @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** 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 The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Free Documentation License Usage ** Alternatively, this file may be used under the terms of the GNU Free @@ -20,7 +20,7 @@ ** Foundation and appearing in the file included in the packaging of ** this file. Please review the following information to ensure ** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v1.2.3