[X2Go-Commits] [x2goclient] 04/04: src/sessionbutton.cpp: instead of using the hamburger.svg file directly, render it to a raster image and use this Pixmap as the icon file - otherwise the icon will not show up.

git-admin at x2go.org git-admin at x2go.org
Wed Jan 18 07:54:01 CET 2017


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2goclient.

commit b04960e58b8664b76b807fe28f6569d9654acaf0
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Wed Jan 18 07:53:04 2017 +0100

    src/sessionbutton.cpp: instead of using the hamburger.svg file directly, render it to a raster image and use this Pixmap as the icon file - otherwise the icon will not show up.
    
    Also change the icon size back to 16x16 px, that's big enough.
---
 debian/changelog      |    4 ++++
 src/sessionbutton.cpp |   26 +++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 998ae31..e3b968a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -31,6 +31,10 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium
       optional "base" parameter, that might be empty and is put in-between the
       fixed resource path string and the filename parameter.
     - src/onmainwindow.cpp: use images_resource_path () in iconsPath ().
+    - src/sessionbutton.cpp: instead of using the hamburger.svg file directly,
+      render it to a raster image and use this Pixmap as the icon file -
+      otherwise the icon will not show up. Also change the icon size back to
+      16x16 px, that's big enough.
 
   [ Bernard Cafarelli ]
   * New upstream version (4.0.5.3):
diff --git a/src/sessionbutton.cpp b/src/sessionbutton.cpp
index 49f0ae3..2863050 100644
--- a/src/sessionbutton.cpp
+++ b/src/sessionbutton.cpp
@@ -33,6 +33,10 @@
 #include "x2gologdebug.h"
 #include <QApplication>
 #include <QDesktopWidget>
+#include <QSvgRenderer>
+#include <QPainter>
+#include <QImage>
+#include <QPixmap>
 #include "sessionexplorer.h"
 
 
@@ -121,9 +125,21 @@ SessionButton::SessionButton ( ONMainWindow* mw,QWidget *parent, QString id )
     editBut=new QPushButton ( this );
     editBut->setMouseTracking ( true );
     connect ( editBut,SIGNAL ( pressed() ),this,SLOT ( slotShowMenu() ) );
-    editBut->setIcon ( QIcon ( par->images_resource_path ( "/svg/hamburger.svg" ) ) );
-    editBut->setIconSize ( QSize ( 32,32 ) );
-    editBut->setFixedSize ( 48,48 );
+
+    /* Load our edit button SVG file. */
+    QSvgRenderer svg_renderer (par->images_resource_path ("/svg/hamburger.svg"));
+
+    /* Prepare image to render to with full transparency. */
+    QImage tmp_image (16, 16, QImage::Format_ARGB32);
+    tmp_image.fill (0x00000000);
+
+    /* Paint icon to the image. */
+    QPainter tmp_painter (&tmp_image);
+    svg_renderer.render (&tmp_painter);
+
+    editBut->setIcon ( QIcon ( QPixmap::fromImage (tmp_image) ) );
+    editBut->setIconSize ( QSize ( 16,16 ) );
+    editBut->setFixedSize ( 24,24 );
     editBut->setFlat ( true );
     editBut->setPalette ( cpal );
     sessMenu=new QMenu ( this );
@@ -167,7 +183,7 @@ SessionButton::SessionButton ( ONMainWindow* mw,QWidget *parent, QString id )
     {
         sessName->move ( 80,34 );
         sessStatus->move(80,50);
-        editBut->move ( 283,132 );
+        editBut->move ( 307,156 );
         serverIcon->move ( 58,84 );
         server->move ( 80,84 );
         cmdIcon->move ( 58,108 );
@@ -181,7 +197,7 @@ SessionButton::SessionButton ( ONMainWindow* mw,QWidget *parent, QString id )
     }
     else
     {
-        editBut->move ( 194,89 );
+        editBut->move ( 218,113 );
         sessName->move ( 64,11 );
         sessStatus->hide();
         serverIcon->move ( 66,44 );

--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list