mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 05:33:33 +00:00
Remove the iconScaleFactor() method from src/support.
I am moving the corresponding code directly to InsetInfo.cpp. Moreover, the size of the image displayed by the info inset is now dynamically set according to the text size.
This commit is contained in:
parent
32f5639fbc
commit
a3d5f27038
@ -22,6 +22,7 @@
|
||||
#include "KeyMap.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "LayoutFile.h"
|
||||
#include "Length.h"
|
||||
#include "LyXAction.h"
|
||||
#include "LyXRC.h"
|
||||
#include "LyXVC.h"
|
||||
@ -40,10 +41,13 @@
|
||||
#include "support/filetools.h"
|
||||
#include "support/gettext.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/qstring_helpers.h"
|
||||
#include "support/Translator.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <QtGui/QImage>
|
||||
|
||||
using namespace std;
|
||||
using namespace lyx::support;
|
||||
|
||||
@ -408,11 +412,18 @@ void InsetInfo::updateInfo()
|
||||
FileName file(to_utf8(icon_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;
|
||||
}
|
||||
InsetGraphics * inset = new InsetGraphics(buffer_);
|
||||
InsetGraphicsParams igp;
|
||||
igp.filename = file;
|
||||
igp.lyxscale = iconScaleFactor(file);
|
||||
igp.scale = convert<string>(igp.lyxscale);
|
||||
igp.lyxscale = percent_scale;
|
||||
igp.scale = string();
|
||||
igp.width = Length(1, Length::EM);
|
||||
inset->setParams(igp);
|
||||
clear();
|
||||
Font const f(inherit_font, buffer().params().language);
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "support/qstring_helpers.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QImage>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
#include "support/lassert.h"
|
||||
@ -416,24 +415,6 @@ 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,11 +115,6 @@ 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