summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@theqtcompany.com>2015-09-07 13:28:15 +0200
committerMitch Curtis <mitch.curtis@theqtcompany.com>2015-09-07 11:59:43 +0000
commit1c6a510c16b35c937af202f517604620b4a97ff0 (patch)
treea745089765089e20cc472a677387bfb610563eaf
parentf770dbe9d38214a37e12adb591498dcd1ad0293e (diff)
downloadqtquickcontrols-1c6a510c16b35c937af202f517604620b4a97ff0.tar.gz
Button: only enable mnemonic if button itself is enabled.
Otherwise users can trigger shortcuts even when buttons are disabled. Change-Id: If97c6a3c3df574a4271c53cf7bcfd8fdb1a059d6 Task-number: QTBUG-48144 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r--src/controls/Private/BasicButton.qml1
-rw-r--r--tests/auto/controls/data/tst_button.qml22
2 files changed, 23 insertions, 0 deletions
diff --git a/src/controls/Private/BasicButton.qml b/src/controls/Private/BasicButton.qml
index 5de95aa9..1756a296 100644
--- a/src/controls/Private/BasicButton.qml
+++ b/src/controls/Private/BasicButton.qml
@@ -146,6 +146,7 @@ Control {
Action {
id: ownAction
+ enabled: button.enabled
iconSource: !button.action || __iconOverriden ? button.iconSource : ""
iconName: !button.action || __iconOverriden ? button.iconName : ""
diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml
index 136f82cc..0d226ffc 100644
--- a/tests/auto/controls/data/tst_button.qml
+++ b/tests/auto/controls/data/tst_button.qml
@@ -40,6 +40,7 @@
import QtQuick 2.2
import QtTest 1.0
+import QtQuick.Controls 1.4
import QtQuickControlsTests 1.0
Item {
@@ -278,5 +279,26 @@ TestCase {
button.destroy()
}
+
+ Component {
+ id: mnemonicButtonComponent
+
+ Button {
+ text: "&Hi"
+ enabled: false
+ }
+ }
+
+ function test_mnemonic() {
+ var button = mnemonicButtonComponent.createObject(container);
+ verify(button);
+
+ clickSpy.clear();
+ clickSpy.target = button;
+ keyClick(Qt.Key_H, Qt.AltModifier);
+ compare(clickSpy.count, 0);
+
+ button.destroy();
+ }
}
}