]> git.lyx.org Git - features.git/commitdiff
Revert "Show toolbar context menu only when clicking on the toolbar"
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 16 Sep 2020 14:54:33 +0000 (16:54 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 16 Sep 2020 14:54:33 +0000 (16:54 +0200)
Something is wrong.

This reverts commit f25253f89ac121b1981fe26f0b90af9e2bbbe849.

src/frontends/qt/GuiToolbar.cpp
src/frontends/qt/GuiToolbar.h
src/frontends/qt/GuiView.cpp
src/frontends/qt/GuiView.h

index e80dc4887c1d6cd2e49e42dec036ec456bab024a..f58069bde3b82ab8fc25c1b9ec699b169a5f243e 100644 (file)
@@ -34,7 +34,6 @@
 #include "LayoutBox.h"
 #include "LyX.h"
 #include "LyXRC.h"
-#include "Menus.h"
 #include "qt_helpers.h"
 #include "Session.h"
 #include "Text.h"
@@ -71,9 +70,6 @@ GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
        setIconSize(owner.iconSize());
        connect(&owner, SIGNAL(iconSizeChanged(QSize)), this,
                SLOT(setIconSize(QSize)));
-       // install toolbar filter for context menu including disabled buttons
-       setContextMenuPolicy(Qt::PreventContextMenu);
-       QCoreApplication::instance()->installEventFilter(this);
 
        // This is used by QMainWindow::restoreState for proper main window state
        // restoration.
@@ -127,24 +123,6 @@ void GuiToolbar::showEvent(QShowEvent * ev)
 }
 
 
-bool GuiToolbar::eventFilter(QObject * obj, QEvent * ev)
-{
-       if (obj == this || obj->parent() == this) {
-               if (ev->type() == QEvent::ContextMenu) {
-                       QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(ev);
-                       QMenu * menu = guiApp->menus().menu(toqstr("context-toolbars"), owner_);
-                       menu->exec(mouseEvent->globalPos());
-                       return true;
-               } else {
-                       return false;
-               }
-       } else {
-               // pass the event on to the parent class
-               return QToolBar::eventFilter(obj, ev);
-       }
-}
-
-
 void GuiToolbar::setVisibility(int visibility)
 {
        visibility_ = visibility;
index bd4ef8f86277ef588fb20135aad3f254065b0552..eccd05a6fb31fc6772c4ffa377b87bd3533cac0b 100644 (file)
@@ -177,8 +177,6 @@ private:
        void fill();
        ///
        void showEvent(QShowEvent *);
-       ///
-       bool eventFilter(QObject * obj, QEvent * ev);
 
        ///
        QList<Action *> actions_;
index 7dd6dbb1aa3179a26813c902d794dfcd2b3e5e01..948deb9a756c8378faa666f9974db143287037bd 100644 (file)
@@ -677,6 +677,11 @@ GuiView::GuiView(int id)
        connect(this, SIGNAL(triggerShowDialog(QString const &, QString const &, Inset *)),
                SLOT(doShowDialog(QString const &, QString const &, Inset *)));
 
+       // set custom application bars context menu, e.g. tool bar and menu bar
+       setContextMenuPolicy(Qt::CustomContextMenu);
+       connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
+               SLOT(toolBarPopup(const QPoint &)));
+
        // Forbid too small unresizable window because it can happen
        // with some window manager under X11.
        setMinimumSize(300, 200);
@@ -3783,6 +3788,13 @@ bool GuiView::goToFileRow(string const & argument)
 }
 
 
+void GuiView::toolBarPopup(const QPoint & /*pos*/)
+{
+       QMenu * menu = guiApp->menus().menu(toqstr("context-toolbars"), * this);
+       menu->exec(QCursor::pos());
+}
+
+
 template<class T>
 Buffer::ExportStatus GuiView::GuiViewPrivate::runAndDestroy(const T& func,
                Buffer const * orig, Buffer * clone, string const & format)
index 1ad534a747681c117a0be5024906e24cc18b4fc1..d611b39e0f586655ed7bd8f0c8eb427d1b249cba 100644 (file)
@@ -260,6 +260,9 @@ private Q_SLOTS:
        void updateStatusBarMessage(QString const & str);
        void clearMessageText();
 
+       ///
+       void toolBarPopup(const QPoint &pos);
+
 private:
        /// Open given child document in current buffer directory.
        void openChildDocument(std::string const & filename);