Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/qml/Previews.qml
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 54 | delegate: Item { | |||
---|---|---|---|---|---|
67 | MouseArea { | 67 | MouseArea { | ||
68 | hoverEnabled: false | 68 | hoverEnabled: false | ||
69 | anchors.fill: parent | 69 | anchors.fill: parent | ||
70 | onClicked: { | 70 | onClicked: { | ||
71 | gridView.currentIndex = index; | 71 | gridView.currentIndex = index; | ||
72 | } | 72 | } | ||
73 | } | 73 | } | ||
74 | ColumnLayout { | 74 | ColumnLayout { | ||
75 | id: decorationPreviews | ||||
76 | property string themeName: model["display"] | ||||
75 | anchors.fill: parent | 77 | anchors.fill: parent | ||
76 | Item { | 78 | Item { | ||
77 | KDecoration.Decoration { | 79 | KDecoration.Decoration { | ||
78 | id: inactivePreview | 80 | id: inactivePreview | ||
79 | bridge: bridgeItem.bridge | 81 | bridge: bridgeItem.bridge | ||
80 | settings: settingsItem | 82 | settings: settingsItem | ||
81 | anchors.fill: parent | 83 | anchors.fill: parent | ||
82 | Component.onCompleted: { | 84 | Component.onCompleted: { | ||
83 | client.caption = Qt.binding(function() { return model["display"]; }); | 85 | client.caption = decorationPreviews.themeName | ||
84 | client.active = false; | 86 | client.active = false; | ||
85 | anchors.leftMargin = Qt.binding(function() { return 40 - (inactivePreview.shadow ? inactivePreview.shadow.paddingLeft : 0);}); | 87 | anchors.leftMargin = Qt.binding(function() { return 40 - (inactivePreview.shadow ? inactivePreview.shadow.paddingLeft : 0);}); | ||
86 | anchors.rightMargin = Qt.binding(function() { return 10 - (inactivePreview.shadow ? inactivePreview.shadow.paddingRight : 0);}); | 88 | anchors.rightMargin = Qt.binding(function() { return 10 - (inactivePreview.shadow ? inactivePreview.shadow.paddingRight : 0);}); | ||
87 | anchors.topMargin = Qt.binding(function() { return 10 - (inactivePreview.shadow ? inactivePreview.shadow.paddingTop : 0);}); | 89 | anchors.topMargin = Qt.binding(function() { return 10 - (inactivePreview.shadow ? inactivePreview.shadow.paddingTop : 0);}); | ||
88 | anchors.bottomMargin = Qt.binding(function() { return 40 - (inactivePreview.shadow ? inactivePreview.shadow.paddingBottom : 0);}); | 90 | anchors.bottomMargin = Qt.binding(function() { return 40 - (inactivePreview.shadow ? inactivePreview.shadow.paddingBottom : 0);}); | ||
89 | } | 91 | } | ||
90 | } | 92 | } | ||
91 | KDecoration.Decoration { | 93 | KDecoration.Decoration { | ||
92 | id: activePreview | 94 | id: activePreview | ||
93 | bridge: bridgeItem.bridge | 95 | bridge: bridgeItem.bridge | ||
94 | settings: settingsItem | 96 | settings: settingsItem | ||
95 | anchors.fill: parent | 97 | anchors.fill: parent | ||
96 | Component.onCompleted: { | 98 | Component.onCompleted: { | ||
97 | client.caption = Qt.binding(function() { return model["display"]; }); | 99 | client.caption = decorationPreviews.themeName | ||
98 | client.active = true; | 100 | client.active = true; | ||
99 | anchors.leftMargin = Qt.binding(function() { return 10 - (activePreview.shadow ? activePreview.shadow.paddingLeft : 0);}); | 101 | anchors.leftMargin = Qt.binding(function() { return 10 - (activePreview.shadow ? activePreview.shadow.paddingLeft : 0);}); | ||
100 | anchors.rightMargin = Qt.binding(function() { return 40 - (activePreview.shadow ? activePreview.shadow.paddingRight : 0);}); | 102 | anchors.rightMargin = Qt.binding(function() { return 40 - (activePreview.shadow ? activePreview.shadow.paddingRight : 0);}); | ||
101 | anchors.topMargin = Qt.binding(function() { return 40 - (activePreview.shadow ? activePreview.shadow.paddingTop : 0);}); | 103 | anchors.topMargin = Qt.binding(function() { return 40 - (activePreview.shadow ? activePreview.shadow.paddingTop : 0);}); | ||
102 | anchors.bottomMargin = Qt.binding(function() { return 10 - (activePreview.shadow ? activePreview.shadow.paddingBottom : 0);}); | 104 | anchors.bottomMargin = Qt.binding(function() { return 10 - (activePreview.shadow ? activePreview.shadow.paddingBottom : 0);}); | ||
103 | } | 105 | } | ||
104 | } | 106 | } | ||
105 | MouseArea { | 107 | MouseArea { | ||
106 | hoverEnabled: false | 108 | hoverEnabled: false | ||
107 | anchors.fill: parent | 109 | anchors.fill: parent | ||
108 | onClicked: { | 110 | onClicked: { | ||
109 | gridView.currentIndex = index; | 111 | gridView.currentIndex = index; | ||
110 | } | 112 | } | ||
111 | } | 113 | } | ||
112 | Layout.fillWidth: true | 114 | Layout.fillWidth: true | ||
113 | Layout.fillHeight: true | 115 | Layout.fillHeight: true | ||
114 | Button { | 116 | /* Create an invisible rectangle that's the same size as the inner content rect | ||
115 | id: configureButton | 117 | of the foreground window preview so that we can center the button within it. | ||
118 | We have to center rather than using anchors because the button width varies | ||||
119 | with different localizations */ | ||||
120 | Item { | ||||
graesslin: Why a rectangle? Just use an Item | |||||
116 | anchors { | 121 | anchors { | ||
117 | left: parent.left | 122 | left: parent.left | ||
123 | leftMargin: 10 | ||||
124 | right: parent.right | ||||
125 | rightMargin: 40 | ||||
126 | top: parent.top | ||||
127 | topMargin: 68 | ||||
118 | bottom: parent.bottom | 128 | bottom: parent.bottom | ||
119 | margins: 20 | 129 | bottomMargin: 10 | ||
130 | } | ||||
131 | Button { | ||||
132 | id: configureButton | ||||
133 | anchors { | ||||
134 | horizontalCenter: parent.horizontalCenter | ||||
135 | verticalCenter: parent.verticalCenter | ||||
120 | } | 136 | } | ||
121 | enabled: model["configureable"] | 137 | enabled: model["configureable"] | ||
122 | iconName: "configure" | 138 | iconName: "configure" | ||
123 | onClicked: bridgeItem.bridge.configure() | 139 | text: i18n("Configure %1...", decorationPreviews.themeName) | ||
140 | onClicked: { | ||||
141 | gridView.currentIndex = index | ||||
142 | bridgeItem.bridge.configure() | ||||
143 | } | ||||
144 | } | ||||
124 | } | 145 | } | ||
125 | } | 146 | } | ||
126 | } | 147 | } | ||
127 | } | 148 | } | ||
128 | } | 149 | } | ||
129 | Layout.preferredHeight: 20 * units.gridUnit | 150 | Layout.preferredHeight: 20 * units.gridUnit | ||
130 | } | 151 | } | ||
131 | 152 | |
Why a rectangle? Just use an Item