-
Notifications
You must be signed in to change notification settings - Fork 44
fix: Fix the issue where removing an item from the dropdown list does not cancel the highlight #563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
|
|
||
| import QtQuick | ||
| import QtQuick.Layouts | ||
| import QtQuick.Controls | ||
| import QtQuick.Templates as T | ||
| import org.deepin.dtk 1.0 as D | ||
| import org.deepin.dtk.style 1.0 as DS | ||
|
|
@@ -34,7 +35,7 @@ T.ComboBox { | |
| useIndicatorPadding: true | ||
| text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : (model[control.textRole] === undefined ? modelData[control.textRole] : model[control.textRole])) : modelData | ||
| icon.name: (control.iconNameRole && model[control.iconNameRole] !== undefined) ? model[control.iconNameRole] : null | ||
| highlighted: control.highlightedIndex === index | ||
| highlighted: (control.highlightedIndex === index) && (arrowListView.hovered || (subMenu && subMenu.visible)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 能不能只去判断MenuItem的hover呀,而不是通过外面的那个Popup有没有hover去判断,因为现在Popup可能存在margin,这样的话,在hover时,MenuItem也应该失去highlight的,不显示background, |
||
| hoverEnabled: control.hoverEnabled | ||
| autoExclusive: true | ||
| checked: control.currentIndex === index | ||
|
|
@@ -166,6 +167,7 @@ T.ComboBox { | |
| palette: control.palette | ||
| implicitWidth: control.flat ? Math.max(contentItem.implicitWidth, control.width) : control.width | ||
| contentItem: ArrowListView { | ||
| id: arrowListView | ||
| clip: true | ||
| maxVisibleItems: control.maxVisibleItems | ||
| view.model: control.delegateModel | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import QtQuick | |
| import QtQuick.Window | ||
| import QtQuick.Layouts | ||
| import QtQuick.Templates as T | ||
| import QtQuick.Controls | ||
| import org.deepin.dtk 1.0 as D | ||
| import org.deepin.dtk.style 1.0 as DS | ||
|
|
||
|
|
@@ -47,6 +48,28 @@ T.Menu { | |
| // QTBUG-99897 focus doesn't be clear. | ||
| implicitWidth: viewLayout.implicitWidth | ||
| implicitHeight: viewLayout.implicitHeight | ||
|
|
||
| HoverHandler { | ||
| id: menuHoverHandler | ||
| target: viewLayout | ||
| onHoveredChanged: { | ||
| if (!hovered) { | ||
| var currentItem = control.itemAt(control.currentIndex) | ||
| var hasOpenSubMenu = false | ||
|
|
||
| if (currentItem) { | ||
| if (currentItem.subMenu && currentItem.subMenu.visible) { | ||
| hasOpenSubMenu = true | ||
| } | ||
| } | ||
|
|
||
| if (!hasOpenSubMenu) { | ||
| control.currentIndex = -1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 能不修改currentIndex么,因为currentIndex是对外暴露的,外面可能监听了这个属性,如果我们改变了currentIndex,会导致调用方的业务逻辑发生变化, |
||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ColumnLayout { | ||
| id: viewLayout | ||
| spacing: 0 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在外面不要访问contentItem里的arrowListView,因为contentItem可能被外面复写,