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

>> And the entries that should be removed are not. Did Help>About move
>> too?

Bennett> "Help > About" is there.

Yes, I simply forgot the code that removes such entries :)

>> Also, are entries like Document>Dettings... still there? This is
>> the part that causes me the most worries.

Bennett> "Document > Settings" is there. (I'm not sure what other
Bennett> entries you're worried about. Under the Document menu are:
Bennett> Change Tracking, LaTeX Log File..., Table of Contents...,
Bennett> Start Appendix Here, and Settings.)

I am worried about all entries that have names that Qt/Mac could
mistake for preferences (with Settings, Options Config or Setup in
their names). I guess there is only Edit>Paragraph settings.

OK, try the following new version of the patch. It should fix the menu
positions, but not yet the actions that they initiate. However, when
you select a menu entry, your should see a debug message like:
QLPopupMenu::fire, index=7

Please report what you get. The entries in LyX should have an index
like 5001, 5002 or 5003.

JMarc

Index: src/frontends/qt2/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v
retrieving revision 1.704
diff -u -p -r1.704 ChangeLog
--- src/frontends/qt2/ChangeLog	9 Aug 2004 13:00:30 -0000	1.704
+++ src/frontends/qt2/ChangeLog	10 Aug 2004 14:33:18 -0000
@@ -1,3 +1,21 @@
+2004-08-10  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* QLPopupMenu.C (populate): ignore the entries for About, Quit and
+	Preferences.
+
+2004-07-12  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* lyx_gui.C (parse_init): add a new translator whose sole purpose
+	is to hide some menu entries from Qt/Mac scrutiniy and avoid some
+	menu merging.
+
+	* QLMenubar.C (QLMenubar): remove special code to work around
+	Qt/Mac menu merging madness.
+
+	* QLPopupMenu.C (QLPopupMenu): add dummy entries to toplevel menus
+	(so that Qt/Mac moves them to the LyX menu)
+	(fire): recognize special values of index under Qt/Mac
+
 2004-08-09  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
 	* FileDialog.C: #define USE_NATIVE_FILEDIALOG under LyX/Mac
Index: src/frontends/qt2/QLMenubar.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLMenubar.C,v
retrieving revision 1.9
diff -u -p -r1.9 QLMenubar.C
--- src/frontends/qt2/QLMenubar.C	9 Jun 2004 14:10:27 -0000	1.9
+++ src/frontends/qt2/QLMenubar.C	10 Aug 2004 14:33:18 -0000
@@ -22,7 +22,6 @@
 #include <qmenubar.h>
 #include <qcursor.h>
 
-
 using std::pair;
 using std::string;
 
@@ -41,17 +40,6 @@ QLMenubar::QLMenubar(LyXView * view, Men
 		pair<int, QLPopupMenu *> menu =
 			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
-		   moves some menu entries that it recognizes by name
-		   (ex: "Preferences...") to the "LyX" menu. This
-		   feature can only work if the menu entries are
-		   always available. Since we build menus on demand,
-		   we have to have a reasonable default value before
-		   the menus have been explicitely opened. (JMarc)
-		*/
-		menu.second->showing();
-#endif
 	}
 }
 
Index: src/frontends/qt2/QLPopupMenu.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLPopupMenu.C,v
retrieving revision 1.32
diff -u -p -r1.32 QLPopupMenu.C
--- src/frontends/qt2/QLPopupMenu.C	7 Jul 2004 09:32:19 -0000	1.32
+++ src/frontends/qt2/QLPopupMenu.C	10 Aug 2004 14:33:18 -0000
@@ -23,6 +23,7 @@
 #include "support/lstrings.h"
 
 #ifdef Q_WS_MACX
+#include "debug.h"
 #include "kbmap.h"
 #include "QLyXKeySym.h"
 extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
@@ -55,6 +56,14 @@ string const getLabel(MenuItem const & m
 	return label;
 }
 
+#ifdef Q_WS_MACX
+// some constants needed for special handling of Mac menus
+// They are chosen to be large enough to avoid clashes with real menu indices.
+const int aboutIndex = 5001;
+const int prefsIndex = 5002;
+const int quitIndex = 5003;
+#endif
+
 } // namespace anon
 
 
