diff options
-rw-r--r-- | .qmake.conf | 2 | ||||
-rw-r--r-- | src/controls/ComboBox.qml | 8 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 55 |
3 files changed, 62 insertions, 3 deletions
diff --git a/.qmake.conf b/.qmake.conf index c053efd7..6ef30f78 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -2,4 +2,4 @@ load(qt_build_config) CONFIG += warning_clean android|ios|qnx|winrt|isEmpty(QT.widgets.name): CONFIG += no_desktop -MODULE_VERSION = 5.11.0 +MODULE_VERSION = 5.12.0 diff --git a/src/controls/ComboBox.qml b/src/controls/ComboBox.qml index bd42f76b..7c6f93a7 100644 --- a/src/controls/ComboBox.qml +++ b/src/controls/ComboBox.qml @@ -570,11 +570,16 @@ Control { onSelectedTextChanged: popup.currentText = selectedText property string selectedText + property int triggeredIndex: -1 on__SelectedIndexChanged: { if (__selectedIndex === -1) popup.currentText = "" else updateSelectedText() + if (triggeredIndex >= 0 && triggeredIndex == __selectedIndex) { + activated(currentIndex) + triggeredIndex = -1 + } } property string textRole: "" @@ -611,8 +616,7 @@ Control { modelData : ((popup.modelIsArray ? modelData[popup.textRole] : model[popup.textRole]) || '') onTriggered: { - if (index !== currentIndex) - activated(index) + popup.triggeredIndex = index comboBox.editText = text } onTextChanged: if (index === currentIndex) popup.updateSelectedText(); diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 415d3ad3..bccac8d2 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -418,6 +418,61 @@ TestCase { comboBox.destroy() } + function test_activated_index_QTBUG_43050(){ + if (Qt.platform.os === "osx") + skip("When the menu pops up on OS X, it does not return and the test fails after time out") + if (Qt.platform.os === "windows") + skip("Test randomly fails under Windows") + + var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.2; \ + ComboBox { \ + property bool indexWasUpdated: false; \ + model: 4; \ + onActivated: indexWasUpdated = (index === currentIndex); \ + }', container, ''); + var menuIndex = getMenuIndex(comboBox) + verify(menuIndex !== -1) + comboBox.forceActiveFocus() + verify(!comboBox.data[menuIndex].__popupVisible) + keyPress(Qt.Key_Space) + verify(comboBox.data[menuIndex].__popupVisible) + + waitForRendering(comboBox) + keyPress(Qt.Key_Down) + keyPress(Qt.Key_Down) + verify(!comboBox.indexWasUpdated) + keyPress(Qt.Key_Enter) + verify(comboBox.indexWasUpdated) + + comboBox.destroy() + } + + function test_update_index_on_activated_QTBUG_51113(){ + if (Qt.platform.os === "osx") + skip("When the menu pops up on OS X, it does not return and the test fails after time out") + if (Qt.platform.os === "windows") + skip("Test randomly fails under Windows") + + var comboBox = Qt.createQmlObject('import QtQuick.Controls 1.2; \ + ComboBox { \ + model: 4; \ + onActivated: if (index == 1) currentIndex = 3; \ + }', container, ''); + var menuIndex = getMenuIndex(comboBox) + verify(menuIndex !== -1) + comboBox.forceActiveFocus() + verify(!comboBox.data[menuIndex].__popupVisible) + keyPress(Qt.Key_Space) + verify(comboBox.data[menuIndex].__popupVisible) + + waitForRendering(comboBox) + keyPress(Qt.Key_Down) + keyPress(Qt.Key_Enter) + compare(comboBox.currentIndex, 3) + + comboBox.destroy() + } + function test_activeFocusOnTab() { if (Qt.styleHints.tabFocusBehavior != Qt.TabFocusAllControls) skip("This function doesn't support NOT iterating all.") |