[LyX/master] Restrict toolbar menu to toolbar
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Sat Dec 10 18:35:03 UTC 2022
commit bfff93d879672e3a67505fe6ded2ff1a04360dca
Author: Daniel Ramoeller <d.lyx at web.de>
Date: Sat Dec 10 16:26:25 2022 +0100
Restrict toolbar menu to toolbar
Partial fix for bug #11949.
---
src/frontends/qt/GuiToolbar.cpp | 11 +++++++++++
src/frontends/qt/GuiToolbar.h | 3 +++
src/frontends/qt/GuiView.cpp | 12 ------------
src/frontends/qt/GuiView.h | 3 ---
4 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/src/frontends/qt/GuiToolbar.cpp b/src/frontends/qt/GuiToolbar.cpp
index ed8dd0a..cc61f2f 100644
--- a/src/frontends/qt/GuiToolbar.cpp
+++ b/src/frontends/qt/GuiToolbar.cpp
@@ -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);
diff --git a/src/frontends/qt/GuiToolbar.h b/src/frontends/qt/GuiToolbar.h
index 6b3581c..23ee961 100644
--- a/src/frontends/qt/GuiToolbar.h
+++ b/src/frontends/qt/GuiToolbar.h
@@ -179,6 +179,9 @@ Q_SIGNALS:
///
void updated();
+private Q_SLOTS:
+ void showContextMenu(QPoint pos);
+
private:
// load flags with saved values
void initFlags();
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 1f4567d..b229a78 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -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)
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index 8cf0315..eff923b 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -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);
More information about the lyx-cvs
mailing list