aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-10-24 23:27:44 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-10-25 08:45:21 +0000
commit2de38813d72ff243459897aea2b2596287e4e1d3 (patch)
treedd4deccf587019e9986677a549cfacc20d543cc0 /src
parentbd4f5a04969b2e69a56c9f735e9376e89ef83690 (diff)
QQuickButton: promote autoRepeat back to QQuickAbstractButton
The original reason why autoRepeat was demoted to QQuickButton was that some subclasses, such as QQuickCheckBox, did not need this property. The same was done with the checkable property. It was first demoted, and then promoted back to QQuickAbstractButton. These can be useful for building custom AbstractButton-based controls. Now that we want to make auto-repeat configurable (autoRepeatInterval and autoRepeatDelay), and the logic has to be in the base class anyway, it makes more sense to expose all these in the base class instead of doing the property hiding tricks for all three properties. [ChangeLog][Controls][AbstractButton] The autoRepeat property was promoted from Button to AbstractButton. Change-Id: Ife105da00d7d87a74fc8160ec35762b6f71d3ad9 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp10
-rw-r--r--src/quicktemplates2/qquickabstractbutton_p.h3
-rw-r--r--src/quicktemplates2/qquickbutton.cpp18
-rw-r--r--src/quicktemplates2/qquickbutton_p.h4
4 files changed, 11 insertions, 24 deletions
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index 2100dce2..44d1da25 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -630,6 +630,14 @@ void QQuickAbstractButton::setAutoExclusive(bool exclusive)
emit autoExclusiveChanged();
}
+/*!
+ \qmlproperty bool QtQuick.Controls::AbstractButton::autoRepeat
+
+ This property holds whether the button repeats \l pressed(), \l released()
+ and \l clicked() signals while the button is pressed and held down.
+
+ The default value is \c false.
+*/
bool QQuickAbstractButton::autoRepeat() const
{
Q_D(const QQuickAbstractButton);
@@ -644,7 +652,7 @@ void QQuickAbstractButton::setAutoRepeat(bool repeat)
d->stopPressRepeat();
d->autoRepeat = repeat;
- buttonChange(ButtonAutoRepeatChange);
+ emit autoRepeatChanged();
}
/*!
diff --git a/src/quicktemplates2/qquickabstractbutton_p.h b/src/quicktemplates2/qquickabstractbutton_p.h
index 81384298..4d192ae7 100644
--- a/src/quicktemplates2/qquickabstractbutton_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p.h
@@ -65,6 +65,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAbstractButton : public QQuickContr
Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL)
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL)
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(QQuickIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL REVISION 3)
Q_PROPERTY(Display display READ display WRITE setDisplay NOTIFY displayChanged FINAL REVISION 3)
@@ -138,6 +139,7 @@ Q_SIGNALS:
void checkedChanged();
void checkableChanged();
void autoExclusiveChanged();
+ void autoRepeatChanged();
void indicatorChanged();
Q_REVISION(3) void iconChanged();
Q_REVISION(3) void displayChanged();
@@ -157,7 +159,6 @@ protected:
void itemChange(ItemChange change, const ItemChangeData &value) override;
enum ButtonChange {
- ButtonAutoRepeatChange,
ButtonCheckedChange,
ButtonCheckableChange,
ButtonPressedChanged,
diff --git a/src/quicktemplates2/qquickbutton.cpp b/src/quicktemplates2/qquickbutton.cpp
index b5a8ac1c..adbc48fd 100644
--- a/src/quicktemplates2/qquickbutton.cpp
+++ b/src/quicktemplates2/qquickbutton.cpp
@@ -99,24 +99,6 @@ QQuickButton::QQuickButton(QQuickButtonPrivate &dd, QQuickItem *parent)
{
}
-/*!
- \qmlproperty bool QtQuick.Controls::Button::autoRepeat
-
- This property holds whether the button repeats
- \l {AbstractButton::}{pressed()}, \l {AbstractButton::}{released()}
- and \l {AbstractButton::}{clicked()} signals while the button is pressed
- and held down.
-
- The default value is \c false.
-*/
-
-void QQuickButton::buttonChange(ButtonChange change)
-{
- QQuickAbstractButton::buttonChange(change);
- if (change == ButtonAutoRepeatChange)
- emit autoRepeatChanged();
-}
-
QFont QQuickButton::defaultFont() const
{
return QQuickControlPrivate::themeFont(QPlatformTheme::PushButtonFont);
diff --git a/src/quicktemplates2/qquickbutton_p.h b/src/quicktemplates2/qquickbutton_p.h
index f1a34b10..a77db16e 100644
--- a/src/quicktemplates2/qquickbutton_p.h
+++ b/src/quicktemplates2/qquickbutton_p.h
@@ -57,7 +57,6 @@ class QQuickButtonPrivate;
class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickButton : public QQuickAbstractButton
{
Q_OBJECT
- Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL)
Q_PROPERTY(bool highlighted READ isHighlighted WRITE setHighlighted NOTIFY highlightedChanged FINAL)
Q_PROPERTY(bool flat READ isFlat WRITE setFlat NOTIFY flatChanged FINAL)
@@ -71,15 +70,12 @@ public:
void setFlat(bool flat);
Q_SIGNALS:
- void autoRepeatChanged();
void highlightedChanged();
void flatChanged();
protected:
QQuickButton(QQuickButtonPrivate &dd, QQuickItem *parent);
- void buttonChange(ButtonChange change) override;
-
QFont defaultFont() const override;
QPalette defaultPalette() const override;