From 87b21a5702be5f91e18ca8af5ac169fa111c31d5 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 30 Aug 2016 17:16:43 +0200 Subject: Make a plain Control calculate suitable implicit size [ChangeLog][Controls][Control] A plain Control now calculates its implicit size based on the implicit size of the content item plus paddings, and the implicit size of the background item. Change-Id: I086ecf8e3f564ee49df2f9d30015e127dc88db6e Reviewed-by: Mitch Curtis --- src/imports/controls/Control.qml | 47 +++++++++++++++++++++++++ src/imports/controls/controls.pri | 1 + src/imports/controls/qtquickcontrols2plugin.cpp | 2 +- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/imports/controls/Control.qml (limited to 'src') diff --git a/src/imports/controls/Control.qml b/src/imports/controls/Control.qml new file mode 100644 index 00000000..a4bb95fe --- /dev/null +++ b/src/imports/controls/Control.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and 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. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Templates 2.0 as T + +T.Control { + id: control + + implicitWidth: Math.max(background ? background.implicitWidth : 0, + (contentItem ? contentItem.implicitWidth : 0) + leftPadding + rightPadding) + implicitHeight: Math.max(background ? background.implicitHeight : 0, + (contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding) +} diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri index 523356a1..dc4f7d4e 100644 --- a/src/imports/controls/controls.pri +++ b/src/imports/controls/controls.pri @@ -16,6 +16,7 @@ QML_CONTROLS = \ CheckDelegate.qml \ CheckIndicator.qml \ ComboBox.qml \ + Control.qml \ Dial.qml \ Drawer.qml \ Frame.qml \ diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp index 1982b392..c2e27ba3 100644 --- a/src/imports/controls/qtquickcontrols2plugin.cpp +++ b/src/imports/controls/qtquickcontrols2plugin.cpp @@ -86,7 +86,6 @@ void QtQuickControls2Plugin::registerTypes(const char *uri) qmlRegisterType(uri, 2, 0, "ButtonGroup"); qmlRegisterType(); qmlRegisterType(uri, 2, 0, "Container"); - qmlRegisterType(uri, 2, 0, "Control"); QQuickStyleSelector selector; selector.setBaseUrl(typeUrl()); @@ -101,6 +100,7 @@ void QtQuickControls2Plugin::registerTypes(const char *uri) qmlRegisterType(selector.select(QStringLiteral("CheckBox.qml")), uri, 2, 0, "CheckBox"); qmlRegisterType(selector.select(QStringLiteral("CheckDelegate.qml")), uri, 2, 0, "CheckDelegate"); qmlRegisterType(selector.select(QStringLiteral("ComboBox.qml")), uri, 2, 0, "ComboBox"); + qmlRegisterType(selector.select(QStringLiteral("Control.qml")), uri, 2, 0, "Control"); qmlRegisterType(selector.select(QStringLiteral("Dial.qml")), uri, 2, 0, "Dial"); qmlRegisterType(selector.select(QStringLiteral("Drawer.qml")), uri, 2, 0, "Drawer"); qmlRegisterType(selector.select(QStringLiteral("Frame.qml")), uri, 2, 0, "Frame"); -- cgit v1.2.3