Changeset View
Changeset View
Standalone View
Standalone View
applets/colorpicker/package/contents/ui/main.qml
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Line(s) | 173 | if (event.mimeData.hasColor()) { | |||
---|---|---|---|---|---|
174 | addColorToHistory(event.mimeData.color) | 174 | addColorToHistory(event.mimeData.color) | ||
175 | } else if (ColorPicker.Utils.isValidColor(event.mimeData.text)) { | 175 | } else if (ColorPicker.Utils.isValidColor(event.mimeData.text)) { | ||
176 | addColorToHistory(event.mimeData.text) | 176 | addColorToHistory(event.mimeData.text) | ||
177 | } | 177 | } | ||
178 | containsAcceptableDrag = false | 178 | containsAcceptableDrag = false | ||
179 | } | 179 | } | ||
180 | 180 | | |||
181 | PlasmaComponents.ToolButton { | 181 | PlasmaComponents.ToolButton { | ||
182 | id: colorButton | ||||
182 | anchors.fill: parent | 183 | anchors.fill: parent | ||
183 | tooltip: i18nc("@info:tooltip", "Color options") | 184 | tooltip: i18nc("@info:tooltip", "Color options") | ||
184 | onClicked: plasmoid.expanded = !plasmoid.expanded | 185 | onClicked: plasmoid.expanded = !plasmoid.expanded | ||
185 | // indicate viable drag... | 186 | // indicate viable drag... | ||
186 | checked: dropArea.containsAcceptableDrag | 187 | checked: dropArea.containsAcceptableDrag || colorButtonDragger.pressed | ||
187 | checkable: checked | 188 | checkable: checked | ||
188 | 189 | | |||
189 | Rectangle { | 190 | Rectangle { | ||
190 | id: colorCircle | 191 | id: colorCircle | ||
191 | anchors.centerIn: parent | 192 | anchors.centerIn: parent | ||
192 | // try to match the color-picker icon in size | 193 | // try to match the color-picker icon in size | ||
193 | width: units.roundToIconSize(pickerIcon.width) * 0.75 | 194 | width: units.roundToIconSize(pickerIcon.width) * 0.75 | ||
194 | height: units.roundToIconSize(pickerIcon.height) * 0.75 | 195 | height: units.roundToIconSize(pickerIcon.height) * 0.75 | ||
Show All 24 Lines | 216 | width: { | |||
219 | if (contrast > 3 && colorCircle.color.a > 0.5) { | 220 | if (contrast > 3 && colorCircle.color.a > 0.5) { | ||
220 | return 0; | 221 | return 0; | ||
221 | } else { | 222 | } else { | ||
222 | return Math.round(Math.max(units.devicePixelRatio, width / 20)); | 223 | return Math.round(Math.max(units.devicePixelRatio, width / 20)); | ||
223 | } | 224 | } | ||
224 | } | 225 | } | ||
225 | } | 226 | } | ||
226 | } | 227 | } | ||
228 | | ||||
229 | MouseArea { | ||||
230 | id: colorButtonDragger | ||||
231 | anchors.fill: parent | ||||
232 | onClicked: colorButton.clicked() | ||||
233 | | ||||
234 | onPressed: colorCircle.grabToImage(function (result) { | ||||
235 | Drag.imageSource = result.url; | ||||
236 | }); | ||||
237 | | ||||
238 | drag.target: colorCircle | ||||
239 | Drag.dragType: Drag.Automatic | ||||
240 | Drag.active: drag.active | ||||
241 | Drag.mimeData: { | ||||
242 | "application/x-color": colorCircle.color, | ||||
243 | "text/plain": Logic.formatColor(colorCircle.color, root.defaultFormat) | ||||
244 | } | ||||
245 | } | ||||
227 | } | 246 | } | ||
228 | } | 247 | } | ||
229 | } | 248 | } | ||
230 | 249 | | |||
231 | Plasmoid.fullRepresentation: GridView { | 250 | Plasmoid.fullRepresentation: GridView { | ||
232 | id: fullRoot | 251 | id: fullRoot | ||
233 | 252 | | |||
234 | readonly property int columns: 3 | 253 | readonly property int columns: 3 | ||
▲ Show 20 Lines • Show All 150 Lines • Show Last 20 Lines |