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.
 
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