From 582b59dae29bda334cd35c72c4b2bd2e8fcf0314 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 15 Jan 2019 15:14:51 +0200 Subject: [PATCH] enable/disable colorizing from user --when the user has enabled the monochrome colorizing in that case in applet options there is now a new option in order for the user to choose if wants or not that applet to be colorized. Such an example are colorful applets that lose their proper appearance through monochrome option. --- app/layout.cpp | 9 ++-- .../package/contents/code/LayoutManager.js | 43 +++++++++++++++---- containment/package/contents/config/main.xml | 3 ++ .../package/contents/ui/ConfigOverlay.qml | 16 ++++++- .../package/contents/ui/applet/AppletItem.qml | 6 ++- containment/package/contents/ui/main.qml | 4 +- 6 files changed, 66 insertions(+), 15 deletions(-) diff --git a/app/layout.cpp b/app/layout.cpp index 48e63d697..7796a2767 100644 --- a/app/layout.cpp +++ b/app/layout.cpp @@ -1375,9 +1375,12 @@ QString Layout::newUniqueIdsLayoutFromFile(QString file) //! update applet ids in their containment order and in MultipleLayouts update also the layoutId foreach (auto cId, investigate_conts.groupList()) { - //! Update (appletOrder) and (lockedZoomApplets) - for (int i = 1; i <= 2; ++i) { - QString settingStr = (i == 1) ? "appletOrder" : "lockedZoomApplets"; + //! Update options that contain applet ids + //! (appletOrder) and (lockedZoomApplets) and (userBlocksColorizingApplets) + QStringList options; + options << "appletOrder" << "lockedZoomApplets" << "userBlocksColorizingApplets"; + + foreach (auto settingStr, options) { QString order1 = investigate_conts.group(cId).group("General").readEntry(settingStr, QString()); if (!order1.isEmpty()) { diff --git a/containment/package/contents/code/LayoutManager.js b/containment/package/contents/code/LayoutManager.js index 2179bef0a..85a60f553 100644 --- a/containment/package/contents/code/LayoutManager.js +++ b/containment/package/contents/code/LayoutManager.js @@ -88,7 +88,7 @@ function restore() { //rewrite, so if in the orders there were now invalid ids or if some were missing creates a correct list instead save(); - restoreLocks(); + restoreOptions(); inRestore = false; @@ -96,8 +96,20 @@ function restore() { root.updateLayouts(); } -function restoreLocks() { - var configString = String(plasmoid.configuration.lockedZoomApplets) +function restoreOptions() { + restoreOption("lockedZoomApplets"); + restoreOption("userBlocksColorizingApplets"); +} + +function restoreOption(option) { + var configString; + + if (option === "lockedZoomApplets") { + configString = String(plasmoid.configuration.lockedZoomApplets); + } else if (option === "userBlocksColorizingApplets") { + configString = String(plasmoid.configuration.userBlocksColorizingApplets); + } + //array, a cell for encoded item order var itemsArray = configString.split(";"); @@ -106,7 +118,11 @@ function restoreLocks() { var child = layout.children[j]; if (child.applet && (child.applet.id == itemsArray[i])) { - child.lockZoom = true; + if (option === "lockedZoomApplets") { + child.lockZoom = true; + } else if (option === "userBlocksColorizingApplets") { + child.userBlocksColorizing = true; + } } } } @@ -170,18 +186,29 @@ function save() { plasmoid.configuration.appletOrder = ids.join(';'); } -function saveLocks() { +function saveOptions() { + saveOption("lockedZoomApplets"); + saveOption("userBlocksColorizingApplets"); +} + +function saveOption(option) { var ids = new Array(); for (var i = 0; i < layout.children.length; ++i) { var child = layout.children[i]; - if (child.applet && child.lockZoom) { + if (child.applet + && (option === "lockedZoomApplets" && child.lockZoom) + || (option === "userBlocksColorizingApplets" && child.userBlocksColorizing)) { ids.push(child.applet.id); } } - plasmoid.configuration.lockedZoomApplets = ids.join(';'); -} + if (option === "lockedZoomApplets") { + plasmoid.configuration.lockedZoomApplets = ids.join(';'); + } else if (option === "userBlocksColorizingApplets") { + plasmoid.configuration.userBlocksColorizingApplets = ids.join(';'); + } +} function removeApplet (applet) { for (var i = layout.children.length - 1; i >= 0; --i) { diff --git a/containment/package/contents/config/main.xml b/containment/package/contents/config/main.xml index e5da2eab5..69365596f 100644 --- a/containment/package/contents/config/main.xml +++ b/containment/package/contents/config/main.xml @@ -12,6 +12,9 @@ + + + diff --git a/containment/package/contents/ui/ConfigOverlay.qml b/containment/package/contents/ui/ConfigOverlay.qml index 9247c9235..c83a2c497 100644 --- a/containment/package/contents/ui/ConfigOverlay.qml +++ b/containment/package/contents/ui/ConfigOverlay.qml @@ -151,6 +151,7 @@ MouseArea { handle.height = currentApplet.height; lockButton.checked = currentApplet.lockZoom; + colorizingButton.checked = !currentApplet.userBlocksColorizing; repositionHandler.restart(); } @@ -411,6 +412,7 @@ MouseArea { lockButton.visible = !currentApplet.isInternalViewSplitter && (currentApplet.applet.pluginName !== "org.kde.plasma.systemtray") && (currentApplet.applet.pluginName !== root.plasmoidName) && !currentApplet.isSeparator + colorizingButton.visible = root.forceColorizer && !currentApplet.appletBlocksColorizing; label.text = currentApplet.isInternalViewSplitter ? i18n("Justify Splitter") : currentApplet.applet.title; } else { @@ -418,6 +420,7 @@ MouseArea { configureButton.visible = false; closeButton.visible = false; lockButton.visible = false; + colorizingButton.visible = false; label.text = ruler.tooltip; tooltip.visible = true; @@ -478,7 +481,18 @@ MouseArea { when: currentApplet === ruler value: ruler.tooltip } + } + + PlasmaComponents.ToolButton{ + id: colorizingButton + checkable: true + iconSource: "color-picker" + tooltip: i18n("Enable/Disable painting for this applet") + onCheckedChanged: { + currentApplet.userBlocksColorizing = !checked; + root.layoutManagerSaveOptions(); + } } PlasmaComponents.ToolButton{ @@ -489,7 +503,7 @@ MouseArea { onCheckedChanged: { currentApplet.lockZoom = checked; - root.layoutManagerSaveLocks(); + root.layoutManagerSaveOptions(); } } diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index 7d3b2a708..3f508a709 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -57,6 +57,9 @@ Item { else return false; } + + property bool userBlocksColorizing: false + property bool appletBlocksColorizing: communicator.disableLatteSideColoring property bool showZoomed: false property bool lockZoom: false property bool isExpanded: applet && applet.status >= PlasmaCore.Types.NeedsAttentionStatus @@ -567,7 +570,8 @@ Item { opacity: mustBeShown ? 1 : 0 readonly property bool mustBeShown: colorizerManager.mustBeShown - && !communicator.disableLatteSideColoring + && !container.userBlocksColorizing + && !container.appletBlocksColorizing Behavior on opacity { NumberAnimation { diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 79fe00933..f17ea4c12 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -1110,8 +1110,8 @@ DragDrop.DropArea { LayoutManager.save(); } - function layoutManagerSaveLocks() { - LayoutManager.saveLocks(); + function layoutManagerSaveOptions() { + LayoutManager.saveOptions(); } function mouseInCanBeHoveredApplet(){