summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Uwe Broulik <[email protected]>2016-12-13 14:38:00 +0100
committerKai Uwe Broulik <[email protected]>2016-12-13 14:38:00 +0100
commit682de67634f2f822a0aab967936d0ec9f59e97f6 (patch)
treed565a0ab7f5806a1c429ca2eb2d7eb6c96290a63
parenta08ef2ea5a93dbde3effa807e639242a6acbd90b (diff)
[Color Picker] Add color dialog to context menu
Should you ever feel the urge to mix some colors...
-rw-r--r--applets/colorpicker/package/contents/ui/main.qml30
1 files changed, 22 insertions, 8 deletions
diff --git a/applets/colorpicker/package/contents/ui/main.qml b/applets/colorpicker/package/contents/ui/main.qml
index d5a53e9..b45d004 100644
--- a/applets/colorpicker/package/contents/ui/main.qml
+++ b/applets/colorpicker/package/contents/ui/main.qml
@@ -19,6 +19,7 @@
import QtQuick 2.2
import QtQuick.Controls 1.1 as QtControls
import QtQuick.Layouts 1.1
+import QtQuick.Dialogs 1.0 as QtDialogs
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
@@ -53,17 +54,25 @@ Item {
plasmoid.configuration.history = history.slice(0, 9)
}
+ function colorPicked(color) {
+ if (color != recentColor) {
+ addColorToHistory(color)
+ }
+
+ if (plasmoid.configuration.autoClipboard) {
+ picker.copyToClipboard(Logic.formatColor(color, root.defaultFormat))
+ }
+ }
+
ColorPicker.GrabWidget {
id: picker
- onCurrentColorChanged: {
- if (currentColor != recentColor) {
- addColorToHistory(currentColor)
- }
+ onCurrentColorChanged: colorPicked(currentColor)
+ }
- if (plasmoid.configuration.autoClipboard) {
- picker.copyToClipboard(Logic.formatColor(currentColor, root.defaultFormat))
- }
- }
+ QtDialogs.ColorDialog {
+ id: colorDialog
+ color: recentColor
+ onColorChanged: colorPicked(color)
}
// prevents the popup from actually opening, needs to be queued
@@ -86,7 +95,12 @@ Item {
plasmoid.configuration.history = []
}
+ function action_colordialog() {
+ colorDialog.open()
+ }
+
Component.onCompleted: {
+ plasmoid.setAction("colordialog", i18n("Open Color Dialog"), "color-management")
plasmoid.setAction("clear", i18n("Clear History"), "edit-clear-history")
}