Hi Stephan,

Thanks for looking into this.

I think we are mixing two bugs here (please correct me if I'm wrong).

Bug 1: SVG converts poorly, so the effort has been to make the pictures look better. These are actually pictures in the LyX body, not the LyX toolbar icons themselves. I believe this is the bug you addressed in your latest patch.

Bug 2: Specifically for MinGW-W64 pacman repository built Qt libs, the pixmap.load(path); will fail for SVGs and SVGZs (built without SVG support). So icons all go blank and instead show fall-back text. My patch was aiming to only temporarily address Bug 2 not Bug 1.

I'll double-check your latest patch on a Windows machine, but do let me know if my understanding is wrong.

Thanks!
Shankar

On 05/07/16 01:38, Stephan Witt wrote:
Am 07.05.2016 um 04:11 schrieb Shankar Giri Venkita Giri <gir...@gmx.com>:
Hi Scott, Yes. The problem is the Qt5.6 binaries which I installed from the MSYS2+MINGW64 repository using the standard "pacman". The Qt5.6 libraries bundled with MINGW64 appear not to have built-in SVG image support(if we query the image formats supported, svg and svgz are not among them). Thus, it appears that we cannot load an svg or svgz into a pixmap for the icons like for eg. png or jpeg. But interestingly, the Qt5.6 QtSVG module/plugin did come with the install. So while we cannot open it natively, we can use the SVG module api to open SVG, render on an empty pixmap and send it on its way to the toolbar code. This is essentailly what my patch does. I'm guessing (don't know for sure) that the MSVC folks either a) compile and install Qt5.6 from source with SVG support enabled or b) they use a pre-compiled version of Qt5.6 that does have svg native support enabled. I filed a ticket to the MINGW64 package repository owner to try and update their packages with native svg image support, we'll see if that will eventually happen. But for mingw64 build users (my patch for the mingw64 build fixes recently got committed into 2.3-staging thanks to Georg, I suspect they will see the problem. I don't expect most users to perform lengthy Qt5 compilations - like me, they'd most likely just install from the pacman repo. I also mentioned this in the mingw ticket I filed because this problem appears specific to the mingw64 builds. http://www.lyx.org/trac/ticket/10053#comment:9 I'm not quite sure how to proceed. My patch will work universally, I think (needs review), but it is not needed for other build platforms. I'll leave you guys to make the call.
Hi Shankar,

I’ve just changed the code you provided a patch for. See ticket 10114 for the 
reasoning (http://www.lyx.org/trac/ticket/10114).

The way you’ve solved the problem will definitively not produce good results on 
all platforms.
On HiDPI the icons are needed with much higher resolutions than 16x16.

Regards,
Stephan

Right now, its just maintaining awareness that I see such an issue, it is due to this reason and can be solved this way. Regards,
Shankar
Sent: Friday, May 06, 2016 at 1:18 PM
From: "Scott Kostyshak" <skost...@lyx.org>
To: lyx-devel@lists.lyx.org
Subject: Re: SVG Icon going to fallback plaintext in Windows
On Mon, Apr 04, 2016 at 09:05:38AM +0200, Shankar Giri Venkita Giri wrote:
I noticed something interesting today. I had a Windows laptop where I
used the Qt5.5 libraries and git master lyx sources. It compiled fine
and the toolbar icons were all fine. Today, I compiled it on a fresh
Win8 desktop using Qt5.6 and Lyx git master and all icons
disappeared!

But this is most likely a false diagnostic. In my previous laptop, I
had the stable bundle installed, so most likely it was sourcing icons
from that. In a fresh install, ann icons disappear because I noticed
all icons are .svgz now. So I patched GuiApplication.cpp to use
QtSVGRenderer to paint the svg onto a QPixMap - as far as the rest of
the code is concerned, its still getting a PixMap and not a SVG for
rendering directly on the canvas. Now how are other follks getting to
see the images in Qt5.6 without this change? I'm confused!
Hi Shankar, did you figure out what's going on?

Scott

-Shankar

PS:- Attaching patch used in plaintext inline as well as attachment.

diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4
/GuiApplication.cpp
index 12f99d5..9edf05f 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -101,6 +101,7 @@
#include <QMenuBar>
#include <QMimeData>
#include <QObject>
+#include <QPainter>
#include <QPixmap>
#include <QPixmapCache>
#include <QRegExp>
@@ -110,6 +111,7 @@
#include <QSocketNotifier>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
+#include <QSvgRenderer>
#include <QTextCodec>
#include <QTimer>
#include <QTranslator>
@@ -552,18 +554,27 @@ QString iconName(FuncRequest const & f, bool
unknown)

bool getPixmap(QPixmap & pixmap, QString const & path)
{
- if (pixmap.load(path)) {
+ bool success;
#if QT_VERSION >= 0x050000
- if (path.endsWith(".svgz") || path.endsWith(".svg") ) {
- GuiApplication const * guiApp = theGuiApp();
- if (guiApp != 0) {
- pixmap.setDevicePixelRatio(guiApp->pixelRatio());
- }
+ if (path.endsWith(".svgz") || path.endsWith(".svg") ) {
+ GuiApplication const * guiApp = theGuiApp();
+ if (guiApp != 0) {
+ pixmap.setDevicePixelRatio(guiApp->pixelRatio());
}
-#endif
- return true;
+ QSvgRenderer renderer;
+ success = renderer.load(path);
+ pixmap = QPixmap(16, 16); //UGLY: Does not work without
this. Why???
+ QPainter painter(&pixmap);
+ renderer.render(&painter);
}
- return false;
+ else {
+ success = pixmap.load(path);
+ }
+
+#else
+ success = pixmap.load(path);
+#endif
+ return success;
}


Reply via email to