[krita] /: FEATURE: Actions for toggling layer visibility, lock, alpha inherit and alpha lock
Boudewijn Rempt
null at kde.org
Thu Jun 8 07:22:09 UTC 2017
Git commit c2b3000ea5b3d3a097bc21b4aa52d193e6ce19f4 by Boudewijn Rempt.
Committed on 08/06/2017 at 07:20.
Pushed by rempt into branch 'master'.
FEATURE: Actions for toggling layer visibility, lock, alpha inherit and alpha lock
CCMAIL:kimageshop at kde.org
BUG:376946
The actions don't have shortcuts by default, but are in the layer
menu.
Patch by Valeriy Malov
M +48 -24 krita/krita.action
M +80 -23 libs/ui/kis_node_manager.cpp
M +5 -2 libs/ui/kis_node_manager.h
M +5 -0 plugins/dockers/defaultdockers/kis_layer_box.cpp
https://commits.kde.org/krita/c2b3000ea5b3d3a097bc21b4aa52d193e6ce19f4
diff --git a/krita/krita.action b/krita/krita.action
index ec10ab6977f..90b5abdf15b 100644
--- a/krita/krita.action
+++ b/krita/krita.action
@@ -2262,6 +2262,54 @@
<isCheckable>true</isCheckable>
<statusTip></statusTip>
</Action>
+ <Action name="toggle_layer_lock">
+ <icon>layer-locked</icon>
+ <text>&Lock/unlock layer</text>
+ <whatsThis></whatsThis>
+ <toolTip>Lock/unlock layer</toolTip>
+ <iconText>Lock/unlock layer</iconText>
+ <activationFlags>1000</activationFlags>
+ <activationConditions>0</activationConditions>
+ <shortcut></shortcut>
+ <isCheckable>false</isCheckable>
+ <statusTip></statusTip>
+ </Action>
+ <Action name="toggle_layer_visibility">
+ <icon>visible</icon>
+ <text>Toggle layer &visibility</text>
+ <whatsThis></whatsThis>
+ <toolTip>Toggle layer visibility</toolTip>
+ <iconText>Toggle layer visibility</iconText>
+ <activationFlags>1000</activationFlags>
+ <activationConditions>0</activationConditions>
+ <shortcut></shortcut>
+ <isCheckable>false</isCheckable>
+ <statusTip></statusTip>
+ </Action>
+ <Action name="toggle_layer_alpha_lock">
+ <icon>transparency-locked</icon>
+ <text>Lock/unlock layer &alpha</text>
+ <whatsThis></whatsThis>
+ <toolTip>Lock/unlock layer's alpha</toolTip>
+ <iconText>Lock/unlock layer's alpha</iconText>
+ <activationFlags>1000</activationFlags>
+ <activationConditions>0</activationConditions>
+ <shortcut></shortcut>
+ <isCheckable>false</isCheckable>
+ <statusTip></statusTip>
+ </Action>
+ <Action name="toggle_layer_inherit_alpha">
+ <icon>transparency-enabled</icon>
+ <text>Toggle layer alpha &inheritance</text>
+ <whatsThis></whatsThis>
+ <toolTip>Toggle layer alpha inheritance</toolTip>
+ <iconText>Toggle layer alpha inheritance</iconText>
+ <activationFlags>1000</activationFlags>
+ <activationConditions>0</activationConditions>
+ <shortcut></shortcut>
+ <isCheckable>false</isCheckable>
+ <statusTip></statusTip>
+ </Action>
<Action name="add_new_paint_layer">
<icon>paintLayer</icon>
<text>&Paint Layer</text>
@@ -2670,30 +2718,6 @@
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
- <Action name="nodeVisibility">
- <icon></icon>
- <text>Node Visibility</text>
- <whatsThis></whatsThis>
- <toolTip>Node Visibility</toolTip>
- <iconText>Node Visibility</iconText>
- <activationFlags>1000</activationFlags>
- <activationConditions>0</activationConditions>
- <shortcut>Ctrl+Shift+K</shortcut>
- <isCheckable>false</isCheckable>
- <statusTip></statusTip>
- </Action>
- <Action name="layerLock">
- <icon></icon>
- <text>Layer Lock</text>
- <whatsThis></whatsThis>
- <toolTip>Layer Lock</toolTip>
- <iconText>Layer Lock</iconText>
- <activationFlags>1000</activationFlags>
- <activationConditions>0</activationConditions>
- <shortcut>Ctrl+Shift+J</shortcut>
- <isCheckable>false</isCheckable>
- <statusTip></statusTip>
- </Action>
<Action name="mirrorNodeY">
<icon>symmetry-vertical</icon>
<text>Mirror Layer &Vertically</text>
diff --git a/libs/ui/kis_node_manager.cpp b/libs/ui/kis_node_manager.cpp
index 173e2584b7e..00b7fd98761 100644
--- a/libs/ui/kis_node_manager.cpp
+++ b/libs/ui/kis_node_manager.cpp
@@ -243,12 +243,6 @@ void KisNodeManager::setup(KActionCollection * actionCollection, KisActionManage
KisAction * action = actionManager->createAction("mirrorNodeX");
connect(action, SIGNAL(triggered()), this, SLOT(mirrorNodeX()));
- action = actionManager->createAction("nodeVisibility");
- connect(action,SIGNAL(triggered(bool)),this,SLOT(nodeVisibilityChanged()));
-
- action = actionManager->createAction("layerLock");
- connect(action,SIGNAL(triggered(bool)),this,SLOT(layerLockedChanged()));
-
action = actionManager->createAction("mirrorNodeY");
connect(action, SIGNAL(triggered()), this, SLOT(mirrorNodeY()));
@@ -346,6 +340,18 @@ void KisNodeManager::setup(KActionCollection * actionCollection, KisActionManage
action = actionManager->createAction("isolate_layer");
connect(action, SIGNAL(triggered(bool)), this, SLOT(toggleIsolateMode(bool)));
+ action = actionManager->createAction("toggle_layer_lock");
+ connect(action, SIGNAL(triggered()), this, SLOT(toggleLock()));
+
+ action = actionManager->createAction("toggle_layer_visibility");
+ connect(action, SIGNAL(triggered()), this, SLOT(toggleVisibility()));
+
+ action = actionManager->createAction("toggle_layer_alpha_lock");
+ connect(action, SIGNAL(triggered()), this, SLOT(toggleAlphaLock()));
+
+ action = actionManager->createAction("toggle_layer_inherit_alpha");
+ connect(action, SIGNAL(triggered()), this, SLOT(toggleInheritAlpha()));
+
action = actionManager->createAction("split_alpha_into_mask");
connect(action, SIGNAL(triggered()), this, SLOT(slotSplitAlphaIntoMask()));
@@ -696,8 +702,6 @@ void KisNodeManager::setNodeCompositeOp(KisNodeSP node,
m_d->commandsAdapter.setCompositeOp(node, compositeOp);
}
-
-
void KisNodeManager::slotImageRequestNodeReselection(KisNodeSP activeNode, const KisNodeList &selectedNodes)
{
if (activeNode) {
@@ -743,21 +747,6 @@ void KisNodeManager::nodeCompositeOpChanged(const KoCompositeOp* op)
setNodeCompositeOp(node, op);
}
-void KisNodeManager::nodeVisibilityChanged()
-{
- KisNodeSP node = activeNode();
- if(!node) return;
- node->setVisible(!node->visible());
- node->setDirty();
-}
-
-void KisNodeManager::layerLockedChanged()
-{
- KisNodeSP node = activeNode();
- if(!node) return;
- node->setUserLocked(!node->userLocked());
-}
-
void KisNodeManager::duplicateActiveNode()
{
KUndo2MagicString actionName = kundo2_i18n("Duplicate Nodes");
@@ -1154,6 +1143,74 @@ void KisNodeManager::slotSplitAlphaSaveMerged()
m_d->mergeTransparencyMaskAsAlpha(false);
}
+void KisNodeManager::toggleLock()
+{
+ KisNodeList nodes = this->selectedNodes();
+ KisNodeSP active = activeNode();
+ if (nodes.isEmpty() || !active) return;
+
+ bool isLocked = active->userLocked();
+
+ for (auto &node : nodes) {
+ node->setUserLocked(!isLocked);
+ }
+}
+
+void KisNodeManager::toggleVisibility()
+{
+ KisNodeList nodes = this->selectedNodes();
+ KisNodeSP active = activeNode();
+ if (nodes.isEmpty() || !active) return;
+
+ bool isVisible = active->visible();
+
+ for (auto &node : nodes) {
+ node->setVisible(!isVisible);
+ node->setDirty();
+ }
+}
+
+void KisNodeManager::toggleAlphaLock()
+{
+ KisNodeList nodes = this->selectedNodes();
+ KisNodeSP active = activeNode();
+ if (nodes.isEmpty() || !active) return;
+
+ auto layer = qobject_cast<KisPaintLayer*>(active.data());
+ if (!layer) {
+ return;
+ }
+
+ bool isAlphaLocked = layer->alphaLocked();
+ for (auto &node : nodes) {
+ auto layer = qobject_cast<KisPaintLayer*>(node.data());
+ if (layer) {
+ layer->setAlphaLocked(!isAlphaLocked);
+ }
+ }
+}
+
+void KisNodeManager::toggleInheritAlpha()
+{
+ KisNodeList nodes = this->selectedNodes();
+ KisNodeSP active = activeNode();
+ if (nodes.isEmpty() || !active) return;
+
+ auto layer = qobject_cast<KisLayer*>(active.data());
+ if (!layer) {
+ return;
+ }
+
+ bool isAlphaDisabled = layer->alphaChannelDisabled();
+ for (auto &node : nodes) {
+ auto layer = qobject_cast<KisLayer*>(node.data());
+ if (layer) {
+ layer->disableAlphaChannel(!isAlphaDisabled);
+ node->setDirty();
+ }
+ }
+}
+
void KisNodeManager::cutLayersToClipboard()
{
KisNodeList nodes = this->selectedNodes();
diff --git a/libs/ui/kis_node_manager.h b/libs/ui/kis_node_manager.h
index d493614c89f..80dc92a9d2f 100644
--- a/libs/ui/kis_node_manager.h
+++ b/libs/ui/kis_node_manager.h
@@ -170,8 +170,6 @@ public Q_SLOTS:
void nodeProperties(KisNodeSP node);
void nodeOpacityChanged(qreal opacity, bool finalChange);
void nodeCompositeOpChanged(const KoCompositeOp* op);
- void nodeVisibilityChanged();
- void layerLockedChanged();
void duplicateActiveNode();
void removeNode();
void mirrorNodeX();
@@ -202,6 +200,11 @@ public Q_SLOTS:
void slotSplitAlphaWrite();
void slotSplitAlphaSaveMerged();
+ void toggleLock();
+ void toggleVisibility();
+ void toggleAlphaLock();
+ void toggleInheritAlpha();
+
/**
* @brief slotSetSelectedNodes set the list of nodes selected in the layerbox. Selected nodes are not necessarily active nodes.
* @param nodes the selected nodes
diff --git a/plugins/dockers/defaultdockers/kis_layer_box.cpp b/plugins/dockers/defaultdockers/kis_layer_box.cpp
index 218c65011cd..1c45264ba56 100644
--- a/plugins/dockers/defaultdockers/kis_layer_box.cpp
+++ b/plugins/dockers/defaultdockers/kis_layer_box.cpp
@@ -564,6 +564,11 @@ void KisLayerBox::slotContextMenuRequested(const QPoint &pos, const QModelIndex
addActionToMenu(groupMenu, "create_quick_group");
addActionToMenu(groupMenu, "create_quick_clipping_group");
addActionToMenu(groupMenu, "quick_ungroup");
+ QMenu *locksMenu = menu.addMenu(i18n("&Locks && visibility"));
+ addActionToMenu(locksMenu, "toggle_layer_lock");
+ addActionToMenu(locksMenu, "toggle_layer_visibility");
+ addActionToMenu(locksMenu, "toggle_layer_alpha_lock");
+ addActionToMenu(locksMenu, "toggle_layer_inherit_alpha");
if (singleLayer) {
QMenu *addLayerMenu = menu.addMenu(i18n("&Add"));
More information about the kimageshop
mailing list