This patch tries to sanitize a bit the way menus are generated on qt4.
Actions are not made checkable for no reason, and the code to set
action features is moved to Action::update.

JMarc

Index: src/frontends/qt4/Action.C
===================================================================
--- src/frontends/qt4/Action.C	(revision 14809)
+++ src/frontends/qt4/Action.C	(working copy)
@@ -48,7 +48,7 @@ Action::Action(LyXView & lyxView, string
 	setToolTip(toqstr(tooltip));
 	setStatusTip(toqstr(tooltip));
 	connect(this, SIGNAL(triggered()), this, SLOT(action()));
-	this->setCheckable(true);
+	update();
 }
 
 Action::Action(LyXView & lyxView, string const & icon, string const & text,
@@ -60,7 +60,7 @@ Action::Action(LyXView & lyxView, string
 	setToolTip(toqstr(tooltip));
 	setStatusTip(toqstr(tooltip));
 	connect(this, SIGNAL(triggered()), this, SLOT(action()));
-	this->setCheckable(true);
+	update();
 }
 
 /*
@@ -74,8 +74,17 @@ void Action::update()
 {
 	FuncStatus const status = lyxView_.getLyXFunc().getStatus(func_);
 
-	this->setChecked(status.onoff(true));
-	this->setEnabled(status.enabled());
+	if (status.onoff(true)) {
+		setCheckable(true);
+		setChecked(true);
+	} else if (status.onoff(false)) {
+		setCheckable(true);
+		setChecked(false);
+	} else {
+		setCheckable(false);
+	}
+
+	setEnabled(status.enabled());
 }
 
 
Index: src/frontends/qt4/QLPopupMenu.C
===================================================================
--- src/frontends/qt4/QLPopupMenu.C	(revision 14809)
+++ src/frontends/qt4/QLPopupMenu.C	(working copy)
@@ -114,16 +114,13 @@ void QLPopupMenu::populate(QMenu* qMenu,
 
 		} else { // we have a MenuItem::Command
 
-			FuncStatus status = m->status();
 			lyxerr[Debug::GUI] << "creating Menu Item " << m->label() << endl;
 
 			string label = getLabel(*m);
 			addBinding(label, *m);
 
-			Action * action = new Action(*(owner_->view()), label, m->func());
-			action->setEnabled(m->status().enabled());
-			action->setChecked(m->status().onoff(true));
-			// Actually insert the menu item
+			Action * action = new Action(*(owner_->view()), 
+						     label, m->func());
 			qMenu->addAction(action);
 		}
 	}

Reply via email to