Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/qml/Buttons.qml
Show All 31 Lines | 30 | KDecoration.Bridge { | |||
---|---|---|---|---|---|
32 | plugin: "org.kde.breeze" | 32 | plugin: "org.kde.breeze" | ||
33 | } | 33 | } | ||
34 | KDecoration.Settings { | 34 | KDecoration.Settings { | ||
35 | id: settingsItem | 35 | id: settingsItem | ||
36 | bridge: bridgeItem.bridge | 36 | bridge: bridgeItem.bridge | ||
37 | } | 37 | } | ||
38 | Rectangle { | 38 | Rectangle { | ||
39 | anchors.fill: parent | 39 | anchors.fill: parent | ||
40 | anchors.topMargin: units.gridUnit / 2 | | |||
41 | border.width: Math.ceil(units.gridUnit / 16.0) | 40 | border.width: Math.ceil(units.gridUnit / 16.0) | ||
42 | color: backgroundColor; | 41 | border.color: highlightColor | ||
43 | border.color: highlightColor; | 42 | color: baseColor | ||
44 | ColumnLayout { | 43 | ColumnLayout { | ||
45 | id: layout | 44 | id: layout | ||
46 | width: parent.width | 45 | width: parent.width | ||
47 | height: titlebarRect.height + availableGrid.height + dragHint.height + 5*layout.spacing | 46 | height: titlebarRect.height + availableGrid.height + dragHint.height + 5*layout.spacing | ||
48 | Rectangle { | 47 | Rectangle { | ||
49 | id: titlebarRect | 48 | id: titlebarRect | ||
50 | height: buttonPreviewRow.height + units.smallSpacing | 49 | height: buttonPreviewRow.height + units.smallSpacing | ||
51 | Layout.fillWidth: true | | |||
52 | border.width: Math.ceil(units.gridUnit / 16.0) | 50 | border.width: Math.ceil(units.gridUnit / 16.0) | ||
53 | border.color: highlightColor | 51 | border.color: highlightColor | ||
54 | color: backgroundColor; | 52 | color: backgroundColor | ||
53 | Layout.fillWidth: true | ||||
54 | Layout.topMargin: -border.width // prevent a double top border | ||||
davidedmundson: what's this about? | |||||
Without this, the top border of the fake window is double thickness, since it's actually two borders (the whole window + the titlebar). vpilo: Without this, the top border of the fake window is double thickness, since it's actually two… | |||||
55 | RowLayout { | 55 | RowLayout { | ||
56 | id: buttonPreviewRow | 56 | id: buttonPreviewRow | ||
57 | anchors.top: parent.top; | 57 | anchors.top: parent.top; | ||
58 | anchors.left: parent.left; | 58 | anchors.left: parent.left; | ||
59 | anchors.right: parent.right; | 59 | anchors.right: parent.right; | ||
60 | anchors.margins: units.smallSpacing / 2 | 60 | anchors.margins: units.smallSpacing / 2 | ||
61 | height: Math.max(units.iconSizes.small, titlebar.implicitHeight) + units.smallSpacing/2 | 61 | height: Math.max(units.iconSizes.small, titlebar.implicitHeight) + units.smallSpacing/2 | ||
62 | ButtonGroup { | 62 | ButtonGroup { | ||
Show All 13 Lines | |||||
76 | ButtonGroup { | 76 | ButtonGroup { | ||
77 | id: rightButtonsView | 77 | id: rightButtonsView | ||
78 | height: buttonPreviewRow.height | 78 | height: buttonPreviewRow.height | ||
79 | model: rightButtons | 79 | model: rightButtons | ||
80 | key: "decoButtonRight" | 80 | key: "decoButtonRight" | ||
81 | } | 81 | } | ||
82 | } | 82 | } | ||
83 | DropArea { | 83 | DropArea { | ||
84 | anchors.fill: buttonPreviewRow | 84 | anchors { | ||
85 | fill: titlebarRect | ||||
86 | leftMargin: -units.iconSizes.small | ||||
87 | topMargin: -units.iconSizes.small | ||||
88 | rightMargin: +units.iconSizes.small | ||||
89 | bottomMargin: +units.iconSizes.small | ||||
90 | } | ||||
85 | keys: [ "decoButtonAdd", "decoButtonRight", "decoButtonLeft" ] | 91 | keys: [ "decoButtonAdd", "decoButtonRight", "decoButtonLeft" ] | ||
86 | onEntered: { | 92 | onEntered: { | ||
87 | drag.accept(); | 93 | drag.accept(); | ||
88 | } | 94 | } | ||
89 | onDropped: { | 95 | onDropped: { | ||
90 | var view = undefined; | 96 | var view = undefined; | ||
91 | var left = drag.x - (leftButtonsView.x + leftButtonsView.width); | 97 | var left = drag.x - (leftButtonsView.x + leftButtonsView.width); | ||
92 | var right = drag.x - rightButtonsView.x; | 98 | var right = drag.x - rightButtonsView.x; | ||
Show All 25 Lines | 114 | } else if (drop.keys.indexOf("decoButtonLeft") != -1) { | |||
118 | } | 124 | } | ||
119 | } else if (drop.keys.indexOf("decoButtonRight") != -1) { | 125 | } else if (drop.keys.indexOf("decoButtonRight") != -1) { | ||
120 | if (view == rightButtonsView) { | 126 | if (view == rightButtonsView) { | ||
121 | // move in same view | 127 | // move in same view | ||
122 | if (index != drag.source.itemIndex) { | 128 | if (index != drag.source.itemIndex) { | ||
123 | drag.source.buttonsModel.move(drag.source.itemIndex, index); | 129 | drag.source.buttonsModel.move(drag.source.itemIndex, index); | ||
124 | } | 130 | } | ||
125 | } else { | 131 | } else { | ||
126 | // move to right view | 132 | // move to left view | ||
127 | view.model.add(index, drag.source.type); | 133 | view.model.add(index, drag.source.type); | ||
128 | drag.source.buttonsModel.remove(drag.source.itemIndex); | 134 | drag.source.buttonsModel.remove(drag.source.itemIndex); | ||
129 | } | 135 | } | ||
130 | } | 136 | } | ||
131 | } | 137 | } | ||
132 | } | 138 | } | ||
133 | } | 139 | } | ||
134 | Text { | | |||
135 | id: iCannotBelieveIDoThis | | |||
136 | text: "gnarf" | | |||
137 | visible: false | | |||
138 | } | | |||
139 | GridView { | 140 | GridView { | ||
140 | id: availableGrid | 141 | id: availableGrid | ||
141 | Layout.fillWidth: true | 142 | Layout.fillWidth: true | ||
142 | model: availableButtons | 143 | model: availableButtons | ||
143 | interactive: false | 144 | interactive: false | ||
144 | cellWidth: iconLabel.implicitWidth | 145 | height: Math.ceil(cellHeight * 3) | ||
It still makes sense to calculate this from the icon and text like before. (Though with QFontMetrics instead of fake Text elements) davidedmundson: It still makes sense to calculate this from the icon and text like before.
(Though with… | |||||
vpilo: How so? From kcm.cpp via a property? Or the TextMetrics QML type? | |||||
145 | cellHeight: units.iconSizes.small + iCannotBelieveIDoThis.implicitHeight + 4*units.smallSpacing | | |||
146 | height: Math.ceil(cellHeight * 2.5) | | |||
147 | delegate: Item { | 146 | delegate: Item { | ||
148 | id: availableDelegate | 147 | id: availableDelegate | ||
148 | Layout.margins: units.gridUnit | ||||
149 | width: availableGrid.cellWidth | 149 | width: availableGrid.cellWidth | ||
150 | height: availableGrid.cellHeight | 150 | height: availableGrid.cellHeight | ||
151 | opacity: (leftButtonsView.dragging || rightButtonsView.dragging) ? 0.25 : 1.0 | 151 | opacity: (leftButtonsView.dragging || rightButtonsView.dragging) ? 0.25 : 1.0 | ||
152 | KDecoration.Button { | 152 | KDecoration.Button { | ||
153 | id: availableButton | 153 | id: availableButton | ||
154 | anchors.centerIn: Drag.active ? undefined : parent | 154 | anchors.centerIn: Drag.active ? undefined : parent | ||
155 | bridge: bridgeItem.bridge | 155 | bridge: bridgeItem.bridge | ||
156 | settings: settingsItem | 156 | settings: settingsItem | ||
157 | type: model["button"] | 157 | type: model["button"] | ||
158 | width: units.iconSizes.small | 158 | width: units.iconSizes.small | ||
159 | height: units.iconSizes.small | 159 | height: units.iconSizes.small | ||
160 | Drag.keys: [ "decoButtonAdd" ] | 160 | Drag.keys: [ "decoButtonAdd" ] | ||
161 | Drag.active: dragArea.drag.active | 161 | Drag.active: dragArea.drag.active | ||
162 | } | 162 | } | ||
163 | QQC2.Label { | 163 | QQC2.Label { | ||
164 | id: iconLabel | 164 | id: iconLabel | ||
165 | text: model["display"] | 165 | text: model["display"] | ||
166 | horizontalAlignment: Text.AlignHCenter | 166 | horizontalAlignment: Text.AlignHCenter | ||
167 | verticalAlignment: Text.AlignTop | ||||
167 | anchors.bottom: parent.bottom | 168 | anchors.bottom: parent.bottom | ||
168 | anchors.left: parent.left | 169 | anchors.left: parent.left | ||
169 | anchors.right: parent.right | 170 | anchors.right: parent.right | ||
170 | elide: Text.ElideRight | 171 | elide: Text.ElideRight | ||
171 | wrapMode: Text.NoWrap | 172 | wrapMode: Text.Wrap | ||
173 | height: 2 * dragHint.implicitHeight + lineHeight | ||||
172 | } | 174 | } | ||
173 | MouseArea { | 175 | MouseArea { | ||
174 | id: dragArea | 176 | id: dragArea | ||
175 | anchors.fill: parent | 177 | anchors.fill: availableButton | ||
176 | drag.target: availableButton | 178 | drag.target: availableButton | ||
177 | cursorShape: Qt.PointingHandCursor | 179 | cursorShape: Qt.SizeAllCursor | ||
ngraham: Same | |||||
178 | onReleased: { | 180 | onReleased: { | ||
179 | if (availableButton.Drag.target) { | 181 | if (availableButton.Drag.target) { | ||
180 | availableButton.Drag.drop(); | 182 | availableButton.Drag.drop(); | ||
181 | } else { | 183 | } else { | ||
182 | availableButton.Drag.cancel(); | 184 | availableButton.Drag.cancel(); | ||
183 | } | 185 | } | ||
184 | } | 186 | } | ||
185 | } | 187 | } | ||
186 | } | 188 | } | ||
187 | DropArea { | 189 | DropArea { | ||
188 | anchors.fill: parent | 190 | anchors.fill: parent | ||
189 | keys: [ "decoButtonRemove" ] | 191 | keys: [ "decoButtonRemove" ] | ||
190 | onEntered: { | 192 | onEntered: { | ||
191 | drag.accept(); | 193 | drag.accept(); | ||
192 | } | 194 | } | ||
193 | onDropped: { | 195 | onDropped: { | ||
194 | drag.source.buttonsModel.remove(drag.source.itemIndex); | 196 | drag.source.buttonsModel.remove(drag.source.itemIndex); | ||
195 | } | 197 | } | ||
196 | ColumnLayout { | 198 | ColumnLayout { | ||
197 | anchors.centerIn: parent | 199 | anchors.centerIn: parent | ||
198 | visible: leftButtonsView.dragging || rightButtonsView.dragging | 200 | opacity: (leftButtonsView.dragging || rightButtonsView.dragging) ? 1.0 : 0.0 | ||
199 | QQC2.Label { | 201 | QQC2.Label { | ||
200 | text: i18n("Drop here to remove button") | 202 | text: i18n("Drop here to remove button") | ||
201 | font.weight: Font.Bold | 203 | font.weight: Font.Bold | ||
204 | Layout.bottomMargin: units.smallSpacing | ||||
202 | } | 205 | } | ||
203 | KQuickControlsAddons.QIconItem { | 206 | KQuickControlsAddons.QIconItem { | ||
204 | id: icon | 207 | id: icon | ||
205 | width: 64 | 208 | width: units.iconSizes.smallMedium | ||
206 | height: 64 | 209 | height: units.iconSizes.smallMedium | ||
Maybe medium would be more appropriate here? smallMedium is a bit, well, small! ngraham: Maybe medium would be more appropriate here? `smallMedium` is a bit, well, small! | |||||
I've got another patch lined up to take care of the sizes, among other things.. First things first :) vpilo: I've got another patch lined up to take care of the sizes, among other things.. First things… | |||||
207 | icon: "list-remove" | 210 | icon: "emblem-remove" | ||
208 | Layout.alignment: Qt.AlignHCenter | 211 | Layout.alignment: Qt.AlignHCenter | ||
209 | } | 212 | } | ||
210 | Item { | 213 | Item { | ||
211 | Layout.fillHeight: true | 214 | Layout.fillHeight: true | ||
212 | } | 215 | } | ||
213 | } | 216 | } | ||
214 | } | 217 | } | ||
215 | } | 218 | } | ||
216 | Text { | 219 | Text { | ||
217 | id: dragHint | 220 | id: dragHint | ||
218 | visible: !(leftButtonsView.dragging || rightButtonsView.dragging || availableGrid.dragging) | 221 | opacity: (leftButtonsView.dragging || rightButtonsView.dragging || availableGrid.dragging) ? 0.0 : 0.50 | ||
219 | Layout.fillWidth: true | 222 | Layout.fillWidth: true | ||
220 | color: backgroundColor; | 223 | Layout.bottomMargin: units.smallSpacing | ||
221 | opacity: 0.66 | | |||
222 | horizontalAlignment: Text.AlignHCenter | 224 | horizontalAlignment: Text.AlignHCenter | ||
223 | verticalAlignment: Text.AlignTop | 225 | verticalAlignment: Text.AlignTop | ||
226 | wrapMode: Text.NoWrap | ||||
224 | text: i18n("Drag buttons between here and the titlebar") | 227 | text: i18n("Drag buttons between here and the titlebar") | ||
225 | } | 228 | } | ||
226 | } | 229 | } | ||
227 | } | 230 | } | ||
228 | } | 231 | } |
what's this about?