File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,10 +14,16 @@ FocusScope {
1414 property int maxVisibleItems : DS .Style .arrowListView .maxVisibleItems
1515 property int itemHeight: DS .Style .arrowListView .itemHeight
1616 property alias view: itemsView
17+ property bool hovered: hoverHandler .hovered
1718
1819 implicitWidth: Math .max (DS .Style .arrowListView .width , contentLayout .implicitWidth )
1920 implicitHeight: contentLayout .implicitHeight
2021
22+ HoverHandler {
23+ id: hoverHandler
24+ target: itemsView
25+ }
26+
2127 ColumnLayout {
2228 id: contentLayout
2329 anchors .fill : parent
Original file line number Diff line number Diff line change 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
@@ -34,7 +35,7 @@ T.ComboBox {
3435 useIndicatorPadding: true
3536 text: control .textRole ? (Array .isArray (control .model ) ? modelData[control .textRole ] : (model[control .textRole ] === undefined ? modelData[control .textRole ] : model[control .textRole ])) : modelData
3637 icon .name : (control .iconNameRole && model[control .iconNameRole ] !== undefined ) ? model[control .iconNameRole ] : null
37- highlighted: control .highlightedIndex === index
38+ highlighted: ( control .highlightedIndex === index) && ( arrowListView . hovered || (subMenu && subMenu . visible ))
3839 hoverEnabled: control .hoverEnabled
3940 autoExclusive: true
4041 checked: control .currentIndex === index
@@ -166,6 +167,7 @@ T.ComboBox {
166167 palette: control .palette
167168 implicitWidth: control .flat ? Math .max (contentItem .implicitWidth , control .width ) : control .width
168169 contentItem: ArrowListView {
170+ id: arrowListView
169171 clip: true
170172 maxVisibleItems: control .maxVisibleItems
171173 view .model : control .delegateModel
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import QtQuick
66import QtQuick.Window
77import QtQuick.Layouts
88import QtQuick.Templates as T
9+ import QtQuick.Controls
910import org.deepin.dtk 1.0 as D
1011import org.deepin.dtk.style 1.0 as DS
1112
@@ -47,6 +48,28 @@ T.Menu {
4748 // QTBUG-99897 focus doesn't be clear.
4849 implicitWidth: viewLayout .implicitWidth
4950 implicitHeight: viewLayout .implicitHeight
51+
52+ HoverHandler {
53+ id: menuHoverHandler
54+ target: viewLayout
55+ onHoveredChanged: {
56+ if (! hovered) {
57+ var currentItem = control .itemAt (control .currentIndex )
58+ var hasOpenSubMenu = false
59+
60+ if (currentItem) {
61+ if (currentItem .subMenu && currentItem .subMenu .visible ) {
62+ hasOpenSubMenu = true
63+ }
64+ }
65+
66+ if (! hasOpenSubMenu) {
67+ control .currentIndex = - 1
68+ }
69+ }
70+ }
71+ }
72+
5073 ColumnLayout {
5174 id: viewLayout
5275 spacing: 0
You can’t perform that action at this time.
0 commit comments