Commit e801f946 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Recover active node when the user toggles "Edit Global Selection"

When the mask is requested to hide, it checks if the "active node"
has been changed at least once since the mask was activated and

a) if the user hasn't change the active node, restores the
   previously active node
b) if the user changed the active node, then do nothing

BUG:409944
parent c6d00e8f
......@@ -221,6 +221,12 @@ LayerBox::LayerBox()
connect(m_nodeModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(updateUI()));
connect(m_nodeModel, SIGNAL(modelReset()), SLOT(slotModelReset()));
connect(m_nodeModel, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(slotForgetAboutSavedNodeBeforeEditSelectionMode()));
connect(m_nodeModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(slotForgetAboutSavedNodeBeforeEditSelectionMode()));
connect(m_nodeModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), SLOT(slotForgetAboutSavedNodeBeforeEditSelectionMode()));
connect(m_nodeModel, SIGNAL(modelReset()), SLOT(slotForgetAboutSavedNodeBeforeEditSelectionMode()));
KisAction *showGlobalSelectionMask = new KisAction(i18n("&Show Global Selection Mask"), this);
showGlobalSelectionMask->setObjectName("show-global-selection-mask");
showGlobalSelectionMask->setActivationFlags(KisAction::ACTIVE_IMAGE);
......@@ -334,6 +340,10 @@ void LayerBox::setViewManager(KisViewManager* kisview)
{
m_nodeManager = kisview->nodeManager();
if (m_nodeManager) {
connect(m_nodeManager, SIGNAL(sigNodeActivated(KisNodeSP)), SLOT(slotForgetAboutSavedNodeBeforeEditSelectionMode()));
}
Q_FOREACH (KisAction *action, m_actions) {
kisview->actionManager()->
addAction(action->objectName(),
......@@ -850,7 +860,10 @@ void LayerBox::slotEditGlobalSelection(bool showSelections)
KisSelectionMaskSP globalSelectionMask;
if (!showSelections) {
activateNode = findNonHidableNode(activateNode);
activateNode =
m_savedNodeBeforeEditSelectionMode ?
KisNodeSP(m_savedNodeBeforeEditSelectionMode) :
findNonHidableNode(activateNode);
}
m_nodeModel->setShowGlobalSelection(showSelections);
......@@ -919,6 +932,9 @@ void LayerBox::slotEditGlobalSelection(bool showSelections)
applicator.end();
}
if (showSelections) {
m_savedNodeBeforeEditSelectionMode = lastActiveNode;
}
}
void LayerBox::selectionChanged(const QModelIndexList selection)
......@@ -1082,6 +1098,11 @@ void LayerBox::slotImageTimeChanged(int time)
updateUI();
}
void LayerBox::slotForgetAboutSavedNodeBeforeEditSelectionMode()
{
m_savedNodeBeforeEditSelectionMode = 0;
}
void LayerBox::slotUpdateIcons() {
m_wdgLayerBox->bnAdd->setIcon(KisIconUtils::loadIcon("addlayer"));
m_wdgLayerBox->bnRaise->setIcon(KisIconUtils::loadIcon("arrowupblr"));
......
......@@ -139,6 +139,8 @@ private Q_SLOTS:
void slotOpacityKeyframeMoved(KisKeyframeSP keyframe, int fromTime);
void slotImageTimeChanged(int time);
void slotForgetAboutSavedNodeBeforeEditSelectionMode();
private:
inline void connectActionToButton(KisViewManager* view, QAbstractButton *button, const QString &id);
inline void addActionToMenu(QMenu *menu, const QString &id);
......@@ -171,6 +173,7 @@ private:
QSlider* thumbnailSizeSlider;
KisNodeSP m_activeNode;
KisNodeWSP m_savedNodeBeforeEditSelectionMode;
QPointer<KisKeyframeChannel> m_opacityChannel;
bool m_blockOpacityUpdate {false};
};
......
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