Commit b3696ad6 authored by Felix Ernst's avatar Felix Ernst 🇺🇦
Browse files

Improve status bar zoom button ux

- Increase button height so it has the same height as the other
    buttons on the status bar.
- Have them show the typical zoom in/out button tooltips including
    the keyboard shortcuts.

This has no impact on the default look of Gwenview because both of
these things are only noticeable when hovering with the mouse.
parent b947770f
Pipeline #121985 passed with stage
in 5 minutes and 41 seconds
......@@ -38,8 +38,6 @@ struct ZoomSliderPrivate {
QToolButton *mZoomOutButton;
QToolButton *mZoomInButton;
QSlider *mSlider;
QAction *mZoomInAction;
QAction *mZoomOutAction;
void updateButtons()
{
......@@ -55,6 +53,7 @@ static QToolButton *createZoomButton(const QString &iconName)
{
auto *button = new QToolButton;
button->setIcon(QIcon::fromTheme(iconName));
button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
button->setAutoRaise(true);
button->setAutoRepeat(true);
return button;
......@@ -66,8 +65,6 @@ ZoomSlider::ZoomSlider(QWidget *parent)
{
d->mZoomInButton = createZoomButton(QStringLiteral("zoom-in"));
d->mZoomOutButton = createZoomButton(QStringLiteral("zoom-out"));
d->mZoomInAction = nullptr;
d->mZoomOutAction = nullptr;
d->mSlider = new QSlider;
d->mSlider->setOrientation(Qt::Horizontal);
......@@ -116,12 +113,14 @@ void ZoomSlider::setMaximum(int value)
void ZoomSlider::setZoomInAction(QAction *action)
{
d->mZoomInAction = action;
disconnect(d->mZoomInButton, &QToolButton::clicked, this, &ZoomSlider::zoomIn);
d->mZoomInButton->setDefaultAction(action);
}
void ZoomSlider::setZoomOutAction(QAction *action)
{
d->mZoomOutAction = action;
disconnect(d->mZoomOutButton, &QToolButton::clicked, this, &ZoomSlider::zoomOut);
d->mZoomOutButton->setDefaultAction(action);
}
void ZoomSlider::slotActionTriggered(int)
......@@ -131,18 +130,14 @@ void ZoomSlider::slotActionTriggered(int)
void ZoomSlider::zoomOut()
{
if (d->mZoomOutAction) {
d->mZoomOutAction->trigger();
} else {
if (!d->mZoomOutButton->defaultAction()) {
d->mSlider->triggerAction(QAbstractSlider::SliderPageStepSub);
}
}
void ZoomSlider::zoomIn()
{
if (d->mZoomInAction) {
d->mZoomInAction->trigger();
} else {
if (!d->mZoomInButton->defaultAction()) {
d->mSlider->triggerAction(QAbstractSlider::SliderPageStepAdd);
}
}
......
......@@ -78,7 +78,7 @@ ZoomWidget::ZoomWidget(QWidget *parent)
d->q = this;
d->mZoomUpdatedBySlider = false;
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
d->mZoomSlider = new ZoomSlider;
d->mZoomSlider->setMinimumWidth(150);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment