]> git.lyx.org Git - features.git/commitdiff
fix disappearing menus syndrome on Qt/Mac
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 9 Jun 2004 14:10:27 +0000 (14:10 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 9 Jun 2004 14:10:27 +0000 (14:10 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8812 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt2/ChangeLog
src/frontends/qt2/QLMenubar.C
src/frontends/qt2/QLMenubar.h

index b240e9320944dbf4eff112bde544cff400790f7a..353bf9740f43c609be9f372dfaf66e44c134efa5 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-08  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
+
+       * QLMenubar.C (QLMenubar): use QLMenubar::menuBar().
+       (menuBar): new method; returns the menu bar that LyX should use.
+
 2004-06-02  Angus Leeming  <leeming@lyx.org>
 
        * Q[a-zA-Z]*DialogBase.C: reverse yesterday's patch, as discussed
index ca16d63c7f24d590bef03f65054f979c0a92601e..ac979e660410acd1a6a20d74851d7ca7f31d4531 100644 (file)
@@ -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,7 +55,6 @@ QLMenubar::QLMenubar(LyXView * view, MenuBackend const & mbe)
        }
 }
 
-
 void QLMenubar::openByName(string const & name)
 {
        NameMap::const_iterator const cit = name_map_.find(name);
@@ -79,5 +81,36 @@ 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_.get();
+#else
+       return owner_->menuBar();
+#endif
+}
+
 } // namespace frontend
 } // namespace lyx
index 98dcf812b45465459a0b691ccb0a438591d84ca6..678ab34823ad02386ff3fe415f864516ea27a71f 100644 (file)
@@ -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
+       boost::scoped_ptr<QMenuBar> menubar_;
+#endif
 };
 
 } // namespace frontend