Starting with FreeCAD 0.17 custom toolbar position configured by the user should now be restored in all workbenches. In addition (optionally) developer now can have more control over default toolbar position in workbench.
Reference:
https://forum.freecadweb.org/viewtopic.php?f=22&t=16954
Persistent toolbars
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Persistent toolbars
since 0.17.10489, to be exact.
Thanks!
Thanks!
Can you elaborate on this a little bit? I'm researching how to automate adding a global toolbar from part-o-magic...triplus wrote:In addition (optionally) developer now can have more control over default toolbar position in workbench.
Re: Persistent toolbars
You're welcome.DeepSOIC wrote:since 0.17.10489, to be exact.
Thanks!
Here you can find an example for Sketcher workbench:Can you elaborate on this a little bit?triplus wrote:In addition (optionally) developer now can have more control over default toolbar position in workbench.
https://forum.freecadweb.org/viewtopic. ... 20#p164854
Well luckily you came to the right place. You actually already use something like that as you use TabBar. And adding global toolbar in FreeCAD isn't all that hard. But when adding commands to the toolbar things can get a bit complicated. Therefore i did a few tests and simply add this to part-o-magic InitGui.py file:I'm researching how to automate adding a global toolbar from part-o-magic...
Code: Select all
def Deactivated(self):
from PySide import QtGui
mw = FreeCADGui.getMainWindow()
mw.findChild(QtGui.QToolBar, "POMContainers").show()
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Persistent toolbars
Okay, I'll check what it does. What I've been looking at before was to add some parameters as if user has created a global toolbar: The up side is user has control over it, the usual way. The downside is that FreeCAD needs to be restarted. So I'll think on which option to choose.triplus wrote:Code: Select all
def Deactivated(self): from PySide import QtGui mw = FreeCADGui.getMainWindow() mw.findChild(QtGui.QToolBar, "POMContainers").show()
Re: Persistent toolbars
First a bit of explanation for anybody reading this thread. Not to get confused on what persistent toolbars should do. Show/hide toolbar algorithm is still provided by FreeCAD as it has always has been (C++). What was missing is saving/restoring toolbar position in all workbenches. Toolbar position was restored (when FreeCAD was started) only in default workbench. Algorithm provided by persistent toolbars (Python) now adds that missing piece and restores toolbar positions in all workbenches.
As for your question @DeepSOIC. On how to add global toolbar to FreeCAD from Python.
If you would want to add a real global toolbar. You can look for reference in TabBar on how it can be done. Note that in not that distant future SelectorToolbar module will be made. And the toolbar functionality from TabBar will be moved to it. After you create such toolbar it will be available on FreeCAD start. You would need to search for corresponding commands manually and add them to the toolbar yourself. PoM module would still needed to be loaded first. As it provides the commands or the toolbar would end up being empty until PoM module would be loaded or some bypassing would happen for the commands on FreeCAD start. On every workbench change you need to clear the toolbar and add the commands. And from good integration point of view small amount of toolbar flickering could happen when workbench changes (i am still searching for sensible solution to be used for SelectorToolbar purposes).
As for your question @DeepSOIC. On how to add global toolbar to FreeCAD from Python.
Mentioned code i provided doesn't add global toolbar per se. What it does it makes local toolbar from PoM visible in all workbenches. PoM module provides this toolbar therefore PoM workbench must be loaded before the toolbar will be available in all workbenches. Only small amount of bypassing FreeCAD show/hide algorithm happens and therefore everything else still results in standard FreeCAD behaviour.DeepSOIC wrote:Okay, I'll check what it does. What I've been looking at before was to add some parameters as if user has created a global toolbar:
If you would want to add a real global toolbar. You can look for reference in TabBar on how it can be done. Note that in not that distant future SelectorToolbar module will be made. And the toolbar functionality from TabBar will be moved to it. After you create such toolbar it will be available on FreeCAD start. You would need to search for corresponding commands manually and add them to the toolbar yourself. PoM module would still needed to be loaded first. As it provides the commands or the toolbar would end up being empty until PoM module would be loaded or some bypassing would happen for the commands on FreeCAD start. On every workbench change you need to clear the toolbar and add the commands. And from good integration point of view small amount of toolbar flickering could happen when workbench changes (i am still searching for sensible solution to be used for SelectorToolbar purposes).
Re: Persistent toolbars
I checked what you are doing with PoM. And as you are already bypassing FreeCAD by directly importing PoM commands in InitGui.py this is basically the missing piece you need. To add global PoM toolbar with PoM related commands on it (FreeCAD manages the result therefore no potential issues mentioned earlier apply):
Code: Select all
import FreeCAD
path = "User parameter:BaseApp/Workbench/Global/Toolbar/PoM"
p = FreeCAD.ParamGet(path)
p.SetString("Name", "PoM")
p.SetString("PartOMagic_Module", "FreeCAD")
p.SetBool("Active", 1)
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Persistent toolbars
I feel that if I procrastinate just a bit more, you will come with a pull request Sorry for hijacking the thread
Re: Persistent toolbars
Well i guess i could couldn't i. Give me a few hours and i will do it (edit: done).DeepSOIC wrote:I feel that if I procrastinate just a bit more, you will come with a pull request
As long as the resulting toolbar will keep user set workbench specific position i am fine with that.Sorry for hijacking the thread