Allow syncing open/close status of branch inset with it's activation status.

This was kicked out by 742b39f4 (the code in inset toggle survived).
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg217311.html
This commit is contained in:
Pavel Sanda 2022-04-17 00:16:19 +02:00
parent 28b206665f
commit 02ffd6dd70
3 changed files with 18 additions and 1 deletions

View File

@ -502,6 +502,7 @@ enum FuncCode
LFUN_SPELLING_REMOVE_LOCAL, // jspitzm 20210307 LFUN_SPELLING_REMOVE_LOCAL, // jspitzm 20210307
LFUN_FINISHED_DOWN, // lasgouttes 20210629 LFUN_FINISHED_DOWN, // lasgouttes 20210629
LFUN_FINISHED_UP, // lasgouttes 20210629 LFUN_FINISHED_UP, // lasgouttes 20210629
LFUN_BRANCH_SYNC_ALL, // sanda 20220415
LFUN_LASTACTION // end of the table LFUN_LASTACTION // end of the table
}; };

View File

@ -452,6 +452,15 @@ void LyXAction::init()
*/ */
{ LFUN_BRANCH_INSERT, "branch-insert", Noop, Edit }, { LFUN_BRANCH_INSERT, "branch-insert", Noop, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_BRANCH_SYNC_ALL
* \li Action: Open/close all insets of selected branch (depending on its selection status).
* \li Syntax: branch-toggle-all
* \li Origin: sanda, 15 April 2022
* \endvar
*/
{ LFUN_BRANCH_SYNC_ALL, "branch-sync-all", AtPoint, Buffer },
/*! /*!
* \var lyx::FuncCode lyx::LFUN_BRANCH_INVERT * \var lyx::FuncCode lyx::LFUN_BRANCH_INVERT
* \li Action: Toggles inversion status of branch inset. * \li Action: Toggles inversion status of branch inset.

View File

@ -224,9 +224,12 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_BRANCH_ADD: case LFUN_BRANCH_ADD:
lyx::dispatch(FuncRequest(LFUN_BRANCH_ADD, params_.branch)); lyx::dispatch(FuncRequest(LFUN_BRANCH_ADD, params_.branch));
break; break;
case LFUN_BRANCH_SYNC_ALL:
lyx::dispatch(FuncRequest(LFUN_INSET_FORALL, "Branch:" + params_.branch + " inset-toggle assign"));
break;
case LFUN_INSET_TOGGLE: case LFUN_INSET_TOGGLE:
if (cmd.argument() == "assign") if (cmd.argument() == "assign")
setStatus(cur, isBranchSelected() ? Open : Collapsed); setStatus(cur, (isBranchSelected(true) != params_.inverted) ? Open : Collapsed);
else else
InsetCollapsible::doDispatch(cur, cmd); InsetCollapsible::doDispatch(cur, cmd);
break; break;
@ -276,6 +279,10 @@ bool InsetBranch::getStatus(Cursor & cur, FuncRequest const & cmd,
flag.setEnabled(buffer().parent() && isBranchSelected()); flag.setEnabled(buffer().parent() && isBranchSelected());
break; break;
case LFUN_BRANCH_SYNC_ALL:
flag.setEnabled(known_branch);
break;
case LFUN_INSET_TOGGLE: case LFUN_INSET_TOGGLE:
if (cmd.argument() == "assign") if (cmd.argument() == "assign")
flag.setEnabled(true); flag.setEnabled(true);