@@ -77,12 +86,43 @@ QLPopupMenu::QLPopupMenu(QLMenubar * own
 		connect(this, SIGNAL(aboutToShow()), this, SLOT(showing()));
 	connect(this, SIGNAL(activated(int)),
 		this, SLOT(fire(int)));
+#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 each menu (JMarc)
+	*/
+	if (toplevel) {
+		insertItem("About LyX", aboutIndex);
+		insertItem("Preferences...", prefsIndex);
+		insertItem("Quit LyX", quitIndex);
+	}
+#endif
 }
 
 
 void QLPopupMenu::fire(int index)
 {
+#ifdef Q_WS_MACX
+	lyxerr << "QLPopupMenu::fire, index=" << index << std::endl;
+	switch (index) {
+	case aboutIndex:
+		owner_->view()->activated(FuncRequest(LFUN_DIALOG_SHOW, "aboutlyx"));
+		break;
+	case prefsIndex:
+		owner_->view()->activated(FuncRequest(LFUN_DIALOG_SHOW, "prefs"));
+		break;
+	case quitIndex:
+		owner_->view()->activated(FuncRequest(LFUN_QUIT));
+		break;
+	default:
+		owner_->view()->activated(funcs_[index]);
+	}
+#else
 	owner_->view()->activated(funcs_[index]);
+#endif
 }
 
 
@@ -99,7 +139,21 @@ void QLPopupMenu::populate(Menu * menu)
 			pair<int, QLPopupMenu *> res = createMenu(this, &(*m), owner_);
 			setItemEnabled(res.first, m->status().enabled());
 			res.second->populate(m->submenu());
-		} else {
+		} else { // we have a MenuItem::Command
+#ifdef Q_WS_MACX
+			switch(m->func().action) {
+			  case LFUN_QUIT: 
+				  continue;
+			case LFUN_DIALOG_SHOW: 
+				if (m->func().argument == "prefs"
+				    || m->func().argument == "aboutlyx")
+					continue;
+				break;
+			default:
+				break;
+			}
+#endif
+
 			FuncStatus const status = m->status();
 
 			Funcs::iterator fit =
@@ -129,6 +183,8 @@ void QLPopupMenu::populate(Menu * menu)
 				label += '\t' + toqstr(binding);
 			}
 #endif
+
+			// Actually insert the menu item
 			insertItem(label, index);
 			setItemEnabled(index, status.enabled());
 			setItemChecked(index, status.onoff(true));
Index: src/frontends/qt2/lyx_gui.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/lyx_gui.C,v
retrieving revision 1.69
diff -u -p -r1.69 lyx_gui.C
--- src/frontends/qt2/lyx_gui.C	8 Aug 2004 22:37:39 -0000	1.69
+++ src/frontends/qt2/lyx_gui.C	10 Aug 2004 14:33:18 -0000
@@ -152,7 +152,6 @@ namespace lyx_gui {
 
 bool use_gui = true;
 
-
 void parse_init(int & argc, char * argv[])
 {
 	static LQApplication app(argc, argv);
@@ -173,6 +172,23 @@ void parse_init(int & argc, char * argv[
 		lyxerr[Debug::GUI]
 			<< "Could not find  Qt translations for locale "
 			<< QTextCodec::locale() << std::endl;
+#endif
+
+#ifdef Q_WS_MACX
+	// These translations are meant to break Qt/Mac menu merging
+	// algorithm on some entries. It lists the menu names that
+	// should not be moved to the LyX menu
+	static QTranslator aqua_trans(0);
+	aqua_trans.insert(QTranslatorMessage("QMenuBar", "Setting", 0, 
+					     "do_not_merge_me"));
+	aqua_trans.insert(QTranslatorMessage("QMenuBar", "Config", 0, 
+					     "do_not_merge_me"));
+	aqua_trans.insert(QTranslatorMessage("QMenuBar", "Options", 0, 
+					     "do_not_merge_me"));
+	aqua_trans.insert(QTranslatorMessage("QMenuBar", "Setup", 0, 
+					     "do_not_merge_me"));
+
+	app.installTranslator(&aqua_trans);
 #endif
 
 	using namespace lyx::graphics;

Reply via email to