aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp38
-rw-r--r--src/quicktemplates2/qquickabstractbutton_p.h13
-rw-r--r--src/quicktemplates2/qquickabstractbutton_p_p.h1
3 files changed, 51 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index 0a2c7e6d..c0d8101e 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -92,6 +92,9 @@ static const int AUTO_REPEAT_INTERVAL = 100;
the behavior is the same as the \l {Image::}{sourceSize} property of
\l Image.
+ The \l display property can be used to control how the icon and text are
+ displayed within the button.
+
\sa ButtonGroup, {Button Controls}
*/
@@ -157,7 +160,8 @@ QQuickAbstractButtonPrivate::QQuickAbstractButtonPrivate()
repeatButton(Qt::NoButton),
indicator(nullptr),
group(nullptr),
- icon(nullptr)
+ icon(nullptr),
+ display(QQuickAbstractButton::TextBesideIcon)
{
}
@@ -815,4 +819,36 @@ QAccessible::Role QQuickAbstractButton::accessibleRole() const
}
#endif
+/*!
+ \since QtQuick.Controls 2.3
+ \qmlproperty enumeration QtQuick.Controls::AbstractButton::display
+
+ This property determines how the \l icon and \l text are displayed within
+ the button.
+
+ \table
+ \header \li Display \li Result
+ \row \li \c AbstractButton.IconOnly \li \image qtquickcontrols2-button-icononly.png
+ \row \li \c AbstractButton.TextOnly \li \image qtquickcontrols2-button-textonly.png
+ \row \li \c AbstractButton.TextBesideIcon \li \image qtquickcontrols2-button-textbesideicon.png
+ \endtable
+
+ \sa {Control::}{spacing}, {Control::}{padding}
+*/
+QQuickAbstractButton::Display QQuickAbstractButton::display() const
+{
+ Q_D(const QQuickAbstractButton);
+ return d->display;
+}
+
+void QQuickAbstractButton::setDisplay(Display display)
+{
+ Q_D(QQuickAbstractButton);
+ if (display == d->display)
+ return;
+
+ d->display = display;
+ emit displayChanged();
+}
+
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickabstractbutton_p.h b/src/quicktemplates2/qquickabstractbutton_p.h
index 42af6650..e6041e28 100644
--- a/src/quicktemplates2/qquickabstractbutton_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p.h
@@ -67,6 +67,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAbstractButton : public QQuickContr
Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive NOTIFY autoExclusiveChanged FINAL)
Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL)
Q_PROPERTY(QQuickIcon *icon READ icon CONSTANT FINAL REVISION 3)
+ Q_PROPERTY(Display display READ display WRITE setDisplay NOTIFY displayChanged REVISION 3)
public:
explicit QQuickAbstractButton(QQuickItem *parent = nullptr);
@@ -99,6 +100,17 @@ public:
QQuickIcon *icon() const;
+ enum Display {
+ IconOnly,
+ TextOnly,
+ TextBesideIcon,
+ TextUnderIcon // unused, but reserved for future use
+ };
+ Q_ENUM(Display)
+
+ Display display() const;
+ void setDisplay(Display display);
+
public Q_SLOTS:
void toggle();
@@ -117,6 +129,7 @@ Q_SIGNALS:
void checkableChanged();
void autoExclusiveChanged();
void indicatorChanged();
+ Q_REVISION(3) void displayChanged();
protected:
QQuickAbstractButton(QQuickAbstractButtonPrivate &dd, QQuickItem *parent);
diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h
index 388e5517..4864356b 100644
--- a/src/quicktemplates2/qquickabstractbutton_p_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p_p.h
@@ -105,6 +105,7 @@ public:
QQuickItem *indicator;
QQuickButtonGroup *group;
QQuickIcon *icon;
+ QQuickAbstractButton::Display display;
};
QT_END_NAMESPACE