#include "GuiApplication.h"
#include "GuiWorkArea.h"
#include "GuiKeySymbol.h"
-#include "GuiMenubar.h"
#include "GuiToolbar.h"
#include "GuiToolbars.h"
-#include "GuiProgress.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"
# include <unistd.h>
#endif
-using std::endl;
-using std::string;
-using std::vector;
+using namespace std;
+using namespace lyx::support;
namespace lyx {
namespace frontend {
-using support::addPath;
-using support::bformat;
-using support::FileFilterList;
-using support::FileName;
-using support::makeAbsPath;
-using support::makeDisplayPath;
-using support::package;
-using support::removeAutosaveFile;
-using support::trim;
-
namespace {
class BackgroundWidget : public QWidget
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.
GuiLayoutBox * layout_;
///
- std::map<std::string, Inset *> open_insets_;
+ map<string, Inset *> open_insets_;
///
- std::map<std::string, DialogPtr> dialogs_;
+ map<string, DialogPtr> dialogs_;
unsigned int smallIconSize;
unsigned int normalIconSize;
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_);
settings.setValue(key + "/icon_size", iconSize());
d.toolbars_->saveToolbarInfo();
// Now take care of all other dialogs:
- std::map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
+ map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
for (; it!= d.dialogs_.end(); ++it)
it->second->saveSession();
}
LYXERR(Debug::GUI, "GuiView::dropEvent: got URLs!");
for (int i = 0; i != files.size(); ++i) {
- string const file = support::os::internal_path(fromqstr(
+ string const file = os::internal_path(fromqstr(
files.at(i).toLocalFile()));
if (!file.empty())
lyx::dispatch(FuncRequest(LFUN_FILE_OPEN, file));
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();
if (!isDialogVisible(name))
return;
- std::map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
+ map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
if (it == d.dialogs_.end())
return;
if (b)
setBuffer(b);
+ // Ensure the cursor is correctly positionned on screen.
+ view()->showCursor();
}
dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
dlg.setButton2(_("Templates|#T#t"), from_utf8(lyxrc.template_path));
- if (!support::isLyXFilename(fname.absFilename()))
+ if (!isLyXFilename(fname.absFilename()))
fname.changeExtension(".lyx");
- support::FileFilterList const filter(_("LyX Documents (*.lyx)"));
+ FileFilterList const filter(_("LyX Documents (*.lyx)"));
FileDialog::Result result =
dlg.save(from_utf8(fname.onlyPath().absFilename()),
if (fname.empty())
return false;
- if (!support::isLyXFilename(fname.absFilename()))
+ if (!isLyXFilename(fname.absFilename()))
fname.changeExtension(".lyx");
}
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:
"thesaurus",
#endif
-"texinfo", "toc", "href", "view-source", "view-console", "vspace", "wrap", "listings" };
+"texinfo", "toc", "href", "view-source", "vspace", "wrap", "listings" };
char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *));
bool isValidName(string const & name)
{
- return std::find_if(dialognames, end_dialognames,
+ return find_if(dialognames, end_dialognames,
cmpCStr(name.c_str())) != end_dialognames;
}
// 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.
if (!isValidName(name))
return 0;
- std::map<string, DialogPtr>::iterator it = d.dialogs_.find(name);
+ map<string, DialogPtr>::iterator it = d.dialogs_.find(name);
if (it != d.dialogs_.end())
return it->second.get();
bool GuiView::isDialogVisible(string const & name) const
{
- std::map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
+ map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
if (it == d.dialogs_.end())
return false;
return it->second.get()->isVisibleView();
if (quitting)
return;
- std::map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
+ map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
if (it == d.dialogs_.end())
return;
if (!isValidName(name))
return 0;
- std::map<string, Inset *>::const_iterator it = d.open_insets_.find(name);
+ map<string, Inset *>::const_iterator it = d.open_insets_.find(name);
return it == d.open_insets_.end() ? 0 : it->second;
}
void GuiView::hideAll() const
{
- std::map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
- std::map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
+ map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
+ map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
for(; it != end; ++it)
it->second->hideView();
void GuiView::hideBufferDependent() const
{
- std::map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
- std::map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
+ map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
+ map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
for(; it != end; ++it) {
Dialog * dialog = it->second.get();
void GuiView::updateBufferDependent(bool switched) const
{
- std::map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
- std::map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
+ map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
+ map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
for(; it != end; ++it) {
Dialog * dialog = it->second.get();
void GuiView::checkStatus()
{
- std::map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
- std::map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
+ map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
+ map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
for(; it != end; ++it) {
Dialog * const dialog = it->second.get();
Dialog * createGuiHyperlink(GuiView & lv);
Dialog * createGuiVSpace(GuiView & lv);
Dialog * createGuiViewSource(GuiView & lv);
-Dialog * createGuiProgress(GuiView & lv);
Dialog * createGuiWrap(GuiView & lv);
return createGuiLog(*this);
if (name == "view-source")
return createGuiViewSource(*this);
- if (name == "view-console")
- return createGuiProgress(*this);
if (name == "mathdelimiter")
return createGuiDelimiter(*this);
if (name == "mathmatrix")