Commit aa3e7b21 authored by Nicholas LaPointe's avatar Nicholas LaPointe

Add hotkey to toggle between the two most recently selected layers

Although this generally seems to work fine, I have noticed two minor problems that I'm not sure how to solve:
* Using the hotkey after reordering layers will cause the wrong layer to be selected. This is because activateNodeImpl() gets called when a layer is moved around in the stack.
* Bug 373741 ("Drawing while switching between layers with PgUp/PgDown results in a layer acting like it's in a locked group") applies and is easier to reproduce (at step 2, hold the hotkey instead of alternating page-up and page-down).

Differential Revision: https://phabricator.kde.org/D3750
Ref T1734
parent b4bee9dd
......@@ -2096,6 +2096,18 @@
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="switchToPreviouslyActiveNode">
<icon></icon>
<text>Activate previously selected layer</text>
<whatsThis></whatsThis>
<toolTip>Activate previously selected layer</toolTip>
<iconText>Activate previously selected layer</iconText>
<activationFlags>1000</activationFlags>
<activationConditions>0</activationConditions>
<shortcut>;</shortcut>
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="add_new_group_layer">
<icon>groupLayer</icon>
<text>&amp;Group Layer</text>
......
......@@ -106,6 +106,8 @@ struct KisNodeManager::Private {
KisNodeList selectedNodes;
QPointer<KisNodeJugglerCompressed> nodeJuggler;
KisNodeWSP previouslyActiveNode;
bool activateNodeImpl(KisNodeSP node);
QSignalMapper nodeCreationSignalMapper;
......@@ -144,8 +146,11 @@ bool KisNodeManager::Private::activateNodeImpl(KisNodeSP node)
imageView->setCurrentNode(0);
maskManager.activateMask(0);
layerManager.activateLayer(0);
previouslyActiveNode = q->activeNode();
} else {
previouslyActiveNode = q->activeNode();
KoShape * shape = view->document()->shapeForNode(node);
KIS_ASSERT_RECOVER_RETURN_VALUE(shape, false);
......@@ -247,6 +252,9 @@ void KisNodeManager::setup(KActionCollection * actionCollection, KisActionManage
action = actionManager->createAction("activatePreviousLayer");
connect(action, SIGNAL(triggered()), this, SLOT(activatePreviousNode()));
action = actionManager->createAction("switchToPreviouslyActiveNode");
connect(action, SIGNAL(triggered()), this, SLOT(switchToPreviouslyActiveNode()));
action = actionManager->createAction("save_node_as_image");
connect(action, SIGNAL(triggered()), this, SLOT(saveNodeAsImage()));
......@@ -868,6 +876,13 @@ void KisNodeManager::activatePreviousNode()
}
}
void KisNodeManager::switchToPreviouslyActiveNode()
{
if (m_d->previouslyActiveNode && m_d->previouslyActiveNode->parent()) {
slotNonUiActivatedNode(m_d->previouslyActiveNode);
}
}
void KisNodeManager::mergeLayer()
{
m_d->layerManager.mergeLayer();
......
......@@ -177,6 +177,7 @@ public Q_SLOTS:
void mirrorNode(KisNodeSP node, const KUndo2MagicString& commandName, Qt::Orientation orientation);
void activateNextNode();
void activatePreviousNode();
void switchToPreviouslyActiveNode();
/**
* move the active node up the nodestack.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment