helloSystem / Menu

Global menu bar written in Qt
43 stars 14 forks source link

Show shortcuts in the Search menu results #98

Closed probonopd closed 2 years ago

probonopd commented 2 years ago

Continuation from https://github.com/helloSystem/Menu/issues/65#issuecomment-1279948338:

Can we show shortcuts (e.g., Command+C) in the Search menu results as well?

@jsm222:

I did not copy the shortcut property in the results menu because I do not know how Qt will react to duplicate shortcuts.

Only one way to find out: Let's try.

I would assume Qt uses the first matching shortcut it finds, and since both are for the same action, it will not matter that there are two...

probonopd commented 2 years ago

Adding cpy->setShortcut(orig->shortcut()); after cpy->setText(v); in src/appmenuwidget.cpp does the trick.

While we are add it, I'll also copy the tooltip. Anything else?

    cpy->setShortcut(orig->shortcut());
    cpy->setToolTip(orig->toolTip());

For the tooltops to work, before menuBar->addMenu(m_searchMenu); we need to add

    m_searchMenu->setToolTipsVisible(true);