Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions qt6/src/qml/ArrowListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ FocusScope {
property int maxVisibleItems : DS.Style.arrowListView.maxVisibleItems
property int itemHeight: DS.Style.arrowListView.itemHeight
property alias view: itemsView
property bool hovered: hoverHandler.hovered

implicitWidth: Math.max(DS.Style.arrowListView.width, contentLayout.implicitWidth)
implicitHeight: contentLayout.implicitHeight

HoverHandler {
id: hoverHandler
target: itemsView
}

ColumnLayout {
id: contentLayout
anchors.fill: parent
Expand Down
4 changes: 3 additions & 1 deletion qt6/src/qml/ComboBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在外面不要访问contentItem里的arrowListView,因为contentItem可能被外面复写,

Copy link
Contributor

Choose a reason for hiding this comment

The 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
Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions qt6/src/qml/Menu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

能不修改currentIndex么,因为currentIndex是对外暴露的,外面可能监听了这个属性,如果我们改变了currentIndex,会导致调用方的业务逻辑发生变化,

}
}
}
}

ColumnLayout {
id: viewLayout
spacing: 0
Expand Down