Changeset View
Changeset View
Standalone View
Standalone View
sidebar/package/contents/ui/SubCategoryPage.qml
Show All 18 Lines | |||||
19 | import QtQuick 2.5 | 19 | import QtQuick 2.5 | ||
20 | import QtQuick.Controls 2.5 as QQC2 | 20 | import QtQuick.Controls 2.5 as QQC2 | ||
21 | import QtQuick.Layouts 1.1 | 21 | import QtQuick.Layouts 1.1 | ||
22 | 22 | | |||
23 | import org.kde.kirigami 2.5 as Kirigami | 23 | import org.kde.kirigami 2.5 as Kirigami | ||
24 | 24 | | |||
25 | Kirigami.ScrollablePage { | 25 | Kirigami.ScrollablePage { | ||
26 | id: subCategoryColumn | 26 | id: subCategoryColumn | ||
27 | title: systemsettings.subCategoryModel.title | ||||
28 | | ||||
27 | header: Rectangle { | 29 | header: Rectangle { | ||
28 | id: headerRect | 30 | id: headerRect | ||
29 | Kirigami.Theme.colorSet: Kirigami.Theme.Window | 31 | Kirigami.Theme.colorSet: Kirigami.Theme.Window | ||
30 | Kirigami.Theme.inherit: false | 32 | Kirigami.Theme.inherit: false | ||
31 | color: { | 33 | color: { | ||
32 | if (headerControls.pressed) { | 34 | if (headerControls.pressed) { | ||
33 | return Kirigami.Theme.highlightColor; | 35 | return Kirigami.Theme.highlightColor; | ||
34 | } else if (headerControls.containsMouse) { | 36 | } else if (headerControls.containsMouse) { | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | |||||
102 | background: Rectangle { | 104 | background: Rectangle { | ||
103 | Kirigami.Theme.colorSet: Kirigami.Theme.View | 105 | Kirigami.Theme.colorSet: Kirigami.Theme.View | ||
104 | color: Kirigami.Theme.backgroundColor | 106 | color: Kirigami.Theme.backgroundColor | ||
105 | } | 107 | } | ||
106 | ListView { | 108 | ListView { | ||
107 | id: subCategoryView | 109 | id: subCategoryView | ||
108 | anchors.fill: parent | 110 | anchors.fill: parent | ||
109 | model: systemsettings.subCategoryModel | 111 | model: systemsettings.subCategoryModel | ||
110 | currentIndex: systemsettings.activeSubCategory | 112 | currentIndex: systemsettings.activeSubCategoryRow | ||
111 | onContentYChanged: systemsettings.hideSubCategoryToolTip(); | 113 | onContentYChanged: systemsettings.hideToolTip(); | ||
112 | activeFocusOnTab: true | 114 | activeFocusOnTab: true | ||
113 | keyNavigationWraps: true | 115 | keyNavigationWraps: true | ||
114 | Accessible.role: Accessible.List | 116 | Accessible.role: Accessible.List | ||
115 | Keys.onTabPressed: root.focusNextRequest(); | 117 | Keys.onTabPressed: root.focusNextRequest(); | ||
116 | Keys.onBacktabPressed: { | 118 | Keys.onBacktabPressed: { | ||
117 | mainColumn.focus = true; | 119 | mainColumn.focus = true; | ||
118 | } | 120 | } | ||
119 | onCountChanged: { | 121 | onCountChanged: { | ||
120 | if (count > 1) { | 122 | if (count > 1 && !root.searchMode) { | ||
121 | if (root.pageStack.depth < 2) { | 123 | if (root.pageStack.depth < 2) { | ||
122 | root.pageStack.push(subCategoryColumn); | 124 | root.pageStack.push(subCategoryColumn); | ||
123 | } | 125 | } | ||
124 | } else { | 126 | } else { | ||
125 | root.pageStack.pop(mainColumn) | 127 | root.pageStack.pop(mainColumn) | ||
126 | } | 128 | } | ||
127 | } | 129 | } | ||
128 | 130 | | |||
129 | Connections { | 131 | Connections { | ||
132 | target: root | ||||
133 | onSearchModeChanged: { | ||||
134 | if (root.searchMode) { | ||||
135 | root.pageStack.pop(mainColumn); | ||||
136 | } else if (subCategoryView.count > 1) { | ||||
137 | root.pageStack.push(subCategoryColumn); | ||||
138 | } | ||||
139 | } | ||||
140 | } | ||||
141 | Connections { | ||||
130 | target: systemsettings | 142 | target: systemsettings | ||
131 | onActiveSubCategoryChanged: { | 143 | onActiveSubCategoryChanged: { | ||
132 | subCategoryView.currentIndex = systemsettings.activeSubCategory; | 144 | subCategoryView.currentIndex = systemsettings.activeSubCategoryRow; | ||
133 | if (systemsettings.activeSubCategory < 0) { | 145 | if (systemsettings.activeSubCategoryRow < 0) { | ||
134 | root.pageStack.pop(mainColumn) | 146 | root.pageStack.pop(mainColumn) | ||
135 | } else { | 147 | } else { | ||
136 | root.pageStack.currentIndex = 1; | 148 | root.pageStack.currentIndex = 1; | ||
137 | subCategoryView.forceActiveFocus(); | 149 | subCategoryView.forceActiveFocus(); | ||
138 | } | 150 | } | ||
139 | } | 151 | } | ||
152 | onIntroPageVisibleChanged: { | ||||
153 | if (systemsettings.introPageVisible) { | ||||
154 | root.pageStack.pop(mainColumn) | ||||
155 | } | ||||
156 | } | ||||
140 | } | 157 | } | ||
141 | 158 | | |||
142 | delegate: Kirigami.BasicListItem { | 159 | delegate: Kirigami.BasicListItem { | ||
143 | id: delegate | 160 | id: delegate | ||
144 | icon: model.decoration | 161 | icon: model.decoration | ||
145 | label: model.display | 162 | label: model.display | ||
146 | separatorVisible: false | 163 | separatorVisible: false | ||
147 | onClicked: systemsettings.activeSubCategory = index | 164 | onClicked: { | ||
165 | systemsettings.loadModule(subCategoryView.model.index(index, 0)); | ||||
166 | } | ||||
148 | onHoveredChanged: { | 167 | onHoveredChanged: { | ||
149 | if (hovered) { | 168 | if (hovered) { | ||
150 | systemsettings.requestSubCategoryToolTip(index, delegate.mapToItem(root, 0, 0, width, height)); | 169 | systemsettings.requestToolTip(subCategoryView.model.index(index, 0), delegate.mapToItem(root, 0, 0, width, height)); | ||
151 | } else { | 170 | } else { | ||
152 | systemsettings.hideSubCategoryToolTip(); | 171 | systemsettings.hideToolTip(); | ||
153 | } | 172 | } | ||
154 | } | 173 | } | ||
155 | onFocusChanged: { | 174 | onFocusChanged: { | ||
156 | if (focus) { | 175 | if (focus) { | ||
157 | onCurrentIndexChanged: subCategoryView.positionViewAtIndex(index, ListView.Contain); | 176 | onCurrentIndexChanged: subCategoryView.positionViewAtIndex(index, ListView.Contain); | ||
158 | } | 177 | } | ||
159 | } | 178 | } | ||
160 | highlighted: systemsettings.activeSubCategory == index | 179 | highlighted: systemsettings.activeSubCategoryRow == index | ||
161 | Keys.onEnterPressed: clicked(); | 180 | Keys.onEnterPressed: clicked(); | ||
162 | Keys.onReturnPressed: clicked(); | 181 | Keys.onReturnPressed: clicked(); | ||
163 | } | 182 | } | ||
164 | } | 183 | } | ||
165 | } | 184 | } |