]> git.lyx.org Git - lyx.git/commitdiff
Prepare the code for context menu support.
authorAbdelrazak Younes <younes@lyx.org>
Tue, 25 Dec 2007 20:12:07 +0000 (20:12 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 25 Dec 2007 20:12:07 +0000 (20:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22300 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/BufferView.h
src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/GuiWorkArea.h

index c535cab436ea461f5e6e2cb922d848778a17561f..a13a3df033ab49b5a8d3c1e8001e12dcb740d585 100644 (file)
@@ -39,6 +39,7 @@
 #include "LyXFunc.h"
 #include "Layout.h"
 #include "LyXRC.h"
+#include "MenuBackend.h"
 #include "MetricsInfo.h"
 #include "Paragraph.h"
 #include "paragraph_funcs.h"
@@ -490,6 +491,13 @@ docstring BufferView::toolTip(int x, int y) const
 }
 
 
+Menu const & BufferView::contextMenu(int x, int y) const
+{
+       // FIXME: Do something more elaborate here.
+       return menubackend.getMenu(from_ascii("edit"));
+}
+
+
 void BufferView::scrollDocView(int value)
 {
        int const offset = value - d->scrollbarParameters_.position;
index 104fa805f15fac6d6adafb6bf1e9c41af2f76665..53821b76931c1cecee2765e303a9f9a370a3edc8 100644 (file)
@@ -36,6 +36,7 @@ class FuncRequest;
 class FuncStatus;
 class Intl;
 class Inset;
+class Menu;
 class ParIterator;
 class ParagraphMetrics;
 class Point;
@@ -106,6 +107,8 @@ public:
        ScrollbarParameters const & scrollbarParameters() const;
        /// \return Tool tip for the given position.
        docstring toolTip(int x, int y) const;
+       /// \return the context menu for the given position.
+       Menu const & contextMenu(int x, int y) const;
 
        /// Save the current position as bookmark.
        /// if idx == 0, save to temp_bookmark
index c01c2c663009cd67651f074f7bd22e730b57d81b..a5948e5d37e5c6b3d39c041d7c4eb2dca3544b52 100644 (file)
@@ -23,6 +23,7 @@
 #include "GuiApplication.h"
 #include "GuiKeySymbol.h"
 #include "GuiPainter.h"
+#include "GuiPopupMenu.h"
 #include "GuiView.h"
 #include "KeySymbol.h"
 #include "Language.h"
 #include "frontends/FontMetrics.h"
 #include "frontends/WorkAreaManager.h"
 
+#include <QContextMenuEvent>
 #include <QInputContext>
+#include <QHelpEvent>
 #include <QLayout>
 #include <QMainWindow>
 #include <QPainter>
-#include <QToolButton>
 #include <QPalette>
 #include <QScrollBar>
 #include <QTabBar>
 #include <QTimer>
+#include <QToolButton>
 
 #include <boost/bind.hpp>
 
@@ -512,6 +515,19 @@ bool GuiWorkArea::event(QEvent * e)
 }
 
 
+void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e)
+{
+       QPoint pos = e->pos();
+       Menu const & menu = buffer_view_->contextMenu(pos.x(), pos.y());
+       LYXERR(Debug::GUI, "context menu resquested: " << menu.name());
+
+       // FIXME: do something with GuiPopupMenu and MenuBackend.
+       // Some cleanups of GuiPopupMenu and GuiMenubar are needed
+       // before!
+       QAbstractScrollArea::contextMenuEvent(e);
+}
+
+
 void GuiWorkArea::focusInEvent(QFocusEvent * /*event*/)
 {
        // Repaint the whole screen.
index 7e254a3448baaaa50c24f0070b2fb75eb2e689f2..5019786b4b0070b84a10b50020d4810caf7341fb 100644 (file)
 #include <QTabWidget>
 #include <QTimer>
 
-class QWidget;
+class QContextMenuEvent;
 class QDragEnterEvent;
 class QDropEvent;
 class QKeyEvent;
 class QWheelEvent;
 class QPaintEvent;
+class QWidget;
 
 #ifdef CursorShape
 #undef CursorShape
@@ -167,6 +168,8 @@ private:
        ///
        bool event(QEvent *);
        ///
+       void contextMenuEvent(QContextMenuEvent *);
+       ///
        void focusInEvent(QFocusEvent *);
        ///
        void focusOutEvent(QFocusEvent *);