#include "GuiApplication.h"
#include "GuiWorkArea.h"
#include "GuiKeySymbol.h"
-#include "GuiMenubar.h"
#include "GuiToolbar.h"
#include "GuiToolbars.h"
+#include "Menus.h"
#include "qt_helpers.h"
#include "LyX.h"
#include "LyXRC.h"
#include "LyXVC.h"
-#include "MenuBackend.h"
#include "Paragraph.h"
#include "TextClass.h"
#include "Text.h"
#include "support/FileFilterList.h"
#include "support/FileName.h"
#include "support/filetools.h"
+#include "support/ForkedCalls.h"
#include "support/lstrings.h"
#include "support/os.h"
#include "support/Package.h"
delete splitter_;
delete bg_widget_;
delete stack_widget_;
- delete menubar_;
delete toolbars_;
}
QSplitter * splitter_;
QStackedWidget * stack_widget_;
BackgroundWidget * bg_widget_;
- /// view's menubar
- GuiMenubar * menubar_;
/// view's toolbars
GuiToolbars * toolbars_;
/// The main layout box.
GuiView::GuiView(int id)
: d(*new GuiViewPrivate), id_(id)
{
- // GuiToolbars *must* be initialised before GuiMenubar.
+ // GuiToolbars *must* be initialised before the menu bar.
d.toolbars_ = new GuiToolbars(*this);
- d.menubar_ = new GuiMenubar(this, menubackend);
+
+ // Fill up the menu bar.
+ guiApp->menus().fillMenuBar(this);
setCentralWidget(d.stack_widget_);
void GuiView::message(docstring const & str)
{
+ if (ForkedProcess::iAmAChild())
+ return;
+
statusBar()->showMessage(toqstr(str));
d.statusbar_timer_.stop();
d.statusbar_timer_.start(3000);
}
return QMainWindow::event(e);
}
+
case QEvent::ShortcutOverride: {
+ if (d.current_work_area_)
+ // Nothing special to do.
+ return QMainWindow::event(e);
+
QKeyEvent * ke = static_cast<QKeyEvent*>(e);
- if (!d.current_work_area_) {
- theLyXFunc().setLyXView(this);
- KeySymbol sym;
- setKeySymbol(&sym, ke);
- theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
- e->accept();
- return true;
- }
- if (ke->key() == Qt::Key_Tab || ke->key() == Qt::Key_Backtab) {
- KeySymbol sym;
- setKeySymbol(&sym, ke);
- d.current_work_area_->processKeySym(sym, NoModifier);
- e->accept();
- return true;
- }
+
+ // Let Qt handle menu access and the Tab keys to navigate keys to navigate
+ // between controls.
+ if (ke->modifiers() & Qt::AltModifier || ke->key() == Qt::Key_Tab
+ || ke->key() == Qt::Key_Backtab)
+ return QMainWindow::event(e);
+
+ // Allow processing of shortcuts that are allowed even when no Buffer
+ // is viewed.
+ theLyXFunc().setLyXView(this);
+ KeySymbol sym;
+ setKeySymbol(&sym, ke);
+ theLyXFunc().processKeySym(sym, q_key_state(ke->modifiers()));
+ e->accept();
+ return true;
}
+
default:
return QMainWindow::event(e);
}
bool const review =
lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
+ bool const mathmacrotemplate =
+ lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
- d.toolbars_->update(math, table, review);
+ d.toolbars_->update(math, table, review, mathmacrotemplate);
} else
- d.toolbars_->update(false, false, false);
+ d.toolbars_->update(false, false, false, false);
// update read-only status of open dialogs.
checkStatus();
break;
case LFUN_MENU_OPEN:
- d.menubar_->openByName(toqstr(cmd.argument()));
+ if (QMenu * menu = guiApp->menus().menu(toqstr(cmd.argument())))
+ menu->exec(QCursor::pos());
break;
case LFUN_FILE_INSERT:
// Make sure that no LFUN uses any LyXView.
theLyXFunc().setLyXView(0);
d.toolbars_->init();
- d.menubar_->init();
+ guiApp->menus().fillMenuBar(this);
if (d.layout_)
d.layout_->updateContents(true);
// Now update controls with current buffer.