From: Enrico Forestieri Date: Thu, 12 Mar 2015 23:38:05 +0000 (+0100) Subject: Use the nominal theme's icon size for displaying the icon in an info inset. X-Git-Tag: 2.2.0alpha1~1202 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d00dcc2ca7bf1b9a3043d23b1c5b598ff7e46aad;p=features.git Use the nominal theme's icon size for displaying the icon in an info inset. --- diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index d914d94938..3d35e293e0 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -31,6 +31,7 @@ #include "frontends/Application.h" +#include "support/convert.h" #include "support/debug.h" #include "support/docstream.h" #include "support/docstring_list.h" @@ -410,6 +411,8 @@ void InsetInfo::updateInfo() InsetGraphics * inset = new InsetGraphics(buffer_); InsetGraphicsParams igp; igp.filename = file; + igp.lyxscale = iconScaleFactor(file); + igp.scale = convert(igp.lyxscale); inset->setParams(igp); clear(); Font const f(inherit_font, buffer().params().language); diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp index 134dc17561..f5cdb27751 100644 --- a/src/support/filetools.cpp +++ b/src/support/filetools.cpp @@ -37,6 +37,7 @@ #include "support/qstring_helpers.h" #include +#include #include #include "support/lassert.h" @@ -407,6 +408,24 @@ FileName const imageLibFileSearch(string & dir, string const & name, } +int iconScaleFactor(FileName const & image) +{ + int imgsize = QImage(toqstr(image.absFileName())).height(); + if (imgsize <= 0) + return 100; + + // default icon size + int iconsize = 20; + + string dir = "images"; + FileName const fn = imageLibFileSearch(dir, "iconsize.png"); + if (!fn.empty()) + iconsize = QImage(toqstr(fn.absFileName())).height(); + + return (100 * iconsize + imgsize / 2)/imgsize; +} + + string const commandPrep(string const & command_in) { static string const token_scriptpath = "$$s/"; diff --git a/src/support/filetools.h b/src/support/filetools.h index b041b366a2..0180f29d35 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -115,6 +115,11 @@ imageLibFileSearch(std::string & dir, std::string const & name, std::string const & ext = std::string(), search_mode mode = must_exist); +/** Returns the percentage factor by which an image has to be + scaled for matching the (theme dependent) nominal icon size + */ +int iconScaleFactor(FileName const & image); + /// How to quote a filename enum quote_style { /** Quote for the (OS dependant) shell. This is needed for command