Re: More questions about statusbar menu

2022-09-07 Thread Daniel

On 2022-09-08 07:15, Daniel wrote:

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.)


Sorry, slightly improved version attached. (The pressed signal was 
previously also emitted on right click which interfered with the context 
menu event.)


Daniel
From c5daa4cbb8c1c2191ab07877d70820572ebbf2af Mon Sep 17 00:00:00 2001
From: Daniel Ramoeller 
Date: Thu, 8 Sep 2022 07:44:15 +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 |  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 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..bad90f3b8e 100644
--- a/src/frontends/qt/GuiClickableLabel.cpp
+++ b/src/frontends/qt/GuiClickableLabel.cpp
@@ -11,7 +11,7 @@
 
 #include "GuiClickableLabel.h"
 
-#include 
+#include 
 
 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 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 = 

Re: More questions about statusbar menu

2022-09-07 Thread Daniel

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.)


DanielFrom 468517474274a356746ab75afe0bdd76f95b0fad Mon Sep 17 00:00:00 2001
From: Daniel Ramoeller 
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());
@@