// This function runs "configure" and then rereads lyx.defaults to
// reconfigure the automatic settings.
// This function runs "configure" and then rereads lyx.defaults to
// reconfigure the automatic settings.
-void reconfigure(LyXView & lv, string const & option)
+void reconfigure(LyXView * lv, string const & option)
{
// emit message signal.
{
// emit message signal.
- lv.message(_("Running configure..."));
+ if (lv)
+ lv->message(_("Running configure..."));
// Run configure in user lyx directory
PathChanger p(package().user_support());
// Run configure in user lyx directory
PathChanger p(package().user_support());
int ret = one.startscript(Systemcall::Wait, configure_command);
p.pop();
// emit message signal.
int ret = one.startscript(Systemcall::Wait, configure_command);
p.pop();
// emit message signal.
- lv.message(_("Reloading configuration..."));
+ if (lv)
+ lv->message(_("Reloading configuration..."));
lyxrc.read(libFileSearch(string(), "lyxrc.defaults"));
// Re-read packages.lst
LaTeXFeatures::getAvailable();
lyxrc.read(libFileSearch(string(), "lyxrc.defaults"));
// Re-read packages.lst
LaTeXFeatures::getAvailable();
if (keysym.isModifier()) {
LYXERR(Debug::KEY, "isModifier true");
if (keysym.isModifier()) {
LYXERR(Debug::KEY, "isModifier true");
- lyx_view_->restartCursor();
+ if (lyx_view_)
+ lyx_view_->restartCursor();
//lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
FuncStatus flag;
//lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
FuncStatus flag;
- Buffer * buf = lyx_view_? lyx_view_->buffer() : 0;
+ Buffer * buf = lyx_view_ ? lyx_view_->buffer() : 0;
if (cmd.action == LFUN_NOACTION) {
flag.message(from_utf8(N_("Nothing to do")));
if (cmd.action == LFUN_NOACTION) {
flag.message(from_utf8(N_("Nothing to do")));
break;
case LFUN_RECONFIGURE:
break;
case LFUN_RECONFIGURE:
- BOOST_ASSERT(lyx_view_);
// argument is any additional parameter to the configure.py command
// argument is any additional parameter to the configure.py command
- reconfigure(*lyx_view_, argument);
+ reconfigure(lyx_view_, argument);
break;
case LFUN_HELP_OPEN: {
break;
case LFUN_HELP_OPEN: {
// Nothing more to do.
return;
// Nothing more to do.
return;
+ // Everything below is only for active lyx_view_
+ if (lyx_view_ == 0)
+ break;
+
// Let the current LyXView dispatch its own actions.
// Let the current LyXView dispatch its own actions.
- BOOST_ASSERT(lyx_view_);
if (lyx_view_->dispatch(cmd)) {
if (lyx_view_->view())
updateFlags = lyx_view_->view()->cursor().result().update();
if (lyx_view_->dispatch(cmd)) {
if (lyx_view_->view())
updateFlags = lyx_view_->view()->cursor().result().update();
-Action::Action(GuiView & lyxView, QIcon const & icon,
+Action::Action(GuiView * lyxView, QIcon const & icon,
QString const & text, FuncRequest const & func,
QString const & text, FuncRequest const & func,
- QString const & tooltip)
- : QAction(&lyxView), func_(func), lyxView_(lyxView)
+ QString const & tooltip, QObject * parent)
+ : QAction(parent), func_(func), lyxView_(lyxView)
{
// only Qt/Mac handles that
setMenuRole(NoRole);
{
// only Qt/Mac handles that
setMenuRole(NoRole);
void Action::action()
{
//LYXERR(Debug::ACTION, "calling LyXFunc::dispatch: func_: ");
void Action::action()
{
//LYXERR(Debug::ACTION, "calling LyXFunc::dispatch: func_: ");
- theLyXFunc().setLyXView(&lyxView_);
+
+ if (lyxView_)
+ theLyXFunc().setLyXView(lyxView_);
+
lyx::dispatch(func_);
triggered(this);
}
lyx::dispatch(func_);
triggered(this);
}
- Action(GuiView & lyxView, QIcon const & icon, QString const & text,
- FuncRequest const & func, QString const & tooltip);
+ Action(GuiView * lyxView, QIcon const & icon, QString const & text,
+ FuncRequest const & func, QString const & tooltip, QObject * parent);
private:
FuncRequest const & func_ ;
private:
FuncRequest const & func_ ;
Action * GuiToolbar::addItem(ToolbarItem const & item)
{
Action * GuiToolbar::addItem(ToolbarItem const & item)
{
- Action * act = new Action(owner_,
- getIcon(item.func_, false),
- toqstr(item.label_), item.func_, toqstr(item.label_));
+ Action * act = new Action(&owner_, getIcon(item.func_, false),
+ toqstr(item.label_), item.func_, toqstr(item.label_), this);
actions_.append(act);
return act;
}
actions_.append(act);
return act;
}
d.toolbars_ = new GuiToolbars(*this);
// Fill up the menu bar.
d.toolbars_ = new GuiToolbars(*this);
// Fill up the menu bar.
- guiApp->menus().fillMenuBar(this);
+ guiApp->menus().fillMenuBar(menuBar(), this);
setCentralWidget(d.stack_widget_);
setCentralWidget(d.stack_widget_);
// FIXME: the "math panels" toolbar takes an awful lot of time to
// initialise so we don't do that for the time being.
//d.toolbars_->init();
// FIXME: the "math panels" toolbar takes an awful lot of time to
// initialise so we don't do that for the time being.
//d.toolbars_->init();
- guiApp->menus().fillMenuBar(this);
+ guiApp->menus().fillMenuBar(menuBar(), this);
if (d.layout_)
d.layout_->updateContents(true);
// Now update controls with current buffer.
if (d.layout_)
d.layout_->updateContents(true);
// Now update controls with current buffer.
populate(*subMenu, m->submenu());
} else {
// we have a MenuItem::Command
populate(*subMenu, m->submenu());
} else {
// we have a MenuItem::Command
- qMenu.addAction(new Action(*view, QIcon(), label(*m), m->func(),
- QString()));
+ qMenu.addAction(new Action(view, QIcon(), label(*m),
+ m->func(), QString(), &qMenu));
ViewFormats, ExportFormats, UpdateFormats, Branches
*/
void expand(MenuDefinition const & frommenu, MenuDefinition & tomenu,
ViewFormats, ExportFormats, UpdateFormats, Branches
*/
void expand(MenuDefinition const & frommenu, MenuDefinition & tomenu,
/// Initialize specific MACOS X menubar
/// Initialize specific MACOS X menubar
- void macxMenuBarInit(GuiView * view);
+ void macxMenuBarInit(GuiView * view, QMenuBar * qmb);
/// Mac special menu.
/** This defines a menu whose entries list the FuncRequests
/// Mac special menu.
/** This defines a menu whose entries list the FuncRequests
that this menubar will be used also when one of LyX' dialogs has
focus. (JMarc)
*/
that this menubar will be used also when one of LyX' dialogs has
focus. (JMarc)
*/
-void Menus::Impl::macxMenuBarInit(GuiView * view)
+void Menus::Impl::macxMenuBarInit(GuiView * view, QMenuBar * qmb)
{
// The Mac menubar initialisation must be done only once!
static bool done = false;
{
// The Mac menubar initialisation must be done only once!
static bool done = false;
// add the entries to a QMenu that will eventually be empty
// and therefore invisible.
// add the entries to a QMenu that will eventually be empty
// and therefore invisible.
- QMenu * qMenu = view->menuBar()->addMenu("special");
+ QMenu * qMenu = qmb->addMenu("special");
MenuDefinition::const_iterator cit = specialmenu_.begin();
MenuDefinition::const_iterator end = specialmenu_.end();
for (size_t i = 0 ; cit != end ; ++cit, ++i) {
MenuDefinition::const_iterator cit = specialmenu_.begin();
MenuDefinition::const_iterator end = specialmenu_.end();
for (size_t i = 0 ; cit != end ; ++cit, ++i) {
- Action * action = new Action(*view, QIcon(), cit->label(),
- cit->func(), QString());
+ Action * action = new Action(view, QIcon(), cit->label(),
+ cit->func(), QString(), qMenu);
action->setMenuRole(entries[i].role);
qMenu->addAction(action);
}
action->setMenuRole(entries[i].role);
qMenu->addAction(action);
}
-void Menus::fillMenuBar(GuiView * view)
+void Menus::fillMenuBar(QMenuBar * qmb, GuiView * view)
{
// Clear all menubar contents before filling it.
{
// Clear all menubar contents before filling it.
- view->menuBar()->clear();
#ifdef Q_WS_MACX
// setup special mac specific menu item
#ifdef Q_WS_MACX
// setup special mac specific menu item
- d->macxMenuBarInit(view);
+ d->macxMenuBarInit(view, qmb);
#endif
LYXERR(Debug::GUI, "populating menu bar" << fromqstr(d->menubar_.name()));
#endif
LYXERR(Debug::GUI, "populating menu bar" << fromqstr(d->menubar_.name()));
- d->expand(d->menubar_, menu, view->buffer());
+ Buffer * buf = 0;
+ if (view)
+ buf = view->buffer();
+ d->expand(d->menubar_, menu, buf);
MenuDefinition::const_iterator m = menu.begin();
MenuDefinition::const_iterator end = menu.end();
MenuDefinition::const_iterator m = menu.begin();
MenuDefinition::const_iterator end = menu.end();
}
MenuDefinition const & fromLyxMenu = d->getMenu(qmenu->d->name);
}
MenuDefinition const & fromLyxMenu = d->getMenu(qmenu->d->name);
- d->expand(fromLyxMenu, *qmenu->d->top_level_menu, qmenu->d->view->buffer());
+ Buffer * buf = 0;
+ if (qmenu->d->view)
+ buf = qmenu->d->view->buffer();
+ d->expand(fromLyxMenu, *qmenu->d->top_level_menu, buf);
qmenu->d->populate(*qmenu, *qmenu->d->top_level_menu);
}
qmenu->d->populate(*qmenu, *qmenu->d->top_level_menu);
}
bool searchMenu(FuncRequest const & func,
std::vector<docstring> & names) const;
///
bool searchMenu(FuncRequest const & func,
std::vector<docstring> & names) const;
///
- void fillMenuBar(GuiView * view);
+ void fillMenuBar(QMenuBar * qmb, GuiView * view);
/// \return a top-level submenu given its name.
Menu * menu(QString const & name, GuiView & view);
/// \return a top-level submenu given its name.
Menu * menu(QString const & name, GuiView & view);