aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp72
-rw-r--r--src/quicktemplates2/qquickabstractbutton_p.h10
-rw-r--r--src/quicktemplates2/qquickabstractbutton_p_p.h3
3 files changed, 85 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index 0a8b8ddf..9f92155e 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -388,6 +388,22 @@ void QQuickAbstractButtonPrivate::executeIndicator(bool complete)
quickCompleteDeferred(q, indicatorName(), indicator);
}
+void QQuickAbstractButtonPrivate::itemImplicitWidthChanged(QQuickItem *item)
+{
+ Q_Q(QQuickAbstractButton);
+ QQuickControlPrivate::itemImplicitWidthChanged(item);
+ if (item == indicator)
+ emit q->implicitIndicatorWidthChanged();
+}
+
+void QQuickAbstractButtonPrivate::itemImplicitHeightChanged(QQuickItem *item)
+{
+ Q_Q(QQuickAbstractButton);
+ QQuickControlPrivate::itemImplicitHeightChanged(item);
+ if (item == indicator)
+ emit q->implicitIndicatorHeightChanged();
+}
+
QQuickAbstractButton *QQuickAbstractButtonPrivate::findCheckedButton() const
{
Q_Q(const QQuickAbstractButton);
@@ -458,6 +474,7 @@ QQuickAbstractButton::QQuickAbstractButton(QQuickAbstractButtonPrivate &dd, QQui
QQuickAbstractButton::~QQuickAbstractButton()
{
Q_D(QQuickAbstractButton);
+ d->removeImplicitSizeListener(d->indicator);
if (d->group)
d->group->removeButton(this);
d->ungrabShortcut();
@@ -706,13 +723,24 @@ void QQuickAbstractButton::setIndicator(QQuickItem *indicator)
if (!d->indicator.isExecuting())
d->cancelIndicator();
+ const qreal oldImplicitIndicatorWidth = implicitIndicatorWidth();
+ const qreal oldImplicitIndicatorHeight = implicitIndicatorHeight();
+
+ d->removeImplicitSizeListener(d->indicator);
delete d->indicator;
d->indicator = indicator;
+
if (indicator) {
if (!indicator->parentItem())
indicator->setParentItem(this);
indicator->setAcceptedMouseButtons(Qt::LeftButton);
+ d->addImplicitSizeListener(indicator);
}
+
+ if (!qFuzzyCompare(oldImplicitIndicatorWidth, implicitIndicatorWidth()))
+ emit implicitIndicatorWidthChanged();
+ if (!qFuzzyCompare(oldImplicitIndicatorHeight, implicitIndicatorHeight()))
+ emit implicitIndicatorHeightChanged();
if (!d->indicator.isExecuting())
emit indicatorChanged();
}
@@ -940,6 +968,50 @@ qreal QQuickAbstractButton::pressY() const
}
/*!
+ \since QtQuick.Controls 2.5 (Qt 5.12)
+ \qmlproperty real QtQuick.Controls::AbstractButton::implicitIndicatorWidth
+ \readonly
+
+ This property holds the implicit indicator width.
+
+ The value is equal to \c {indicator ? indicator.implicitWidth : 0}.
+
+ This is typically used, together with \l {Control::}{implicitContentWidth} and
+ \l {Control::}{implicitBackgroundWidth}, to calculate the \l {Item::}{implicitWidth}.
+
+ \sa implicitIndicatorHeight
+*/
+qreal QQuickAbstractButton::implicitIndicatorWidth() const
+{
+ Q_D(const QQuickAbstractButton);
+ if (!d->indicator)
+ return 0;
+ return d->indicator->implicitWidth();
+}
+
+/*!
+ \since QtQuick.Controls 2.5 (Qt 5.12)
+ \qmlproperty real QtQuick.Controls::AbstractButton::implicitIndicatorHeight
+ \readonly
+
+ This property holds the implicit indicator height.
+
+ The value is equal to \c {indicator ? indicator.implicitHeight : 0}.
+
+ This is typically used, together with \l {Control::}{implicitContentHeight} and
+ \l {Control::}{implicitBackgroundHeight}, to calculate the \l {Item::}{implicitHeight}.
+
+ \sa implicitIndicatorWidth
+*/
+qreal QQuickAbstractButton::implicitIndicatorHeight() const
+{
+ Q_D(const QQuickAbstractButton);
+ if (!d->indicator)
+ return 0;
+ return d->indicator->implicitHeight();
+}
+
+/*!
\qmlmethod void QtQuick.Controls::AbstractButton::toggle()
Toggles the checked state of the button.
diff --git a/src/quicktemplates2/qquickabstractbutton_p.h b/src/quicktemplates2/qquickabstractbutton_p.h
index de0c26ab..0fa48980 100644
--- a/src/quicktemplates2/qquickabstractbutton_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p.h
@@ -76,6 +76,9 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAbstractButton : public QQuickContr
Q_PROPERTY(int autoRepeatInterval READ autoRepeatInterval WRITE setAutoRepeatInterval NOTIFY autoRepeatIntervalChanged FINAL REVISION 4)
Q_PROPERTY(qreal pressX READ pressX NOTIFY pressXChanged FINAL REVISION 4)
Q_PROPERTY(qreal pressY READ pressY NOTIFY pressYChanged FINAL REVISION 4)
+ // 2.5 (Qt 5.12)
+ Q_PROPERTY(qreal implicitIndicatorWidth READ implicitIndicatorWidth NOTIFY implicitIndicatorWidthChanged FINAL REVISION 5)
+ Q_PROPERTY(qreal implicitIndicatorHeight READ implicitIndicatorHeight NOTIFY implicitIndicatorHeightChanged FINAL REVISION 5)
Q_CLASSINFO("DeferredPropertyNames", "background,contentItem,indicator")
public:
@@ -141,6 +144,10 @@ public:
qreal pressX() const;
qreal pressY() const;
+ // 2.5 (Qt 5.12)
+ qreal implicitIndicatorWidth() const;
+ qreal implicitIndicatorHeight() const;
+
public Q_SLOTS:
void toggle();
@@ -170,6 +177,9 @@ Q_SIGNALS:
Q_REVISION(4) void autoRepeatIntervalChanged();
Q_REVISION(4) void pressXChanged();
Q_REVISION(4) void pressYChanged();
+ // 2.5 (Qt 5.12)
+ Q_REVISION(5) void implicitIndicatorWidthChanged();
+ Q_REVISION(5) void implicitIndicatorHeightChanged();
protected:
QQuickAbstractButton(QQuickAbstractButtonPrivate &dd, QQuickItem *parent);
diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h
index bb74e143..d88e5d31 100644
--- a/src/quicktemplates2/qquickabstractbutton_p_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p_p.h
@@ -105,6 +105,9 @@ public:
void cancelIndicator();
void executeIndicator(bool complete = false);
+ void itemImplicitWidthChanged(QQuickItem *item) override;
+ void itemImplicitHeightChanged(QQuickItem *item) override;
+
QString text;
bool explicitText;
bool down;