mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Use the nominal theme's icon size for displaying the icon in an info inset.
This commit is contained in:
parent
bd9f5408cf
commit
d00dcc2ca7
@ -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<string>(igp.lyxscale);
|
||||
inset->setParams(igp);
|
||||
clear();
|
||||
Font const f(inherit_font, buffer().params().language);
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "support/qstring_helpers.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QImage>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
#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/";
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user