aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/controls/qquickbutton.cpp48
-rw-r--r--src/controls/qquickbutton_p.h5
-rw-r--r--src/controls/qquickbutton_p_p.h4
-rw-r--r--src/imports/controls/Button.qml5
4 files changed, 7 insertions, 55 deletions
diff --git a/src/controls/qquickbutton.cpp b/src/controls/qquickbutton.cpp
index 4bf2c08a..f8aa426c 100644
--- a/src/controls/qquickbutton.cpp
+++ b/src/controls/qquickbutton.cpp
@@ -97,9 +97,7 @@ QT_BEGIN_NAMESPACE
\image qtquickcontrols2-button-label.png
- If the \l {Button::label}{label} delegate has no explicit size specified,
- it automatically follows the control's size without padding. The following
- snippet presents the default label delegate implementation.
+ The following snippet presents the default label delegate implementation.
\snippet Button.qml label
@@ -134,26 +132,10 @@ QT_BEGIN_NAMESPACE
This signal is emitted when the button is clicked.
*/
-QQuickButtonPrivate::QQuickButtonPrivate() :
- pressed(false), label(Q_NULLPTR), labelHasWidth(true), labelHasHeight(true)
+QQuickButtonPrivate::QQuickButtonPrivate() : pressed(false), label(Q_NULLPTR)
{
}
-void QQuickButtonPrivate::updateGeometry()
-{
- Q_Q(QQuickButton);
- if (label) {
- if (!labelHasWidth) {
- label->setX(q->leftPadding());
- label->setWidth(q->width() - q->leftPadding() - q->rightPadding());
- }
- if (!labelHasHeight) {
- label->setY(q->topPadding());
- label->setHeight(q->height() - q->topPadding() - q->bottomPadding());
- }
- }
-}
-
QQuickButton::QQuickButton(QQuickItem *parent) :
QQuickControl(*(new QQuickButtonPrivate), parent)
{
@@ -218,9 +200,6 @@ void QQuickButton::setPressed(bool isPressed)
This property holds the label delegate.
- If the label delegate has no explicit size specified, it
- automatically follows the control's size without padding.
-
The implicit size of the label delegate is used to calculate
the implicit size of the control.
@@ -315,27 +294,4 @@ void QQuickButton::mouseUngrabEvent()
}
}
-void QQuickButton::componentComplete()
-{
- Q_D(QQuickButton);
- QQuickControl::componentComplete();
- d->labelHasWidth = d->label && QQuickItemPrivate::get(d->label)->widthValid;
- d->labelHasHeight = d->label && QQuickItemPrivate::get(d->label)->heightValid;
- d->updateGeometry();
-}
-
-void QQuickButton::paddingChange()
-{
- Q_D(QQuickButton);
- QQuickControl::paddingChange();
- d->updateGeometry();
-}
-
-void QQuickButton::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
-{
- Q_D(QQuickButton);
- QQuickControl::geometryChanged(newGeometry, oldGeometry);
- d->updateGeometry();
-}
-
QT_END_NAMESPACE
diff --git a/src/controls/qquickbutton_p.h b/src/controls/qquickbutton_p.h
index 903af206..43ac6ae4 100644
--- a/src/controls/qquickbutton_p.h
+++ b/src/controls/qquickbutton_p.h
@@ -93,11 +93,6 @@ protected:
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseUngrabEvent() Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
-
- void paddingChange() Q_DECL_OVERRIDE;
- void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) Q_DECL_OVERRIDE;
-
private:
Q_DISABLE_COPY(QQuickButton)
Q_DECLARE_PRIVATE(QQuickButton)
diff --git a/src/controls/qquickbutton_p_p.h b/src/controls/qquickbutton_p_p.h
index 42827fd2..ca67c224 100644
--- a/src/controls/qquickbutton_p_p.h
+++ b/src/controls/qquickbutton_p_p.h
@@ -59,13 +59,9 @@ class QQuickButtonPrivate : public QQuickControlPrivate
public:
QQuickButtonPrivate();
- void updateGeometry();
-
QString text;
bool pressed;
QQuickItem *label;
- bool labelHasWidth;
- bool labelHasHeight;
};
QT_END_NAMESPACE
diff --git a/src/imports/controls/Button.qml b/src/imports/controls/Button.qml
index 708dc845..c0c4033c 100644
--- a/src/imports/controls/Button.qml
+++ b/src/imports/controls/Button.qml
@@ -53,6 +53,11 @@ AbstractButton {
//! [label]
label: Text {
+ x: control.leftPadding
+ y: control.topPadding
+ width: control.contentWidth
+ height: control.contentHeight
+
text: control.text
color: control.Theme.selectedTextColor
horizontalAlignment: Text.AlignHCenter