Use the nominal theme's icon size for displaying the icon in an info inset.

This commit is contained in:
Enrico Forestieri 2015-03-13 00:38:05 +01:00
parent bd9f5408cf
commit d00dcc2ca7
3 changed files with 27 additions and 0 deletions

View File

@ -31,6 +31,7 @@
#include "frontends/Application.h" #include "frontends/Application.h"
#include "support/convert.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/docstream.h" #include "support/docstream.h"
#include "support/docstring_list.h" #include "support/docstring_list.h"
@ -410,6 +411,8 @@ void InsetInfo::updateInfo()
InsetGraphics * inset = new InsetGraphics(buffer_); InsetGraphics * inset = new InsetGraphics(buffer_);
InsetGraphicsParams igp; InsetGraphicsParams igp;
igp.filename = file; igp.filename = file;
igp.lyxscale = iconScaleFactor(file);
igp.scale = convert<string>(igp.lyxscale);
inset->setParams(igp); inset->setParams(igp);
clear(); clear();
Font const f(inherit_font, buffer().params().language); Font const f(inherit_font, buffer().params().language);

View File

@ -37,6 +37,7 @@
#include "support/qstring_helpers.h" #include "support/qstring_helpers.h"
#include <QDir> #include <QDir>
#include <QImage>
#include <QTemporaryFile> #include <QTemporaryFile>
#include "support/lassert.h" #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) string const commandPrep(string const & command_in)
{ {
static string const token_scriptpath = "$$s/"; static string const token_scriptpath = "$$s/";

View File

@ -115,6 +115,11 @@ imageLibFileSearch(std::string & dir, std::string const & name,
std::string const & ext = std::string(), std::string const & ext = std::string(),
search_mode mode = must_exist); 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 /// How to quote a filename
enum quote_style { enum quote_style {
/** Quote for the (OS dependant) shell. This is needed for command /** Quote for the (OS dependant) shell. This is needed for command