X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetInfo.cpp;h=2f26c971f864b8293b3d146e59fb038d21775f23;hb=83d2c7fa3704a221b143a54b0c78747fbd712504;hp=acf073aa107103064ee5fd4e67d8a4e1fb1e1359;hpb=0f0750a65a7782a5723e8be6af0896b94c448068;p=lyx.git diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index acf073aa10..2f26c971f8 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -10,7 +10,7 @@ #include #include "InsetInfo.h" - +#include "LyX.h" #include "Buffer.h" #include "BufferParams.h" #include "BufferView.h" @@ -94,7 +94,6 @@ NameTranslator const & nameTranslator() InsetInfo::InsetInfo(Buffer * buf, string const & name) : InsetCollapsable(buf), type_(UNKNOWN_INFO), name_() { - setAutoBreakRows(true); setInfo(name); status_ = Collapsed; } @@ -170,12 +169,20 @@ bool InsetInfo::validateModifyArgument(docstring const & arg) const case SHORTCUT_INFO: case SHORTCUTS_INFO: - case MENU_INFO: - case ICON_INFO: { + case MENU_INFO: { FuncRequest func = lyxaction.lookupFunc(name); return func.action() != LFUN_UNKNOWN_ACTION; } + case ICON_INFO: { + FuncCode const action = lyxaction.lookupFunc(name).action(); + if (action == LFUN_UNKNOWN_ACTION) { + string dir = "images"; + return !imageLibFileSearch(dir, name, "svgz,png").empty(); + } + return true; + } + case LYXRC_INFO: { ostringstream oss; lyxrc.write(oss, true, name); @@ -419,10 +426,16 @@ void InsetInfo::updateInfo() if (!file.exists()) break; int percent_scale = 100; - int imgsize = QImage(toqstr(file.absFileName())).width(); - if (imgsize > 0) { - int iconsize = Length(1, Length::EM).inPixels(1); - percent_scale = (100 * iconsize + imgsize / 2)/imgsize; + if (use_gui) { + // Compute the scale factor for the icon such that its + // width on screen is equal to 1em in pixels. + // The scale factor is rounded to the integer nearest + // to the float value of the ratio 100*iconsize/imgsize. + int imgsize = QImage(toqstr(file.absFileName())).width(); + if (imgsize > 0) { + int iconsize = Length(1, Length::EM).inPixels(1); + percent_scale = (100 * iconsize + imgsize / 2)/imgsize; + } } InsetGraphics * inset = new InsetGraphics(buffer_); InsetGraphicsParams igp;