diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-08-30 17:26:50 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-08-31 07:57:07 +0000 |
commit | 0e01d1d979fd747671512b2c4e987d1f8cb3c019 (patch) | |
tree | b5f223426972f009013a4bfb0091e9143a6a6e35 /src | |
parent | 87b21a5702be5f91e18ca8af5ac169fa111c31d5 (diff) |
Make a plain Container calculate suitable implicit size
[ChangeLog][Controls][Container] A plain Container 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: I0481aef0ce713d92bee8b119bf5158dea612d598
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/controls/Container.qml | 47 | ||||
-rw-r--r-- | src/imports/controls/controls.pri | 1 | ||||
-rw-r--r-- | src/imports/controls/qtquickcontrols2plugin.cpp | 2 |
3 files changed, 49 insertions, 1 deletions
diff --git a/src/imports/controls/Container.qml b/src/imports/controls/Container.qml new file mode 100644 index 00000000..9e9215f8 --- /dev/null +++ b/src/imports/controls/Container.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.Container { + 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 dc4f7d4e..788bfe27 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 \ + Container.qml \ Control.qml \ Dial.qml \ Drawer.qml \ diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp index c2e27ba3..541d18d6 100644 --- a/src/imports/controls/qtquickcontrols2plugin.cpp +++ b/src/imports/controls/qtquickcontrols2plugin.cpp @@ -85,7 +85,6 @@ void QtQuickControls2Plugin::registerTypes(const char *uri) qmlRegisterType<QQuickAbstractButton>(uri, 2, 0, "AbstractButton"); qmlRegisterType<QQuickButtonGroup>(uri, 2, 0, "ButtonGroup"); qmlRegisterType<QQuickButtonGroupAttached>(); - qmlRegisterType<QQuickContainer>(uri, 2, 0, "Container"); QQuickStyleSelector selector; selector.setBaseUrl(typeUrl()); @@ -100,6 +99,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("Container.qml")), uri, 2, 0, "Container"); 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"); |