#include <config.h>
#include "InsetInfo.h"
-
+#include "LyX.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "BufferView.h"
InsetInfo::InsetInfo(Buffer * buf, string const & name)
: InsetCollapsable(buf), type_(UNKNOWN_INFO), name_()
{
- setAutoBreakRows(true);
setInfo(name);
status_ = Collapsed;
}
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);
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;