Menu

#569 Add icon to Qt terminal

open
nobody
None
5
2015-07-21
2012-01-05
No

Despite the fact that I'm unable to see Qt terminal working, here is a tiny feature request - to add some gnuplot icon.

Here is a hello-world example of how to achieve this (it works on Mac, I didn't test any other platform):

#include <QApplication>
#include <QTextEdit>
#include <QIcon>

int main(int argv, char **args)
{
QApplication app(argv, args);
QTextEdit textEdit;
textEdit.show();

QIcon appIcon;
appIcon.addFile\("icon.svg"\);
QApplication::setWindowIcon\(appIcon\);

app.exec();
}

Related

Bugs: #2383

Discussion

  • Mojca Miklavec

    Mojca Miklavec - 2012-01-05
     
  • Mojca Miklavec

    Mojca Miklavec - 2012-01-08

    Model function based on 32x32 pixel icon

     
  • Mojca Miklavec

    Mojca Miklavec - 2012-01-08

    Pixelated look of gnuplot icon on Mac OS X

     
  • Dan Sebald

    Dan Sebald - 2015-07-21

    The Qt terminal appears to have this icon. Has this patch effectively been implemented? Should this be closed?

    BTW, I'd be interested in having some means for the user to specify the icon to be used with the terminal, e.g.,

    set term qt icon <filename> ...

    for any of the window based terminals.

     
  • Mojca Miklavec

    Mojca Miklavec - 2015-07-21

    My point was that the current icon looks ugly (= way too pixelated) and I would prefer to see either a vector image or a high resolution icon.

     
  • Dan Sebald

    Dan Sebald - 2015-07-21

    Oh, I see. Clicking on the gnuplot-in-apps.png thumbnail shows a higher resolution image in which the gnuplot icon is up-sampled and low-pass filtered.

    I've tried compiling the test file but I hit a snag:

    /usr/bin/ld: /tmp/ccL6A5gZ.o: undefined reference to symbol 'gxx_personality_v0@@CXXABI_1.3'
    /usr/bin/ld: note: '
    gxx_personality_v0@@CXXABI_1.3' is defined in DSO /usr/lib64/libstdc++.so.6 so try adding it to the linker command line

    which appears to be something having to do with a DSO change in Fedora a few years back. Anyway, so you have the high res icon in the file icon.svg, yet Qt is treating it as low resolution somehow, if I understand correctly. Perhaps when the appIcon.addFile("icon.svg"); is done a QSize needs to be supplied that is as large as the Mac icons:

    http://doc.qt.io/qt-4.8/qicon.html#addFile

    E.g.,

    appIcon.addFile("icon.svg", QSize(30,30));

    It could be that the application (i.e., this small sample program) has no idea what the maximum size will be since this is a vector graphics file, so it picks 10x10. If this were a high res icon, or an icon with a set of sizes internally (that's what the QList list tells one from QList<QSize> QIcon::availableSizes), it might be a different story.

    See if that helps.

    What is gnuplot_icon_model.pdf? That's not a very nice looking result.

     
  • Mojca Miklavec

    Mojca Miklavec - 2015-07-21

    No, that was a misunderstanding, I don't need help with SVG sizes. If I use the SVG file (created with gnuplot and included in attachment; I could add source if needed) then I get full resolution.

    The pixelated image comes from src/qtterminal/QtGnuplotResource.qrc:

    <file alias="images/gnuplot">images/icon32x32.xpm</file>
    

    that is being used in either QtGnuplotWindow.cpp or QtGnuplotApplication.cpp (not sure which one as it's been three years since I opened this ticket):

    setWindowIcon(QIcon(":/images/gnuplot"));
    

    This means that the gnuplot's source code is deliberately using a 32x32 image that comes out pixelated on some systems. In contrast to Linux and Windows, Mac is known for its huge icons, so maybe the pixelation might only be visible on Macs under default settings.

    If I change the code as described above, I get a nice vector image on my computer, no need for any additional hacks.

    gnuplot_icon_model.pdf has been created by taking the old 32x32 icon (that icon is used on Windows at least) and overlaying it with a vector image to show the comparison between the old bitmap and the new vector icon. For the sake of this ticket you may safely ignore it (other than to satisfy the curiosity) and consider just icon.svg – that is the only file that could actually be used.

     
  • Dan Sebald

    Dan Sebald - 2015-07-21

    I see now. Really then, this is merely putting a higher res icon in place. I've tried replacing

    <file alias="images/gnuplot">images/icon32x32.xpm</file>

    in the Qt resource file with

    <file alias="images/gnuplot">images/icon.svg</file>

    and it seems to work fine on Linux. The icon looks slightly different in terms of weight, so I will attach some screen shots.

    If this change is made, please credit to Mojca, but the diff file is attached, with the additional change of icon.svg added to CVS in the "images" subdirectory while icon32x32.xpm is deleted from CVS.

     
  • Dan Sebald

    Dan Sebald - 2015-07-21

    Here is the current XPM bitmap icon appearance on my Linux computer. Notice it has heavier weight black border lines.

     
  • Dan Sebald

    Dan Sebald - 2015-07-21

    And the higher-res SVG icon appearance on Linux. This has thinner weight. In some sense it's an improvement, with the one concern being that the inside r/g/b lines leak over the border a pixel in the upper right window icon scaling.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.