]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiView.cpp
Allow use of Tab keys when no document's open.
[lyx.git] / src / frontends / qt4 / GuiView.cpp
index 4f1b4ce51ebd0061281d254d7dae165cf805766f..c07aa04ec0aedc20424c0bd294ad51f41dbb3bdd 100644 (file)
@@ -20,9 +20,9 @@
 #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"
 
@@ -45,7 +45,6 @@
 #include "LyX.h"
 #include "LyXRC.h"
 #include "LyXVC.h"
-#include "MenuBackend.h"
 #include "Paragraph.h"
 #include "TextClass.h"
 #include "Text.h"
@@ -55,6 +54,7 @@
 #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"
@@ -165,7 +165,6 @@ struct GuiView::GuiViewPrivate
                delete splitter_;
                delete bg_widget_;
                delete stack_widget_;
-               delete menubar_;
                delete toolbars_;
        }
 
@@ -242,8 +241,6 @@ public:
        QSplitter * splitter_;
        QStackedWidget * stack_widget_;
        BackgroundWidget * bg_widget_;
-       /// view's menubar
-       GuiMenubar * menubar_;
        /// view's toolbars
        GuiToolbars * toolbars_;
        /// The main layout box.
@@ -280,9 +277,11 @@ public:
 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);
+
+       // Fill up the menu bar.
+       guiApp->menus().fillMenuBar(this);
 
        setCentralWidget(d.stack_widget_);
 
@@ -461,6 +460,9 @@ void GuiView::dropEvent(QDropEvent* event)
 
 void GuiView::message(docstring const & str)
 {
+       if (ForkedProcess::iAmAChild())
+               return;
+
        statusBar()->showMessage(toqstr(str));
        d.statusbar_timer_.stop();
        d.statusbar_timer_.start(3000);
@@ -576,24 +578,30 @@ bool GuiView::event(QEvent * e)
                }
                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);
        }
@@ -1366,7 +1374,8 @@ bool GuiView::dispatch(FuncRequest const & cmd)
                        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:
@@ -1596,7 +1605,7 @@ void GuiView::resetDialogs()
        // 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.