Changeset View
Changeset View
Standalone View
Standalone View
sidebar/package/contents/ui/SubCategoryPage.qml
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 26 | Kirigami.ScrollablePage { | |||
---|---|---|---|---|---|
93 | background: Rectangle { | 93 | background: Rectangle { | ||
94 | color: Kirigami.Theme.viewBackgroundColor | 94 | color: Kirigami.Theme.viewBackgroundColor | ||
95 | } | 95 | } | ||
96 | ListView { | 96 | ListView { | ||
97 | id: subCategoryView | 97 | id: subCategoryView | ||
98 | anchors.fill: parent | 98 | anchors.fill: parent | ||
99 | model: systemsettings.subCategoryModel | 99 | model: systemsettings.subCategoryModel | ||
100 | currentIndex: systemsettings.activeSubCategory | 100 | currentIndex: systemsettings.activeSubCategory | ||
101 | activeFocusOnTab: true | ||||
102 | keyNavigationWraps: true | ||||
103 | Accessible.role: Accessible.List | ||||
104 | Keys.onTabPressed: root.focusNextRequest(); | ||||
105 | Keys.onBacktabPressed: { | ||||
106 | mainColumn.focus = true; | ||||
107 | } | ||||
101 | onCountChanged: { | 108 | onCountChanged: { | ||
102 | if (count > 1) { | 109 | if (count > 1) { | ||
103 | if (root.pageStack.depth < 2) { | 110 | if (root.pageStack.depth < 2) { | ||
104 | root.pageStack.push(subCategoryColumn); | 111 | root.pageStack.push(subCategoryColumn); | ||
105 | } | 112 | } | ||
106 | } else { | 113 | } else { | ||
107 | root.pageStack.pop(mainColumn) | 114 | root.pageStack.pop(mainColumn) | ||
108 | } | 115 | } | ||
109 | } | 116 | } | ||
110 | Connections { | 117 | Connections { | ||
111 | target: systemsettings | 118 | target: systemsettings | ||
112 | onActiveSubCategoryChanged: { | 119 | onActiveSubCategoryChanged: { | ||
113 | root.pageStack.currentIndex = 1; | 120 | root.pageStack.currentIndex = 1; | ||
114 | subCategoryView.forceActiveFocus(); | 121 | subCategoryView.forceActiveFocus(); | ||
115 | } | 122 | } | ||
116 | } | 123 | } | ||
117 | 124 | | |||
118 | delegate: Kirigami.BasicListItem { | 125 | delegate: Kirigami.BasicListItem { | ||
119 | id: delegate | 126 | id: delegate | ||
120 | icon: model.decoration | 127 | icon: model.decoration | ||
121 | label: model.display | 128 | label: model.display | ||
122 | separatorVisible: false | 129 | separatorVisible: false | ||
123 | activeFocusOnTab: root.pageStack.currentIndex == 1 | | |||
124 | highlighted: focus | 130 | highlighted: focus | ||
125 | onClicked: systemsettings.activeSubCategory = index | 131 | onClicked: systemsettings.activeSubCategory = index | ||
126 | onFocusChanged: { | 132 | onFocusChanged: { | ||
127 | if (focus) { | 133 | if (focus) { | ||
128 | onCurrentIndexChanged: subCategoryView.positionViewAtIndex(index, ListView.Contain); | 134 | onCurrentIndexChanged: subCategoryView.positionViewAtIndex(index, ListView.Contain); | ||
129 | } | 135 | } | ||
130 | } | 136 | } | ||
131 | checked: systemsettings.activeSubCategory == index | 137 | checked: systemsettings.activeSubCategory == index | ||
132 | //checkable: false | 138 | //checkable: false | ||
133 | //FIXME: Qt 5.7 doesn't have checkable, this way fails at runtime but still works correctly on 5.7 | 139 | //FIXME: Qt 5.7 doesn't have checkable, this way fails at runtime but still works correctly on 5.7 | ||
134 | Component.onCompleted: delegate.checkable = true; | 140 | Component.onCompleted: delegate.checkable = true; | ||
135 | Keys.onPressed: { | | |||
136 | switch (event.key) { | | |||
137 | case Qt.Key_Up: | | |||
138 | delegate.nextItemInFocusChain(false).forceActiveFocus(); | | |||
139 | break; | | |||
140 | case Qt.Key_Down: | | |||
141 | delegate.nextItemInFocusChain(true).forceActiveFocus(); | | |||
142 | break; | | |||
143 | case Qt.Key_left: | | |||
144 | case Qt.Key_Backspace: | | |||
145 | root.pageStack.currentIndex = 0; | | |||
146 | mainColumn.forceActiveFocus(); | | |||
147 | break; | | |||
148 | default: | | |||
149 | break; | | |||
150 | } | | |||
151 | } | | |||
152 | } | 141 | } | ||
153 | } | 142 | } | ||
154 | } | 143 | } |