Skip to content

Commit

Permalink
fix: modify launchpad tab focus chain order
Browse files Browse the repository at this point in the history
Modify focus chain order according to design

Log: modify launchpad tab focus chain order
Influence: tab focus chain order
  • Loading branch information
yixinshark committed Apr 12, 2024
1 parent 10da343 commit a9b0609
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 2 deletions.
5 changes: 5 additions & 0 deletions qml/windowed/AnalysisView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import "."
Control {
id: control

property Item keyTabTarget: frequentlyUsedView.keyTabTarget
property Item nextKeyTabTarget

onFocusChanged: () => {
frequentlyUsedView.focus = true
}
Expand All @@ -36,12 +39,14 @@ Control {
id: frequentlyUsedView
visible: count > 0
maxCount: recentlyInstalledView.visible ? 12 : 16
nextKeyTabTarget : recentlyInstalledView.visible ? recentlyInstalledView.keyTabTarget : control.nextKeyTabTarget
}

RecentlyInstalledView {
id: recentlyInstalledView
visible: count > 0
Layout.topMargin: -(Helper.frequentlyUsed.cellPaddingRows / 2)
nextKeyTabTarget: control.nextKeyTabTarget
}

Item {
Expand Down
9 changes: 9 additions & 0 deletions qml/windowed/AppList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ ColumnLayout {

signal freeSortViewFolderClicked(string folderId, string folderName)

property Item keyTabTarget: loader.item
property Item nextKeyTabTarget

onFocusChanged: () => {
loader.item.focus = true
}

function positionViewAtBeginning() {
loader.item.positionViewAtBeginning()
}
Expand All @@ -43,6 +50,7 @@ ColumnLayout {
id: appCategoryListView

MouseAreaCom {}
KeyNavigation.tab: nextKeyTabTarget
}
}

Expand All @@ -56,6 +64,7 @@ ColumnLayout {
}

MouseAreaCom {}
KeyNavigation.tab: nextKeyTabTarget
}
}

Expand Down
4 changes: 4 additions & 0 deletions qml/windowed/BottomBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ import "."
Control {
id: control

property Item keyTabTarget: shutdownBtn
property Item nextKeyTabTarget
property alias searchEdit: searchEdit

contentItem: RowLayout {
width: parent.width

ToolButton {
id: shutdownBtn
icon.name: "shutdown"
ToolTip.visible: hovered
ToolTip.delay: 1000
Expand Down Expand Up @@ -76,6 +79,7 @@ Control {
onClicked: {
LauncherController.currentFrame = "FullscreenFrame"
}
KeyNavigation.tab: nextKeyTabTarget
}
}

Expand Down
8 changes: 6 additions & 2 deletions qml/windowed/FreeSortListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ Item {

signal folderClicked(string folderId, string folderName)

property Item keyTabTarget: listView

onFocusChanged: () => {
listView.focus = true
}

function positionViewAtBeginning() {
listView.positionViewAtBeginning()
}

ListView {
id: listView
anchors.fill: parent
activeFocusOnTab: true
highlightFollowsCurrentItem: true

clip: true
focus: true
highlight: Item {
SystemPalette { id: highlightPalette }
FocusBoxBorder {
Expand Down
4 changes: 4 additions & 0 deletions qml/windowed/FrequentlyUsedView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Control {
frequentlyUsedViewContainer.focus = true
}

property Item nextKeyTabTarget
property Item keyTabTarget: frequentlyUsedViewContainer

property int count: frequentlyUsedViewContainer.count
property int maxCount: 16

Expand All @@ -36,6 +39,7 @@ Control {
GridViewContainer {
id: frequentlyUsedViewContainer

KeyNavigation.tab: control.nextKeyTabTarget
Layout.alignment: Qt.AlignRight
Layout.topMargin: 10
Layout.preferredHeight: frequentlyUsedViewContainer.height
Expand Down
10 changes: 10 additions & 0 deletions qml/windowed/GridViewContainer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ FocusScope {
visible: gridView.activeFocus
}
}

Keys.onPressed: function (event) {
if (event.key === Qt.Key_Right && currentIndex === gridView.count - 1) {
gridView.currentIndex = 0;
event.accepted = true;
} else if (event.key === Qt.Key_Left && currentIndex === 0) {
currentIndex = gridView.count - 1;
event.accepted = true;
}
}
}
}
}
8 changes: 8 additions & 0 deletions qml/windowed/RecentlyInstalledView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ import "."
Control {
id: control

property Item nextKeyTabTarget
property Item keyTabTarget: recentlyInstalledViewContainer

readonly property int count: recentlyInstalledViewContainer.count
readonly property var model: recentlyInstalledViewContainer.model

onFocusChanged: () => {
recentlyInstalledViewContainer.focus = true
}

function positionViewAtBeginning() {
recentlyInstalledViewContainer.positionViewAtBeginning()
}
Expand All @@ -31,6 +38,7 @@ Control {
GridViewContainer {
id: recentlyInstalledViewContainer

KeyNavigation.tab: nextKeyTabTarget
Layout.alignment: Qt.AlignRight
Layout.preferredHeight: recentlyInstalledViewContainer.height
Layout.preferredWidth: recentlyInstalledViewContainer.width
Expand Down
3 changes: 3 additions & 0 deletions qml/windowed/SideBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ ColumnLayout {
spacing: 10

property var isFreeSort: true
property Item keyTabTarget: title
property Item nextKeyTabTarget

signal switchToFreeSort(bool freeSort)

Expand Down Expand Up @@ -81,6 +83,7 @@ ColumnLayout {
Layout.alignment: Qt.AlignCenter
KeyNavigation.down: computer
KeyNavigation.up: setting
KeyNavigation.tab: nextKeyTabTarget

contentItem: Item {
ColumnLayout {
Expand Down
6 changes: 6 additions & 0 deletions qml/windowed/WindowedFrame.qml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Item {
anchors.bottom: parent.bottom
anchors.topMargin: 10
anchors.leftMargin: 5
nextKeyTabTarget: bottomBar.keyTabTarget
}

Rectangle {
Expand All @@ -89,13 +90,17 @@ Item {
Layout.fillWidth: true
Layout.preferredWidth: 220
Layout.fillHeight: true
nextKeyTabTarget: sideBar.keyTabTarget
}

Loader {
id: appGridLoader
property Item keyTabTarget: appGridLoader.item.keyTabTarget
Component {
id: analysisViewCom
AnalysisView {
id: analysisViewCom
nextKeyTabTarget: appList.keyTabTarget
}
}
Component {
Expand All @@ -120,6 +125,7 @@ Item {
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 5
nextKeyTabTarget: appGridLoader.keyTabTarget
}

Rectangle {
Expand Down

0 comments on commit a9b0609

Please sign in to comment.