Add some options to index context menu

This commit is contained in:
Juergen Spitzmueller 2022-11-04 11:29:56 +01:00
parent 4299d842e8
commit 68e268e117
2 changed files with 42 additions and 0 deletions

View File

@ -630,6 +630,16 @@ Menuset
Menu "context-index"
IndicesContext
Separator
OptItem "Single Page (No Page Range)|P" "inset-modify changeparam range none"
OptItem "Start Page Range|t" "inset-modify changeparam range start"
OptItem "End Page Range|E" "inset-modify changeparam range end"
Separator
OptItem "No Page Formatting|N" "inset-modify changeparam pagefmt default"
OptItem "Bold Page Formatting|B" "inset-modify changeparam pagefmt textbf"
OptItem "Italic Page Formatting|I" "inset-modify changeparam pagefmt textit"
OptItem "Emphasized Page Formatting|z" "inset-modify changeparam pagefmt emph"
OptItem "Custom Page Formatting|C" "inset-modify changeparam pagefmt custom"
End
Menu "context-edit-index"

View File

@ -582,6 +582,21 @@ void InsetIndex::doDispatch(Cursor & cur, FuncRequest & cmd)
params_.index = from_utf8(cmd.getArg(1));
break;
}
if (cmd.getArg(0) == "changeparam") {
string const p = cmd.getArg(1);
string const v = cmd.getArg(2);
cur.recordUndoInset(this);
if (p == "range")
params_.range = insetindexpagerangetranslator().find(v);
if (p == "pagefmt") {
if (v == "default" || v == "textbf"
|| v == "textit" || v == "emph")
params_.pagefmt = v;
else
lyx::dispatch(FuncRequest(LFUN_INSET_SETTINGS, "index"));
}
break;
}
InsetIndexParams params;
InsetIndex::string2params(to_utf8(cmd.argument()), params);
cur.recordUndoInset(this);
@ -629,6 +644,23 @@ bool InsetIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
from_utf8(cmd.getArg(1)) == params_.index);
return true;
}
if (cmd.getArg(0) == "changeparam") {
string const p = cmd.getArg(1);
string const v = cmd.getArg(2);
if (p == "range") {
flag.setEnabled(v == "none" || v == "start" || v == "end");
flag.setOnOff(params_.range == insetindexpagerangetranslator().find(v));
}
if (p == "pagefmt") {
flag.setEnabled(!v.empty());
if (params_.pagefmt == "default" || params_.pagefmt == "textbf"
|| params_.pagefmt == "textit" || params_.pagefmt == "emph")
flag.setOnOff(params_.pagefmt == v);
else
flag.setOnOff(v == "custom");
}
return true;
}
return InsetCollapsible::getStatus(cur, cmd, flag);
case LFUN_INSET_DIALOG_UPDATE: {