Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/package/contents/ui/Themes.qml
Show All 18 Lines | |||||
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | */ | 20 | */ | ||
21 | import QtQuick 2.7 | 21 | import QtQuick 2.7 | ||
22 | import org.kde.kcm 1.1 as KCM | 22 | import org.kde.kcm 1.1 as KCM | ||
23 | import org.kde.kirigami 2.2 as Kirigami | 23 | import org.kde.kirigami 2.2 as Kirigami | ||
24 | import org.kde.kwin.private.kdecoration 1.0 as KDecoration | 24 | import org.kde.kwin.private.kdecoration 1.0 as KDecoration | ||
25 | 25 | | |||
26 | KCM.GridView { | 26 | KCM.GridView { | ||
27 | property int cellSpacing: 2 * units.largeSpacing | | |||
28 | property int previewWidth: 18 * units.gridUnit | | |||
29 | property int previewHeight: previewWidth / 1.7 | | |||
30 | | ||||
31 | function updateDecoration(item, marginTopLeft, marginBottomRight) { | 27 | function updateDecoration(item, marginTopLeft, marginBottomRight) { | ||
32 | var mainMargin = units.largeSpacing | 28 | var mainMargin = units.largeSpacing | ||
33 | var shd = item.shadow | 29 | var shd = item.shadow | ||
34 | item.anchors.leftMargin = mainMargin + marginTopLeft - (shd ? shd.paddingLeft : 0) | 30 | item.anchors.leftMargin = mainMargin + marginTopLeft - (shd ? shd.paddingLeft : 0) | ||
35 | item.anchors.rightMargin = mainMargin + marginBottomRight - (shd ? shd.paddingRight : 0) | 31 | item.anchors.rightMargin = mainMargin + marginBottomRight - (shd ? shd.paddingRight : 0) | ||
36 | item.anchors.topMargin = mainMargin + marginTopLeft - (shd ? shd.paddingTop : 0) | 32 | item.anchors.topMargin = mainMargin + marginTopLeft - (shd ? shd.paddingTop : 0) | ||
37 | item.anchors.bottomMargin = mainMargin + marginBottomRight - (shd ? shd.paddingBottom : 0) | 33 | item.anchors.bottomMargin = mainMargin + marginBottomRight - (shd ? shd.paddingBottom : 0) | ||
38 | } | 34 | } | ||
39 | 35 | | |||
40 | view.model: kcm.themesModel | 36 | view.model: kcm.themesModel | ||
41 | view.currentIndex: kcm.theme | 37 | view.currentIndex: kcm.theme | ||
42 | view.onCurrentIndexChanged: kcm.theme = view.currentIndex | 38 | view.onCurrentIndexChanged: kcm.theme = view.currentIndex | ||
43 | view.onContentHeightChanged: view.positionViewAtIndex(view.currentIndex, GridView.Visible) | 39 | view.onContentHeightChanged: view.positionViewAtIndex(view.currentIndex, GridView.Visible) | ||
44 | 40 | | |||
45 | view.cellWidth: previewWidth + cellSpacing | 41 | view.implicitCellWidth: Kirigami.Units.gridUnit * 18 | ||
46 | view.cellHeight: previewHeight + cellSpacing | | |||
47 | 42 | | |||
48 | view.delegate: KCM.GridDelegate { | 43 | view.delegate: KCM.GridDelegate { | ||
49 | text: model.display | 44 | text: model.display | ||
50 | 45 | | |||
51 | thumbnailAvailable: true | 46 | thumbnailAvailable: true | ||
52 | thumbnail: Rectangle { | 47 | thumbnail: Rectangle { | ||
53 | anchors.fill: parent | 48 | anchors.fill: parent | ||
54 | width: previewWidth | | |||
55 | height: previewHeight | | |||
56 | color: palette.base | 49 | color: palette.base | ||
57 | clip: true | 50 | clip: true | ||
58 | 51 | | |||
59 | // Workaround: the thumbnail size can't be otherwise changed | | |||
60 | Component.onCompleted: { | | |||
61 | parent.parent.width = previewWidth | | |||
62 | parent.parent.height = previewHeight | | |||
63 | } | | |||
64 | | ||||
65 | KDecoration.Bridge { | 52 | KDecoration.Bridge { | ||
66 | id: bridgeItem | 53 | id: bridgeItem | ||
67 | plugin: model.plugin | 54 | plugin: model.plugin | ||
68 | theme: model.theme | 55 | theme: model.theme | ||
69 | } | 56 | } | ||
70 | KDecoration.Settings { | 57 | KDecoration.Settings { | ||
71 | id: settingsItem | 58 | id: settingsItem | ||
72 | bridge: bridgeItem.bridge | 59 | bridge: bridgeItem.bridge | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |