Commit 2c627bf8 authored by Laurent Montel's avatar Laurent Montel 😁

Allow to change zoom with wheel

parent 678c22f0
......@@ -33,6 +33,11 @@ class QAction;
class QWidget;
namespace WebEngineViewer
{
class ZoomActionMenu;
}
namespace Akregator
{
......@@ -57,6 +62,8 @@ public:
virtual QAction *action(const QString &name) = 0;
virtual QWidget *container(const QString &name) = 0;
virtual WebEngineViewer::ZoomActionMenu *zoomActionMenu() const = 0;
virtual void setArticleActionsEnabled(bool enabled) = 0;
private:
......
......@@ -71,7 +71,7 @@ public:
void setArticleActionsEnabled(bool enabled) Q_DECL_OVERRIDE;
void setTrayIcon(TrayIcon *trayIcon);
KActionCollection *actionCollection() const;
WebEngineViewer::ZoomActionMenu *zoomActionMenu() const;
WebEngineViewer::ZoomActionMenu *zoomActionMenu() const Q_DECL_OVERRIDE;
QString quickSearchLineText() const;
public Q_SLOTS:
......
......@@ -19,6 +19,7 @@
#include "akregator_debug.h"
#include "articleviewerwebenginepage.h"
#include "webengine/urlhandlerwebenginemanager.h"
#include <WebEngineViewer/ZoomActionMenu>
#include "actionmanager.h"
#include "akregatorconfig.h"
#include "actions/actions.h"
......@@ -348,6 +349,16 @@ void ArticleViewerWebEngine::forwardWheelEvent(QWheelEvent *e)
if (Settings::self()->accessKeyEnabled()) {
mWebEngineViewAccessKey->wheelEvent(e);
}
if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
const int numDegrees = e->delta() / 8;
const int numSteps = numDegrees / 15;
const qreal factor = ActionManager::getInstance()->zoomActionMenu()->zoomFactor() + numSteps * 10;
if (factor >= 10 && factor <= 300) {
ActionManager::getInstance()->zoomActionMenu()->setZoomFactor(factor);
ActionManager::getInstance()->zoomActionMenu()->setWebViewerZoomFactor(factor / 100.0);
}
e->accept();
}
}
void ArticleViewerWebEngine::resizeEvent(QResizeEvent *e)
......
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