diff options
author | Gabriel de Dietrich <gabriel.dedietrich@digia.com> | 2013-06-03 14:05:26 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-03 22:25:54 +0200 |
commit | eeb3c959334d1e6b4ea9f7538b603a711f8a8262 (patch) | |
tree | a8e8336d2cc1de41e64ddfdfa4092b5afe329000 /src/controls | |
parent | 4e5bf941f1b3089c22392bb5416d44cb8defe47d (diff) | |
download | qtquickcontrols-eeb3c959334d1e6b4ea9f7538b603a711f8a8262.tar.gz |
Buttons: Allow overriding of visual properties when 'action' is set
Those properties are, text, tooltip, iconName, and iconSource.
Also, properly capitalized gallery's tooltips.
Change-Id: I1995a85565edd7aaa420279821d7c1a31ef18253
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/controls')
-rw-r--r-- | src/controls/Button.qml | 22 | ||||
-rw-r--r-- | src/controls/ToolButton.qml | 12 | ||||
-rw-r--r-- | src/controls/qquickaction_p.h | 9 | ||||
-rw-r--r-- | src/controls/qquickmenuitem.cpp | 2 |
4 files changed, 15 insertions, 30 deletions
diff --git a/src/controls/Button.qml b/src/controls/Button.qml index 21231e57..1f00dccb 100644 --- a/src/controls/Button.qml +++ b/src/controls/Button.qml @@ -72,20 +72,6 @@ BasicButton { */ property bool isDefault: false - /*! This property holds the text shown on the button. If the button has no - text, the \l text property will be an empty string. - - The default value is the empty string. - */ - property string text - - /*! This property holds the icon shown on the button. If the button has no - icon, the iconSource property will be an empty string. - - The default value is the empty string. - */ - property url iconSource - /*! Assign a \l Menu to this property to get a pull-down menu button. The default value is \c null. @@ -115,6 +101,14 @@ BasicButton { value: button } + Binding { + target: button + property: "tooltip" + // We don't want a tooltip if it's the same as the button text + when: !!text && !(action && (!!action.tooltip || action.tooltip === text)) + value: "" + } + Connections { target: __behavior onEffectivePressedChanged: { diff --git a/src/controls/ToolButton.qml b/src/controls/ToolButton.qml index 6cd3661b..3c1eab1a 100644 --- a/src/controls/ToolButton.qml +++ b/src/controls/ToolButton.qml @@ -62,18 +62,6 @@ import QtQuick.Controls.Private 1.0 BasicButton { id: button - /*! The image label source as file name or resource. */ - property url iconSource - - /*! The image label source as theme name. - When an icon from the platform icon theme is found, this takes - precedence over iconSource. - */ - property url iconName - - /*! The label text. */ - property string text - activeFocusOnTab: true Accessible.name: text diff --git a/src/controls/qquickaction_p.h b/src/controls/qquickaction_p.h index e106a920..aa63b408 100644 --- a/src/controls/qquickaction_p.h +++ b/src/controls/qquickaction_p.h @@ -57,11 +57,11 @@ class QQuickAction : public QObject { Q_OBJECT - Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) - Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged) + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged RESET resetText) + Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged RESET resetIconSource) Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged) Q_PROPERTY(QVariant __icon READ iconVariant NOTIFY iconChanged) - Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged) + Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged RESET resetTooltip) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged) Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled) @@ -76,6 +76,7 @@ public: ~QQuickAction(); QString text() const { return m_text; } + void resetText() { setText(QString()); } void setText(const QString &text); QString shortcut() const; @@ -87,9 +88,11 @@ public: void setIconName(const QString &iconName); QUrl iconSource() const { return m_iconSource; } + void resetIconSource() { setIconSource(QString()); } void setIconSource(const QUrl &iconSource); QString tooltip() const { return m_tooltip; } + void resetTooltip() { setTooltip(QString()); } void setTooltip(const QString &tooltip); bool isEnabled() const { return m_enabled; } diff --git a/src/controls/qquickmenuitem.cpp b/src/controls/qquickmenuitem.cpp index 622fdd2d..ed03b336 100644 --- a/src/controls/qquickmenuitem.cpp +++ b/src/controls/qquickmenuitem.cpp @@ -503,7 +503,7 @@ void QQuickMenuItem::setBoundAction(QQuickAction *a) QString QQuickMenuItem::text() const { QString ownText = QQuickMenuText::text(); - if (!ownText.isEmpty()) + if (!ownText.isNull()) return ownText; return m_boundAction ? m_boundAction->text() : QString(); } |