commit 974534f28a87bd57546be8b7d4d7899318974fe8
Author: Daniel Ramoeller <[email protected]>
Date: Thu Sep 8 07:44:15 2022 +0200
Disentangle status bar and zoom menu
- Moves the zoom menu to the zoom value
---
lib/ui/stdcontext.inc | 9 +++++++--
src/frontends/qt/GuiClickableLabel.cpp | 7 ++++++-
src/frontends/qt/GuiClickableLabel.h | 2 ++
src/frontends/qt/GuiView.cpp | 14 ++++++++++++--
src/frontends/qt/GuiView.h | 4 +++-
5 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc
index eb44a58..b9a2304 100644
--- a/lib/ui/stdcontext.inc
+++ b/lib/ui/stdcontext.inc
@@ -724,11 +724,16 @@ Menuset
End
#
+# Status bar zoom context menu
+#
+ Menu "context-zoom"
+ ZoomOptions
+ End
+
+#
# Status bar context menu
#
Menu "context-statusbar"
- ZoomOptions
- Separator
Item "Zoom Level|Z" "ui-toggle zoomlevel"
Item "Zoom Slider|S" "ui-toggle zoomslider"
Separator
diff --git a/src/frontends/qt/GuiClickableLabel.cpp
b/src/frontends/qt/GuiClickableLabel.cpp
index 311755d..bad90f3 100644
--- a/src/frontends/qt/GuiClickableLabel.cpp
+++ b/src/frontends/qt/GuiClickableLabel.cpp
@@ -11,7 +11,7 @@
#include "GuiClickableLabel.h"
-#include <QStyle>
+#include <QMouseEvent>
namespace lyx {
namespace frontend {
@@ -23,6 +23,11 @@ GuiClickableLabel::GuiClickableLabel(QWidget * parent)
GuiClickableLabel::~GuiClickableLabel()
{}
+void GuiClickableLabel::mousePressEvent(QMouseEvent * e) {
+ if (e->button() == Qt::LeftButton)
+ Q_EMIT pressed();
+}
+
void GuiClickableLabel::mouseReleaseEvent(QMouseEvent *) {
Q_EMIT clicked();
}
diff --git a/src/frontends/qt/GuiClickableLabel.h
b/src/frontends/qt/GuiClickableLabel.h
index b14ba15..2fb4e8e 100644
--- a/src/frontends/qt/GuiClickableLabel.h
+++ b/src/frontends/qt/GuiClickableLabel.h
@@ -25,8 +25,10 @@ public:
Q_SIGNALS:
void clicked();
+ void pressed();
protected:
+ void mousePressEvent(QMouseEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override;
};
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index b87b494..24d6703 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -706,7 +706,8 @@ GuiView::GuiView(int id)
// QPalette palette = statusBar()->palette();
- zoom_value_ = new QLabel(statusBar());
+ zoom_value_ = new GuiClickableLabel(statusBar());
+ connect(zoom_value_, SIGNAL(pressed()), this,
SLOT(showZoomContextMenu()));
// zoom_value_->setPalette(palette);
zoom_value_->setForegroundRole(statusBar()->foregroundRole());
zoom_value_->setFixedHeight(fm.height());
@@ -722,7 +723,7 @@ GuiView::GuiView(int id)
statusBar()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(statusBar(), SIGNAL(customContextMenuRequested(QPoint)),
- this, SLOT(showZoomContextMenu()));
+ this, SLOT(showStatusBarContextMenu()));
// enable pinch to zoom
grabGesture(Qt::PinchGesture);
@@ -863,6 +864,15 @@ void GuiView::zoomOutPressed()
void GuiView::showZoomContextMenu()
{
+ QMenu * menu = guiApp->menus().menu(toqstr("context-zoom"), * this);
+ if (!menu)
+ return;
+ menu->exec(QCursor::pos());
+}
+
+
+void GuiView::showStatusBarContextMenu()
+{
QMenu * menu = guiApp->menus().menu(toqstr("context-statusbar"), *
this);
if (!menu)
return;
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index 7b89370..cbe805e 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -263,6 +263,8 @@ private Q_SLOTS:
///
void showZoomContextMenu();
///
+ void showStatusBarContextMenu();
+ ///
void on_currentWorkAreaChanged(GuiWorkArea *);
///
void onBufferViewChanged();
@@ -526,7 +528,7 @@ private:
/// This excludes blanks
bool char_nb_count_enabled_;
/// Statusbar widget that shows zoom value
- QLabel * zoom_value_;
+ GuiClickableLabel * zoom_value_;
/// The zoom slider widget
QSlider * zoom_slider_;
/// Zoom in ("+") Button
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs