Git commit f3ca4e6f96e905a05ac8313e0ec5b5d2f2095e08 by Jan Kundrát. Committed on 21/05/2016 at 15:25. Pushed by gerrit into branch 'master'.
GUI: Enable QWebView's zooming This is using QWebView's native zooming features. The zooming is implemented through a context menu and a pait of standard shortcuts. Thanks to an accessibility report by Dan Miner <[email protected]> over the ML. Change-Id: Id9ecc2829782a98209a21b2b1be1f6205a451b31 M +14 -0 src/Gui/EmbeddedWebView.cpp M +3 -0 src/Gui/EmbeddedWebView.h M +19 -0 src/Gui/SimplePartWidget.cpp M +1 -0 src/Gui/SimplePartWidget.h http://commits.kde.org/trojita/f3ca4e6f96e905a05ac8313e0ec5b5d2f2095e08 diff --git a/src/Gui/EmbeddedWebView.cpp b/src/Gui/EmbeddedWebView.cpp index 103849c..283042d 100644 --- a/src/Gui/EmbeddedWebView.cpp +++ b/src/Gui/EmbeddedWebView.cpp @@ -234,6 +234,20 @@ void EmbeddedWebView::mouseReleaseEvent(QMouseEvent *e) QWebView::mouseReleaseEvent(e); } +const auto zoomConstant = 1.1; + +void EmbeddedWebView::zoomIn() +{ + setZoomFactor(zoomFactor() * zoomConstant); + constrainSize(); +} + +void EmbeddedWebView::zoomOut() +{ + setZoomFactor(zoomFactor() / zoomConstant); + constrainSize(); +} + void EmbeddedWebView::findScrollParent() { if (m_scrollParent) diff --git a/src/Gui/EmbeddedWebView.h b/src/Gui/EmbeddedWebView.h index 020efe8..2c0b091 100644 --- a/src/Gui/EmbeddedWebView.h +++ b/src/Gui/EmbeddedWebView.h @@ -71,6 +71,9 @@ protected: void mouseReleaseEvent(QMouseEvent *e); void showEvent(QShowEvent *se); void addCustomStylesheet(const QString &css); +protected slots: + void zoomIn(); + void zoomOut(); private: void findScrollParent(); private slots: diff --git a/src/Gui/SimplePartWidget.cpp b/src/Gui/SimplePartWidget.cpp index 0e562ea..c9b388f 100644 --- a/src/Gui/SimplePartWidget.cpp +++ b/src/Gui/SimplePartWidget.cpp @@ -84,6 +84,20 @@ SimplePartWidget::SimplePartWidget(QWidget *parent, Imap::Network::MsgPartNetAcc connect(m_findAction, &QAction::triggered, this, &SimplePartWidget::searchDialogRequested); addAction(m_findAction); + m_zoomIn = new QAction(UiUtils::loadIcon(QStringLiteral("zoom-in")), tr("Zoom In"), this); + m_zoomIn->setShortcut(QKeySequence::ZoomIn); + addAction(m_zoomIn); + connect(m_zoomIn, &QAction::triggered, this, &SimplePartWidget::zoomIn); + + m_zoomOut = new QAction(UiUtils::loadIcon(QStringLiteral("zoom-out")), tr("Zoom Out"), this); + m_zoomOut->setShortcut(QKeySequence::ZoomOut); + addAction(m_zoomOut); + connect(m_zoomOut, &QAction::triggered, this, &SimplePartWidget::zoomOut); + + m_zoomReset = new QAction(UiUtils::loadIcon(QStringLiteral("zoom-original")), tr("Original Size"), this); + addAction(m_zoomReset); + connect(m_zoomReset, &QAction::triggered, this, [this]() { setZoomFactor(1); }); + setContextMenuPolicy(Qt::CustomContextMenu); // It is actually OK to construct this widget without any connection to a messageView -- this is often used when @@ -177,6 +191,11 @@ void SimplePartWidget::buildContextMenu(const QPoint &point, QMenu &menu) const } a->setActionGroup(ag); } + + auto zoomMenu = menu.addMenu(UiUtils::loadIcon(QStringLiteral("zoom")), tr("Zoom")); + zoomMenu->addAction(m_zoomIn); + zoomMenu->addAction(m_zoomOut); + zoomMenu->addAction(m_zoomReset); } void SimplePartWidget::slotDownloadPart() diff --git a/src/Gui/SimplePartWidget.h b/src/Gui/SimplePartWidget.h index 9d59a37..7c6f12d 100644 --- a/src/Gui/SimplePartWidget.h +++ b/src/Gui/SimplePartWidget.h @@ -74,6 +74,7 @@ private: QAction *m_savePart; QAction *m_saveMessage; QAction *m_findAction; + QAction *m_zoomIn, *m_zoomOut, *m_zoomReset; MessageView *m_messageView; Imap::Network::MsgPartNetAccessManager *m_netAccessManager; _______________________________________________ kde-doc-english mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-doc-english
