Am 06.01.2014 um 16:58 schrieb Richard Heck <rgh...@lyx.org>:

> On 01/06/2014 02:37 AM, Stephan Witt wrote:
>> Am 05.01.2014 um 22:28 schrieb Jean-Marc Lasgouttes <lasgout...@lyx.org>:
>> 
>>> Le 05/01/2014 21:35, Stephan Witt a écrit :
>>>> This looks interesting - from the Qt docs:
>>>> 
>>>> "If you want all windows in a Mac application to share one menu bar, you 
>>>> must create a menu bar that does not have a parent.
>>>> Create a parent-less menu bar this way:
>>>>  QMenuBar *menuBar = new QMenuBar(0);
>>>> Note: Do not call QMainWindow::menuBar() to create the shared menu bar, 
>>>> because that menu bar will have theQMainWindow as its parent. That menu 
>>>> bar would only be displayed for the parent QMainWindow."
>>>> 
>>>> This is the relevant code from LyX:
>>>> 
>>>> GuiView.cpp, lines 434 and 435:
>>>> 
>>>>    // Fill up the menu bar.
>>>>    guiApp->menus().fillMenuBar(menuBar(), this, true);
>>>> 
>>>> So, it's done exactly the wrong way.
>>> This is indeed quite interesting, but might be for master only for now. 
>>> OTOH, having Reconfigure inserted only once might be good for 2.0.7. I 
>>> cannot test it myself, unfortunately. Maybe the static array could have a 
>>> bool member indicating whether the said entry has already been handled and 
>>> in this case one would skip it.
>> 
>> I tried this already and it didn't help. It crashes nevertheless.
>> The QMenuBar has to be without view parent or the move to the Application 
>> menu shouldn't happen, IMHO.
>> 
>> The attached patch (for trunk) improves the situation. There are only 2 
>> global QMenuBar instances on Mac then.
>> 
>> But there are related problems: see bug 6902 
>> (http://www.lyx.org/trac/ticket/6902)
>> IMHO, LyX isn't aware of the situation when having no view open. Is this a 
>> possible scenario on Linux too?
>> 
>> With this patch there is no crash and the Reconfigure menu is an Application 
>> menu item.
>> But the dialog actions for About and Preferences are usable only while 
>> having any view open.
>> Perhaps the LFUN code has to be moved to the GuiApplication class somehow 
>> too.
>> 
>> This all looks like stuff for master and too adventurous for 2.0.x indeed.
>> 
>> I'll try to find a less intrusive solution for branch.
> 
> OK. I will wait.

I cannot find any other solution instead of using the static global QMenuBar 
instance on Mac.

The attached patch does:
* enable the About and Preferences dialog application wide on Mac
* use static global QMenuBar instead of view related instance on Mac
* do the Mac specific menu bar init only the first time

All changes are inside #ifdef Q_WS_MACX blocks.

This works for me and nothing else.

One drawback I can see: the About and Preferences dialog don't show up if there 
is no view.

Stephan

Attachment: macMenuBar-3.patch
Description: Binary data

Reply via email to