Changeset View
Changeset View
Standalone View
Standalone View
kcms/style/package/contents/ui/main.qml
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 28 | KCM.GridViewKCM { | |||
---|---|---|---|---|---|
63 | 63 | | |||
64 | view.delegate: KCM.GridDelegate { | 64 | view.delegate: KCM.GridDelegate { | ||
65 | id: delegate | 65 | id: delegate | ||
66 | 66 | | |||
67 | text: model.display | 67 | text: model.display | ||
68 | toolTip: model.description | 68 | toolTip: model.description | ||
69 | 69 | | |||
70 | thumbnailAvailable: thumbnailItem.valid | 70 | thumbnailAvailable: thumbnailItem.valid | ||
71 | thumbnail: Private.PreviewItem { | 71 | thumbnail: Item { | ||
72 | id: thumbnailItem | | |||
73 | anchors.fill: parent | 72 | anchors.fill: parent | ||
73 | clip: thumbnailItem.implicitWidth * thumbnailItem.scale > width | ||||
74 | | ||||
75 | Private.PreviewItem { | ||||
76 | id: thumbnailItem | ||||
77 | anchors.centerIn: parent | ||||
78 | // Fit the widget's width in the grid view | ||||
79 | // Round up to the nearest 0.05, so that 0.95 gets scaled up to 1.0 | ||||
80 | // to avoid blurriness in case the widget is only slightly bigger | ||||
81 | scale: (Math.ceil(Math.min(1, parent.width / implicitWidth) * 20) / 20).toFixed(2) | ||||
82 | width: Math.max(parent.width, implicitWidth) | ||||
83 | // Scale the height back up as the background color comes from the style | ||||
84 | // and we don't want to leave an ugly gap above/below it | ||||
85 | height: parent.height / scale | ||||
86 | smooth: true | ||||
74 | styleName: model.styleName | 87 | styleName: model.styleName | ||
88 | } | ||||
75 | 89 | | |||
76 | Connections { | 90 | Connections { | ||
77 | target: kcm | 91 | target: kcm | ||
78 | onStyleReconfigured: { | 92 | onStyleReconfigured: { | ||
79 | if (styleName === model.styleName) { | 93 | if (styleName === model.styleName) { | ||
80 | thumbnailItem.reload(); | 94 | thumbnailItem.reload(); | ||
81 | } | 95 | } | ||
82 | } | 96 | } | ||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |