diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2017-03-01 13:06:44 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2017-03-28 06:17:35 +0000 |
commit | b44048ae27bd916d0eaa1e7d6a5456488ff76f29 (patch) | |
tree | bb00c7612f6baee2dbe0697205a52fd2792e9ee8 /src/quicktemplates2/qquickabstractbutton.cpp | |
parent | a7d9818dd414565cdcc4f4c9415f67735d146c68 (diff) |
AbstractButton: add display property
This property allows control over how icons and text are displayed
within buttons, without having to implement custom delegates. It is
also necessary for the upcoming Action type.
[ChangeLog][Controls][AbstractButton] Added display property to
allow control over how icons and text are displayed within buttons,
without having to implement custom delegates.
Task-number: QTBUG-49820
Change-Id: Ie924e2c54ed49961fd40129999875c8175606ecd
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickabstractbutton.cpp')
-rw-r--r-- | src/quicktemplates2/qquickabstractbutton.cpp | 38 |
1 files changed, 37 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 |