]> git.lyx.org Git - lyx.git/commitdiff
* QLMenubar.C (macxMenuBarInit): fix workaround for menu merging
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 20 Dec 2006 14:28:06 +0000 (14:28 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 20 Dec 2006 14:28:06 +0000 (14:28 +0000)
with Qt/Mac. Still does not work in non-default locale.

* QLPopupMenu.C (specialMacXmenuHack): remove, not needed anymore.

* GuiView.C (init): remove Mac hack, not needed anymore.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16349 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiView.C
src/frontends/qt4/GuiView.h
src/frontends/qt4/QLMenubar.C
src/frontends/qt4/QLPopupMenu.C
src/frontends/qt4/QLPopupMenu.h

index 0877822c8b73cebaa5f7b29b58f0ae64db3bfe09..863475241014b0f91d22afc29907505e9dee2d54 100644 (file)
@@ -219,25 +219,6 @@ void GuiView::init()
        updateToolbars();
        updateLayoutChoice();
        updateMenubar();
-
-#ifdef Q_WS_MACX
-       // Qt docs:
-       // "quit or exit        Application Menu | Quit <application name>      
-       // If this entry is not found a default Quit item will be created to call
-       // QApplication::quit()"
-       QMenu * lyxMenu =  menuBar()->addMenu("&LyX");
-       QAction * quitAction = new QAction(tr("&Quit"), this);
-       lyxMenu->addAction(quitAction);
-       connect(quitAction, SIGNAL(triggered()),this, SLOT(macQuit()));
-#endif
-
-}
-
-
-void GuiView::macQuit()
-{
-       // this slot is only called on Mac
-       dispatch(FuncRequest(LFUN_LYX_QUIT));
 }
 
 
index 5aaa1e9c896d9214f1adfd38c6f6a7c7c389737f..255606be50e21297e974014e3ccd8ac1b7f91eb7 100644 (file)
@@ -103,9 +103,6 @@ public Q_SLOTS:
        void normalSizedIcons();
        void bigSizedIcons();
 
-       /// slot needed by the Mac
-       void macQuit();
-
 protected:
        /// make sure we quit cleanly
        virtual void closeEvent(QCloseEvent * e);
index 67a8e60798cd495e3b13f49c2ae47812206df693..bbe027d076540f0076a5fa4a5375fc78e93d474f 100644 (file)
@@ -14,6 +14,7 @@
 // All is well if the namespace is visible first.
 #include "GuiView.h"
 
+#include "Action.h"
 #include "QLMenubar.h"
 #include "QLPopupMenu.h"
 
@@ -126,6 +127,8 @@ MenuBackend const & QLMenubar::backend()
 }
 
 
+/// Some special Qt/Mac support hacks
+
 /*
   Here is what the Qt documentation says about how a menubar is chosen:
 
@@ -156,17 +159,44 @@ QMenuBar * QLMenubar::menuBar() const
 #endif
 }
 
+#ifdef Q_WS_MACX
+# define MERGE_MAC_MENUS
+# ifndef MERGE_MAC_MENUS
+extern void qt_mac_set_menubar_merge(bool b);
+# endif
+#endif
+
 void QLMenubar::macxMenuBarInit()
 {
 #ifdef Q_WS_MACX
        mac_menubar_.reset(new QMenuBar);
 
+# ifdef MERGE_MAC_MENUS
+       /* The qt/mac menu code has a very silly hack that moves some
+          menu entries that it recognizes by name (e.g.
+          "Preferences...") to the "LyX" menu. This feature can only
+          work if the menu entries are always available. Since we
+          build menus on demand, we add the entries to a dummy menu
+          (JMarc)
+       */
+
        // this is the name of the menu that contains our special entries
-       menubackend_.specialMenu(lyx::from_ascii("LyX"));
-       // make sure that the special entries are added to the first
-       // menu even before this menu has been opened.
-       //name_map_[menubackend_.getMenubar().begin()->submenuname()]->update();
-#endif
+       docstring const & specialname = from_ascii("LyX");
+       if (menubackend_.hasMenu(specialname)) {
+               QMenu * qMenu = owner_->menuBar()->addMenu("special");
+               //qMenu->setVisible(false);
+
+               menubackend_.specialMenu(specialname);
+               Menu const & special = menubackend_.getMenu(specialname);
+               Menu::const_iterator end = special.end();
+               for (Menu::const_iterator cit = special.begin();
+                    cit != end ; ++cit) 
+                       qMenu->addAction(new Action(*owner_, cit->label(), cit->func()));
+       }
+# else
+       qt_mac_set_menubar_merge(false);
+# endif // MERGE_MAC_MENUS
+#endif // Q_WS_MACX
 }
 
 } // namespace frontend
index 3acc391ee0adbc699ef9f261b9b4edfe03de65d1..9410f602811f500892de556bf20d104799d97e9d 100644 (file)
@@ -41,8 +41,6 @@ namespace lyx {
 namespace frontend {
 
 
-// MacOSX specific stuff is at the end.
-
 QLPopupMenu::QLPopupMenu(QLMenubar * owner,
                                                 MenuItem const & mi, bool topLevelMenu)
        : owner_(owner)
@@ -77,8 +75,6 @@ void QLPopupMenu::update()
                lyxerr[Debug::GUI] << "\tWARNING: menu seems empty" << lyx::to_utf8(topLevelMenu_.name()) << endl;
        }
        populate(this, &topLevelMenu_);
-
-       specialMacXmenuHack();
 }
 
 void QLPopupMenu::populate(QMenu* qMenu, Menu * menu)
@@ -138,7 +134,6 @@ docstring const QLPopupMenu::getLabel(MenuItem const & mi)
        return label;
 }
 
-/// \todo Mac specific binding handling.
 void QLPopupMenu::addBinding(docstring & label, MenuItem const & mi)
 {
        docstring const binding(mi.binding());
@@ -147,31 +142,6 @@ void QLPopupMenu::addBinding(docstring & label, MenuItem const & mi)
        }
 }
 
-/// \todo Fix Mac specific menu hack
-void QLPopupMenu::specialMacXmenuHack()
-{
-#ifdef Q_WS_MACX
-       /* The qt/mac menu code has a very silly hack that
-          moves some menu entries that it recognizes by name
-          (e.g. "Preferences...") to the "LyX" menu. This
-          feature can only work if the menu entries are
-          always available. Since we build menus on demand,
-          we add some dummy contents to one of the menus (JMarc)
-       */
-/*
-       static QLPopupMenu * themenu = this;
-       if (themenu == this && owner_->backend().hasMenu("LyX")) {
-               Menu special = owner_->backend().getMenu("LyX");
-               Menu::const_iterator end = special.end();
-               Menu::size_type i = 0;
-               for (Menu::const_iterator cit = special.begin();
-                    cit != end ; ++cit, ++i)
-                       insertItem(toqstr(cit->label()), indexOffset + i);
-       }
-*/
-#endif
-}
-
 } // namespace frontend
 } // namespace lyx
 
index 4c4fed5623678f56c4de1cd4497062408c7f86eb..c565990e16185240f7a377a7b3ac950a763a9f7b 100644 (file)
@@ -50,15 +50,10 @@ private:
        lyx::docstring const getLabel(MenuItem const & mi);
 
        /// add binding keys a the menu item label.
-       /// \todo Mac specific binding handling.
        void addBinding(lyx::docstring & label, MenuItem const & mi);
 
        /// Top Level Menu
        Menu topLevelMenu_;
-
-       /// Mac specific menu hack
-       /// \todo Fix it
-       void specialMacXmenuHack();
 };
 
 } // namespace frontend