diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-02-05 15:47:24 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-02-06 13:16:25 +0000 |
commit | 66487fec4c558d8b77dd0573e524a61d11e33c2a (patch) | |
tree | dbb6e6ef4ef7231c6b0668289cdef6e00fa14fef | |
parent | 39cd9bce138e3463a0c460119531542acb7d126f (diff) |
Remove AbstractButton::label in favor of contentItem
This has been on the TODO list for a long time and should have been
done earlier. It's time to cleanup the API and remove all the delegate
properties that became redundant when Control::contentItem was
introduced.
The biggest benefit of using Control::contentItem is that it is resized
and positioned automatically, so we save a few QML bindings. Furthemore,
contentItem is a common naming pattern in Qt Quick (Window, Flickable)
and therefore less likely to conflict with IDs in user code (a thing
that always bothered me with "label").
Change-Id: I8143a9f08d726db31cf4618670af48bd37f80b89
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
-rw-r--r-- | src/imports/controls/plugins.qmltypes | 1 | ||||
-rw-r--r-- | src/imports/templates/plugins.qmltypes | 1 | ||||
-rw-r--r-- | src/templates/qquickabstractbutton.cpp | 31 | ||||
-rw-r--r-- | src/templates/qquickabstractbutton_p.h | 5 | ||||
-rw-r--r-- | src/templates/qquickabstractbutton_p_p.h | 1 |
5 files changed, 3 insertions, 36 deletions
diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes index 75805fdd..62287cb5 100644 --- a/src/imports/controls/plugins.qmltypes +++ b/src/imports/controls/plugins.qmltypes @@ -28,7 +28,6 @@ Module { Property { name: "autoExclusive"; type: "bool" } Property { name: "autoRepeat"; type: "bool" } Property { name: "indicator"; type: "QQuickItem"; isPointer: true } - Property { name: "label"; type: "QQuickItem"; isPointer: true } Signal { name: "pressed" } Signal { name: "released" } Signal { name: "canceled" } diff --git a/src/imports/templates/plugins.qmltypes b/src/imports/templates/plugins.qmltypes index d96563a7..d3ca28fc 100644 --- a/src/imports/templates/plugins.qmltypes +++ b/src/imports/templates/plugins.qmltypes @@ -22,7 +22,6 @@ Module { Property { name: "autoExclusive"; type: "bool" } Property { name: "autoRepeat"; type: "bool" } Property { name: "indicator"; type: "QQuickItem"; isPointer: true } - Property { name: "label"; type: "QQuickItem"; isPointer: true } Signal { name: "pressed" } Signal { name: "released" } Signal { name: "canceled" } diff --git a/src/templates/qquickabstractbutton.cpp b/src/templates/qquickabstractbutton.cpp index 9edb4d2e..9f1667fe 100644 --- a/src/templates/qquickabstractbutton.cpp +++ b/src/templates/qquickabstractbutton.cpp @@ -100,7 +100,7 @@ static const int AUTO_REPEAT_INTERVAL = 100; QQuickAbstractButtonPrivate::QQuickAbstractButtonPrivate() : pressed(false), checked(false), checkable(false), highlighted(false), autoExclusive(false), autoRepeat(false), - delayTimer(0), repeatTimer(0), repeatButton(Qt::NoButton), label(nullptr), indicator(nullptr), group(nullptr) + delayTimer(0), repeatTimer(0), repeatButton(Qt::NoButton), indicator(nullptr), group(nullptr) { } @@ -203,9 +203,9 @@ QQuickAbstractButton::~QQuickAbstractButton() This property holds a textual description of the button. \note The text is used for accessibility purposes, so it makes sense to - set a textual description even if the label item is an image. + set a textual description even if the content item is an image. - \sa label + \sa contentItem */ QString QQuickAbstractButton::text() const { @@ -395,31 +395,6 @@ void QQuickAbstractButton::setIndicator(QQuickItem *indicator) } /*! - \qmlproperty Item Qt.labs.controls::AbstractButton::label - - This property holds the label item. - - \sa text -*/ -QQuickItem *QQuickAbstractButton::label() const -{ - Q_D(const QQuickAbstractButton); - return d->label; -} - -void QQuickAbstractButton::setLabel(QQuickItem *label) -{ - Q_D(QQuickAbstractButton); - if (d->label != label) { - delete d->label; - d->label = label; - if (label && !label->parentItem()) - label->setParentItem(this); - emit labelChanged(); - } -} - -/*! \qmlmethod void Qt.labs.controls::Button::toggle() Toggles the checked state of the button. diff --git a/src/templates/qquickabstractbutton_p.h b/src/templates/qquickabstractbutton_p.h index b50f5ec7..7ff98f66 100644 --- a/src/templates/qquickabstractbutton_p.h +++ b/src/templates/qquickabstractbutton_p.h @@ -65,7 +65,6 @@ class Q_LABSTEMPLATES_EXPORT QQuickAbstractButton : public QQuickControl Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive NOTIFY autoExclusiveChanged FINAL) Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL) Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) - Q_PROPERTY(QQuickItem *label READ label WRITE setLabel NOTIFY labelChanged FINAL) public: explicit QQuickAbstractButton(QQuickItem *parent = nullptr); @@ -95,9 +94,6 @@ public: QQuickItem *indicator() const; void setIndicator(QQuickItem *indicator); - QQuickItem *label() const; - void setLabel(QQuickItem *label); - public Q_SLOTS: void toggle(); @@ -115,7 +111,6 @@ Q_SIGNALS: void autoExclusiveChanged(); void autoRepeatChanged(); void indicatorChanged(); - void labelChanged(); protected: QQuickAbstractButton(QQuickAbstractButtonPrivate &dd, QQuickItem *parent); diff --git a/src/templates/qquickabstractbutton_p_p.h b/src/templates/qquickabstractbutton_p_p.h index 601c6dc7..be53946a 100644 --- a/src/templates/qquickabstractbutton_p_p.h +++ b/src/templates/qquickabstractbutton_p_p.h @@ -85,7 +85,6 @@ public: int repeatTimer; QPointF pressPoint; Qt::MouseButton repeatButton; - QQuickItem *label; QQuickItem *indicator; QQuickButtonGroup *group; }; |