Disentangle status bar and zoom menu

- Moves the zoom menu to the zoom value
This commit is contained in:
Daniel Ramoeller 2022-09-08 07:44:15 +02:00 committed by Jean-Marc Lasgouttes
parent edc339dcc1
commit 974534f28a
5 changed files with 30 additions and 6 deletions

View File

@ -723,12 +723,17 @@ Menuset
Item "Giant-sized Icons" "icon-size giant"
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

View File

@ -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();
}

View File

@ -25,8 +25,10 @@ public:
Q_SIGNALS:
void clicked();
void pressed();
protected:
void mousePressEvent(QMouseEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override;
};

View File

@ -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);
@ -862,6 +863,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)

View File

@ -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