Workbench drop down list is long, too long.

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

Re: Workbench drop down list is long, too long.

Post by wmayer »

A simple Alt+number for the 10 most used workbenches would be a big improvement...
If we implement this Start menu then you can customize your short cuts as with every command, too.
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Workbench drop down list is long, too long.

Post by PrzemoF »

wmayer wrote:
A simple Alt+number for the 10 most used workbenches would be a big improvement...
If we implement this Start menu then you can customize your short cuts as with every command, too.
I don't think it's within my current knowledge about FreeCAD/C++ ..... unless I get some help. I think I know how to add an item to the menubar/toolbar [1] , but what command should it call or what to call to activate a workbench from a menu?

[1] https://github.com/FreeCAD/FreeCAD_sf_m ... h.cpp#L462
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Workbench drop down list is long, too long.

Post by PrzemoF »

Quick & dirty, but working solution. Requires FreeCAD restart beacuse I don't know how to call WorkbenchGroup::refreshWorkbenchList() from src/Gui/DlgSettingsWorkbenchesImp.cpp [1]

https://github.com/PrzemoF/FreeCAD_sf_m ... orkbenches

[1] https://github.com/PrzemoF/FreeCAD_sf_m ... p.cpp#L114
Attachments
FreeCAD_workbenches_switcher.png
FreeCAD_workbenches_switcher.png (171.03 KiB) Viewed 1290 times
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Workbench drop down list is long, too long.

Post by ickby »

Please consider using a list view with checkable items, see QListWidget and void QListWidgetItem::setFlags, It would be way more usable.

EDIT: usable in the sense that the preference window does not get that big, possibly bigger than the sceen for many workbenches
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Workbench drop down list is long, too long.

Post by PrzemoF »

What about this (see the screenshot):
1 - List of all workbenches
2 - Items that would show in the "Workbench" menu

That would allow to pick most often used workbenches, change order and (as menu item) assign keyboard shortcuts.
Attachments
FreeCAD_workbench_switcher.png
FreeCAD_workbench_switcher.png (220.61 KiB) Viewed 1284 times
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Workbench drop down list is long, too long.

Post by microelly2 »

PrzemoF wrote: but what command should it call or what to call to activate a workbench from a menu?
I have written a macro like this ..

Code: Select all

FreeCAD.Console.PrintMessage("I start FEM ... ")
FreeCADGui.activateWorkbench("FemWorkbench")
FreeCAD.Console.PrintMessage("started.")
assigned it to a symbol of the global toolbar with shortcut ctrl+4
and it works
Attachments
bn_655.png
bn_655.png (17.92 KiB) Viewed 1283 times
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Workbench drop down list is long, too long.

Post by PrzemoF »

Thanks! However I'll have to start a workbench from C++ which is the main part of the problem for me :)
wmayer
Founder
Posts: 20307
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Workbench drop down list is long, too long.

Post by wmayer »

* IMO this doesn't need to be in the preferences dialog. I would use an own dialog for this or put it to the customize panel
* as ickby said a QListWidget should be used because it's easier to deal with and if the panel gets too big it automatically add scroll bars
* IMO, it's OK to let the change take effect after a restart because it's a lot of work to update everything on the fly. And this is something you don't do all the time
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Workbench drop down list is long, too long.

Post by triplus »

Implementing this in a way the end result would be modern and would satisfy all groups of users is probably quite a huge task. The way i understand this attempt it's all about providing much simpler solution for now that would work with existing set of tools (Workbench Switcher). This simple task can become harder as it first looks. For example it will affect Start up module set preference. Anyway this is the solution i use and i will mention it here as it does not need FreeCAD restart and it cleans up Workbench Switcher. Solution was provided by user @ttype:

viewtopic.php?t=4171&p=32619
http://paste.ubuntu.com/5776142/

How does it work. I can remove specific workbench i don't use by simply running one command. For example Web Workbench:

Code: Select all

Gui.removeWorkbench("WebWorkbench")
I never investigated how to add it back without FreeCAD restart. After quick look I do see there is Gui.addWorkbench function available any maybe that could be used. I am guessing Gui.listWorkbenches could be used to fill QListWidget with the list of available workbenches including 3rd Party ones?

Anyway as i use this solution i mentioned it here if it helps in any way to achieve the final goal.

Cheers.
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Workbench drop down list is long, too long.

Post by PrzemoF »

Again, thanks for all suggesions and opinions! Below a screenshot of "work in progress" on workbenches customisation. Please don't hold back your opinions, positive or negative ;)
Attachments
FreeCAD_workbenches_customisation.png
FreeCAD_workbenches_customisation.png (169.86 KiB) Viewed 1215 times
Post Reply