Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/package/contents/ui/Buttons.qml
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | 104 | onDropped: { | |||
---|---|---|---|---|---|
117 | var index = 0 | 117 | var index = 0 | ||
118 | for(var childIndex = 0 ; childIndex < (view.count - 1) ; childIndex++) { | 118 | for(var childIndex = 0 ; childIndex < (view.count - 1) ; childIndex++) { | ||
119 | var child = view.contentItem.children[childIndex] | 119 | var child = view.contentItem.children[childIndex] | ||
120 | if (child.x > point.x) { | 120 | if (child.x > point.x) { | ||
121 | break | 121 | break | ||
122 | } | 122 | } | ||
123 | index = childIndex + 1 | 123 | index = childIndex + 1 | ||
124 | } | 124 | } | ||
125 | if (drop.keys.indexOf("decoButtonAdd") != -1) { | 125 | if (drop.keys.indexOf("decoButtonAdd") !== -1) { | ||
126 | view.model.add(index, drag.source.type); | 126 | view.model.add(index, drag.source.type); | ||
127 | } else if (drop.keys.indexOf("decoButtonLeft") != -1) { | 127 | } else if (drop.keys.indexOf("decoButtonLeft") !== -1) { | ||
128 | if (view == leftButtonsView) { | 128 | if (view === leftButtonsView) { | ||
129 | // move in same view | 129 | // move in same view | ||
130 | if (index != drag.source.itemIndex) { | 130 | if (index !== drag.source.itemIndex) { | ||
131 | drag.source.buttonsModel.move(drag.source.itemIndex, index); | 131 | drag.source.buttonsModel.move(drag.source.itemIndex, index); | ||
132 | } | 132 | } | ||
133 | } else { | 133 | } else { | ||
134 | // move to right view | 134 | // move to right view | ||
135 | view.model.add(index, drag.source.type); | 135 | view.model.add(index, drag.source.type); | ||
136 | drag.source.buttonsModel.remove(drag.source.itemIndex); | 136 | drag.source.buttonsModel.remove(drag.source.itemIndex); | ||
137 | } | 137 | } | ||
138 | } else if (drop.keys.indexOf("decoButtonRight") != -1) { | 138 | } else if (drop.keys.indexOf("decoButtonRight") !== -1) { | ||
139 | if (view == rightButtonsView) { | 139 | if (view === rightButtonsView) { | ||
140 | // move in same view | 140 | // move in same view | ||
141 | if (index != drag.source.itemIndex) { | 141 | if (index !== drag.source.itemIndex) { | ||
142 | drag.source.buttonsModel.move(drag.source.itemIndex, index); | 142 | drag.source.buttonsModel.move(drag.source.itemIndex, index); | ||
143 | } | 143 | } | ||
144 | } else { | 144 | } else { | ||
145 | // move to left view | 145 | // move to left view | ||
146 | view.model.add(index, drag.source.type); | 146 | view.model.add(index, drag.source.type); | ||
147 | drag.source.buttonsModel.remove(drag.source.itemIndex); | 147 | drag.source.buttonsModel.remove(drag.source.itemIndex); | ||
148 | } | 148 | } | ||
149 | } | 149 | } | ||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 223 | Kirigami.Heading { | |||
227 | anchors.centerIn: parent | 227 | anchors.centerIn: parent | ||
228 | opacity: (leftButtonsView.dragging || rightButtonsView.dragging) ? 1.0 : 0.0 | 228 | opacity: (leftButtonsView.dragging || rightButtonsView.dragging) ? 1.0 : 0.0 | ||
229 | } | 229 | } | ||
230 | } | 230 | } | ||
231 | } | 231 | } | ||
232 | Text { | 232 | Text { | ||
233 | id: dragHint | 233 | id: dragHint | ||
234 | color: palette.windowText | 234 | color: palette.windowText | ||
235 | opacity: (leftButtonsView.dragging || rightButtonsView.dragging || availableButtonsGrid.dragging) ? 0.0 : 1.0 | 235 | opacity: (leftButtonsView.dragging || rightButtonsView.dragging || availableButtonsGrid.dragging) ? 0.0 : enabled ? 1.0 : 0.3 | ||
ervin: I think it'd be worth splitting that up in several sub-expressions using properties just to… | |||||
236 | Layout.fillWidth: true | 236 | Layout.fillWidth: true | ||
237 | Layout.topMargin: titleBarSpacing | 237 | Layout.topMargin: titleBarSpacing | ||
238 | Layout.bottomMargin: titleBarSpacing | 238 | Layout.bottomMargin: titleBarSpacing | ||
239 | horizontalAlignment: Text.AlignHCenter | 239 | horizontalAlignment: Text.AlignHCenter | ||
240 | wrapMode: Text.NoWrap | 240 | wrapMode: Text.NoWrap | ||
241 | text: i18n("Drag buttons between here and the titlebar") | 241 | text: i18n("Drag buttons between here and the titlebar") | ||
242 | } | 242 | } | ||
243 | } | 243 | } | ||
244 | } | 244 | } | ||
245 | } | 245 | } |
I think it'd be worth splitting that up in several sub-expressions using properties just to improve readability.