Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/package/contents/ui/ItemListView.qml
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 62 | Timer { | |||
---|---|---|---|---|---|
67 | interval: 70 | 67 | interval: 70 | ||
68 | repeat: false | 68 | repeat: false | ||
69 | 69 | | |||
70 | onTriggered: { | 70 | onTriggered: { | ||
71 | if (!plasmoid.expanded || model === undefined || currentIndex == -1) { | 71 | if (!plasmoid.expanded || model === undefined || currentIndex == -1) { | ||
72 | return; | 72 | return; | ||
73 | } | 73 | } | ||
74 | 74 | | |||
75 | if (childDialog != null) { | 75 | if (itemList.childDialog != null) { | ||
76 | childDialog.delayedDestroy(); | 76 | itemList.childDialog.delayedDestroy(); | ||
77 | } | 77 | } | ||
78 | 78 | | |||
79 | // Gets reenabled after the dialog spawn causes a focus-in on the dialog window. | 79 | // Gets reenabled after the dialog spawn causes a focus-in on the dialog window. | ||
80 | plasmoid.hideOnWindowDeactivate = false; | 80 | plasmoid.hideOnWindowDeactivate = false; | ||
81 | 81 | | |||
82 | childDialog = itemListDialogComponent.createObject(itemList); | 82 | itemList.childDialog = itemListDialogComponent.createObject(itemList); | ||
83 | childDialog.focusParent = itemList; | 83 | itemList.childDialog.focusParent = itemList; | ||
84 | childDialog.visualParent = listView.currentItem; | 84 | itemList.childDialog.visualParent = listView.currentItem; | ||
85 | childDialog.model = model.modelForRow(listView.currentIndex); | 85 | itemList.childDialog.model = model.modelForRow(listView.currentIndex); | ||
86 | childDialog.visible = true; | 86 | itemList.childDialog.visible = true; | ||
87 | 87 | | |||
88 | windowSystem.forceActive(childDialog.mainItem); | 88 | windowSystem.forceActive(itemList.childDialog.mainItem); | ||
89 | childDialog.mainItem.focus = true; | 89 | itemList.childDialog.mainItem.focus = true; | ||
90 | 90 | | |||
91 | if (focusOnSpawn) { | 91 | if (focusOnSpawn) { | ||
92 | childDialog.mainItem.showChildDialogs = false; | 92 | itemList.childDialog.mainItem.showChildDialogs = false; | ||
93 | childDialog.mainItem.currentIndex = 0; | 93 | itemList.childDialog.mainItem.currentIndex = 0; | ||
94 | childDialog.mainItem.showChildDialogs = true; | 94 | itemList.childDialog.mainItem.showChildDialogs = true; | ||
95 | } | 95 | } | ||
96 | } | 96 | } | ||
97 | } | 97 | } | ||
98 | 98 | | |||
99 | Timer { | 99 | Timer { | ||
100 | id: resetIndexTimer | 100 | id: resetIndexTimer | ||
101 | 101 | | |||
102 | interval: (dialog != null) ? 50 : 150 | 102 | interval: (dialog != null) ? 50 : 150 | ||
103 | repeat: false | 103 | repeat: false | ||
104 | 104 | | |||
105 | onTriggered: { | 105 | onTriggered: { | ||
106 | if (focus && (!childDialog || !childDialog.mainItem.containsMouse)) { | 106 | if (focus && (!itemList.childDialog || !itemList.childDialog.mainItem.containsMouse)) { | ||
107 | currentIndex = -1; | 107 | currentIndex = -1; | ||
108 | itemList.exited(); | 108 | itemList.exited(); | ||
109 | } | 109 | } | ||
110 | } | 110 | } | ||
111 | } | 111 | } | ||
112 | 112 | | |||
113 | MouseEventListener { | 113 | MouseEventListener { | ||
114 | id: listener | 114 | id: listener | ||
115 | 115 | | |||
116 | anchors.fill: parent | 116 | anchors.fill: parent | ||
117 | 117 | | |||
118 | hoverEnabled: true | 118 | hoverEnabled: true | ||
119 | 119 | | |||
120 | onContainsMouseChanged: { | 120 | onContainsMouseChanged: { | ||
121 | listView.eligibleWidth = listView.width; | 121 | listView.eligibleWidth = listView.width; | ||
122 | 122 | | |||
123 | if (containsMouse) { | 123 | if (containsMouse) { | ||
124 | resetIndexTimer.stop(); | 124 | resetIndexTimer.stop(); | ||
125 | itemList.forceActiveFocus(); | 125 | itemList.forceActiveFocus(); | ||
126 | } else if ((!childDialog || !dialog) | 126 | } else if ((!itemList.childDialog || !dialog) | ||
127 | && (!currentItem || !currentItem.menu.opened)) { | 127 | && (!currentItem || !currentItem.menu.opened)) { | ||
128 | resetIndexTimer.start(); | 128 | resetIndexTimer.start(); | ||
129 | } | 129 | } | ||
130 | } | 130 | } | ||
131 | 131 | | |||
132 | PlasmaExtras.ScrollArea { | 132 | PlasmaExtras.ScrollArea { | ||
133 | anchors.fill: parent | 133 | anchors.fill: parent | ||
134 | 134 | | |||
Show All 25 Lines | 137 | ListView { | |||
160 | highlightMoveDuration: 0 | 160 | highlightMoveDuration: 0 | ||
161 | 161 | | |||
162 | onCountChanged: { | 162 | onCountChanged: { | ||
163 | currentIndex = -1; | 163 | currentIndex = -1; | ||
164 | } | 164 | } | ||
165 | 165 | | |||
166 | onCurrentIndexChanged: { | 166 | onCurrentIndexChanged: { | ||
167 | if (currentIndex != -1) { | 167 | if (currentIndex != -1) { | ||
168 | if (childDialog) { | 168 | if (itemList.childDialog) { | ||
169 | if (currentItem && currentItem.hasChildren) { | 169 | if (currentItem && currentItem.hasChildren) { | ||
170 | childDialog.mainItem.width = itemList.minimumWidth; | 170 | itemList.childDialog.mainItem.width = itemList.minimumWidth; | ||
171 | childDialog.model = model.modelForRow(currentIndex); | 171 | itemList.childDialog.model = model.modelForRow(currentIndex); | ||
172 | childDialog.visualParent = listView.currentItem; | 172 | itemList.childDialog.visualParent = listView.currentItem; | ||
173 | } else { | 173 | } else { | ||
174 | childDialog.delayedDestroy(); | 174 | itemList.childDialog.delayedDestroy(); | ||
175 | } | 175 | } | ||
176 | 176 | | |||
177 | return; | 177 | return; | ||
178 | } | 178 | } | ||
179 | 179 | | |||
180 | if (currentItem == null || !currentItem.hasChildren || !plasmoid.expanded) { | 180 | if (currentItem == null || !currentItem.hasChildren || !plasmoid.expanded) { | ||
181 | dialogSpawnTimer.stop(); | 181 | dialogSpawnTimer.stop(); | ||
182 | 182 | | |||
183 | return; | 183 | return; | ||
184 | } | 184 | } | ||
185 | 185 | | |||
186 | if (showChildDialogs) { | 186 | if (showChildDialogs) { | ||
187 | dialogSpawnTimer.focusOnSpawn = false; | 187 | dialogSpawnTimer.focusOnSpawn = false; | ||
188 | dialogSpawnTimer.restart(); | 188 | dialogSpawnTimer.restart(); | ||
189 | } | 189 | } | ||
190 | } else if (childDialog != null) { | 190 | } else if (itemList.childDialog != null) { | ||
191 | childDialog.delayedDestroy(); | 191 | itemList.childDialog.delayedDestroy(); | ||
192 | childDialog = null; | 192 | itemList.childDialog = null; | ||
193 | } | 193 | } | ||
194 | } | 194 | } | ||
195 | 195 | | |||
196 | onCurrentItemChanged: { | 196 | onCurrentItemChanged: { | ||
197 | if (currentItem) { | 197 | if (currentItem) { | ||
198 | currentItem.menu.closed.connect(resetIndexTimer.restart); | 198 | currentItem.menu.closed.connect(resetIndexTimer.restart); | ||
199 | } | 199 | } | ||
200 | } | 200 | } | ||
201 | 201 | | |||
202 | Keys.onPressed: { | 202 | Keys.onPressed: event => { | ||
203 | if (event.key === Qt.Key_Up) { | 203 | if (event.key === Qt.Key_Up) { | ||
204 | event.accepted = true; | 204 | event.accepted = true; | ||
205 | 205 | | |||
206 | if (!keyNavigationWraps && currentIndex == 0) { | 206 | if (!keyNavigationWraps && currentIndex == 0) { | ||
207 | itemList.keyNavigationAtListEnd(); | 207 | itemList.keyNavigationAtListEnd(); | ||
208 | 208 | | |||
209 | return; | 209 | return; | ||
210 | } | 210 | } | ||
Show All 18 Lines | 220 | } else if (event.key === Qt.Key_Down) { | |||
229 | showChildDialogs = false; | 229 | showChildDialogs = false; | ||
230 | incrementCurrentIndex(); | 230 | incrementCurrentIndex(); | ||
231 | 231 | | |||
232 | if (currentItem.isSeparator) { | 232 | if (currentItem.isSeparator) { | ||
233 | incrementCurrentIndex(); | 233 | incrementCurrentIndex(); | ||
234 | } | 234 | } | ||
235 | 235 | | |||
236 | showChildDialogs = true; | 236 | showChildDialogs = true; | ||
237 | } else if ((event.key === Qt.Key_Right || event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && childDialog != null) { | 237 | } else if ((event.key === Qt.Key_Right || event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && itemList.childDialog != null) { | ||
238 | windowSystem.forceActive(childDialog.mainItem); | 238 | windowSystem.forceActive(itemList.childDialog.mainItem); | ||
239 | childDialog.mainItem.focus = true; | 239 | itemList.childDialog.mainItem.focus = true; | ||
240 | childDialog.mainItem.currentIndex = 0; | 240 | itemList.childDialog.mainItem.currentIndex = 0; | ||
241 | } else if ((event.key === Qt.Key_Right || event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && childDialog == null | 241 | } else if ((event.key === Qt.Key_Right || event.key === Qt.Key_Return || event.key === Qt.Key_Enter) && itemList.childDialog == null | ||
242 | && currentItem != null && currentItem.hasChildren) { | 242 | && currentItem != null && currentItem.hasChildren) { | ||
243 | dialogSpawnTimer.focusOnSpawn = true; | 243 | dialogSpawnTimer.focusOnSpawn = true; | ||
244 | dialogSpawnTimer.restart(); | 244 | dialogSpawnTimer.restart(); | ||
245 | } else if (event.key === Qt.Key_Left && dialog != null) { | 245 | } else if (event.key === Qt.Key_Left && dialog != null) { | ||
246 | dialog.destroy(); | 246 | dialog.destroy(); | ||
247 | } else if (event.key === Qt.Key_Escape) { | 247 | } else if (event.key === Qt.Key_Escape) { | ||
248 | plasmoid.expanded = false; | 248 | plasmoid.expanded = false; | ||
249 | } else if (event.key === Qt.Key_Tab) { | 249 | } else if (event.key === Qt.Key_Tab) { | ||
Show All 17 Lines |