From 796382454c1f60ac5ecd92fe83001e5417434930 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Wed, 11 Jul 2018 14:43:14 +0200 Subject: WebView: always add zoom widget to context menu --- src/webengine/webview.cpp | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src/webengine') diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp index 8ae7eeb..b7258ea 100644 --- a/src/webengine/webview.cpp +++ b/src/webengine/webview.cpp @@ -182,33 +182,33 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) createWindow(QWebEnginePage::WebBrowserWindow)->load(ctxdata.linkUrl()); }); } + } else { + menu = page()->createStandardContextMenu(); + } - // zoom widget - { - menu->addSeparator(); + // zoom widget + { + menu->addSeparator(); - auto *zoomSlider = new QSlider(Qt::Horizontal); - zoomSlider->setMinimum(5); - zoomSlider->setMaximum(50); - zoomSlider->setValue(zoomFactor() * 10); + auto *zoomSlider = new QSlider(Qt::Horizontal); + zoomSlider->setMinimum(5); + zoomSlider->setMaximum(50); + zoomSlider->setValue(zoomFactor() * 10); - auto *zoomAction = menu->addAction(tr("Zoom: %1x").arg(zoomFactor())); - connect(zoomAction, &QAction::triggered, this, [zoomSlider]() { - zoomSlider->setValue(10); - }); + auto *zoomAction = menu->addAction(tr("Zoom: %1x").arg(zoomFactor())); + connect(zoomAction, &QAction::triggered, this, [zoomSlider]() { + zoomSlider->setValue(10); + }); - connect(zoomSlider, &QSlider::valueChanged, this, [this, zoomAction](int value) { - zoomAction->setText(tr("Zoom: %1x").arg(static_cast(value) / 10)); - setZoomFactor(static_cast(value) / 10); - }); + connect(zoomSlider, &QSlider::valueChanged, this, [this, zoomAction](int value) { + zoomAction->setText(tr("Zoom: %1x").arg(static_cast(value) / 10)); + setZoomFactor(static_cast(value) / 10); + }); - auto *zoomWidgetAction = new QWidgetAction(this); - zoomWidgetAction->setDefaultWidget(zoomSlider); + auto *zoomWidgetAction = new QWidgetAction(this); + zoomWidgetAction->setDefaultWidget(zoomSlider); - menu->addAction(zoomWidgetAction); - } - } else { - menu = page()->createStandardContextMenu(); + menu->addAction(zoomWidgetAction); } menu->setMinimumWidth(250); -- cgit v1.2.1