FC can display tooltips for WB dropdown list (but only if <none> is selected as workbench)

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

FC can display tooltips for WB dropdown list (but only if <none> is selected as workbench)

Post by Kunda1 »

This is a UX related issue, therefore I'm posting here. If its not supposed to be here, let me know.

So I discovered something weird. If you choose <none> from the FC Workbench dropdown menu, first resets the UI with no toolbars or fancy widgets AND when you open the workbench dropdown list, all the WBs have tooltips.
Image
I'm interested in how we can have tooltips for these WBs normally, any ideas?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: FC can display tooltips for WB dropdown list (but only if <none> is selected as workbench)

Post by vocx »

Kunda1 wrote: Thu Oct 03, 2019 10:34 pm ...
I'm interested in how we can have tooltips for these WBs normally, any ideas?
The view menu shows tooltips always. That is, View -> Workbenches. This is available all the time, without choosing <none> first.

But the Workbench toolbar has a combobox object to select the workbenches. Maybe this combobox doesn't have the code to show the tooltips.

Something like this needs to be done
https://stackoverflow.com/questions/233 ... x/23381249

Code: Select all

ui->comboBox->setItemData(0, "This is a tooltip for item[0]", Qt::ToolTipRole);
In the code there seems to be various references to a WorkbenchComboBox, but I cannot pinpoint exactly which is the widget that appears in the toolbar.

For example in src/Gui/Action.cpp there is clearly code to set up the tooltips
https://github.com/FreeCAD/FreeCAD/blob ... n.cpp#L531

Code: Select all

    if (w->inherits("QToolBar")) {
        QToolBar* bar = qobject_cast<QToolBar*>(w);
        QComboBox* box = new WorkbenchComboBox(this, w);
        box->setIconSize(QSize(16, 16));
        box->setToolTip(_action->toolTip());
        box->setStatusTip(_action->statusTip());
        box->setWhatsThis(_action->whatsThis());
        box->addActions(_group->actions());
        connect(_group, SIGNAL(triggered(QAction*)), box, SLOT(onActivated (QAction*)));
        bar->addWidget(box);
Maybe the tooltips need to be placed in ToolBarManager.cpp, or WorkbenchManager.cpp, or Workbench.cpp, or in one of .ui files.

The command that is executed is simply called "Std_Workbench", but this does not define the appearance of the combobox.
https://github.com/FreeCAD/FreeCAD/blob ... td.cpp#L76
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: FC can display tooltips for WB dropdown list (but only if <none> is selected as workbench)

Post by Kunda1 »

yorik wrote::bell:
Care to weigh in on this? This would be useful as we could have elaborate tooltips for each workbench that would explain what it does etc...
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: FC can display tooltips for WB dropdown list (but only if <none> is selected as workbench)

Post by vocx »

Kunda1 wrote: Sat Oct 12, 2019 3:07 pm Care to weigh in on this? This would be useful as we could have elaborate tooltips for each workbench that would explain what it does etc...
If you really want to know where the combobox for the workbench selector is implemented you should ask Werner.

And by the way, the tooltip is just defined in the InitGui.py of each workbench in Mod/.

https://github.com/FreeCAD/FreeCAD/blob ... py#L28-L38

Code: Select all

class DraftWorkbench(Workbench):
    '''The Draft Workbench definition'''
    def __init__(self):

        def QT_TRANSLATE_NOOP(scope, text):
            return text

        self.__class__.Icon = FreeCAD.getResourceDir() + "Mod/Draft/Resources/icons/DraftWorkbench.svg"
        self.__class__.MenuText = QT_TRANSLATE_NOOP("draft", "Draft")
        self.__class__.ToolTip = QT_TRANSLATE_NOOP("draft", "The Draft module is used for basic 2D CAD Drafting")
...
The attributes Icon, MenuText, and ToolTip are then taken by the internal C++ code, and added where appropriate to the View -> Workbenches list. As I said, we just need to find the specific place where the workbench selector is defined, to make sure it is using the tooltips.

But meanwhile, you can already go to the InitGui.py of all workbenches and add the appropriate tooltip with more information.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Post Reply