From 02110a3d5ba8d3484133470760117db643324473 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 25 Dec 2007 20:12:07 +0000 Subject: [PATCH] Prepare the code for context menu support. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22300 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 8 ++++++++ src/BufferView.h | 3 +++ src/frontends/qt4/GuiWorkArea.cpp | 18 +++++++++++++++++- src/frontends/qt4/GuiWorkArea.h | 5 ++++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index c535cab436..a13a3df033 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -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; diff --git a/src/BufferView.h b/src/BufferView.h index 104fa805f1..53821b7693 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -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 diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index c01c2c6630..a5948e5d37 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -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" @@ -44,15 +45,17 @@ #include "frontends/FontMetrics.h" #include "frontends/WorkAreaManager.h" +#include #include +#include #include #include #include -#include #include #include #include #include +#include #include @@ -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. diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h index 7e254a3448..5019786b4b 100644 --- a/src/frontends/qt4/GuiWorkArea.h +++ b/src/frontends/qt4/GuiWorkArea.h @@ -25,12 +25,13 @@ #include #include -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 *); -- 2.39.2