44
55import QtQuick
66import QtQuick.Layouts
7+ import QtQuick.Controls
78import QtQuick.Templates as T
89import org.deepin.dtk 1.0 as D
910import org.deepin.dtk.style 1.0 as DS
@@ -20,6 +21,7 @@ T.ComboBox {
2021 property D .Palette separatorColor: DS .Style .comboBox .edit .separator
2122 property var horizontalAlignment: control .flat ? Text .AlignRight : Text .AlignLeft
2223 opacity: enabled ? 1.0 : 0.4
24+ property bool forceNoHighlight: false
2325
2426 implicitWidth: DS .Style .control .implicitWidth (control)
2527 implicitHeight: DS .Style .control .implicitHeight (control)
@@ -34,7 +36,7 @@ T.ComboBox {
3436 useIndicatorPadding: true
3537 text: control .textRole ? (Array .isArray (control .model ) ? modelData[control .textRole ] : (model[control .textRole ] === undefined ? modelData[control .textRole ] : model[control .textRole ])) : modelData
3638 icon .name : (control .iconNameRole && model[control .iconNameRole ] !== undefined ) ? model[control .iconNameRole ] : null
37- highlighted: control .highlightedIndex === index
39+ highlighted: ! control .forceNoHighlight && control . highlightedIndex === index
3840 hoverEnabled: control .hoverEnabled
3941 autoExclusive: true
4042 checked: control .currentIndex === index
@@ -165,13 +167,31 @@ T.ComboBox {
165167 rightMargin: DS .Style .popup .margin
166168 palette: control .palette
167169 implicitWidth: control .flat ? Math .max (contentItem .implicitWidth , control .width ) : control .width
168- contentItem: ArrowListView {
169- clip: true
170- maxVisibleItems: control .maxVisibleItems
171- view .model : control .delegateModel
172- view .currentIndex : control .highlightedIndex
173- view .highlightRangeMode : ListView .ApplyRange
174- view .highlightMoveDuration : 0
170+ contentItem: Item {
171+ implicitWidth: arrowListView .implicitWidth
172+ implicitHeight: arrowListView .implicitHeight
173+
174+ HoverHandler {
175+ id: comboBoxHoverHandler
176+ target: arrowListView
177+ onHoveredChanged: {
178+ if (! hovered) {
179+ control .forceNoHighlight = true
180+ } else {
181+ control .forceNoHighlight = false
182+ }
183+ }
184+ }
185+
186+ ArrowListView {
187+ id: arrowListView
188+ anchors .fill : parent
189+ clip: true
190+ maxVisibleItems: control .maxVisibleItems
191+ view .model : control .delegateModel
192+ view .highlightRangeMode : ListView .ApplyRange
193+ view .highlightMoveDuration : 0
194+ }
175195 }
176196
177197 background: FloatingPanel {
0 commit comments