>>>>> "Bennett" == Bennett Helm <[EMAIL PROTECTED]> writes:

Bennett> This patch has some strange behaviors -- which I'm now
Bennett> noticing are problems with the original patch (as modified by
Bennett> Abdel).

Hmm, I think I know why it happens: a menu with a role can only be
recognized once...

So we have to keep part of the old hack. Please try this new version
of the patch.

JMarc

Index: src/frontends/qt4/QLMenubar.C
===================================================================
--- src/frontends/qt4/QLMenubar.C	(revision 17158)
+++ src/frontends/qt4/QLMenubar.C	(working copy)
@@ -160,8 +160,19 @@ QMenuBar * QLMenubar::menuBar() const
 }
 
 #ifdef Q_WS_MACX
-# define MERGE_MAC_MENUS
-# ifndef MERGE_MAC_MENUS
+# if QT_VERSION >= 0x040200
+namespace {
+void addMacItem(GuiView & view, Menu & special, QMenu * qMenu, 
+		docstring const & text, 
+		FuncRequest const & func, MenuRole role)
+{
+	special.add(MenuItem(MenuItem::Command, text, func));
+	Action * action = new Action(view, text, func);
+	action->setMenuRole(role);
+	qMenu->addAction(action);
+}
+}
+# else
 extern void qt_mac_set_menubar_merge(bool b);
 # endif
 #endif
@@ -171,7 +182,7 @@ void QLMenubar::macxMenuBarInit()
 #ifdef Q_WS_MACX
 	mac_menubar_.reset(new QMenuBar);
 
-# ifdef MERGE_MAC_MENUS
+# if QT_VERSION >= 0x040200
 	/* 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
@@ -181,22 +192,15 @@ void QLMenubar::macxMenuBarInit()
 	*/
 	
 	Menu special;
-	special.add(MenuItem(MenuItem::Command, 
-			     qstring_to_ucs4(QMenuBar::tr("About")), 
-			     FuncRequest(LFUN_DIALOG_SHOW, "aboutlyx")));
-	special.add(MenuItem(MenuItem::Command, 
-			     qstring_to_ucs4(QMenuBar::tr("Preferences")),
-			     FuncRequest(LFUN_DIALOG_SHOW, "prefs")));
-	special.add(MenuItem(MenuItem::Command, 
-			     qstring_to_ucs4(QMenuBar::tr("Quit")),
-			     FuncRequest(LFUN_LYX_QUIT)));
+	QMenu * qMenu = owner_->menuBar()->addMenu("special");	
+	addMacItem(*owner_, special, qMenu, "About LyX",
+		   FuncRequest(LFUN_DIALOG_SHOW, "aboutlyx"), AboutRole);
+	addMacItem(*owner_, special, qMenu, "Preferences",
+		   FuncRequest(LFUN_DIALOG_SHOW, "prefs"), PreferencesRole);
+	addMacItem(*owner_, special, qMenu, "Quit LyX",
+		   FuncRequest(LFUN_LYX_QUIT), QuitRole);
 	menubackend_.specialMenu(special);
 	
-	QMenu * qMenu = owner_->menuBar()->addMenu("special");	
-	Menu::const_iterator end = menubackend_.specialMenu().end();
-	for (Menu::const_iterator cit = menubackend_.specialMenu().begin();
-	     cit != end ; ++cit) 
-		qMenu->addAction(new Action(*owner_, cit->label(), cit->func()));
 # else
 	qt_mac_set_menubar_merge(false);
 # endif // MERGE_MAC_MENUS
Index: src/frontends/qt4/Action.C
===================================================================
--- src/frontends/qt4/Action.C	(revision 17158)
+++ src/frontends/qt4/Action.C	(working copy)
@@ -43,6 +43,10 @@ Action::Action(GuiView & lyxView, docstr
 		FuncRequest const & func, docstring const & tooltip)
 	: QAction(&lyxView), func_(func), lyxView_(lyxView)
 {
+#if QT_VERSION >= 0x040200
+	// only Qt/Mac handles that
+	setMenuRole(NoRole);
+#endif
 	setText(toqstr(text));
 	setToolTip(toqstr(tooltip));
 	setStatusTip(toqstr(tooltip));

Reply via email to