]> git.lyx.org Git - features.git/commitdiff
Restrict toolbar menu to toolbar
authorDaniel Ramoeller <d.lyx@web.de>
Sat, 10 Dec 2022 15:26:25 +0000 (16:26 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sat, 10 Dec 2022 19:30:58 +0000 (20:30 +0100)
Partial fix for bug #11949.

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

index ed8dd0af58cc2ae4adb5451136ef1164e74d4583..cc61f2f665ae5f8d3917935041f7b171e2023b55 100644 (file)
@@ -34,6 +34,7 @@
 #include "LayoutBox.h"
 #include "LyX.h"
 #include "LyXRC.h"
+#include "Menus.h"
 #include "qt_helpers.h"
 #include "Session.h"
 #include "Text.h"
@@ -75,6 +76,9 @@ GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
        setIconSize(owner.iconSize());
        connect(&owner, SIGNAL(iconSizeChanged(QSize)), this,
                SLOT(setIconSize(QSize)));
+       setContextMenuPolicy(Qt::CustomContextMenu);
+       connect(this, SIGNAL(customContextMenuRequested(QPoint)),
+               SLOT(showContextMenu(QPoint)));
 
        // This is used by QMainWindow::restoreState for proper main window state
        // restoration.
@@ -142,6 +146,13 @@ void GuiToolbar::setVisibility(int visibility)
 }
 
 
+void GuiToolbar::showContextMenu(QPoint pos)
+{
+       QMenu * menu = guiApp->menus().menu(toqstr("context-toolbars"), owner_);
+       menu->exec(mapToGlobal(pos));
+}
+
+
 Action * GuiToolbar::addItem(ToolbarItem const & item, bool menu)
 {
        QString text = toqstr(item.label);
index 6b3581c2d2dbb9c249a7d63e84bcdffaf26842ba..23ee9610d14b39deeee9e251080fdc3eeecc68c3 100644 (file)
@@ -179,6 +179,9 @@ Q_SIGNALS:
        ///
        void updated();
 
+private Q_SLOTS:
+       void showContextMenu(QPoint pos);
+
 private:
        // load flags with saved values
        void initFlags();
index 1f4567d4e65a61c3dc64f7c4b41c6bed651abd69..b229a78995f6a1806d1bbe15b7926efb2a34ca9c 100644 (file)
@@ -769,11 +769,6 @@ 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);
@@ -4166,13 +4161,6 @@ 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 8cf031585aff898249c9eef0fb04bda9aa6706fe..eff923bda456862bf163c3c47c0adafde84e2e4d 100644 (file)
@@ -286,9 +286,6 @@ 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);