More questions about statusbar menu
Daniel
xracoonx at gmx.de
Thu Sep 8 05:15:24 UTC 2022
On 2022-09-05 12:36, Jean-Marc Lasgouttes wrote:
> Le 05/09/2022 à 12:26, Jean-Marc Lasgouttes a écrit :
>>> Do as you see fit.
>>
>> I did, but I have more questions now.
>
> PS: I realize that I should have read tickets #12182 and #12187 before
> posting point 3/. I do not want to initiate an endless discussion about
> these things :) It is just that I noticed this while looking at the
> statistics thing.
>>
>> 3/ The contextual menu is a weird merge of what LibreOffice and MS
>> Office do:
>> * LO: each element has its menu, the zoom menu has example values
>> to set (fit width, fit page, 50%, 75%, etc.), no way to tell which
>> statistics should be there
>> * MSO: only one menu with checkboxes to indicate which elements
>> should be shown, no way to tell which statistics should be there, no
>> way to set zoom from menu
>> * LyX one menu that does both selection of elements and zooming,
>> zoom in/out and reset to default (main use IMO is to learn shortcuts),
>> weird-looking precomputed zoom values
>>
>> I understand that splitting the menu would make zoom menu unavailable
>> when both count and slider are off; some solution would be needed if
>> splitting the menus. OTOH I am not sure that the zoom menu is useful,
>> except maybe for the reset to default, which is not available via a
>> mouse click. In this respect, I like the Firefox approach, where
>> clicking on the zoom indicator resets zoom to default.
I don't remember that splitting menus was suggested yet at #12182 and
#12187. (Feel free to ignore my comment otherwise.) I seem to remember
that I suggested the whole status bar menu originally. Back then, there
were was only zoom options which made it rather unproblematic to show
zoom stuff on there. But now that more options were added (and probably
not the last ones), I agree that it should be split up. Further zoom
options are available in both Word and Writer by pressing the zoom
value. I suggest we just use the same (standard) mechanism. Stopping
short of creating a dialog, I suggest to just show a menu as in the
attached patch.
(By the way, setting 100% zoom to be actual zoom as suggested elsewhere
might partly help with the number strangeness - at least as long as the
default zoom is not changed.)
Daniel
-------------- next part --------------
From 468517474274a356746ab75afe0bdd76f95b0fad Mon Sep 17 00:00:00 2001
From: Daniel Ramoeller <d.lyx at web.de>
Date: Thu, 8 Sep 2022 07:04:07 +0200
Subject: [PATCH] Disentangle status bar and zoom menu
- Moves the zoom menu to the zoom value
---
lib/ui/stdcontext.inc | 9 +++++++--
src/frontends/qt/GuiClickableLabel.cpp | 4 ++++
src/frontends/qt/GuiClickableLabel.h | 2 ++
src/frontends/qt/GuiView.cpp | 14 ++++++++++++--
src/frontends/qt/GuiView.h | 4 +++-
5 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/lib/ui/stdcontext.inc b/lib/ui/stdcontext.inc
index eb44a58f30..b9a23040c6 100644
--- a/lib/ui/stdcontext.inc
+++ b/lib/ui/stdcontext.inc
@@ -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
diff --git a/src/frontends/qt/GuiClickableLabel.cpp b/src/frontends/qt/GuiClickableLabel.cpp
index 311755d130..f2c1cd4d52 100644
--- a/src/frontends/qt/GuiClickableLabel.cpp
+++ b/src/frontends/qt/GuiClickableLabel.cpp
@@ -23,6 +23,10 @@ GuiClickableLabel::GuiClickableLabel(QWidget * parent)
GuiClickableLabel::~GuiClickableLabel()
{}
+void GuiClickableLabel::mousePressEvent(QMouseEvent *) {
+ 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 b14ba15de8..2fb4e8e25e 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 b87b494dac..24d6703e30 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);
@@ -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)
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index 7b89370151..cbe805eed3 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
--
2.24.3 (Apple Git-128)
More information about the lyx-devel
mailing list