]> git.lyx.org Git - lyx.git/commitdiff
Remove the iconScaleFactor() method from src/support.
authorEnrico Forestieri <forenr@lyx.org>
Wed, 25 Mar 2015 20:26:32 +0000 (21:26 +0100)
committerEnrico Forestieri <forenr@lyx.org>
Wed, 25 Mar 2015 20:26:32 +0000 (21:26 +0100)
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.

src/insets/InsetInfo.cpp
src/support/filetools.cpp
src/support/filetools.h

index e70b519e0609447ac2ac136099a04b41a4e8e325..98fe7d7c9b21caabb0ddfde97a848375aca91a4d 100644 (file)
@@ -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"
 #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);
index 1f794f2c9ca9e9b82e364b02f8d396dff9a35b3c..a05f9845544513b3ecb5781e890efe1dab1fbb2f 100644 (file)
@@ -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/";
index 0180f29d35af02559065627644c1950cb7fd74c0..b041b366a2ca3ea1d08ce501be5b6e4d100df9ea 100644 (file)
@@ -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