FreeCAD themes

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!
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

FreeCAD themes

Post by PrzemoF »

What's the status of icon themes? I see that bug 2053 [1] is closed, but do we have any instruction how to modify the icons if someone want's to create a new set? I guess it's enough to create properly named icons and drop them to a correct directory? If that's the case I could create the default icon set as a template.

[1] http://freecadweb.org/tracker/view.php?id=2053
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD themes

Post by wmayer »

* Create an index.theme file. When you only provide alternative SVG files you can use the index.theme of the FreeCAD sources but change the Name field.

Code: Select all

[Icon Theme]
Name=FreeCAD-default
Comment=Default FreeCAD icon theme
Inherits=Default

# Directory list
Directories=scalable

[scalable]
Size=48
MinSize=8
MaxSize=512
Type=Scalable
* Create a directory with the theme name you want to use later. Inside this directory put the index.theme file and the icons in the defined sub-directories.

* In case you have put your theme directory outside the system's search path you can run this Python snippet:

Code: Select all

from PySide import QtGui
paths=QtGui.QIcon.themeSearchPaths()
paths.append(Path_of_parent_directory) # <==Here put the parent directory of the theme directory
QtGui.QIcon.setThemeSearchPaths(paths)
* To activate your theme:

Code: Select all

QtGui.QIcon.setThemeName(Your_theme_name)
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: FreeCAD themes

Post by PrzemoF »

Thanks! I could start with coding some GUI changes to allow easy theme switching.
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: FreeCAD themes

Post by PrzemoF »

All works fine, except when I activate a workbench there is no way to update the icons to the new theme.

Code: Select all

mw=Gui.getMainWindow()
mw.update()
doesn't help, switching wb doesn't help. I have to solve that before I can make a theme selector. Switching theme and activating wb later works fine - icon for my custom theme is loaded as expected. Looks like it's now a new problem [1] except nothing works for me now.

[1] viewtopic.php?t=10484&start=30#p93183

Edit:
strace session shows that the icon is loaded, but it's never used (the icon n the b doesn't change):

Code: Select all

stat("/home/przemo/.FreeCAD/themes/new_theme/scalable/fem-quick-analysis.svg", {st_mode=S_IFREG|0644, st_size=19460, ...}) = 0
Edit2:
After starting FreeCAD that works:

Code: Select all

from PySide import QtGui
paths=QtGui.QIcon.themeSearchPaths()
paths.append("/home/przemo/.FreeCAD/themes")
QtGui.QIcon.setThemeSearchPaths(paths)
QtGui.QIcon.setThemeName("new_theme")
Gui.activateWorkbench("FemWorkbench")
but that doesn't work:

Code: Select all

Gui.activateWorkbench("FemWorkbench")
Gui.activateWorkbench("ArchWorkbench")
from PySide import QtGui
paths=QtGui.QIcon.themeSearchPaths()
paths.append("/home/przemo/.FreeCAD/themes")
QtGui.QIcon.setThemeSearchPaths(paths)
QtGui.QIcon.setThemeName("new_theme")
Gui.activateWorkbench("FemWorkbench")
So starting FEM wb loads icons and they are not replaced on theme switching.
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD themes

Post by wmayer »

And moving the mouse over the icons doesn't work either? Can you be sure that it really loads another icon?
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: FreeCAD themes

Post by PrzemoF »

Moving cursor over icon wasn't working, but when I switched back to default theme the icons were dissapearing when I was moving the cursor. I'll have to do more step by step testing and I'll also post the theme files, so we can check it on different systems.

P.S. When we have that problem sovled could we have path to {user_directory}/.FreeCAD/Themes by default in the search path? We already have something similar for Materials. I think that directory is called user settings drectory? That would allow very easy theme installation, possibly even from FreeCAD GUI.
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD themes

Post by wmayer »

When we have that problem sovled could we have path to {user_directory}/.FreeCAD/Themes
Yes, we can think about a user-defined directory. But on Linux platforms isn't there already such a directory like $HOME/.icons or so?
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: FreeCAD themes

Post by PrzemoF »

Yes, there is, but I'm trying to be good and think about win/mac users and .FreeCAD/Themes seems to be the best cross-platform location.
User avatar
yorik
Founder
Posts: 13665
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: FreeCAD themes

Post by yorik »

The .icons folder is a freedesktop.org specification, that Qt (and also GTK) follow (you can place icon themes either in /usr/share/icons or in /home/$USER/.icons). Probably there is an "official" way for Qt to use different icon themes on mac and windows too...
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: FreeCAD themes

Post by PrzemoF »

OK, so it should work on windows as well?
Post Reply