commit 59b8c209c41d4f02448460486bb497aa6f7d9587
Author: Daniel Ramoeller <[email protected]>
Date: Tue Nov 2 08:08:29 2021 +0100
Use labels for zoom slider buttons
Fix for bug #12301.
Also: fixes the width and alignment of the zoom value label.
---
src/frontends/qt/GuiClickableLabel.cpp | 6 ++++--
src/frontends/qt/GuiView.cpp | 22 ++++++++++++++--------
src/frontends/qt/GuiView.h | 7 ++++---
3 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/src/frontends/qt/GuiClickableLabel.cpp
b/src/frontends/qt/GuiClickableLabel.cpp
index 31a5be5..311755d 100644
--- a/src/frontends/qt/GuiClickableLabel.cpp
+++ b/src/frontends/qt/GuiClickableLabel.cpp
@@ -11,6 +11,8 @@
#include "GuiClickableLabel.h"
+#include <QStyle>
+
namespace lyx {
namespace frontend {
@@ -22,8 +24,8 @@ GuiClickableLabel::~GuiClickableLabel()
{}
void GuiClickableLabel::mouseReleaseEvent(QMouseEvent *) {
- Q_EMIT clicked();
- }
+ Q_EMIT clicked();
+}
}
}
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 1068bdd..65d51cf 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -648,14 +648,15 @@ GuiView::GuiView(int id)
zoom_slider_->setToolTip(qt_("Workarea zoom level. Drag, use Ctrl-+/-
or Shift-Mousewheel to adjust."));
// Buttons to change zoom stepwise
- zoom_in_ = new QPushButton(statusBar());
+ QSize s(fm.width('+'), fm.height());
+ zoom_in_ = new GuiClickableLabel(statusBar());
zoom_in_->setText("+");
- zoom_in_->setFlat(true);
- zoom_in_->setFixedSize(QSize(fm.height(), fm.height()));
- zoom_out_ = new QPushButton(statusBar());
+ zoom_in_->setFixedSize(s);
+ zoom_in_->setAlignment(Qt::AlignCenter);
+ zoom_out_ = new GuiClickableLabel(statusBar());
zoom_out_->setText(QString(QChar(0x2212)));
- zoom_out_->setFixedSize(QSize(fm.height(), fm.height()));
- zoom_out_->setFlat(true);
+ zoom_out_->setFixedSize(s);
+ zoom_out_->setAlignment(Qt::AlignCenter);
statusBar()->addPermanentWidget(zoom_out_);
zoom_out_->setEnabled(currentBufferView());
@@ -670,13 +671,18 @@ GuiView::GuiView(int id)
connect(zoom_in_, SIGNAL(clicked()), this, SLOT(zoomInPressed()));
connect(zoom_out_, SIGNAL(clicked()), this, SLOT(zoomOutPressed()));
+ // QPalette palette = statusBar()->palette();
+
zoom_value_ = new QLabel(statusBar());
+ // zoom_value_->setPalette(palette);
+ zoom_value_->setForegroundRole(statusBar()->foregroundRole());
zoom_value_->setFixedHeight(fm.height());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
- zoom_value_->setMinimumWidth(fm.horizontalAdvance("000%"));
+ zoom_value_->setMinimumWidth(fm.horizontalAdvance("444\%"));
#else
- zoom_value_->setMinimumWidth(fm.width("000%"));
+ zoom_value_->setMinimumWidth(fm.width("444\%"));
#endif
+ zoom_value_->setAlignment(Qt::AlignCenter);
zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), zoom)));
statusBar()->addPermanentWidget(zoom_value_);
zoom_value_->setEnabled(currentBufferView());
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index c16b557..145a1f2 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -20,6 +20,7 @@
#include "support/strfwd.h"
#include <QMainWindow>
+#include <QLabel>
#include <QMenu>
#include <QSvgWidget>
@@ -27,7 +28,6 @@ class QCloseEvent;
class QDragEnterEvent;
class QDropEvent;
class QPushButton;
-class QLabel;
class QShowEvent;
class QSlider;
@@ -48,6 +48,7 @@ namespace frontend {
class Dialog;
class LayoutBox;
+class GuiClickableLabel;
class GuiToolbar;
class GuiWorkArea;
class TabWorkArea;
@@ -510,9 +511,9 @@ private:
/// The zoom slider widget
QSlider * zoom_slider_;
/// Zoom in ("+") Button
- QPushButton * zoom_in_;
+ GuiClickableLabel * zoom_in_;
/// Zoom out ("-") Button
- QPushButton * zoom_out_;
+ GuiClickableLabel * zoom_out_;
/// The rate from which the actual zoom value is calculated
/// from the default zoom pref
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs