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 | ||||
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 | cellWidth: iconLabel.implicitWidth | ||
145 | cellHeight: units.iconSizes.small + iCannotBelieveIDoThis.implicitHeight + 4*units.smallSpacing | 146 | cellHeight: 2*units.iconSizes.small + dragHint.implicitHeight | ||
146 | height: Math.ceil(cellHeight * 2.5) | 147 | height: Math.ceil(cellHeight * 2.5) | ||
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? | |||||
147 | delegate: Item { | 148 | delegate: Item { | ||
148 | id: availableDelegate | 149 | id: availableDelegate | ||
149 | width: availableGrid.cellWidth | 150 | width: availableGrid.cellWidth | ||
150 | height: availableGrid.cellHeight | 151 | height: availableGrid.cellHeight | ||
151 | opacity: (leftButtonsView.dragging || rightButtonsView.dragging) ? 0.25 : 1.0 | 152 | opacity: (leftButtonsView.dragging || rightButtonsView.dragging) ? 0.25 : 1.0 | ||
152 | KDecoration.Button { | 153 | KDecoration.Button { | ||
153 | id: availableButton | 154 | id: availableButton | ||
154 | anchors.centerIn: Drag.active ? undefined : parent | 155 | anchors.centerIn: Drag.active ? undefined : parent | ||
Show All 14 Lines | 164 | QQC2.Label { | |||
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.NoWrap | ||
172 | } | 173 | } | ||
173 | MouseArea { | 174 | MouseArea { | ||
174 | id: dragArea | 175 | id: dragArea | ||
175 | anchors.fill: parent | 176 | anchors.fill: parent | ||
176 | drag.target: availableButton | 177 | drag.target: availableButton | ||
177 | cursorShape: Qt.PointingHandCursor | 178 | cursorShape: Qt.DragMoveCursor | ||
ngraham: Same | |||||
178 | onReleased: { | 179 | onReleased: { | ||
179 | if (availableButton.Drag.target) { | 180 | if (availableButton.Drag.target) { | ||
180 | availableButton.Drag.drop(); | 181 | availableButton.Drag.drop(); | ||
181 | } else { | 182 | } else { | ||
182 | availableButton.Drag.cancel(); | 183 | availableButton.Drag.cancel(); | ||
183 | } | 184 | } | ||
184 | } | 185 | } | ||
185 | } | 186 | } | ||
186 | } | 187 | } | ||
187 | DropArea { | 188 | DropArea { | ||
188 | anchors.fill: parent | 189 | anchors.fill: parent | ||
189 | keys: [ "decoButtonRemove" ] | 190 | keys: [ "decoButtonRemove" ] | ||
190 | onEntered: { | 191 | onEntered: { | ||
191 | drag.accept(); | 192 | drag.accept(); | ||
192 | } | 193 | } | ||
193 | onDropped: { | 194 | onDropped: { | ||
194 | drag.source.buttonsModel.remove(drag.source.itemIndex); | 195 | drag.source.buttonsModel.remove(drag.source.itemIndex); | ||
195 | } | 196 | } | ||
196 | ColumnLayout { | 197 | ColumnLayout { | ||
197 | anchors.centerIn: parent | 198 | anchors.centerIn: parent | ||
198 | visible: leftButtonsView.dragging || rightButtonsView.dragging | 199 | opacity: (leftButtonsView.dragging || rightButtonsView.dragging) ? 1.0 : 0.0 | ||
199 | QQC2.Label { | 200 | QQC2.Label { | ||
200 | text: i18n("Drop here to remove button") | 201 | text: i18n("Drop here to remove button") | ||
201 | font.weight: Font.Bold | 202 | font.weight: Font.Bold | ||
202 | } | 203 | } | ||
203 | KQuickControlsAddons.QIconItem { | 204 | KQuickControlsAddons.QIconItem { | ||
204 | id: icon | 205 | id: icon | ||
205 | width: 64 | 206 | width: 64 | ||
206 | height: 64 | 207 | height: 64 | ||
207 | icon: "list-remove" | 208 | icon: "list-remove" | ||
208 | Layout.alignment: Qt.AlignHCenter | 209 | Layout.alignment: Qt.AlignHCenter | ||
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… | |||||
209 | } | 210 | } | ||
210 | Item { | 211 | Item { | ||
211 | Layout.fillHeight: true | 212 | Layout.fillHeight: true | ||
212 | } | 213 | } | ||
213 | } | 214 | } | ||
214 | } | 215 | } | ||
215 | } | 216 | } | ||
216 | Text { | 217 | Text { | ||
217 | id: dragHint | 218 | id: dragHint | ||
218 | visible: !(leftButtonsView.dragging || rightButtonsView.dragging || availableGrid.dragging) | 219 | opacity: (leftButtonsView.dragging || rightButtonsView.dragging || availableGrid.dragging) ? 0.0 : 0.50 | ||
219 | Layout.fillWidth: true | 220 | Layout.fillWidth: true | ||
220 | color: backgroundColor; | | |||
221 | opacity: 0.66 | | |||
222 | horizontalAlignment: Text.AlignHCenter | 221 | horizontalAlignment: Text.AlignHCenter | ||
223 | verticalAlignment: Text.AlignTop | 222 | verticalAlignment: Text.AlignTop | ||
224 | text: i18n("Drag buttons between here and the titlebar") | 223 | text: i18n("Drag buttons between here and the titlebar") | ||
225 | } | 224 | } | ||
226 | } | 225 | } | ||
227 | } | 226 | } | ||
228 | } | 227 | } |
what's this about?