Changeset View
Changeset View
Standalone View
Standalone View
sidebar/package/contents/ui/CategoriesPage.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 | import org.kde.kirigami 2.10 as Kirigami | 22 | import org.kde.kirigami 2.10 as Kirigami | ||
23 | 23 | | |||
24 | Kirigami.ScrollablePage { | 24 | Kirigami.ScrollablePage { | ||
25 | id: mainColumn | 25 | id: mainColumn | ||
26 | Component.onCompleted: searchField.forceActiveFocus() | 26 | Component.onCompleted: searchField.forceActiveFocus() | ||
27 | readonly property bool searchMode: searchField.text.length > 0 | ||||
27 | 28 | | |||
28 | header: Rectangle { | 29 | header: Rectangle { | ||
29 | Kirigami.Theme.colorSet: Kirigami.Theme.Window | 30 | Kirigami.Theme.colorSet: Kirigami.Theme.Window | ||
30 | Kirigami.Theme.inherit: false | 31 | Kirigami.Theme.inherit: false | ||
31 | color: Kirigami.Theme.backgroundColor | 32 | color: Kirigami.Theme.backgroundColor | ||
32 | width: mainColumn.width | 33 | width: mainColumn.width | ||
33 | height: Math.round(Kirigami.Units.gridUnit * 2.5) | 34 | height: Math.round(Kirigami.Units.gridUnit * 2.5) | ||
34 | RowLayout { | 35 | RowLayout { | ||
Show All 23 Lines | |||||
58 | 59 | | |||
59 | Kirigami.SearchField { | 60 | Kirigami.SearchField { | ||
60 | id: searchField | 61 | id: searchField | ||
61 | focus: true | 62 | focus: true | ||
62 | Layout.minimumHeight: Layout.maximumHeight | 63 | Layout.minimumHeight: Layout.maximumHeight | ||
63 | Layout.maximumHeight: Kirigami.Units.iconSizes.smallMedium + Kirigami.Units.smallSpacing * 2 | 64 | Layout.maximumHeight: Kirigami.Units.iconSizes.smallMedium + Kirigami.Units.smallSpacing * 2 | ||
64 | Layout.fillWidth: true | 65 | Layout.fillWidth: true | ||
65 | onTextChanged: { | 66 | onTextChanged: { | ||
66 | systemsettings.categoryModel.filterRegExp = text; | 67 | systemsettings.searchModel.filterRegExp = text; | ||
67 | } | 68 | } | ||
68 | KeyNavigation.tab: categoryView | 69 | KeyNavigation.tab: categoryView | ||
69 | } | 70 | } | ||
70 | 71 | | |||
71 | QQC2.ToolButton { | 72 | QQC2.ToolButton { | ||
72 | id: showIntroPageButton | 73 | id: showIntroPageButton | ||
73 | enabled: !systemsettings.introPageVisible | 74 | enabled: !systemsettings.introPageVisible | ||
74 | icon.name: "go-home" | 75 | icon.name: "go-home" | ||
Show All 30 Lines | 100 | Kirigami.Heading { | |||
105 | opacity: categoryView.count == 0 ? 0.3 : 0 | 106 | opacity: categoryView.count == 0 ? 0.3 : 0 | ||
106 | Behavior on opacity { | 107 | Behavior on opacity { | ||
107 | OpacityAnimator { | 108 | OpacityAnimator { | ||
108 | duration: Kirigami.Units.longDuration | 109 | duration: Kirigami.Units.longDuration | ||
109 | easing.type: Easing.InOutQuad | 110 | easing.type: Easing.InOutQuad | ||
110 | } | 111 | } | ||
111 | } | 112 | } | ||
112 | } | 113 | } | ||
114 | | ||||
115 | Binding { | ||||
116 | target: categoryView | ||||
117 | property: "currentIndex" | ||||
118 | value: mainColumn.searchMode | ||||
119 | ? systemsettings.activeSearchRow | ||||
120 | : systemsettings.activeCategoryRow | ||||
121 | } | ||||
113 | ListView { | 122 | ListView { | ||
114 | id: categoryView | 123 | id: categoryView | ||
115 | anchors.fill: parent | 124 | anchors.fill: parent | ||
116 | model: systemsettings.categoryModel | 125 | model: mainColumn.searchMode ? systemsettings.searchModel : systemsettings.categoryModel | ||
117 | currentIndex: systemsettings.activeCategory | 126 | | ||
118 | onContentYChanged: systemsettings.hideToolTip(); | 127 | onContentYChanged: systemsettings.hideToolTip(); | ||
119 | activeFocusOnTab: true | 128 | activeFocusOnTab: true | ||
120 | keyNavigationWraps: true | 129 | keyNavigationWraps: true | ||
121 | Accessible.role: Accessible.List | 130 | Accessible.role: Accessible.List | ||
122 | Keys.onTabPressed: { | 131 | Keys.onTabPressed: { | ||
123 | if (applicationWindow().wideScreen) { | 132 | if (applicationWindow().wideScreen) { | ||
124 | subCategoryColumn.focus = true; | 133 | subCategoryColumn.focus = true; | ||
125 | } else { | 134 | } else { | ||
126 | root.focusNextRequest(); | 135 | root.focusNextRequest(); | ||
127 | } | 136 | } | ||
128 | } | 137 | } | ||
129 | section { | 138 | section { | ||
130 | property: "categoryDisplayRole" | 139 | property: "categoryDisplayRole" | ||
131 | delegate: Kirigami.ListSectionHeader { | 140 | delegate: Kirigami.ListSectionHeader { | ||
132 | width: categoryView.width | 141 | width: categoryView.width | ||
133 | label: section | 142 | label: section | ||
134 | } | 143 | } | ||
135 | } | 144 | } | ||
136 | 145 | | |||
137 | delegate: Kirigami.BasicListItem { | 146 | delegate: Kirigami.AbstractListItem { | ||
138 | id: delegate | 147 | id: delegate | ||
139 | icon: model.decoration | 148 | | ||
140 | label: model.display | | |||
141 | separatorVisible: false | 149 | separatorVisible: false | ||
ngraham: Remove | |||||
142 | Accessible.role: Accessible.ListItem | 150 | Accessible.role: Accessible.ListItem | ||
143 | Accessible.name: model.display | 151 | Accessible.name: model.display | ||
152 | supportsMouseEvents: !model.IsCategoryRole || !mainColumn.searchMode | ||||
153 | enabled: !model.IsCategoryRole || !mainColumn.searchMode | ||||
144 | onClicked: { | 154 | onClicked: { | ||
145 | if (systemsettings.activeCategory == index) { | 155 | if (model.IsCategoryRole && mainColumn.searchMode) { | ||
156 | return; | ||||
157 | } | ||||
158 | | ||||
159 | if (mainColumn.searchMode || systemsettings.activeCategoryRow !== index) { | ||||
160 | systemsettings.loadModule(categoryView.model.index(index, 0)); | ||||
161 | } | ||||
162 | if (!mainColumn.searchMode && root.pageStack.depth > 1) { | ||||
146 | root.pageStack.currentIndex = 1; | 163 | root.pageStack.currentIndex = 1; | ||
147 | } else { | | |||
148 | systemsettings.activeCategory = index; | | |||
149 | subCategoryColumn.title = model.display; | | |||
150 | } | 164 | } | ||
151 | } | 165 | } | ||
152 | onHoveredChanged: { | 166 | onHoveredChanged: { | ||
167 | if (model.IsCategoryRole && mainColumn.searchMode) { | ||||
168 | return; | ||||
169 | } | ||||
153 | if (hovered) { | 170 | if (hovered) { | ||
154 | systemsettings.requestToolTip(index, delegate.mapToItem(root, 0, 0, width, height)); | 171 | systemsettings.requestToolTip(categoryView.model.index(index, 0), delegate.mapToItem(root, 0, 0, width, height)); | ||
155 | } else { | 172 | } else { | ||
156 | systemsettings.hideToolTip(); | 173 | systemsettings.hideToolTip(); | ||
157 | } | 174 | } | ||
158 | } | 175 | } | ||
159 | onFocusChanged: { | 176 | onFocusChanged: { | ||
177 | if (model.IsCategoryRole && mainColumn.searchMode) { | ||||
178 | return; | ||||
179 | } | ||||
160 | if (focus) { | 180 | if (focus) { | ||
161 | onCurrentIndexChanged: categoryView.positionViewAtIndex(index, ListView.Contain); | 181 | categoryView.positionViewAtIndex(index, ListView.Contain); | ||
162 | } | 182 | } | ||
163 | } | 183 | } | ||
164 | highlighted: systemsettings.activeCategory == index | 184 | highlighted: categoryView.currentIndex == index | ||
165 | Keys.onEnterPressed: clicked(); | 185 | Keys.onEnterPressed: clicked(); | ||
166 | Keys.onReturnPressed: clicked(); | 186 | Keys.onReturnPressed: clicked(); | ||
187 | contentItem: RowLayout { | ||||
188 | id: layout | ||||
189 | spacing: Kirigami.Settings.tabletMode ? Kirigami.Units.largeSpacing : Kirigami.Units.smallSpacing | ||||
190 | Kirigami.Icon { | ||||
191 | id: icon | ||||
192 | source: model.decoration | ||||
193 | Layout.preferredHeight: Layout.preferredWidth | ||||
194 | Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium | ||||
195 | Layout.leftMargin: (model.DepthRole-1) * (icon.width + layout.spacing) | ||||
196 | } | ||||
197 | QQC2.Label { | ||||
198 | Layout.fillWidth: true | ||||
199 | text: model.display | ||||
200 | color: (delegate.highlighted || delegate.checked || (delegate.pressed && delegate.supportsMouseEvents)) ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor | ||||
201 | elide: Text.ElideRight | ||||
202 | } | ||||
203 | } | ||||
167 | } | 204 | } | ||
168 | } | 205 | } | ||
169 | } | 206 | } |
Remove