Icon set(s)

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
User avatar
zbigg
Posts: 136
Joined: Tue Dec 19, 2017 1:11 pm

Icon set(s)

Postby zbigg » Fri Apr 27, 2018 5:38 am

A question to developers:
I just watched development of coming Blender 2.80 and new icon set: https://blenderartists.org/forum/showth ... ad/page192
If one would like to experiment with the icons is this necessary to recompile FC or the icons could be exchanged as separate resource files?

cheers,
cheers,
wmayer
Site Admin
Posts: 17321
Joined: Thu Feb 19, 2009 10:32 am

Re: Icon set(s)

Postby wmayer » Fri Apr 27, 2018 8:20 am

FreeCAD supports themes: http://doc.qt.io/archives/qt-4.8/qicon.html#fromTheme
This means that you don't have to replace the icons and rebuild the sources. The steps you have to do are:
  1. Create a file index.theme, e.g.:

    Code: Select all

    [Icon Theme]
    Name=MyTheme
    Comment=Default FreeCAD icon theme
    Inherits=Default
    
    # Directory list
    Directories=scalable
    
    [scalable]
    Size=48
    MinSize=8
    MaxSize=512
    Type=Scalable
    
  2. It lists "scalable" as the directory name. So, create the sibling directory to the index.theme file and put your icons underneath. Now you have to look at the FreeCAD source code to determine the icon file names.
However, as mentioned in the Qt docs Windows and macOS don't support icon themes but Qt tries to fill this gap. This however means that in order to replace the icons you have to replace two lines in the source code and rebuild the binaries.
In the file src/Gui/Application.cpp you will find these two lines:

Code: Select all

    QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << QString::fromLatin1(":/icons/FreeCAD-default"));
    QIcon::setThemeName(QLatin1String("FreeCAD-default"));
This should be changed to

Code: Select all

    QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << QString::fromLatin1("Directory of the index.theme file") << QString::fromLatin1(":/icons/FreeCAD-default"));
    QIcon::setThemeName(QLatin1String("MyTheme")); // that's the name defined in the index.theme
I think we should add some preferences entries so that users don't have to touch the source code to use themes.
As said above you have to make the changes only for macOS or Windows. Linux supports it by default and you have to check the manual how to use another theme.
wmayer
Site Admin
Posts: 17321
Joined: Thu Feb 19, 2009 10:32 am

Re: Icon set(s)

Postby wmayer » Fri Apr 27, 2018 11:29 am

I think we should add some preferences entries so that users don't have to touch the source code to use themes.
Said and done. git commit d34847f
triplus
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: Icon set(s)

Postby triplus » Fri Apr 27, 2018 5:31 pm

In addition you can read a discussion we had in the past:

https://forum.freecadweb.org/viewtopic.php?f=10&t=13180

As a result IconThemes module was made:

https://forum.freecadweb.org/viewtopic.php?f=22&t=17901

And a nice icon theme from @pablogil was made:

https://forum.freecadweb.org/viewtopic.php?f=22&t=18417

This should work cross-platform and you can use it now. Next version of IconThemes module will try to tackle the resources files support. And by doing that going beyond the limitations IconThemes module currently has.