Changeset View
Changeset View
Standalone View
Standalone View
containments/desktop/package/contents/ui/FolderItemDelegate.qml
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Line(s) | 121 | PlasmaCore.ToolTipArea { | |||
---|---|---|---|---|---|
124 | x: frame.x + Math.min(icon.x, label.x) | 124 | x: frame.x + Math.min(icon.x, label.x) | ||
125 | y: frame.y + icon.y | 125 | y: frame.y + icon.y | ||
126 | 126 | | |||
127 | width: Math.max(icon.width, label.width) | 127 | width: Math.max(icon.width, label.width) | ||
128 | height: (label.y + label.paintedHeight) | 128 | height: (label.y + label.paintedHeight) | ||
129 | 129 | | |||
130 | active: (plasmoid.configuration.toolTips && popupDialog == null && !model.blank) | 130 | active: (plasmoid.configuration.toolTips && popupDialog == null && !model.blank) | ||
131 | interactive: false | 131 | interactive: false | ||
132 | location: root.isPopup ? (plasmoid.location == PlasmaCore.Types.LeftEdge ? PlasmaCore.Types.LeftEdge : PlasmaCore.Types.RightEdge) : plasmoid.location | 132 | location: root.useListViewMode ? (plasmoid.location == PlasmaCore.Types.LeftEdge ? PlasmaCore.Types.LeftEdge : PlasmaCore.Types.RightEdge) : plasmoid.location | ||
133 | 133 | | |||
134 | onContainsMouseChanged: { | 134 | onContainsMouseChanged: { | ||
135 | if (containsMouse && !model.blank) { | 135 | if (containsMouse && !model.blank) { | ||
136 | toolTip.icon = model.decoration; | 136 | toolTip.icon = model.decoration; | ||
137 | toolTip.mainText = model.display; | 137 | toolTip.mainText = model.display; | ||
138 | 138 | | |||
139 | if (model.size != undefined) { | 139 | if (model.size != undefined) { | ||
140 | toolTip.subText = model.type + "\n" + model.size; | 140 | toolTip.subText = model.type + "\n" + model.size; | ||
141 | } else { | 141 | } else { | ||
142 | toolTip.subText = model.type; | 142 | toolTip.subText = model.type; | ||
143 | } | 143 | } | ||
144 | 144 | | |||
145 | main.GridView.view.hoveredItem = main; | 145 | main.GridView.view.hoveredItem = main; | ||
146 | } | 146 | } | ||
147 | } | 147 | } | ||
148 | } | 148 | } | ||
149 | 149 | | |||
150 | PlasmaCore.FrameSvgItem { | 150 | PlasmaCore.FrameSvgItem { | ||
151 | id: frame | 151 | id: frame | ||
152 | 152 | | |||
153 | x: root.isPopup ? 0 : units.smallSpacing | 153 | x: root.useListViewMode ? 0 : units.smallSpacing | ||
154 | y: root.isPopup ? 0 : units.smallSpacing | 154 | y: root.useListViewMode ? 0 : units.smallSpacing | ||
155 | 155 | | |||
156 | width: { | 156 | width: { | ||
157 | if (root.isPopup) { | 157 | if (root.useListViewMode) { | ||
158 | if (main.GridView.view.overflowing) { | 158 | if (main.GridView.view.overflowing) { | ||
159 | return parent.width - units.smallSpacing; | 159 | return parent.width - units.smallSpacing; | ||
160 | } else { | 160 | } else { | ||
161 | return parent.width; | 161 | return parent.width; | ||
162 | } | 162 | } | ||
163 | } | 163 | } | ||
164 | 164 | | |||
165 | return parent.width - (units.smallSpacing * 2); | 165 | return parent.width - (units.smallSpacing * 2); | ||
166 | } | 166 | } | ||
167 | 167 | | |||
168 | height: { | 168 | height: { | ||
169 | if (root.isPopup) { | 169 | if (root.useListViewMode) { | ||
170 | return parent.height; | 170 | return parent.height; | ||
171 | } | 171 | } | ||
172 | 172 | | |||
173 | return (icon.height + (2 * units.smallSpacing) + (label.lineCount | 173 | return (icon.height + (2 * units.smallSpacing) + (label.lineCount | ||
174 | * theme.mSize(theme.defaultFont).height) + (2 * units.largeSpacing)); | 174 | * theme.mSize(theme.defaultFont).height) + (2 * units.largeSpacing)); | ||
175 | } | 175 | } | ||
176 | 176 | | |||
177 | visible: !model.blank | 177 | visible: !model.blank | ||
178 | enabled: visible | 178 | enabled: visible | ||
179 | 179 | | |||
180 | imagePath: "widgets/viewitem" | 180 | imagePath: "widgets/viewitem" | ||
181 | 181 | | |||
182 | PlasmaCore.ColorScope { | 182 | PlasmaCore.ColorScope { | ||
183 | anchors.fill: parent | 183 | anchors.fill: parent | ||
184 | 184 | | |||
185 | colorGroup: ((root.isContainment && main.GridView.view.isRootView) ? PlasmaCore.Theme.ComplementaryColorGroup | 185 | colorGroup: ((root.isContainment && main.GridView.view.isRootView) ? PlasmaCore.Theme.ComplementaryColorGroup | ||
186 | : PlasmaCore.Theme.NormalColorGroup) | 186 | : PlasmaCore.Theme.NormalColorGroup) | ||
187 | 187 | | |||
188 | PlasmaCore.IconItem { | 188 | PlasmaCore.IconItem { | ||
189 | id: icon | 189 | id: icon | ||
190 | 190 | | |||
191 | states: [ | ||||
192 | State { // icon view | ||||
193 | when: !root.useListViewMode | ||||
194 | | ||||
195 | AnchorChanges { | ||||
196 | target: icon | ||||
197 | anchors.top: parent.top | ||||
198 | anchors.horizontalCenter: parent.horizontalCenter | ||||
199 | } | ||||
200 | }, | ||||
201 | State { // list view | ||||
202 | when: root.useListViewMode | ||||
203 | | ||||
204 | AnchorChanges { | ||||
205 | target: icon | ||||
206 | anchors.left: parent.left | ||||
207 | anchors.verticalCenter: parent.verticalCenter | ||||
208 | } | ||||
209 | } | ||||
210 | ] | ||||
211 | | ||||
191 | anchors { | 212 | anchors { | ||
192 | top: root.isPopup ? undefined : parent.top | | |||
193 | topMargin: units.largeSpacing | 213 | topMargin: units.largeSpacing | ||
194 | left: root.isPopup ? parent.left : undefined | | |||
195 | leftMargin: units.smallSpacing | 214 | leftMargin: units.smallSpacing | ||
196 | horizontalCenter: root.isPopup ? undefined : parent.horizontalCenter | | |||
197 | verticalCenter: root.isPopup ? parent.verticalCenter : undefined | | |||
198 | } | 215 | } | ||
199 | 216 | | |||
200 | width: main.GridView.view.iconSize | 217 | width: main.GridView.view.iconSize | ||
201 | height: main.GridView.view.iconSize | 218 | height: main.GridView.view.iconSize | ||
202 | 219 | | |||
203 | opacity: root.isPopup ? (1.3 - selectionButton.opacity) : 1.0 | 220 | opacity: root.useListViewMode ? (1.3 - selectionButton.opacity) : 1.0 | ||
204 | 221 | | |||
205 | animated: false | 222 | animated: false | ||
206 | usesPlasmaTheme: false | 223 | usesPlasmaTheme: false | ||
207 | 224 | | |||
208 | source: model.decoration | 225 | source: model.decoration | ||
209 | } | 226 | } | ||
210 | 227 | | |||
211 | Rectangle { | 228 | Rectangle { | ||
Show All 23 Lines | 249 | TextMetrics { | |||
235 | font: label.font | 252 | font: label.font | ||
236 | elide: Text.ElideNone | 253 | elide: Text.ElideNone | ||
237 | text: label.text | 254 | text: label.text | ||
238 | } | 255 | } | ||
239 | 256 | | |||
240 | PlasmaComponents.Label { | 257 | PlasmaComponents.Label { | ||
241 | id: label | 258 | id: label | ||
242 | 259 | | |||
243 | anchors { | 260 | states: [ | ||
244 | top: root.isPopup ? undefined : icon.bottom | 261 | State { // icon view | ||
245 | topMargin: 2 * units.smallSpacing | 262 | when: !root.useListViewMode | ||
246 | left: root.isPopup ? icon.right : undefined | | |||
247 | leftMargin: units.smallSpacing * 2 | | |||
248 | horizontalCenter: root.isPopup ? undefined : parent.horizontalCenter | | |||
249 | verticalCenter: root.isPopup ? parent.verticalCenter : undefined | | |||
250 | } | | |||
251 | 263 | | |||
252 | width: { | 264 | AnchorChanges { | ||
253 | if (root.isPopup) { | 265 | target: label | ||
254 | return parent.width - icon.width - (units.smallSpacing * 4); | 266 | anchors.top: icon.bottom | ||
267 | anchors.horizontalCenter: parent.horizontalCenter | ||||
255 | } | 268 | } | ||
269 | PropertyChanges { | ||||
270 | target: label | ||||
271 | anchors.topMargin: 2 * units.smallSpacing | ||||
272 | width: Math.min(labelMetrics.advanceWidth + units.smallSpacing, parent.width - units.smallSpacing * 8) | ||||
273 | maximumLineCount: plasmoid.configuration.textLines | ||||
274 | horizontalAlignment: Text.AlignHCenter | ||||
275 | } | ||||
276 | }, | ||||
277 | State { // list view | ||||
278 | when: root.useListViewMode | ||||
256 | 279 | | |||
257 | return Math.min(labelMetrics.advanceWidth + units.smallSpacing, parent.width - units.smallSpacing * 8); | 280 | AnchorChanges { | ||
281 | target: label | ||||
282 | anchors.left: icon.right | ||||
283 | anchors.verticalCenter: parent.verticalCenter | ||||
258 | } | 284 | } | ||
285 | PropertyChanges { | ||||
286 | target: label | ||||
287 | anchors.leftMargin: units.smallSpacing * 2 | ||||
288 | anchors.rightMargin: units.smallSpacing * 2 | ||||
289 | width: parent.width - icon.width - (units.smallSpacing * 4) | ||||
290 | maximumLineCount: 1 | ||||
291 | horizontalAlignment: Text.AlignLeft | ||||
292 | } | ||||
293 | } | ||||
294 | ] | ||||
259 | 295 | | |||
260 | height: undefined // Unset PlasmaComponents.Label's default. | 296 | height: undefined // Unset PlasmaComponents.Label's default. | ||
261 | 297 | | |||
262 | textFormat: Text.PlainText | 298 | textFormat: Text.PlainText | ||
263 | 299 | | |||
264 | maximumLineCount: root.isPopup ? 1 : plasmoid.configuration.textLines | | |||
265 | wrapMode: Text.Wrap | 300 | wrapMode: Text.Wrap | ||
266 | elide: Text.ElideRight | 301 | elide: Text.ElideRight | ||
267 | 302 | | |||
268 | horizontalAlignment: root.isPopup ? Text.AlignHLeft : Text.AlignHCenter | | |||
269 | | ||||
270 | color: PlasmaCore.ColorScope.textColor | 303 | color: PlasmaCore.ColorScope.textColor | ||
271 | 304 | | |||
272 | text: model.blank ? "" : model.display | 305 | text: model.blank ? "" : model.display | ||
273 | 306 | | |||
274 | Component.onCompleted: textFix.disableMouseHandling(label) // FIXME TODO: See https://codereview.qt-project.org/#/c/113758/ | 307 | Component.onCompleted: textFix.disableMouseHandling(label) // FIXME TODO: See https://codereview.qt-project.org/#/c/113758/ | ||
275 | } | 308 | } | ||
276 | } | 309 | } | ||
277 | 310 | | |||
278 | Column { | 311 | Column { | ||
279 | id: actions | 312 | id: actions | ||
280 | 313 | | |||
281 | x: units.smallSpacing * 3 | 314 | x: units.smallSpacing * 3 | ||
282 | y: units.smallSpacing * 3 | 315 | y: units.smallSpacing * 3 | ||
283 | 316 | | |||
284 | anchors { | 317 | anchors { | ||
285 | centerIn: root.isPopup ? icon : undefined | 318 | centerIn: root.useListViewMode ? icon : undefined | ||
286 | } | 319 | } | ||
287 | 320 | | |||
288 | width: implicitWidth | 321 | width: implicitWidth | ||
289 | height: implicitHeight | 322 | height: implicitHeight | ||
290 | 323 | | |||
291 | FolderItemActionButton { | 324 | FolderItemActionButton { | ||
292 | id: selectionButton | 325 | id: selectionButton | ||
293 | 326 | | |||
294 | visible: plasmoid.configuration.selectionMarkers && systemSettings.singleClick() | 327 | visible: plasmoid.configuration.selectionMarkers && systemSettings.singleClick() | ||
295 | opacity: (visible && impl.hovered) ? 1.0 : 0.0 | 328 | opacity: (visible && impl.hovered) ? 1.0 : 0.0 | ||
296 | 329 | | |||
297 | element: model.selected ? "remove" : "add" | 330 | element: model.selected ? "remove" : "add" | ||
298 | 331 | | |||
299 | onClicked: dir.toggleSelected(positioner.map(index)) | 332 | onClicked: dir.toggleSelected(positioner.map(index)) | ||
300 | } | 333 | } | ||
301 | } | 334 | } | ||
302 | 335 | | |||
303 | Component { | 336 | Component { | ||
304 | id: popupButtonComponent | 337 | id: popupButtonComponent | ||
305 | 338 | | |||
306 | FolderItemActionButton { | 339 | FolderItemActionButton { | ||
307 | visible: !root.isPopup | 340 | visible: !root.useListViewMode | ||
308 | 341 | | |||
309 | opacity: (plasmoid.configuration.popups && impl.hovered && impl.popupDialog == null) ? 1.0 : 0.0 | 342 | opacity: (plasmoid.configuration.popups && impl.hovered && impl.popupDialog == null) ? 1.0 : 0.0 | ||
310 | 343 | | |||
311 | element: "open" | 344 | element: "open" | ||
312 | 345 | | |||
313 | onClicked: impl.openPopup() | 346 | onClicked: impl.openPopup() | ||
314 | } | 347 | } | ||
315 | } | 348 | } | ||
Show All 34 Lines |