#include "KeyMap.h"
#include "LaTeXFeatures.h"
#include "LayoutFile.h"
+#include "Length.h"
#include "LyXAction.h"
#include "LyXRC.h"
#include "LyXVC.h"
#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;
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);
#include "support/qstring_helpers.h"
#include <QDir>
-#include <QImage>
#include <QTemporaryFile>
#include "support/lassert.h"
}
-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/";
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