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,18 @@ 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: false
1718
1819 implicitWidth: Math .max (DS .Style .arrowListView .width , contentLayout .implicitWidth )
1920 implicitHeight: contentLayout .implicitHeight
2021
22+ HoverHandler {
23+ target: itemsView
24+ onHoveredChanged: {
25+ control .hovered = hovered
26+ }
27+ }
28+
2129 ColumnLayout {
2230 id: contentLayout
2331 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+ highlightEnabled : arrowListView . hovered || ( control .highlightedIndex === index && 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 @@ -47,6 +47,28 @@ T.Menu {
4747 // QTBUG-99897 focus doesn't be clear.
4848 implicitWidth: viewLayout .implicitWidth
4949 implicitHeight: viewLayout .implicitHeight
50+
51+ HoverHandler {
52+ id: menuHoverHandler
53+ target: viewLayout
54+ onHoveredChanged: {
55+ if (! hovered) {
56+ var currentItem = control .itemAt (control .currentIndex )
57+ var hasOpenSubMenu = false
58+
59+ if (currentItem) {
60+ if (currentItem .subMenu && currentItem .subMenu .visible ) {
61+ hasOpenSubMenu = true
62+ }
63+ }
64+
65+ if (! hasOpenSubMenu) {
66+ control .currentIndex = - 1
67+ }
68+ }
69+ }
70+ }
71+
5072 ColumnLayout {
5173 id: viewLayout
5274 spacing: 0
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import org.deepin.dtk.style 1.0 as DS
1010T .MenuItem {
1111 id: control
1212
13+ property bool highlightEnabled: true
1314 property bool useIndicatorPadding: menu && menu .existsChecked || false
1415 implicitWidth: DS .Style .control .implicitWidth (control)
1516 implicitHeight: DS .Style .control .implicitHeight (control)
@@ -22,7 +23,7 @@ T.MenuItem {
2223 width: DS .Style .menu .item .iconSize .height
2324 }
2425
25- property D .Palette textColor: control .highlighted ? DS .Style .checkedButton .text
26+ property D .Palette textColor: ( control .highlighted && control . highlightEnabled ) ? DS .Style .checkedButton .text
2627 : DS .Style .menu .itemText
2728 property D .Palette subMenuBackgroundColor: DS .Style .menu .subMenuOpenedBackground
2829
@@ -100,7 +101,7 @@ T.MenuItem {
100101 implicitHeight: DS .Style .menu .item .height
101102 Loader {
102103 anchors .fill : parent
103- active: control .highlighted
104+ active: control .highlighted && control . highlightEnabled
104105 sourceComponent: HighlightPanel {
105106 outerShadowColor: null
106107 innerShadowColor: null
You can’t perform that action at this time.
0 commit comments