From 47065844f666e1332a7fb5bcfdc6015e0f7e1591 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 25 Oct 2016 00:19:55 +0200 Subject: Replace QStringLiteral with QLatin1String in the proxy themes This allows us, in theory, to test multiple styles in the same process by calling qmlClearTypeRegistrations() between each style test round. When QML types are cleared, QML plugins are unloaded, and the current style plugin's proxy platform theme is destroyed. It leads to a nasty crash if there are fonts stored in the Qt font database that have their family names stored in the read-only data of an unloaded plugin. Change-Id: I32a70077ac4502e16a753fb68f7efeef35d239b5 Reviewed-by: Mitch Curtis --- src/imports/controls/material/qquickmaterialtheme.cpp | 8 ++++---- src/imports/controls/universal/qquickuniversaltheme.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/imports/controls/material/qquickmaterialtheme.cpp b/src/imports/controls/material/qquickmaterialtheme.cpp index 0d2f8a70..1967a74b 100644 --- a/src/imports/controls/material/qquickmaterialtheme.cpp +++ b/src/imports/controls/material/qquickmaterialtheme.cpp @@ -45,15 +45,15 @@ QQuickMaterialTheme::QQuickMaterialTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme) { QFont font; - font.setFamily(QStringLiteral("Roboto")); + font.setFamily(QLatin1String("Roboto")); QString family = QFontInfo(font).family(); - if (family != QStringLiteral("Roboto")) { - font.setFamily(QStringLiteral("Noto")); + if (family != QLatin1String("Roboto")) { + font.setFamily(QLatin1String("Noto")); family = QFontInfo(font).family(); } - if (family == QStringLiteral("Roboto") || family == QStringLiteral("Noto")) { + if (family == QLatin1String("Roboto") || family == QLatin1String("Noto")) { systemFont.setFamily(family); buttonFont.setFamily(family); toolTipFont.setFamily(family); diff --git a/src/imports/controls/universal/qquickuniversaltheme.cpp b/src/imports/controls/universal/qquickuniversaltheme.cpp index 51642c4a..dc516b45 100644 --- a/src/imports/controls/universal/qquickuniversaltheme.cpp +++ b/src/imports/controls/universal/qquickuniversaltheme.cpp @@ -44,8 +44,8 @@ QT_BEGIN_NAMESPACE QQuickUniversalTheme::QQuickUniversalTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme) { - const QFont font(QStringLiteral("Segoe UI")); - if (QFontInfo(font).family() == QStringLiteral("Segoe UI")) { + const QFont font(QLatin1String("Segoe UI")); + if (QFontInfo(font).family() == QLatin1String("Segoe UI")) { const QString family = font.family(); systemFont.setFamily(family); groupBoxTitleFont.setFamily(family); -- cgit v1.2.3 From fa71ef5a2ccfa4666db9338c4ba8f34d19f2faf1 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 22 Oct 2016 20:46:33 +0200 Subject: QQuickDialog: simplify the button box handling Just fill in the footer with a button box by default from the styles. This makes the next step easier, to provide also a default title bar in the header. Task-number: QTBUG-56711 Change-Id: I621a61f29f9ba2fe4b7e907d81da5988133a98c8 Reviewed-by: Mitch Curtis --- src/imports/controls/Dialog.qml | 4 +- src/imports/controls/material/Dialog.qml | 4 +- src/imports/controls/universal/Dialog.qml | 4 +- src/quicktemplates2/qquickdialog.cpp | 101 +++--------------------------- src/quicktemplates2/qquickdialog_p.h | 7 --- src/quicktemplates2/qquickdialog_p_p.h | 6 +- 6 files changed, 16 insertions(+), 110 deletions(-) (limited to 'src') diff --git a/src/imports/controls/Dialog.qml b/src/imports/controls/Dialog.qml index ce6df0f6..3322a6ea 100644 --- a/src/imports/controls/Dialog.qml +++ b/src/imports/controls/Dialog.qml @@ -59,7 +59,7 @@ T.Dialog { border.color: Default.frameDarkColor } - buttonBox: DialogButtonBox { - position: DialogButtonBox.Footer + footer: DialogButtonBox { + visible: count > 0 } } diff --git a/src/imports/controls/material/Dialog.qml b/src/imports/controls/material/Dialog.qml index 1e2e50ac..7e9fafbe 100644 --- a/src/imports/controls/material/Dialog.qml +++ b/src/imports/controls/material/Dialog.qml @@ -80,7 +80,7 @@ T.Dialog { } } - buttonBox: DialogButtonBox { - position: DialogButtonBox.Footer + footer: DialogButtonBox { + visible: count > 0 } } diff --git a/src/imports/controls/universal/Dialog.qml b/src/imports/controls/universal/Dialog.qml index 0f00b760..bff289d9 100644 --- a/src/imports/controls/universal/Dialog.qml +++ b/src/imports/controls/universal/Dialog.qml @@ -63,7 +63,7 @@ T.Dialog { border.width: 1 // FlyoutBorderThemeThickness } - buttonBox: DialogButtonBox { - position: DialogButtonBox.Footer + footer: DialogButtonBox { + visible: count > 0 } } diff --git a/src/quicktemplates2/qquickdialog.cpp b/src/quicktemplates2/qquickdialog.cpp index eaa7dbb2..356e6c27 100644 --- a/src/quicktemplates2/qquickdialog.cpp +++ b/src/quicktemplates2/qquickdialog.cpp @@ -38,10 +38,6 @@ #include "qquickdialog_p_p.h" #include "qquickdialogbuttonbox_p.h" -#include -#include -#include - QT_BEGIN_NAMESPACE /*! @@ -62,20 +58,14 @@ QT_BEGIN_NAMESPACE \section1 Dialog Buttons - Dialog's standard buttons are managed by \l DialogButtonBox. When a button box - is assigned as a dialog \l footer or \l header, the dialog's \l standardButtons - property is forwarded to the respective property of the button box. Furthermore, - the \l {DialogButtonBox::}{accepted()} and \l {DialogButtonBox::}{rejected()} + Dialog's standard buttons are managed by a \l DialogButtonBox that is assigned + as a dialog \l footer by default. The dialog's \l standardButtons property is + forwarded to the respective property of the button box. Furthermore, the + \l {DialogButtonBox::}{accepted()} and \l {DialogButtonBox::}{rejected()} signals of the button box are connected to the respective signals in Dialog. \snippet qtquickcontrols2-dialog.qml 1 - \note If any standard buttons are specified for the dialog but no button box has - been assigned as a footer or header, Dialog automatically creates an instance of - \l buttonBox, and assigns it as a footer or header of the dialog depending on the - value of the \l {DialogButtonBox::}{position} property. All built-in Dialog styles - assign the button box as a footer. - \section1 Modal Dialogs A \l {Popup::}{modal} dialog blocks input to other content beneath @@ -121,40 +111,6 @@ QT_BEGIN_NAMESPACE \sa accepted() */ -void QQuickDialogPrivate::createButtonBox() -{ - Q_Q(QQuickDialog); - QQmlContext *context = qmlContext(q); - if (!context || !buttonBoxComponent) - return; - - QObject *object = buttonBoxComponent->create(context); - QQuickDialogButtonBox *buttonBox = qobject_cast(object); - if (!buttonBox) { - if (object) { - qmlInfo(q) << "buttonBox must be an instance of DialogButtonBox"; - delete object; - } - return; - } - - if (buttonBox->position() == QQuickDialogButtonBox::Header) { - if (layout->header()) { - qmlInfo(q) << "Custom header detected. Cannot assign buttonBox as a header. No standard buttons will appear in the header."; - delete buttonBox; - } else { - q->setHeader(buttonBox); - } - } else { - if (layout->footer()) { - qmlInfo(q) << "Custom footer detected. Cannot assign buttonBox as a footer. No standard buttons will appear in the footer."; - delete buttonBox; - } else { - q->setFooter(buttonBox); - } - } -} - QQuickDialog::QQuickDialog(QObject *parent) : QQuickPopup(*(new QQuickDialogPrivate), parent) { @@ -176,7 +132,7 @@ QQuickDialog::QQuickDialog(QObject *parent) : header automatically sets the respective \l DialogButtonBox::position, \l ToolBar::position, or \l TabBar::position property to \c Header. - \sa footer, buttonBox + \sa footer */ QQuickItem *QQuickDialog::header() const { @@ -223,7 +179,7 @@ void QQuickDialog::setHeader(QQuickItem *header) footer automatically sets the respective \l DialogButtonBox::position, \l ToolBar::position, or \l TabBar::position property to \c Footer. - \sa header, buttonBox + \sa header */ QQuickItem *QQuickDialog::footer() const { @@ -256,33 +212,6 @@ void QQuickDialog::setFooter(QQuickItem *footer) emit footerChanged(); } -/*! - \qmlproperty Component QtQuick.Controls::Dialog::buttonBox - - This property holds a delegate for creating a button box. - - A button box is only created if any standard buttons are set. - The \l {DialogButtonBox::}{position} property determines whether - the button box is assigned as a \l header or \l footer. - - \sa standardButtons, header, footer, DialogButtonBox -*/ -QQmlComponent *QQuickDialog::buttonBox() const -{ - Q_D(const QQuickDialog); - return d->buttonBoxComponent; -} - -void QQuickDialog::setButtonBox(QQmlComponent *box) -{ - Q_D(QQuickDialog); - if (d->buttonBoxComponent == box) - return; - - d->buttonBoxComponent = box; - emit buttonBoxChanged(); -} - /*! \qmlproperty enumeration QtQuick.Controls::Dialog::standardButtons @@ -311,7 +240,7 @@ void QQuickDialog::setButtonBox(QQmlComponent *box) \value Dialog.Ignore An "Ignore" button defined with the \c AcceptRole. \value Dialog.NoButton An invalid button. - \sa buttonBox, DialogButtonBox + \sa DialogButtonBox */ QPlatformDialogHelper::StandardButtons QQuickDialog::standardButtons() const { @@ -326,12 +255,8 @@ void QQuickDialog::setStandardButtons(QPlatformDialogHelper::StandardButtons but return; d->standardButtons = buttons; - if (isComponentComplete()) { - if (d->buttonBox) - d->buttonBox->setStandardButtons(buttons); - else if (buttons) - d->createButtonBox(); - } + if (d->buttonBox) + d->buttonBox->setStandardButtons(buttons); emit standardButtonsChanged(); } @@ -361,14 +286,6 @@ void QQuickDialog::reject() emit rejected(); } -void QQuickDialog::componentComplete() -{ - Q_D(QQuickDialog); - QQuickPopup::componentComplete(); - if (!d->buttonBox && d->standardButtons) - d->createButtonBox(); -} - void QQuickDialog::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { Q_D(QQuickDialog); diff --git a/src/quicktemplates2/qquickdialog_p.h b/src/quicktemplates2/qquickdialog_p.h index 2c7eee95..1cd50f4a 100644 --- a/src/quicktemplates2/qquickdialog_p.h +++ b/src/quicktemplates2/qquickdialog_p.h @@ -53,7 +53,6 @@ QT_BEGIN_NAMESPACE -class QQmlComponent; class QQuickDialogPrivate; class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialog : public QQuickPopup @@ -61,7 +60,6 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialog : public QQuickPopup Q_OBJECT Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL) Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL) - Q_PROPERTY(QQmlComponent *buttonBox READ buttonBox WRITE setButtonBox NOTIFY buttonBoxChanged FINAL) Q_PROPERTY(QPlatformDialogHelper::StandardButtons standardButtons READ standardButtons WRITE setStandardButtons NOTIFY standardButtonsChanged FINAL) Q_FLAGS(QPlatformDialogHelper::StandardButtons) @@ -74,9 +72,6 @@ public: QQuickItem *footer() const; void setFooter(QQuickItem *footer); - QQmlComponent *buttonBox() const; - void setButtonBox(QQmlComponent *box); - QPlatformDialogHelper::StandardButtons standardButtons() const; void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons); @@ -90,11 +85,9 @@ Q_SIGNALS: void headerChanged(); void footerChanged(); - void buttonBoxChanged(); void standardButtonsChanged(); protected: - void componentComplete() override; void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override; diff --git a/src/quicktemplates2/qquickdialog_p_p.h b/src/quicktemplates2/qquickdialog_p_p.h index a893690d..e5ac7066 100644 --- a/src/quicktemplates2/qquickdialog_p_p.h +++ b/src/quicktemplates2/qquickdialog_p_p.h @@ -53,7 +53,6 @@ QT_BEGIN_NAMESPACE -class QQmlComponent; class QQuickDialogButtonBox; class QQuickDialogPrivate : public QQuickPopupPrivate @@ -61,17 +60,14 @@ class QQuickDialogPrivate : public QQuickPopupPrivate Q_DECLARE_PUBLIC(QQuickDialog) public: - QQuickDialogPrivate() : buttonBox(nullptr), buttonBoxComponent(nullptr) { } + QQuickDialogPrivate() : buttonBox(nullptr) { } static QQuickDialogPrivate *get(QQuickDialog *dialog) { return dialog->d_func(); } - void createButtonBox(); - QQuickDialogButtonBox *buttonBox; - QQmlComponent *buttonBoxComponent; QScopedPointer layout; QPlatformDialogHelper::StandardButtons standardButtons; }; -- cgit v1.2.3 From 52e933ce2b10b0e1b48afa9ce048552830309da7 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 22 Oct 2016 21:18:52 +0200 Subject: Add QQuickDialog::title Dialog is incomplete without built-in support for title. All dialogs in the examples, screenshots, webinars, and blog posts have had a custom title. The Material and Universal designs both have specs for dialog titles. This commit adds support for dialog titles with appropriate looks (padding & font) out of the box. Task-number: QTBUG-56711 Change-Id: I248150313f1ce629a7105fdbe1c70c8fcd69e1cc Reviewed-by: Mitch Curtis --- src/imports/controls/Dialog.qml | 13 ++++++++ .../doc/snippets/qtquickcontrols2-dialog.qml | 1 + src/imports/controls/material/Dialog.qml | 18 ++++++++++ src/imports/controls/universal/Dialog.qml | 17 ++++++++++ src/quicktemplates2/qquickdialog.cpp | 38 +++++++++++++++++++++- src/quicktemplates2/qquickdialog_p.h | 5 +++ src/quicktemplates2/qquickdialog_p_p.h | 1 + 7 files changed, 92 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/imports/controls/Dialog.qml b/src/imports/controls/Dialog.qml index 3322a6ea..a26928c1 100644 --- a/src/imports/controls/Dialog.qml +++ b/src/imports/controls/Dialog.qml @@ -59,6 +59,19 @@ T.Dialog { border.color: Default.frameDarkColor } + header: Label { + text: control.title + visible: control.title + elide: Label.ElideRight + font.bold: true + padding: 12 + background: Rectangle { + x: 1; y: 1 + width: parent.width - 2 + height: parent.height - 1 + } + } + footer: DialogButtonBox { visible: count > 0 } diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-dialog.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-dialog.qml index c5de0b71..69e84914 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-dialog.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-dialog.qml @@ -34,6 +34,7 @@ Item { //! [1] Dialog { id: dialog + title: "Title" standardButtons: Dialog.Ok | Dialog.Cancel onAccepted: console.log("Ok clicked") diff --git a/src/imports/controls/material/Dialog.qml b/src/imports/controls/material/Dialog.qml index 7e9fafbe..ddc80895 100644 --- a/src/imports/controls/material/Dialog.qml +++ b/src/imports/controls/material/Dialog.qml @@ -55,6 +55,7 @@ T.Dialog { contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) padding: 24 + topPadding: 20 Material.elevation: 24 @@ -80,6 +81,23 @@ T.Dialog { } } + header: Label { + text: control.title + visible: control.title + elide: Label.ElideRight + padding: 24 + bottomPadding: 0 + // TODO: QPlatformTheme::TitleBarFont + font.bold: true + font.pixelSize: 16 + background: PaddedRectangle { + radius: 2 + color: control.Material.dialogColor + bottomPadding: -2 + clip: true + } + } + footer: DialogButtonBox { visible: count > 0 } diff --git a/src/imports/controls/universal/Dialog.qml b/src/imports/controls/universal/Dialog.qml index bff289d9..ce34fd07 100644 --- a/src/imports/controls/universal/Dialog.qml +++ b/src/imports/controls/universal/Dialog.qml @@ -63,6 +63,23 @@ T.Dialog { border.width: 1 // FlyoutBorderThemeThickness } + header: Label { + text: control.title + visible: control.title + elide: Label.ElideRight + topPadding: 18 + leftPadding: 24 + rightPadding: 24 + // TODO: QPlatformTheme::TitleBarFont + font.pixelSize: 20 + background: Rectangle { + x: 1; y: 1 // // FlyoutBorderThemeThickness + color: control.Universal.chromeMediumLowColor + width: parent.width - 2 + height: parent.height - 1 + } + } + footer: DialogButtonBox { visible: count > 0 } diff --git a/src/quicktemplates2/qquickdialog.cpp b/src/quicktemplates2/qquickdialog.cpp index 356e6c27..05e0f26d 100644 --- a/src/quicktemplates2/qquickdialog.cpp +++ b/src/quicktemplates2/qquickdialog.cpp @@ -56,7 +56,10 @@ QT_BEGIN_NAMESPACE \image qtquickcontrols2-page-wireframe.png - \section1 Dialog Buttons + \section1 Dialog Title and Buttons + + Dialog's \l title is displayed by a style-specific title bar that is assigned + as a dialog \l header by default. Dialog's standard buttons are managed by a \l DialogButtonBox that is assigned as a dialog \l footer by default. The dialog's \l standardButtons property is @@ -118,6 +121,39 @@ QQuickDialog::QQuickDialog(QObject *parent) : d->layout.reset(new QQuickPageLayout(d->popupItem)); } +/*! + \qmlproperty string QtQuick.Controls::Dialog::title + + This property holds the dialog title. + + The title is displayed in the dialog header. + + \code + Dialog { + title: qsTr("About") + + Label { + text: "Lorem ipsum..." + } + } + \endcode +*/ +QString QQuickDialog::title() const +{ + Q_D(const QQuickDialog); + return d->title; +} + +void QQuickDialog::setTitle(const QString &title) +{ + Q_D(QQuickDialog); + if (d->title == title) + return; + + d->title = title; + emit titleChanged(); +} + /*! \qmlproperty Item QtQuick.Controls::Dialog::header diff --git a/src/quicktemplates2/qquickdialog_p.h b/src/quicktemplates2/qquickdialog_p.h index 1cd50f4a..ff8a1e79 100644 --- a/src/quicktemplates2/qquickdialog_p.h +++ b/src/quicktemplates2/qquickdialog_p.h @@ -58,6 +58,7 @@ class QQuickDialogPrivate; class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialog : public QQuickPopup { Q_OBJECT + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL) Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL) Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL) Q_PROPERTY(QPlatformDialogHelper::StandardButtons standardButtons READ standardButtons WRITE setStandardButtons NOTIFY standardButtonsChanged FINAL) @@ -66,6 +67,9 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialog : public QQuickPopup public: explicit QQuickDialog(QObject *parent = nullptr); + QString title() const; + void setTitle(const QString &title); + QQuickItem *header() const; void setHeader(QQuickItem *header); @@ -83,6 +87,7 @@ Q_SIGNALS: void accepted(); void rejected(); + void titleChanged(); void headerChanged(); void footerChanged(); void standardButtonsChanged(); diff --git a/src/quicktemplates2/qquickdialog_p_p.h b/src/quicktemplates2/qquickdialog_p_p.h index e5ac7066..5ea84cc8 100644 --- a/src/quicktemplates2/qquickdialog_p_p.h +++ b/src/quicktemplates2/qquickdialog_p_p.h @@ -67,6 +67,7 @@ public: return dialog->d_func(); } + QString title; QQuickDialogButtonBox *buttonBox; QScopedPointer layout; QPlatformDialogHelper::StandardButtons standardButtons; -- cgit v1.2.3 From 25d6d137a90ca9e3ce654adcc454c23de4622a49 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 26 Oct 2016 07:48:46 +0200 Subject: Doc: QT_QUICK_CONTROLS_HOVER_ENABLED Change-Id: I91b578e6e7956feadb0a9f874fa0c1f4d97f02bf Reviewed-by: Mitch Curtis --- src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc | 4 ++++ src/quicktemplates2/qquickcontrol.cpp | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc index 7c1b1c16..acca81b8 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc @@ -47,6 +47,10 @@ \li Specifies the location of the \l {Qt Quick Controls 2 configuration file}. By default, the configuration file is loaded from the application's resources in \c ":/qtquickcontrols2.conf". + \row + \li \c QT_QUICK_CONTROLS_HOVER_ENABLED + \li Specifies whether Qt Quick Controls 2 use \l {Control::hoverEnabled}{hover effects}. + The value can be set to \c 0 or \c 1 to disable or enable hover effects, respectively. \endtable \l {Material style} specific environment variables: diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 157c539e..e1df04cc 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -1012,6 +1012,10 @@ void QQuickControl::setHovered(bool hovered) Setting this property propagates the value to all child controls that do not have \c hoverEnabled explicitly set. + You can also enable or disable hover effects for all Qt Quick Controls 2 applications + by setting the \c QT_QUICK_CONTROLS_HOVER_ENABLED \l {Supported Environment Variables + in Qt Quick Controls 2}{environment variable}. + \sa hovered */ bool QQuickControl::isHoverEnabled() const -- cgit v1.2.3 From f6acc98f3a96ab6cafedfe2a3f097a1974abad16 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 26 Oct 2016 10:56:32 +0200 Subject: Default: make disable controls easier to see Task-number: QTBUG-56698 Change-Id: I8e82ee2f2f9c38755e49b6f1b46e9f83a1363463 Reviewed-by: J-P Nurmi --- src/imports/controls/Button.qml | 1 - src/imports/controls/CheckBox.qml | 2 +- src/imports/controls/ComboBox.qml | 4 ++-- src/imports/controls/RadioButton.qml | 2 +- src/imports/controls/RangeSlider.qml | 1 - src/imports/controls/Slider.qml | 1 - src/imports/controls/SpinBox.qml | 1 - src/imports/controls/SwitchIndicator.qml | 1 - 8 files changed, 4 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/imports/controls/Button.qml b/src/imports/controls/Button.qml index f875a97a..cf1f6c99 100644 --- a/src/imports/controls/Button.qml +++ b/src/imports/controls/Button.qml @@ -66,7 +66,6 @@ T.Button { background: Rectangle { implicitWidth: 100 implicitHeight: 40 - opacity: enabled ? 1 : 0.3 visible: !control.flat || control.down || control.checked || control.highlighted color: control.checked || control.highlighted ? (control.visualFocus ? (control.down ? "#599bff" : "#0066ff") : (control.down ? "#585a5c" : "#353637")) : diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml index 3615948a..78b42276 100644 --- a/src/imports/controls/CheckBox.qml +++ b/src/imports/controls/CheckBox.qml @@ -51,7 +51,7 @@ T.CheckBox { padding: 6 spacing: 6 - opacity: enabled ? 1 : 0.2 + opacity: enabled ? 1 : 0.3 //! [indicator] indicator: CheckIndicator { diff --git a/src/imports/controls/ComboBox.qml b/src/imports/controls/ComboBox.qml index 09930aad..791b5da6 100644 --- a/src/imports/controls/ComboBox.qml +++ b/src/imports/controls/ComboBox.qml @@ -54,8 +54,6 @@ T.ComboBox { leftPadding: padding + 6 rightPadding: padding + 6 - opacity: enabled ? 1 : 0.3 - //! [delegate] delegate: ItemDelegate { width: control.popup.width @@ -72,6 +70,7 @@ T.ComboBox { source: "image://default/double-arrow/" + (control.visualFocus ? "#0066ff" : "#353637") sourceSize.width: width sourceSize.height: height + opacity: enabled ? 1 : 0.3 } //! [indicator] @@ -86,6 +85,7 @@ T.ComboBox { horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter elide: Text.ElideRight + opacity: enabled ? 1 : 0.3 } //! [contentItem] diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml index 8a2d7c99..1c63a8de 100644 --- a/src/imports/controls/RadioButton.qml +++ b/src/imports/controls/RadioButton.qml @@ -51,7 +51,7 @@ T.RadioButton { padding: 6 spacing: 6 - opacity: enabled ? 1 : 0.2 + opacity: enabled ? 1 : 0.3 //! [indicator] indicator: RadioIndicator { diff --git a/src/imports/controls/RangeSlider.qml b/src/imports/controls/RangeSlider.qml index 7353e2b5..dae3ffe7 100644 --- a/src/imports/controls/RangeSlider.qml +++ b/src/imports/controls/RangeSlider.qml @@ -88,7 +88,6 @@ T.RangeSlider { width: horizontal ? control.availableWidth : implicitWidth height: horizontal ? implicitHeight : control.availableHeight radius: 3 - opacity: control.enabled ? 1 : 0.3 color: "#e0e0e0" scale: horizontal && control.mirrored ? -1 : 1 diff --git a/src/imports/controls/Slider.qml b/src/imports/controls/Slider.qml index 896dbca0..31f4a989 100644 --- a/src/imports/controls/Slider.qml +++ b/src/imports/controls/Slider.qml @@ -71,7 +71,6 @@ T.Slider { width: horizontal ? control.availableWidth : implicitWidth height: horizontal ? implicitHeight : control.availableHeight radius: 3 - opacity: control.enabled ? 1 : 0.3 color: "#e0e0e0" scale: horizontal && control.mirrored ? -1 : 1 diff --git a/src/imports/controls/SpinBox.qml b/src/imports/controls/SpinBox.qml index 89853116..de1228d1 100644 --- a/src/imports/controls/SpinBox.qml +++ b/src/imports/controls/SpinBox.qml @@ -137,7 +137,6 @@ T.SpinBox { //! [background] background: Rectangle { - opacity: control.enabled ? 1 : 0.3 implicitWidth: 140 border.color: "#e0e0e0" } diff --git a/src/imports/controls/SwitchIndicator.qml b/src/imports/controls/SwitchIndicator.qml index f11f7147..261d9999 100644 --- a/src/imports/controls/SwitchIndicator.qml +++ b/src/imports/controls/SwitchIndicator.qml @@ -47,7 +47,6 @@ Item { width: 56 height: 16 radius: 8 - opacity: control.enabled ? 1 : 0.3 color: control.checked ? (control.visualFocus ? "#0066ff" : "#353637") : "#e0e0e0" border.width: control.visualFocus ? 2 : 0 border.color: "#0066ff" -- cgit v1.2.3 From 935daea1cdd9247d04618fcd67eb2a935060d1db Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 24 Oct 2016 17:38:06 +0200 Subject: Page: support spacing Add spacing support into QQuickPageLayout. Having spacing and padding separately gives more fine-grained control over the layout. Spacing is inserted between the header, content, and footer, but only when the respective building blocks are visible. Change-Id: Ia26a4c33c2756a603ca6d53aefac3a66414b36d3 Reviewed-by: Mitch Curtis --- src/imports/controls/Page.qml | 4 ++-- src/imports/controls/material/Page.qml | 4 ++-- src/imports/controls/universal/Page.qml | 4 ++-- src/quicktemplates2/qquickcontrol.cpp | 17 +++++++++++++---- src/quicktemplates2/qquickcontrol_p.h | 1 + src/quicktemplates2/qquickpage.cpp | 7 +++++++ src/quicktemplates2/qquickpage_p.h | 1 + src/quicktemplates2/qquickpagelayout.cpp | 8 +++++--- 8 files changed, 33 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/imports/controls/Page.qml b/src/imports/controls/Page.qml index fbed527f..edd8d628 100644 --- a/src/imports/controls/Page.qml +++ b/src/imports/controls/Page.qml @@ -48,8 +48,8 @@ T.Page { footer && footer.visible ? footer.implicitWidth : 0) + leftPadding + rightPadding) implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding - + (header && header.visible ? header.implicitHeight : 0) - + (footer && footer.visible ? footer.implicitHeight : 0)) + + (header && header.visible ? header.implicitHeight + spacing : 0) + + (footer && footer.visible ? footer.implicitHeight + spacing : 0)) contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) diff --git a/src/imports/controls/material/Page.qml b/src/imports/controls/material/Page.qml index 707d471e..c91b16c1 100644 --- a/src/imports/controls/material/Page.qml +++ b/src/imports/controls/material/Page.qml @@ -47,8 +47,8 @@ T.Page { footer && footer.visible ? footer.implicitWidth : 0) + leftPadding + rightPadding) implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding - + (header && header.visible ? header.implicitHeight : 0) - + (footer && footer.visible ? footer.implicitHeight : 0)) + + (header && header.visible ? header.implicitHeight + spacing : 0) + + (footer && footer.visible ? footer.implicitHeight + spacing : 0)) contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) diff --git a/src/imports/controls/universal/Page.qml b/src/imports/controls/universal/Page.qml index 9bd85751..e8c7bd4a 100644 --- a/src/imports/controls/universal/Page.qml +++ b/src/imports/controls/universal/Page.qml @@ -47,8 +47,8 @@ T.Page { footer && footer.visible ? footer.implicitWidth : 0) + leftPadding + rightPadding) implicitHeight: Math.max(background ? background.implicitHeight : 0, contentHeight + topPadding + bottomPadding - + (header && header.visible ? header.implicitHeight : 0) - + (footer && footer.visible ? footer.implicitHeight : 0)) + + (header && header.visible ? header.implicitHeight + spacing : 0) + + (footer && footer.visible ? footer.implicitHeight + spacing : 0)) contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index e1df04cc..b1f6bd5f 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -766,10 +766,13 @@ qreal QQuickControl::spacing() const void QQuickControl::setSpacing(qreal spacing) { Q_D(QQuickControl); - if (!qFuzzyCompare(d->spacing, spacing)) { - d->spacing = spacing; - emit spacingChanged(); - } + if (qFuzzyCompare(d->spacing, spacing)) + return; + + qreal oldSpacing = d->spacing; + d->spacing = spacing; + emit spacingChanged(); + spacingChange(spacing, oldSpacing); } void QQuickControl::resetSpacing() @@ -1291,6 +1294,12 @@ void QQuickControl::mirrorChange() emit mirroredChanged(); } +void QQuickControl::spacingChange(qreal newSpacing, qreal oldSpacing) +{ + Q_UNUSED(newSpacing); + Q_UNUSED(oldSpacing); +} + void QQuickControl::paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) { Q_D(QQuickControl); diff --git a/src/quicktemplates2/qquickcontrol_p.h b/src/quicktemplates2/qquickcontrol_p.h index 7187344a..3bc21684 100644 --- a/src/quicktemplates2/qquickcontrol_p.h +++ b/src/quicktemplates2/qquickcontrol_p.h @@ -189,6 +189,7 @@ protected: virtual void fontChange(const QFont &newFont, const QFont &oldFont); virtual void hoverChange(); virtual void mirrorChange(); + virtual void spacingChange(qreal newSpacing, qreal oldSpacing); virtual void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding); virtual void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem); virtual void localeChange(const QLocale &newLocale, const QLocale &oldLocale); diff --git a/src/quicktemplates2/qquickpage.cpp b/src/quicktemplates2/qquickpage.cpp index 0098cb93..432c8c63 100644 --- a/src/quicktemplates2/qquickpage.cpp +++ b/src/quicktemplates2/qquickpage.cpp @@ -349,6 +349,13 @@ void QQuickPage::paddingChange(const QMarginsF &newPadding, const QMarginsF &old d->layout->update(); } +void QQuickPage::spacingChange(qreal newSpacing, qreal oldSpacing) +{ + Q_D(QQuickPage); + QQuickControl::spacingChange(newSpacing, oldSpacing); + d->layout->update(); +} + #ifndef QT_NO_ACCESSIBILITY QAccessible::Role QQuickPage::accessibleRole() const { diff --git a/src/quicktemplates2/qquickpage_p.h b/src/quicktemplates2/qquickpage_p.h index c63b11d7..36ba9fff 100644 --- a/src/quicktemplates2/qquickpage_p.h +++ b/src/quicktemplates2/qquickpage_p.h @@ -100,6 +100,7 @@ protected: void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override; void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override; + void spacingChange(qreal newSpacing, qreal oldSpacing) override; #ifndef QT_NO_ACCESSIBILITY QAccessible::Role accessibleRole() const override; diff --git a/src/quicktemplates2/qquickpagelayout.cpp b/src/quicktemplates2/qquickpagelayout.cpp index a1747b47..b787dd08 100644 --- a/src/quicktemplates2/qquickpagelayout.cpp +++ b/src/quicktemplates2/qquickpagelayout.cpp @@ -142,17 +142,19 @@ void QQuickPageLayout::update() const qreal hh = m_header && m_header->isVisible() ? m_header->height() : 0; const qreal fh = m_footer && m_footer->isVisible() ? m_footer->height() : 0; + const qreal hsp = hh > 0 ? m_control->spacing() : 0; + const qreal fsp = fh > 0 ? m_control->spacing() : 0; - content->setY(hh + m_control->topPadding()); + content->setY(m_control->topPadding() + hh + hsp); content->setX(m_control->leftPadding()); content->setWidth(m_control->availableWidth()); - content->setHeight(m_control->availableHeight() - hh - fh); + content->setHeight(m_control->availableHeight() - hh - fh - hsp - fsp); if (m_header) m_header->setWidth(m_control->width()); if (m_footer) { - m_footer->setY(m_control->height() - fh); + m_footer->setY(m_control->height() - m_footer->height()); m_footer->setWidth(m_control->width()); } } -- cgit v1.2.3 From 41ec11a8157b9f1cbbc75ab8f68a2e08d24280d9 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 26 Oct 2016 12:39:29 +0200 Subject: Doc: fallback style Change-Id: I03996d592de4b7db29b671fa73ab44036a80fa2f Reviewed-by: Mitch Curtis --- .../controls/doc/src/qtquickcontrols2-customize.qdoc | 6 ++++-- .../controls/doc/src/qtquickcontrols2-environment.qdoc | 4 ++++ src/quickcontrols2/qquickstyle.cpp | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc index 866aef23..06201404 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc @@ -136,8 +136,6 @@ \list \li At least one QML file whose name matches a control (for example, \c Button.qml) must exist. - - The Default style will be used for any controls that aren't implemented. \li The files must be in a directory in the filesystem or in the \l {The Qt Resource System}{resource system}. @@ -155,6 +153,10 @@ for example. \endlist + By default, the styling system uses the Default style as a fallback for + controls that aren't implemented. To customize or extend any other built-in + style, it is possible to specify a different fallback style using \l QQuickStyle. + What this means is that you can implement as many controls as you like for your custom style, and place them almost anywhere. It also allows users to create their own styles for your application. diff --git a/src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc index acca81b8..c83adf4b 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-environment.qdoc @@ -42,6 +42,10 @@ \li Specifies the default \l {Styling Qt Quick Controls 2}{Qt Quick Controls 2 style}. The value can be either one of the built-in styles, for example \c "Material", or the path to a custom style such as \c ":/mystyle". + \row + \li \c QT_QUICK_CONTROLS_FALLBACK_STYLE + \li Specifies a fallback style for \l {Creating a Custom Style}{custom styles}. + The value can be one of the built-in styles, for example \c "Material", \row \li \c QT_QUICK_CONTROLS_CONF \li Specifies the location of the \l {Qt Quick Controls 2 configuration file}. diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index 80a7abef..f4fc1764 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -80,6 +80,19 @@ QT_BEGIN_NAMESPACE Qt Quick Controls 2. It is not possible to change the style after the QML types have been registered. + The style can also be specified as a path to a custom style, such as + \c ":/mystyle". See \l {Creating a Custom Style} for more details about + building custom styles. Custom styles do not need to implement all controls. + By default, the styling system uses the \l {Default style} as a fallback + for controls that a custom style does not provide. It is possible to + specify a different fallback style to customize or extend one of the + built-in styles. + + \code + QQuickStyle::setStyle(":/mystyle"); + QQuickStyle::setFallbackStyle("Material"); + \endcode + \sa {Styling Qt Quick Controls 2} */ @@ -273,13 +286,16 @@ void QQuickStyle::setStyle(const QString &style) } /*! - \since 5.9 + \since 5.8 Sets the application fallback style to \a style. \note The fallback style must be the name of one of the built-in Qt Quick Controls 2 styles, e.g. "Material". \note The style must be configured \b before loading QML that imports Qt Quick Controls 2. It is not possible to change the style after the QML types have been registered. + + The fallback style can be also specified by setting the \c QT_QUICK_CONTROLS_FALLBACK_STYLE + \l {Supported Environment Variables in Qt Quick Controls 2}{environment variable}. */ void QQuickStyle::setFallbackStyle(const QString &style) { -- cgit v1.2.3 From e09a8591990e5281929ca2a7bb180bb3a35556ba Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 24 Oct 2016 16:03:39 +0200 Subject: Popup: add spacing support for Dialog This helps to get the dialog layout right (a separate follow-up commit), because we don't need to mess with the paddings of the header, content, and footer, based on their existence and visibility, but we can also adjust the spacing which gets automatically added between the building blocks when they exist and are visible. Change-Id: Ie8b587eeb9d0fb4a8f42baf957879d40bbd3385c Reviewed-by: Mitch Curtis --- src/imports/controls/Dialog.qml | 5 +-- src/imports/controls/material/Dialog.qml | 5 +-- src/imports/controls/universal/Dialog.qml | 5 +-- src/imports/templates/qtquicktemplates2plugin.cpp | 1 + src/quicktemplates2/qquickdialog.cpp | 7 ++++ src/quicktemplates2/qquickdialog_p.h | 1 + src/quicktemplates2/qquickpopup.cpp | 43 +++++++++++++++++++++++ src/quicktemplates2/qquickpopup_p.h | 7 ++++ src/quicktemplates2/qquickpopup_p_p.h | 1 + 9 files changed, 69 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/imports/controls/Dialog.qml b/src/imports/controls/Dialog.qml index a26928c1..1cf64164 100644 --- a/src/imports/controls/Dialog.qml +++ b/src/imports/controls/Dialog.qml @@ -47,8 +47,9 @@ T.Dialog { footer && footer.visible ? footer.implicitWidth : 0, contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0) implicitHeight: Math.max(background ? background.implicitHeight : 0, - (header && header.visible ? header.implicitHeight : 0) + (footer && footer.visible ? footer.implicitHeight : 0)) - + (contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0) + (header && header.visible ? header.implicitHeight + spacing : 0) + + (footer && footer.visible ? footer.implicitHeight + spacing : 0) + + (contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0)) contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) diff --git a/src/imports/controls/material/Dialog.qml b/src/imports/controls/material/Dialog.qml index ddc80895..90cda45a 100644 --- a/src/imports/controls/material/Dialog.qml +++ b/src/imports/controls/material/Dialog.qml @@ -48,8 +48,9 @@ T.Dialog { footer && footer.visible ? footer.implicitWidth : 0, contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0) implicitHeight: Math.max(background ? background.implicitHeight : 0, - (header && header.visible ? header.implicitHeight : 0) + (footer && footer.visible ? footer.implicitHeight : 0)) - + (contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0) + (header && header.visible ? header.implicitHeight + spacing : 0) + + (footer && footer.visible ? footer.implicitHeight + spacing : 0) + + (contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0)) contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) diff --git a/src/imports/controls/universal/Dialog.qml b/src/imports/controls/universal/Dialog.qml index ce34fd07..f805581c 100644 --- a/src/imports/controls/universal/Dialog.qml +++ b/src/imports/controls/universal/Dialog.qml @@ -47,8 +47,9 @@ T.Dialog { footer && footer.visible ? footer.implicitWidth : 0, contentWidth > 0 ? contentWidth + leftPadding + rightPadding : 0) implicitHeight: Math.max(background ? background.implicitHeight : 0, - (header && header.visible ? header.implicitHeight : 0) + (footer && footer.visible ? footer.implicitHeight : 0)) - + (contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0) + (header && header.visible ? header.implicitHeight + spacing : 0) + + (footer && footer.visible ? footer.implicitHeight + spacing : 0) + + (contentHeight > 0 ? contentHeight + topPadding + bottomPadding : 0)) contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0) contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0) diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp index 3a124860..fb8db27e 100644 --- a/src/imports/templates/qtquicktemplates2plugin.cpp +++ b/src/imports/templates/qtquicktemplates2plugin.cpp @@ -187,6 +187,7 @@ void QtQuickTemplates2Plugin::registerTypes(const char *uri) qmlRegisterType(); qmlRegisterType(uri, 2, 1, "MenuSeparator"); qmlRegisterType(uri, 2, 1, "Page"); + qmlRegisterType(uri, 2, 1, "Popup"); qmlRegisterType(uri, 2, 1, "RangeSlider"); qmlRegisterType(uri, 2, 1, "RoundButton"); qmlRegisterType(uri, 2, 1, "Slider"); diff --git a/src/quicktemplates2/qquickdialog.cpp b/src/quicktemplates2/qquickdialog.cpp index 05e0f26d..6bbe73ce 100644 --- a/src/quicktemplates2/qquickdialog.cpp +++ b/src/quicktemplates2/qquickdialog.cpp @@ -336,4 +336,11 @@ void QQuickDialog::paddingChange(const QMarginsF &newPadding, const QMarginsF &o d->layout->update(); } +void QQuickDialog::spacingChange(qreal newSpacing, qreal oldSpacing) +{ + Q_D(QQuickDialog); + QQuickPopup::spacingChange(newSpacing, oldSpacing); + d->layout->update(); +} + QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickdialog_p.h b/src/quicktemplates2/qquickdialog_p.h index ff8a1e79..ea03dddf 100644 --- a/src/quicktemplates2/qquickdialog_p.h +++ b/src/quicktemplates2/qquickdialog_p.h @@ -95,6 +95,7 @@ Q_SIGNALS: protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override; + void spacingChange(qreal newSpacing, qreal oldSpacing) override; private: Q_DISABLE_COPY(QQuickDialog) diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 3f7d6907..63a9a0d9 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -519,6 +519,13 @@ void QQuickPopupItem::paddingChange(const QMarginsF &newPadding, const QMarginsF d->popup->paddingChange(newPadding, oldPadding); } +void QQuickPopupItem::spacingChange(qreal newSpacing, qreal oldSpacing) +{ + Q_D(QQuickPopupItem); + QQuickControl::spacingChange(newSpacing, oldSpacing); + d->popup->spacingChange(newSpacing, oldSpacing); +} + QFont QQuickPopupItem::defaultFont() const { Q_D(const QQuickPopupItem); @@ -1128,6 +1135,35 @@ qreal QQuickPopup::availableHeight() const return d->popupItem->availableHeight(); } +/*! + \since QtQuick.Controls 2.1 + \qmlproperty real QtQuick.Controls::Popup::spacing + + This property holds the spacing. + + Spacing is useful for popups that have multiple or repetitive building + blocks. For example, some styles use spacing to determine the distance + between the header, content, and footer of \l Dialog. Spacing is not + enforced by Popup, so each style may interpret it differently, and some + may ignore it altogether. +*/ +qreal QQuickPopup::spacing() const +{ + Q_D(const QQuickPopup); + return d->popupItem->spacing(); +} + +void QQuickPopup::setSpacing(qreal spacing) +{ + Q_D(QQuickPopup); + d->popupItem->setSpacing(spacing); +} + +void QQuickPopup::resetSpacing() +{ + setSpacing(0); +} + /*! \qmlproperty real QtQuick.Controls::Popup::margins @@ -2152,6 +2188,13 @@ void QQuickPopup::paddingChange(const QMarginsF &newPadding, const QMarginsF &ol emit availableHeightChanged(); } +void QQuickPopup::spacingChange(qreal newSpacing, qreal oldSpacing) +{ + Q_UNUSED(newSpacing); + Q_UNUSED(oldSpacing); + emit spacingChanged(); +} + QFont QQuickPopup::defaultFont() const { return QQuickControlPrivate::themeFont(QPlatformTheme::SystemFont); diff --git a/src/quicktemplates2/qquickpopup_p.h b/src/quicktemplates2/qquickpopup_p.h index a024c68f..de42b793 100644 --- a/src/quicktemplates2/qquickpopup_p.h +++ b/src/quicktemplates2/qquickpopup_p.h @@ -84,6 +84,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopup : public QObject, public QQml Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged FINAL) Q_PROPERTY(qreal availableWidth READ availableWidth NOTIFY availableWidthChanged FINAL) Q_PROPERTY(qreal availableHeight READ availableHeight NOTIFY availableHeightChanged FINAL) + Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing RESET resetSpacing NOTIFY spacingChanged FINAL REVISION 1) Q_PROPERTY(qreal margins READ margins WRITE setMargins RESET resetMargins NOTIFY marginsChanged FINAL) Q_PROPERTY(qreal topMargin READ topMargin WRITE setTopMargin RESET resetTopMargin NOTIFY topMarginChanged FINAL) Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin RESET resetLeftMargin NOTIFY leftMarginChanged FINAL) @@ -154,6 +155,10 @@ public: qreal availableWidth() const; qreal availableHeight() const; + qreal spacing() const; + void setSpacing(qreal spacing); + void resetSpacing(); + qreal margins() const; void setMargins(qreal margins); void resetMargins(); @@ -293,6 +298,7 @@ Q_SIGNALS: void contentHeightChanged(); void availableWidthChanged(); void availableHeightChanged(); + Q_REVISION(1) void spacingChanged(); void marginsChanged(); void topMarginChanged(); void leftMarginChanged(); @@ -354,6 +360,7 @@ protected: virtual void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data); virtual void marginsChange(const QMarginsF &newMargins, const QMarginsF &oldMargins); virtual void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding); + virtual void spacingChange(qreal newSpacing, qreal oldSpacing); virtual QFont defaultFont() const; diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h index a9eeacd8..7675b151 100644 --- a/src/quicktemplates2/qquickpopup_p_p.h +++ b/src/quicktemplates2/qquickpopup_p_p.h @@ -105,6 +105,7 @@ protected: void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override; void itemChange(ItemChange change, const ItemChangeData &data) override; void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override; + void spacingChange(qreal newSpacing, qreal oldSpacing) override; QFont defaultFont() const override; -- cgit v1.2.3 From a66e08da7681f7301e23c55fd1f40ef8461f0896 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 26 Oct 2016 12:48:58 +0200 Subject: Default: move opacity assignments to individual delegates This way, users have control over the opacity of child items. Change-Id: Ie7c0b08eb0b22d11319f8c2f1807e6a3a68790ea Reviewed-by: J-P Nurmi --- src/imports/controls/CheckBox.qml | 2 +- src/imports/controls/CheckIndicator.qml | 1 + src/imports/controls/RadioButton.qml | 2 +- src/imports/controls/RadioIndicator.qml | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/imports/controls/CheckBox.qml b/src/imports/controls/CheckBox.qml index 78b42276..52ce20ef 100644 --- a/src/imports/controls/CheckBox.qml +++ b/src/imports/controls/CheckBox.qml @@ -51,7 +51,6 @@ T.CheckBox { padding: 6 spacing: 6 - opacity: enabled ? 1 : 0.3 //! [indicator] indicator: CheckIndicator { @@ -73,6 +72,7 @@ T.CheckBox { visible: control.text horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter + opacity: enabled ? 1 : 0.3 } //! [contentItem] } diff --git a/src/imports/controls/CheckIndicator.qml b/src/imports/controls/CheckIndicator.qml index d78e9e30..5aad92ef 100644 --- a/src/imports/controls/CheckIndicator.qml +++ b/src/imports/controls/CheckIndicator.qml @@ -47,6 +47,7 @@ Rectangle { color: control.enabled ? (control.down ? (control.visualFocus ? "#cce0ff" : "#f6f6f6") : "#ffffff") : "#353637" border.width: control.visualFocus ? 2 : 1 border.color: control.enabled ? (control.visualFocus ? "#0066ff" : (control.down ? "#808080" : "#909090")) : "transparent" + opacity: enabled ? 1 : 0.3 Image { x: (parent.width - width) / 2 diff --git a/src/imports/controls/RadioButton.qml b/src/imports/controls/RadioButton.qml index 1c63a8de..a1a5d1a1 100644 --- a/src/imports/controls/RadioButton.qml +++ b/src/imports/controls/RadioButton.qml @@ -51,7 +51,6 @@ T.RadioButton { padding: 6 spacing: 6 - opacity: enabled ? 1 : 0.3 //! [indicator] indicator: RadioIndicator { @@ -73,6 +72,7 @@ T.RadioButton { visible: control.text horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter + opacity: enabled ? 1 : 0.3 } //! [contentItem] } diff --git a/src/imports/controls/RadioIndicator.qml b/src/imports/controls/RadioIndicator.qml index 08c24cc5..05ff6673 100644 --- a/src/imports/controls/RadioIndicator.qml +++ b/src/imports/controls/RadioIndicator.qml @@ -44,6 +44,7 @@ Rectangle { color: control.down ? (control.visualFocus ? "#cce0ff" : "#f6f6f6") : (control.visualFocus ? "#f0f6ff" : "#ffffff") border.width: control.visualFocus ? 2 : 1 border.color: control.visualFocus ? "#0066ff" : (control.down ? "#808080" : "#909090") + opacity: enabled ? 1 : 0.3 property Item control -- cgit v1.2.3 From a7e39a28575dc3421970e007b78731b614da258a Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 26 Oct 2016 21:31:03 +0200 Subject: QQuickPopup: fix binding loops with size-dependent positioning Dependencies between popup's size and position easily lead to recursion into reposition(). Blocking recursive reposition() calls messes up the positioning, so schedule polish events instead. Task-number: QTBUG-56755 Change-Id: I72afd14573e5cd57f8162df04e193d4c42fd7236 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickpopup.cpp | 16 ++++++++++++++++ src/quicktemplates2/qquickpopup_p_p.h | 3 +++ 2 files changed, 19 insertions(+) (limited to 'src') diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 124b8c5b..d343fad6 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -128,6 +128,7 @@ QQuickPopupPrivate::QQuickPopupPrivate() , hasDim(false) , visible(false) , complete(false) + , positioning(false) , hasWidth(false) , hasHeight(false) , hasTopMargin(false) @@ -401,6 +402,12 @@ QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) : // connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, this, &QQuickItem::setAcceptHoverEvents); } +void QQuickPopupItem::updatePolish() +{ + Q_D(QQuickPopupItem); + return QQuickPopupPrivate::get(d->popup)->reposition(); +} + bool QQuickPopupItem::childMouseEventFilter(QQuickItem *child, QEvent *event) { Q_D(QQuickPopupItem); @@ -594,6 +601,11 @@ void QQuickPopupPrivate::reposition() if (!popupItem->isVisible()) return; + if (positioning) { + popupItem->polish(); + return; + } + const qreal w = popupItem->width(); const qreal h = popupItem->height(); const qreal iw = popupItem->implicitWidth(); @@ -702,6 +714,8 @@ void QQuickPopupPrivate::reposition() } } + positioning = true; + popupItem->setPosition(rect.topLeft()); const QPointF effectivePos = parentItem ? parentItem->mapFromScene(rect.topLeft()) : rect.topLeft(); @@ -718,6 +732,8 @@ void QQuickPopupPrivate::reposition() popupItem->setWidth(rect.width()); if (!hasHeight && heightAdjusted && rect.height() > 0) popupItem->setHeight(rect.height()); + + positioning = false; } void QQuickPopupPrivate::resizeOverlay() diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h index c8c83ada..d2f16e11 100644 --- a/src/quicktemplates2/qquickpopup_p_p.h +++ b/src/quicktemplates2/qquickpopup_p_p.h @@ -87,6 +87,8 @@ public: explicit QQuickPopupItem(QQuickPopup *popup); protected: + void updatePolish() override; + bool childMouseEventFilter(QQuickItem *child, QEvent *event) override; void focusInEvent(QFocusEvent *event) override; void focusOutEvent(QFocusEvent *event) override; @@ -185,6 +187,7 @@ public: bool hasDim; bool visible; bool complete; + bool positioning; bool hasWidth; bool hasHeight; bool hasTopMargin; -- cgit v1.2.3 From 929fd7b919fb873750f97f3e74b0986ce7c4e022 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 26 Oct 2016 20:27:16 +0200 Subject: Scrollers: give control over layouting if parent != flickable This allows utilizing the convenient attached properties of ScrollBar and ScrollIndicator, but positioning the scrollers outside of a clipping Flickable. Change-Id: I46fe79110658f4797469d042c56f51548eef6c70 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickscrollbar.cpp | 33 ++++++++++++++++++++++++--- src/quicktemplates2/qquickscrollindicator.cpp | 33 ++++++++++++++++++++++++--- 2 files changed, 60 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp index 69cac6ee..d3a2355c 100644 --- a/src/quicktemplates2/qquickscrollbar.cpp +++ b/src/quicktemplates2/qquickscrollbar.cpp @@ -65,9 +65,9 @@ QT_BEGIN_NAMESPACE } \endcode - \note When ScrollBar is attached \l {ScrollBar::vertical}{vertically} or - \l {ScrollBar::horizontal}{horizontally} to a Flickable, its geometry and - the following properties are automatically set and updated as appropriate: + When ScrollBar is attached \l {ScrollBar::vertical}{vertically} or + \l {ScrollBar::horizontal}{horizontally} to a Flickable, the following + properties are automatically set and updated as appropriate: \list \li \l orientation \li \l position @@ -75,6 +75,29 @@ QT_BEGIN_NAMESPACE \li \l active \endlist + An attached ScrollBar re-parents itself to the target Flickable. A vertically + attached ScrollBar resizes itself to the height of the Flickable, and positions + itself to either side of it based on the \l {Control::mirrored}{layout direction}. + A horizontally attached ScrollBar resizes itself to the width of the Flickable, + and positions itself to the bottom. The automatic geometry management can be disabled + by specifying another parent for the attached ScrollBar. This can be useful, for + example, if the ScrollBar should be placed outside a clipping Flickable. This is + demonstrated by the following example: + + \code + Flickable { + id: flickable + clip: true + // ... + ScrollBar.vertical: ScrollBar { + parent: flickable.parent + anchors.top: flickable.top + anchors.left: flickable.right + anchors.bottom: flickable.bottom + } + } + \endcode + Notice that ScrollBar does not filter key events of the Flickable it is attached to. The following example illustrates how to implement scrolling with up and down keys: @@ -465,6 +488,8 @@ void QQuickScrollBarAttachedPrivate::mirrorVertical() void QQuickScrollBarAttachedPrivate::layoutHorizontal(bool move) { Q_ASSERT(horizontal && flickable); + if (horizontal->parentItem() != flickable) + return; horizontal->setWidth(flickable->width()); if (move) horizontal->setY(flickable->height() - horizontal->height()); @@ -473,6 +498,8 @@ void QQuickScrollBarAttachedPrivate::layoutHorizontal(bool move) void QQuickScrollBarAttachedPrivate::layoutVertical(bool move) { Q_ASSERT(vertical && flickable); + if (vertical->parentItem() != flickable) + return; vertical->setHeight(flickable->height()); if (move) vertical->setX(vertical->isMirrored() ? 0 : flickable->width() - vertical->width()); diff --git a/src/quicktemplates2/qquickscrollindicator.cpp b/src/quicktemplates2/qquickscrollindicator.cpp index 48adda0a..91d03ec9 100644 --- a/src/quicktemplates2/qquickscrollindicator.cpp +++ b/src/quicktemplates2/qquickscrollindicator.cpp @@ -65,9 +65,9 @@ QT_BEGIN_NAMESPACE } \endcode - \note When ScrollIndicator is attached \l {ScrollIndicator::vertical}{vertically} - or \l {ScrollIndicator::horizontal}{horizontally} to a Flickable, its geometry and - the following properties are automatically set and updated as appropriate: + When ScrollIndicator is attached \l {ScrollIndicator::vertical}{vertically} or + \l {ScrollIndicator::horizontal}{horizontally} to a Flickable, the following + properties are automatically set and updated as appropriate: \list \li \l orientation \li \l position @@ -75,6 +75,29 @@ QT_BEGIN_NAMESPACE \li \l active \endlist + An attached ScrollIndicator re-parents itself to the target Flickable. A vertically + attached ScrollIndicator resizes itself to the height of the Flickable, and positions + itself to either side of it based on the \l {Control::mirrored}{layout direction}. + A horizontally attached ScrollIndicator resizes itself to the width of the Flickable, + and positions itself to the bottom. The automatic geometry management can be disabled + by specifying another parent for the attached ScrollIndicator. This can be useful, for + example, if the ScrollIndicator should be placed outside a clipping Flickable. This is + demonstrated by the following example: + + \code + Flickable { + id: flickable + clip: true + // ... + ScrollIndicator.vertical: ScrollIndicator { + parent: flickable.parent + anchors.top: flickable.top + anchors.left: flickable.right + anchors.bottom: flickable.bottom + } + } + \endcode + Horizontal and vertical scroll indicators do not share the \l active state with each other by default. In order to keep both indicators visible whilst scrolling to either direction, establish a two-way binding between the active states as @@ -268,6 +291,8 @@ void QQuickScrollIndicatorAttachedPrivate::activateVertical() void QQuickScrollIndicatorAttachedPrivate::layoutHorizontal(bool move) { Q_ASSERT(horizontal && flickable); + if (horizontal->parentItem() != flickable) + return; horizontal->setWidth(flickable->width()); if (move) horizontal->setY(flickable->height() - horizontal->height()); @@ -276,6 +301,8 @@ void QQuickScrollIndicatorAttachedPrivate::layoutHorizontal(bool move) void QQuickScrollIndicatorAttachedPrivate::layoutVertical(bool move) { Q_ASSERT(vertical && flickable); + if (vertical->parentItem() != flickable) + return; vertical->setHeight(flickable->height()); if (move && !QQuickItemPrivate::get(vertical)->isMirrored()) vertical->setX(flickable->width() - vertical->width()); -- cgit v1.2.3 From 541fc438b0c0e49b9eb7a861322ec6dce4dbc238 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Oct 2016 15:03:03 +0200 Subject: Material: fix blurry ComboBox drop indicators Change-Id: I2c3f101182f8b985180695f6cf3c6baabe9969ed Reviewed-by: Mitch Curtis --- src/imports/controls/material/images/drop-indicator.png | Bin 342 -> 192 bytes src/imports/controls/material/images/drop-indicator.svg | 5 +++++ .../controls/material/images/drop-indicator@2x.png | Bin 273 -> 221 bytes .../controls/material/images/drop-indicator@3x.png | Bin 406 -> 256 bytes .../controls/material/images/drop-indicator@4x.png | Bin 520 -> 289 bytes 5 files changed, 5 insertions(+) create mode 100644 src/imports/controls/material/images/drop-indicator.svg (limited to 'src') diff --git a/src/imports/controls/material/images/drop-indicator.png b/src/imports/controls/material/images/drop-indicator.png index b4396ec6..08bb4855 100644 Binary files a/src/imports/controls/material/images/drop-indicator.png and b/src/imports/controls/material/images/drop-indicator.png differ diff --git a/src/imports/controls/material/images/drop-indicator.svg b/src/imports/controls/material/images/drop-indicator.svg new file mode 100644 index 00000000..94b5ca15 --- /dev/null +++ b/src/imports/controls/material/images/drop-indicator.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/imports/controls/material/images/drop-indicator@2x.png b/src/imports/controls/material/images/drop-indicator@2x.png index 1c711bc2..ccdfc2b1 100644 Binary files a/src/imports/controls/material/images/drop-indicator@2x.png and b/src/imports/controls/material/images/drop-indicator@2x.png differ diff --git a/src/imports/controls/material/images/drop-indicator@3x.png b/src/imports/controls/material/images/drop-indicator@3x.png index 06dd8bd2..00cae691 100644 Binary files a/src/imports/controls/material/images/drop-indicator@3x.png and b/src/imports/controls/material/images/drop-indicator@3x.png differ diff --git a/src/imports/controls/material/images/drop-indicator@4x.png b/src/imports/controls/material/images/drop-indicator@4x.png index b2157c30..0a61cb01 100644 Binary files a/src/imports/controls/material/images/drop-indicator@4x.png and b/src/imports/controls/material/images/drop-indicator@4x.png differ -- cgit v1.2.3 From e32ffa19f0cabc50f264c2e20cdae3557e658ac7 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Oct 2016 15:32:36 +0200 Subject: Doc: fix review findings for Drawer Change-Id: Ibdf3f1dee5664979cdf77ba7485e3d71110fc860 Task-number: QTBUG-55904 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickdrawer.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index d35b30cf..dc427bc9 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -156,7 +156,9 @@ QT_BEGIN_NAMESPACE the drawer is opened, don't apply a translation. \note On some platforms, certain edges may be reserved for system - gestures and therefore cannot be used with Drawer. + gestures and therefore cannot be used with Drawer. For example, the + top and bottom edges may be reserved for system notifications and + control centers on Android and iOS. \sa SwipeView, {Customizing Drawer}, {Navigation Controls}, {Popup Controls} */ @@ -481,13 +483,13 @@ QQuickDrawer::QQuickDrawer(QObject *parent) : /*! \qmlproperty enumeration QtQuick.Controls::Drawer::edge - This property holds the edge of the content item at which the drawer will + This property holds the edge of the window at which the drawer will open from. The acceptable values are: - \value Qt.TopEdge The top edge of the content item. - \value Qt.LeftEdge The left edge of the content item (default). - \value Qt.RightEdge The right edge of the content item. - \value Qt.BottomEdge The bottom edge of the content item. + \value Qt.TopEdge The top edge of the window. + \value Qt.LeftEdge The left edge of the window (default). + \value Qt.RightEdge The right edge of the window. + \value Qt.BottomEdge The bottom edge of the window. */ Qt::Edge QQuickDrawer::edge() const { @@ -511,8 +513,8 @@ void QQuickDrawer::setEdge(Qt::Edge edge) \qmlproperty real QtQuick.Controls::Drawer::position This property holds the position of the drawer relative to its final - destination. That is, the position will be \c 0 when the drawer - is fully closed, and \c 1 when fully open. + destination. That is, the position will be \c 0.0 when the drawer + is fully closed, and \c 1.0 when fully open. */ qreal QQuickDrawer::position() const { -- cgit v1.2.3 From dac9c6bd1d7be53a659ce0bffe9221c5ca255b2e Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Oct 2016 15:43:15 +0200 Subject: Doc: link to Control::contentItem in GroupBox detailed description Change-Id: I0f0a93a3ebf0a884e81f9c856490d564b30a90c8 Task-number: QTBUG-55904 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickgroupbox.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickgroupbox.cpp b/src/quicktemplates2/qquickgroupbox.cpp index 27c325ef..5a5a8005 100644 --- a/src/quicktemplates2/qquickgroupbox.cpp +++ b/src/quicktemplates2/qquickgroupbox.cpp @@ -56,8 +56,8 @@ QT_BEGIN_NAMESPACE or a \l ColumnLayout. Items declared as children of a GroupBox are automatically parented to the - GroupBox's contentItem. Items created dynamically need to be explicitly - parented to the contentItem. + GroupBox's \l {Control::}{contentItem}. Items created dynamically need to be + explicitly parented to the contentItem. If only a single item is used within a GroupBox, it will resize to fit the implicit size of its contained item. This makes it particularly suitable -- cgit v1.2.3 From 97decc60e91be415b39785564cc40f8b30362809 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Oct 2016 16:18:11 +0200 Subject: Doc: add one more link to Text in the detailed description of Label Change-Id: Ic205fe6840274c12a3e4c3f1f355080aff8861d7 Task-number: QTBUG-55904 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicklabel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp index 03bed16f..b3596022 100644 --- a/src/quicktemplates2/qquicklabel.cpp +++ b/src/quicktemplates2/qquicklabel.cpp @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE \snippet qtquickcontrols2-label.qml 1 - You can use the properties of Text to change the appearance of the text as desired: + You can use the properties of \l Text to change the appearance of the text as desired: \qml Label { -- cgit v1.2.3 From a7687dbbb0fa0f619324b43bba1ccb9d5b75ce64 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Oct 2016 16:27:58 +0200 Subject: Doc: fix review findings for Switch & SwitchDelegate Change-Id: I1626cb83d75e9b64fc5e274dc29fff04a157741b Task-number: QTBUG-55904 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickswitch.cpp | 14 ++++---------- src/quicktemplates2/qquickswitchdelegate.cpp | 8 ++++++-- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp index a7d17e86..8c3d9f0b 100644 --- a/src/quicktemplates2/qquickswitch.cpp +++ b/src/quicktemplates2/qquickswitch.cpp @@ -57,17 +57,11 @@ QT_BEGIN_NAMESPACE Switch is an option button that can be dragged or toggled on (checked) or off (unchecked). Switches are typically used to select between two states. + For larger sets of options, such as those in a list, consider using + \l SwitchDelegate instead. - \table - \row \li \image qtquickcontrols2-switch-normal.png - \li A switch in its normal state. - \row \li \image qtquickcontrols2-switch-checked.png - \li A switch that is checked. - \row \li \image qtquickcontrols2-switch-focused.png - \li A switch that has active focus. - \row \li \image qtquickcontrols2-switch-disabled.png - \li A switch that is disabled. - \endtable + Switch inherits its API from \l AbstractButton. For instance, the state + of the switch can be set with the \l {AbstractButton::}{checked} property. \code ColumnLayout { diff --git a/src/quicktemplates2/qquickswitchdelegate.cpp b/src/quicktemplates2/qquickswitchdelegate.cpp index 62b677e5..edfb15d5 100644 --- a/src/quicktemplates2/qquickswitchdelegate.cpp +++ b/src/quicktemplates2/qquickswitchdelegate.cpp @@ -53,9 +53,13 @@ QT_BEGIN_NAMESPACE SwitchDelegate presents an item delegate that can be toggled on (checked) or off (unchecked). Switch delegates are typically used to select one or more - options from a set of options. + options from a set of options. For smaller sets of options, or for options + that need to be uniquely identifiable, consider using \l Switch instead. - The state of the check delegate can be set with the + SwitchDelegate inherits its API from \l ItemDelegate, which is inherited + from \l AbstractButton. For instance, you can set \l {AbstractButton::text}{text}, + and react to \l {AbstractButton::clicked}{clicks} using the \l AbstractButton + API. The state of the switch delegate can be set with the \l {AbstractButton::}{checked} property. \code -- cgit v1.2.3 From 548b0bdd0f57c2209c8cbd7ac4ecda204cf69a2e Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 28 Oct 2016 16:31:51 +0200 Subject: Doc: fix review findings for TextArea Change-Id: I0d9ff52d019bfae37e1fd191e914e61a1a07aee0 Task-number: QTBUG-55904 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktextarea.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 1b6aef9f..ee20d477 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -79,6 +79,8 @@ QT_BEGIN_NAMESPACE decoration of the TextArea scrolls together with the rest of the scrollable content. + \section2 Scrollable TextArea + If you want to make a TextArea scrollable, for example, when it covers an entire application page, attach it to a \l Flickable and combine with a \l ScrollBar or \l ScrollIndicator. @@ -87,7 +89,7 @@ QT_BEGIN_NAMESPACE \snippet qtquickcontrols2-textarea-flickable.qml 1 - A TextArea that is attached to a Flickable does the following: + A TextArea that is attached to a \l Flickable does the following: \list \li Sets the content size automatically @@ -630,9 +632,7 @@ QQuickTextAreaAttached::~QQuickTextAreaAttached() This property attaches a text area to a \l Flickable. - \snippet qtquickcontrols2-textarea-flickable.qml 1 - - \sa ScrollBar, ScrollIndicator + \sa ScrollBar, ScrollIndicator, {Scrollable TextArea} */ QQuickTextArea *QQuickTextAreaAttached::flickable() const { -- cgit v1.2.3