[krita] krita: Implement Select All/Visible/Locked layers actions
Dmitry Kazakov
dimula73 at gmail.com
Tue Jan 12 15:01:37 UTC 2016
Git commit af1e0ef9d747cc070370869067e48de0d7f14b8a by Dmitry Kazakov.
Committed on 12/01/2016 at 15:01.
Pushed by dkazakov into branch 'master'.
Implement Select All/Visible/Locked layers actions
By default they have no shortcuts, but you can assign any to them
CC:kimageshop at kde.org
M +65 -0 krita/krita.action
M +9 -0 krita/krita.rc
M +7 -0 krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
M +101 -0 krita/ui/kis_node_manager.cpp
M +8 -0 krita/ui/kis_node_manager.h
http://commits.kde.org/krita/af1e0ef9d747cc070370869067e48de0d7f14b8a
diff --git a/krita/krita.action b/krita/krita.action
index 640e74f..707195d 100644
--- a/krita/krita.action
+++ b/krita/krita.action
@@ -2530,6 +2530,71 @@
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
+ <Action name="select_all_layers">
+ <icon></icon>
+ <text>All Layers</text>
+ <whatsThis></whatsThis>
+ <toolTip>Select all layers</toolTip>
+ <iconText>Select all layers</iconText>
+ <activationFlags>0</activationFlags>
+ <activationConditions>0</activationConditions>
+ <shortcut></shortcut>
+ <defaultShortcut></defaultShortcut>
+ <isCheckable>false</isCheckable>
+ <statusTip></statusTip>
+ </Action>
+ <Action name="select_visible_layers">
+ <icon></icon>
+ <text>Visible Layers</text>
+ <whatsThis></whatsThis>
+ <toolTip>Select all visible layers</toolTip>
+ <iconText>Select all visible layers</iconText>
+ <activationFlags>0</activationFlags>
+ <activationConditions>0</activationConditions>
+ <shortcut></shortcut>
+ <defaultShortcut></defaultShortcut>
+ <isCheckable>false</isCheckable>
+ <statusTip></statusTip>
+ </Action>
+ <Action name="select_locked_layers">
+ <icon></icon>
+ <text>Locked Layers</text>
+ <whatsThis></whatsThis>
+ <toolTip>Select all locked layers</toolTip>
+ <iconText>Select all locked layers</iconText>
+ <activationFlags>0</activationFlags>
+ <activationConditions>0</activationConditions>
+ <shortcut></shortcut>
+ <defaultShortcut></defaultShortcut>
+ <isCheckable>false</isCheckable>
+ <statusTip></statusTip>
+ </Action>
+ <Action name="select_invisible_layers">
+ <icon></icon>
+ <text>Invisible Layers</text>
+ <whatsThis></whatsThis>
+ <toolTip>Select all invisible layers</toolTip>
+ <iconText>Select all invisible layers</iconText>
+ <activationFlags>0</activationFlags>
+ <activationConditions>0</activationConditions>
+ <shortcut></shortcut>
+ <defaultShortcut></defaultShortcut>
+ <isCheckable>false</isCheckable>
+ <statusTip></statusTip>
+ </Action>
+ <Action name="select_unlocked_layers">
+ <icon></icon>
+ <text>Unlocked Layers</text>
+ <whatsThis></whatsThis>
+ <toolTip>Select all unlocked layers</toolTip>
+ <iconText>Select all unlocked layers</iconText>
+ <activationFlags>0</activationFlags>
+ <activationConditions>0</activationConditions>
+ <shortcut></shortcut>
+ <defaultShortcut></defaultShortcut>
+ <isCheckable>false</isCheckable>
+ <statusTip></statusTip>
+ </Action>
<Action name="save_node_as_image">
<icon>document-save</icon>
<text>&Save Layer/Mask...</text>
diff --git a/krita/krita.rc b/krita/krita.rc
index 3ff402b..0b25551 100644
--- a/krita/krita.rc
+++ b/krita/krita.rc
@@ -164,6 +164,15 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org
<Action name="convert_to_selection_mask"/>
</Menu>
<Separator/>
+ <Menu name="LayerSelect">
+ <text>&Select</text>
+ <Action name="select_all_layers"/>
+ <Action name="select_visible_layers"/>
+ <Action name="select_invisible_layers"/>
+ <Action name="select_locked_layers"/>
+ <Action name="select_unlocked_layers"/>
+ </Menu>
+ <Separator/>
<Action name="cut_layer_clipboard"/>
<Action name="copy_layer_clipboard"/>
<Action name="paste_layer_from_clipboard"/>
diff --git a/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp b/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
index ba0c66e..b3825a5 100644
--- a/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
+++ b/krita/plugins/extensions/dockers/defaultdockers/kis_layer_box.cpp
@@ -535,6 +535,13 @@ void KisLayerBox::slotContextMenuRequested(const QPoint &pos, const QModelIndex
addActionToMenu(&menu, "paste_layer_from_clipboard");
menu.addSeparator();
+ QMenu *selectMenu = menu.addMenu(i18n("&Select"));
+ addActionToMenu(selectMenu, "select_all_layers");
+ addActionToMenu(selectMenu, "select_visible_layers");
+ addActionToMenu(selectMenu, "select_invisible_layers");
+ addActionToMenu(selectMenu, "select_locked_layers");
+ addActionToMenu(selectMenu, "select_unlocked_layers");
+ menu.addSeparator();
addActionToMenu(&menu, "create_quick_group");
addActionToMenu(&menu, "create_quick_clipping_group");
menu.addSeparator();
diff --git a/krita/ui/kis_node_manager.cpp b/krita/ui/kis_node_manager.cpp
index 392435e..99921aa 100644
--- a/krita/ui/kis_node_manager.cpp
+++ b/krita/ui/kis_node_manager.cpp
@@ -33,6 +33,8 @@
#include <KisImportExportManager.h>
#include <KoFileDialog.h>
#include <KoToolManager.h>
+#include <KoProperties.h>
+
#include <KoColorSpace.h>
#include <KoColorSpaceRegistry.h>
@@ -73,6 +75,7 @@
#include "kis_node_dummies_graph.h"
#include "kis_mimedata.h"
#include "kis_layer_utils.h"
+#include "krita_utils.h"
#include "processing/kis_mirror_processing_visitor.h"
#include "KisView.h"
@@ -261,6 +264,21 @@ void KisNodeManager::setup(KActionCollection * actionCollection, KisActionManage
action = actionManager->createAction("create_quick_clipping_group");
connect(action, SIGNAL(triggered()), this, SLOT(createQuickClippingGroup()));
+ action = actionManager->createAction("select_all_layers");
+ connect(action, SIGNAL(triggered()), this, SLOT(selectAllNodes()));
+
+ action = actionManager->createAction("select_visible_layers");
+ connect(action, SIGNAL(triggered()), this, SLOT(selectVisibleNodes()));
+
+ action = actionManager->createAction("select_locked_layers");
+ connect(action, SIGNAL(triggered()), this, SLOT(selectLockedNodes()));
+
+ action = actionManager->createAction("select_invisible_layers");
+ connect(action, SIGNAL(triggered()), this, SLOT(selectInvisibleNodes()));
+
+ action = actionManager->createAction("select_unlocked_layers");
+ connect(action, SIGNAL(triggered()), this, SLOT(selectUnlockedNodes()));
+
NEW_LAYER_ACTION("add_new_paint_layer", "KisPaintLayer");
NEW_LAYER_ACTION("add_new_group_layer", "KisGroupLayer");
@@ -1181,3 +1199,86 @@ void KisNodeManager::createQuickClippingGroup()
juggler->addNode(KisNodeList() << maskLayer, parent, above);
}
+
+KisNodeList findNodesWithProps(KisNodeSP root, const KoProperties &props, bool excludeRoot)
+{
+ KisNodeList nodes;
+
+ if ((!excludeRoot || root->parent()) && root->check(props)) {
+ nodes << root;
+ }
+
+ KisNodeSP node = root->firstChild();
+ while (node) {
+ nodes += findNodesWithProps(node, props, excludeRoot);
+ node = node->nextSibling();
+ }
+
+ return nodes;
+}
+
+void KisNodeManager::selectLayersImpl(const KoProperties &props, const KoProperties &invertedProps)
+{
+ KisImageSP image = m_d->view->image();
+ KisNodeList nodes = findNodesWithProps(image->root(), props, true);
+
+ KisNodeList selectedNodes = this->selectedNodes();
+
+ if (KritaUtils::compareListsUnordered(nodes, selectedNodes)) {
+ nodes = findNodesWithProps(image->root(), invertedProps, true);
+ }
+
+ if (!nodes.isEmpty()) {
+ slotImageRequestNodeReselection(nodes.last(), nodes);
+ }
+}
+
+void KisNodeManager::selectAllNodes()
+{
+ KoProperties props;
+ selectLayersImpl(props, props);
+}
+
+void KisNodeManager::selectVisibleNodes()
+{
+ KoProperties props;
+ props.setProperty("visible", true);
+
+ KoProperties invertedProps;
+ invertedProps.setProperty("visible", false);
+
+ selectLayersImpl(props, invertedProps);
+}
+
+void KisNodeManager::selectLockedNodes()
+{
+ KoProperties props;
+ props.setProperty("locked", true);
+
+ KoProperties invertedProps;
+ invertedProps.setProperty("locked", false);
+
+ selectLayersImpl(props, invertedProps);
+}
+
+void KisNodeManager::selectInvisibleNodes()
+{
+ KoProperties props;
+ props.setProperty("visible", false);
+
+ KoProperties invertedProps;
+ invertedProps.setProperty("visible", true);
+
+ selectLayersImpl(props, invertedProps);
+}
+
+void KisNodeManager::selectUnlockedNodes()
+{
+ KoProperties props;
+ props.setProperty("locked", false);
+
+ KoProperties invertedProps;
+ invertedProps.setProperty("locked", true);
+
+ selectLayersImpl(props, invertedProps);
+}
diff --git a/krita/ui/kis_node_manager.h b/krita/ui/kis_node_manager.h
index 7f7c804..a01365f 100644
--- a/krita/ui/kis_node_manager.h
+++ b/krita/ui/kis_node_manager.h
@@ -37,6 +37,7 @@ class KisView;
class KisNodeSelectionAdapter;
class KisNodeInsertionAdapter;
class KisNodeJugglerCompressed;
+class KoProperties;
/**
* The node manager passes requests for new layers or masks on to the mask and layer
@@ -212,6 +213,12 @@ public Q_SLOTS:
void createQuickGroup();
void createQuickClippingGroup();
+ void selectAllNodes();
+ void selectVisibleNodes();
+ void selectLockedNodes();
+ void selectInvisibleNodes();
+ void selectUnlockedNodes();
+
public:
@@ -235,6 +242,7 @@ private:
const QString &overrideGroupName,
KisNodeSP *newGroup,
KisNodeSP *newLastChild);
+ void selectLayersImpl(const KoProperties &props, const KoProperties &invertedProps);
struct Private;
Private * const m_d;
More information about the kimageshop
mailing list