Skip to content

Commit ec28fbd

Browse files
committed
feat: improve app list focus behavior and styling
1. Move Keys.onReturnPressed and Keys.onSpacePressed outside of the button delegate to fix scope issues 2. Replace complex BoxPanel background with FocusBoxBorder for menu items, simplifying styling and improving focus visibility 3. Add forceActiveFocus() call when list gains active focus to ensure proper focus management 4. Change category type change behavior from positionViewAtBeginning to setting currentIndex to 0 for better navigation 5. Simplify ItemBackground focus condition by removing focusPolicy check feat: 改进应用列表焦点行为和样式 1. 将 Keys.onReturnPressed 和 Keys.onSpacePressed 移出按钮委托以修复作用 域问题 2. 使用 FocusBoxBorder 替换复杂的 BoxPanel 背景,简化样式并改进焦点可 见性 3. 在列表获得活动焦点时添加 forceActiveFocus() 调用以确保正确的焦点管理 4. 将类别类型更改行为从 positionViewAtBeginning 改为设置 currentIndex 为 0,改善导航体验 5. 通过移除 focusPolicy 检查简化 ItemBackground 焦点条件 PMS: BUG-334167
1 parent 4c52e66 commit ec28fbd

2 files changed

Lines changed: 14 additions & 37 deletions

File tree

qml/windowed/AppListView.qml

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,13 @@ FocusScope {
241241
implicitHeight: Helper.windowed.listItemHeight
242242
button: itemDelegate
243243
}
244+
}
245+
Keys.onReturnPressed: {
246+
launchApp(desktopId)
247+
}
244248

245-
Keys.onReturnPressed: {
246-
launchApp(desktopId)
247-
}
248-
249-
Keys.onSpacePressed: {
250-
launchApp(desktopId)
251-
}
249+
Keys.onSpacePressed: {
250+
launchApp(desktopId)
252251
}
253252
}
254253
}
@@ -274,34 +273,11 @@ FocusScope {
274273
text: menuItem.text
275274
color: parent.palette.windowText
276275
}
277-
background: BoxPanel {
278-
anchors.left: parent.left
279-
anchors.leftMargin: 2
280-
anchors.right: parent.right
281-
anchors.rightMargin: 2
282-
anchors.top: parent.top
283-
anchors.bottom: parent.bottom
284-
visible: menuItem.down || menuItem.hovered
285-
outsideBorderColor: null
286-
insideBorderColor: null
287-
radius: 6
288-
289-
property Palette background: Palette {
290-
normal {
291-
common: Qt.rgba(0, 0, 0, 0.1)
292-
crystal: Qt.rgba(0, 0, 0, 0.1)
293-
}
294-
normalDark {
295-
common: Qt.rgba(1, 1, 1, 0.1)
296-
crystal: Qt.rgba(1, 1, 1, 0.1)
297-
}
298-
hovered {
299-
common: Qt.rgba(16.0 / 255, 16.0 / 255, 16.0 / 255, 0.1)
300-
crystal: Qt.rgba(16.0 / 255, 16.0 / 255, 16.0 / 255, 0.1)
301-
}
302-
}
303-
color1: background
304-
color2: background
276+
background: FocusBoxBorder {
277+
anchors.fill: parent
278+
anchors.margins: 4
279+
visible: menuItem.down || menuItem.hovered || menuItem.visualFocus
280+
color: menuItem.palette.highlight
305281
}
306282
}
307283
}
@@ -332,13 +308,14 @@ FocusScope {
332308
if (activeFocus) {
333309
// When focus in, we always scroll to the highlight
334310
scrollToIndex(listView.currentIndex, 0)
311+
currentItem.forceActiveFocus()
335312
}
336313
}
337314

338315
Connections {
339316
target: CategorizedSortProxyModel
340317
function onCategoryTypeChanged() {
341-
listView.positionViewAtBeginning()
318+
listView.currentIndex = 0
342319
}
343320
}
344321

qml/windowed/ItemBackground.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ D.BoxPanel {
3939

4040
Loader {
4141
anchors.fill: parent
42-
active: button.visualFocus && control.focusPolicy !== Qt.NoFocus
42+
active: button.visualFocus
4343

4444
sourceComponent: D.FocusBoxBorder {
4545
radius: control.radius

0 commit comments

Comments
 (0)