Icon set(s)

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
zbigg
Posts: 136
Joined: Tue Dec 19, 2017 1:11 pm

Icon set(s)

Post by zbigg »

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
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Icon set(s)

Post by wmayer »

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
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Icon set(s)

Post by wmayer »

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
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Icon set(s)

Post by triplus »

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