helloSystem / Menu

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

Make menubar never show '>>' icon #63

Closed probonopd closed 3 years ago

probonopd commented 3 years ago

Here we have set the menubar MainWindow to 21 pixels high.

The Qt default Unix style seems to need more than 21 pixels height for the menu, and in this case the following happens:

image

Note that the Search box uses the exact same font and it fits in just well.

Can we make the menu always show centered vertically in the MainWindow, and be cropped if necessary, but neve the '>>' icon?

If this is not possible, then is there a way to get the needed number of pixels from the Qt style and use that number of pixels to determine the height of the MainWindow, so that the menu fits in there?

probonopd commented 3 years ago

How can we get the height in pixels of a QMenuItem in Qt? Something with QMenuBar::sizeHint()?

probonopd commented 3 years ago

If the mountain will not come to Muhammad, then Muhammad must go to the mountain

(Francis Bacon).

We now construct and populate(!) a dummy QMenu, get its height, and use that to set the height of the MainWindow. Hence, the global menu bar should hopefully never show that dreaded '>>' icon again, ever.

https://github.com/helloSystem/Menu/commit/fbc3bd693cda8c2f5e8215f30506fb74d8abddad

As a nice side effect, we can set the height of the global menu bar in QtPlugin alone and don't have to keep track of it in two places.

As a possibly not so nice side effect, the heiight of the global menu bar will be unpredictable for other Qt themes/styles.