From 154c5e32af4d59cd04ac907d3f66cb0807ff14e9 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 1 Nov 2016 12:26:22 +0100 Subject: Doc: fix review findings for ToolButton Change-Id: Id427520a390a2a8cb0bb4ac0f66fef5f96e5b39e Task-number: QTBUG-55904 Reviewed-by: Mitch Curtis --- .../doc/images/qtquickcontrols2-toolbar.png | Bin 3358 -> 1186 bytes .../screenshots/qtquickcontrols2-toolbar.qml | 27 ++++++++++++++++----- src/quicktemplates2/qquicktoolbar.cpp | 17 ++++++++----- src/quicktemplates2/qquicktoolbutton.cpp | 6 ++++- 4 files changed, 37 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/imports/controls/doc/images/qtquickcontrols2-toolbar.png b/src/imports/controls/doc/images/qtquickcontrols2-toolbar.png index f4808ca9..1fe353cc 100644 Binary files a/src/imports/controls/doc/images/qtquickcontrols2-toolbar.png and b/src/imports/controls/doc/images/qtquickcontrols2-toolbar.png differ diff --git a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar.qml b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar.qml index fd6754f8..246f3ae5 100644 --- a/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar.qml +++ b/src/imports/controls/doc/snippets/screenshots/qtquickcontrols2-toolbar.qml @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -29,19 +29,34 @@ import QtQuick 2.0 import QtQuick.Layouts 1.0 import QtQuick.Controls 2.0 +Item { + width: children[0].implicitWidth * 2 + height: children[0].implicitHeight + Binding { + target: children[0] + property: "width" + value: width + } //! [1] ToolBar { RowLayout { anchors.fill: parent ToolButton { - text: qsTr("\u25C0 Qt") + text: qsTr("‹") onClicked: stack.pop() } - Item { Layout.fillWidth: true } - Switch { - checked: true - text: qsTr("Notifications") + Label { + text: "Title" + elide: Label.ElideRight + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + Layout.fillWidth: true + } + ToolButton { + text: qsTr("⋮") + onClicked: menu.open() } } } //! [1] +} diff --git a/src/quicktemplates2/qquicktoolbar.cpp b/src/quicktemplates2/qquicktoolbar.cpp index 5a767c73..e6d705ad 100644 --- a/src/quicktemplates2/qquicktoolbar.cpp +++ b/src/quicktemplates2/qquicktoolbar.cpp @@ -69,14 +69,19 @@ QT_BEGIN_NAMESPACE RowLayout { anchors.fill: parent ToolButton { - text: qsTr("\u25C0 %1").arg(Qt.application.name) - enabled: stack.depth > 1 + text: qsTr("‹") onClicked: stack.pop() } - Item { Layout.fillWidth: true } - Switch { - checked: true - text: qsTr("Notifications") + Label { + text: "Title" + elide: Label.ElideRight + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + Layout.fillWidth: true + } + ToolButton { + text: qsTr("⋮") + onClicked: menu.open() } } } diff --git a/src/quicktemplates2/qquicktoolbutton.cpp b/src/quicktemplates2/qquicktoolbutton.cpp index c1f47b97..8009ac28 100644 --- a/src/quicktemplates2/qquicktoolbutton.cpp +++ b/src/quicktemplates2/qquicktoolbutton.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE \inqmlmodule QtQuick.Controls \since 5.7 \ingroup qtquickcontrols2-buttons - \brief A button with a layout suitable for a ToolBar. + \brief A button with a look suitable for a ToolBar. ToolButton is functionally similar to \l Button, but provides a look that is more suitable within a \l ToolBar. @@ -57,6 +57,10 @@ QT_BEGIN_NAMESPACE \snippet qtquickcontrols2-toolbar.qml 1 + ToolButton inherits its API from AbstractButton. For instance, you can set + \l {AbstractButton::text}{text}, and react to \l {AbstractButton::clicked}{clicks} + using the AbstractButton API. + \sa ToolBar, {Customizing ToolButton}, {Button Controls} */ -- cgit v1.2.3