This patch is supposed to fix the disappearing menus problem on Qt/Mac. Bennett, could you tell me whether it helps you? I am not even sure that it compiles for qt/mac, actually :)
It should be very transparent for qt/x11. I guess I should use some scoped_ptr instead of handling my own pointer, though. JMarc
Index: src/frontends/qt2/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v retrieving revision 1.692 diff -u -p -r1.692 ChangeLog --- src/frontends/qt2/ChangeLog 2 Jun 2004 20:13:18 -0000 1.692 +++ src/frontends/qt2/ChangeLog 8 Jun 2004 15:07:11 -0000 @@ -1,3 +1,8 @@ +2004-06-08 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * QLMenubar.C (QLMenubar): use QLMenubar::menuBar(). + (menuBar): new method; returns the menu bar that LyX should use. + 2004-06-02 Angus Leeming <[EMAIL PROTECTED]> * Q[a-zA-Z]*DialogBase.C: reverse yesterday's patch, as discussed Index: src/frontends/qt2/QLMenubar.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLMenubar.C,v retrieving revision 1.8 diff -u -p -r1.8 QLMenubar.C --- src/frontends/qt2/QLMenubar.C 20 May 2004 09:36:27 -0000 1.8 +++ src/frontends/qt2/QLMenubar.C 8 Jun 2004 15:07:11 -0000 @@ -31,12 +31,15 @@ namespace frontend { QLMenubar::QLMenubar(LyXView * view, MenuBackend const & mbe) : owner_(static_cast<QtView*>(view)), menubackend_(mbe) +#ifdef Q_WS_MACX + menubar_(new QMenubar()) +#endif { Menu::const_iterator m = mbe.getMenubar().begin(); Menu::const_iterator end = mbe.getMenubar().end(); for (; m != end; ++m) { pair<int, QLPopupMenu *> menu = - createMenu(owner_->menuBar(), &(*m), this, true); + createMenu(menuBar(), &(*m), this, true); name_map_[m->submenuname()] = menu.second; #ifdef Q_WS_MACX /* The qt/mac menu code has a very silly hack that @@ -52,6 +55,12 @@ QLMenubar::QLMenubar(LyXView * view, Men } } +#ifdef Q_WS_MACX +QLMenubar::~QLMenubar() +{ + delete menubar_; +} +#endif void QLMenubar::openByName(string const & name) { @@ -77,6 +86,37 @@ QtView * QLMenubar::view() MenuBackend const & QLMenubar::backend() { return menubackend_; +} + + +/* + Here is what the Qt documentation says about how a menubar is chosen: + + 1) If the window has a QMenuBar then it is used. 2) If the window + is a modal then its menubar is used. If no menubar is specified + then a default menubar is used (as documented below) 3) If the + window has no parent then the default menubar is used (as + documented below). + + The above 3 steps are applied all the way up the parent window + chain until one of the above are satisifed. If all else fails a + default menubar will be created, the default menubar on Qt/Mac is + an empty menubar, however you can create a different default + menubar by creating a parentless QMenuBar, the first one created + will thus be designated the default menubar, and will be used + whenever a default menubar is needed. + + Thus, for Qt/Mac, we add the menus to a free standing menubar, so + that this menubar will be used also when one of LyX' dialogs has + focus. (JMarc) +*/ +QMenuBar * QLMenubar::menuBar() const +{ +#ifdef Q_WS_MAC + return menubar_; +#else + return owner_->menuBar(); +#endif } } // namespace frontend Index: src/frontends/qt2/QLMenubar.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLMenubar.h,v retrieving revision 1.5 diff -u -p -r1.5 QLMenubar.h --- src/frontends/qt2/QLMenubar.h 19 May 2004 15:11:33 -0000 1.5 +++ src/frontends/qt2/QLMenubar.h 8 Jun 2004 15:07:11 -0000 @@ -19,6 +19,7 @@ class LyXView; class MenuBackend; +class QMenuBar; namespace lyx { namespace frontend { @@ -52,6 +53,13 @@ private: /// name to menu for openByName NameMap name_map_; + + /// The QMenubar used by LyX + QMenuBar * menuBar() const; + +#ifdef Q_WS_MACX + QMenuBar * menubar_; +#endif }; } // namespace frontend