Add default export to the menu

This commit is contained in:
Guillaume Munch 2017-03-04 23:44:34 +01:00
parent 76f3f6eb01
commit 841825aa56
2 changed files with 24 additions and 0 deletions

View File

@ -88,7 +88,9 @@ Menuset
End End
Menu "file_export" Menu "file_export"
ExportFormat
Item "Export As...|s" "buffer-export-as" Item "Export As...|s" "buffer-export-as"
Separator
ExportFormats ExportFormats
Item "More Formats & Options...|r" "buffer-export custom" Item "More Formats & Options...|r" "buffer-export custom"
End End

View File

@ -135,6 +135,9 @@ public:
/** This is a list of exportable formats /** This is a list of exportable formats
typically for the File->Export menu. */ typically for the File->Export menu. */
ExportFormats, ExportFormats,
/** This exports the document default format
typically for the File->Export menu. */
ExportFormat,
/** This is a list of importable formats /** This is a list of importable formats
typically for the File->Import menu. */ typically for the File->Import menu. */
ImportFormats, ImportFormats,
@ -455,6 +458,7 @@ void MenuDefinition::read(Lexer & lex)
md_elements, md_elements,
md_endmenu, md_endmenu,
md_exportformats, md_exportformats,
md_exportformat,
md_importformats, md_importformats,
md_indices, md_indices,
md_indicescontext, md_indicescontext,
@ -496,6 +500,7 @@ void MenuDefinition::read(Lexer & lex)
{ "end", md_endmenu }, { "end", md_endmenu },
{ "environmentseparators", md_env_separators }, { "environmentseparators", md_env_separators },
{ "exportformats", md_exportformats }, { "exportformats", md_exportformats },
{ "exportformat", md_exportformat },
{ "floatinsert", md_floatinsert }, { "floatinsert", md_floatinsert },
{ "floatlistinsert", md_floatlistinsert }, { "floatlistinsert", md_floatlistinsert },
{ "graphicsgroups", md_graphicsgroups }, { "graphicsgroups", md_graphicsgroups },
@ -587,6 +592,10 @@ void MenuDefinition::read(Lexer & lex)
add(MenuItem(MenuItem::ExportFormats)); add(MenuItem(MenuItem::ExportFormats));
break; break;
case md_exportformat:
add(MenuItem(MenuItem::ExportFormat));
break;
case md_importformats: case md_importformats:
add(MenuItem(MenuItem::ImportFormats)); add(MenuItem(MenuItem::ImportFormats));
break; break;
@ -2175,6 +2184,19 @@ void Menus::Impl::expand(MenuDefinition const & frommenu,
tomenu.expandFormats(cit->kind(), buf); tomenu.expandFormats(cit->kind(), buf);
break; break;
case MenuItem::ExportFormat: {
if (!buf)
break;
string const format = buf->params().getDefaultOutputFormat();
Format const * f = formats.getFormat(format);
docstring const name = f ? f->prettyname() : from_utf8(format);
docstring const label = bformat(_("Export [%1$s]|E"), name);
MenuItem item(MenuItem::Command, toqstr(label),
FuncRequest(LFUN_BUFFER_EXPORT));
tomenu.addWithStatusCheck(item);
break;
}
case MenuItem::CharStyles: case MenuItem::CharStyles:
tomenu.expandFlexInsert(buf, InsetLayout::CHARSTYLE); tomenu.expandFlexInsert(buf, InsetLayout::CHARSTYLE);
break; break;