summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2015-10-02 21:31:45 +0200
committerMontel Laurent <[email protected]>2015-10-02 21:31:45 +0200
commit5e6adc5199394b34ed96897245bafc2d7fe58ea8 (patch)
tree380d22e63c9e161b5f945ff832273645def5ad4b
parent3001be7065d7bedf6b35f383aca01c962c69475d (diff)
Use zoomactionmenu
-rw-r--r--messageviewer/autotests/CMakeLists.txt10
-rw-r--r--messageviewer/autotests/zoomactionmenutest.cpp25
-rw-r--r--messageviewer/autotests/zoomactionmenutest.h3
-rw-r--r--messageviewer/src/CMakeLists.txt2
-rw-r--r--messageviewer/src/viewer/mailwebview.h6
-rw-r--r--messageviewer/src/viewer/viewer.cpp11
-rw-r--r--messageviewer/src/viewer/viewer_p.cpp103
-rw-r--r--messageviewer/src/viewer/viewer_p.h14
-rw-r--r--messageviewer/src/widgets/zoomactionmenu.cpp144
-rw-r--r--messageviewer/src/widgets/zoomactionmenu.h41
10 files changed, 241 insertions, 118 deletions
diff --git a/messageviewer/autotests/CMakeLists.txt b/messageviewer/autotests/CMakeLists.txt
index da86f2b..3e3c2bd 100644
--- a/messageviewer/autotests/CMakeLists.txt
+++ b/messageviewer/autotests/CMakeLists.txt
@@ -15,6 +15,15 @@ macro(add_messageviewer_unittest _source)
)
endmacro ()
+macro(add_messageviewer_class_unittest _source _additionalSource)
+ get_filename_component(_name ${_source} NAME_WE)
+ ecm_add_test(${_source} ${_additionalSource}
+ TEST_NAME ${_name}
+ NAME_PREFIX "messageviewer-"
+ LINK_LIBRARIES KF5::MessageViewer Qt5::Test KF5::IconThemes KF5::XmlGui Qt5::WebKitWidgets
+ )
+endmacro ()
+
macro(add_messageviewer_crypto_unittest _source)
set(_test ${_source} util.cpp)
get_filename_component(_name ${_source} NAME_WE)
@@ -43,6 +52,7 @@ add_messageviewer_crypto_unittest( attachmenttest.cpp )
add_messageviewer_unittest( cryptohelpertest.cpp )
add_messageviewer_unittest( messagedisplayformatattributetest.cpp )
add_messageviewer_unittest( nodehelpertest.cpp )
+add_messageviewer_class_unittest(zoomactionmenutest.cpp "../src/widgets/zoomactionmenu.cpp")
# convenience macro to add qtest unit tests
macro(add_messageviewer_mailsourceviewbrowserwidget_unittest _source)
diff --git a/messageviewer/autotests/zoomactionmenutest.cpp b/messageviewer/autotests/zoomactionmenutest.cpp
index 5e142e0..6d6007a 100644
--- a/messageviewer/autotests/zoomactionmenutest.cpp
+++ b/messageviewer/autotests/zoomactionmenutest.cpp
@@ -16,7 +16,10 @@
*/
#include "zoomactionmenutest.h"
+#include "../src/widgets/zoomactionmenu.h"
#include <QTest>
+#include <viewer/mailwebview.h>
+#include <KActionCollection>
ZoomActionMenuTest::ZoomActionMenuTest(QObject *parent)
: QObject(parent)
@@ -29,4 +32,26 @@ ZoomActionMenuTest::~ZoomActionMenuTest()
}
+void ZoomActionMenuTest::shouldHaveDefaultValue()
+{
+ MessageViewer::ZoomActionMenu menu(new MessageViewer::MailWebView(), this);
+ menu.setActionCollection(new KActionCollection(this));
+ menu.createZoomActions();
+
+ QVERIFY(menu.zoomTextOnlyAction());
+ QVERIFY(menu.zoomInAction());
+ QVERIFY(menu.zoomOutAction());
+ QVERIFY(menu.zoomResetAction());
+}
+
+void ZoomActionMenuTest::shouldAssignZoomFactor()
+{
+ MessageViewer::ZoomActionMenu menu(new MessageViewer::MailWebView(), this);
+ menu.setActionCollection(new KActionCollection(this));
+ menu.createZoomActions();
+ qreal initialValue = 50;
+ menu.setZoomFactor(initialValue);
+ QCOMPARE(menu.zoomFactor(), initialValue);
+}
+
QTEST_MAIN(ZoomActionMenuTest)
diff --git a/messageviewer/autotests/zoomactionmenutest.h b/messageviewer/autotests/zoomactionmenutest.h
index 01808f0..78840f3 100644
--- a/messageviewer/autotests/zoomactionmenutest.h
+++ b/messageviewer/autotests/zoomactionmenutest.h
@@ -26,6 +26,9 @@ class ZoomActionMenuTest : public QObject
public:
explicit ZoomActionMenuTest(QObject *parent = Q_NULLPTR);
~ZoomActionMenuTest();
+private Q_SLOTS:
+ void shouldHaveDefaultValue();
+ void shouldAssignZoomFactor();
};
#endif // ZOOMACTIONMENUTEST_H
diff --git a/messageviewer/src/CMakeLists.txt b/messageviewer/src/CMakeLists.txt
index 1089c87..b888599 100644
--- a/messageviewer/src/CMakeLists.txt
+++ b/messageviewer/src/CMakeLists.txt
@@ -74,8 +74,6 @@ else()
adblock/adblockblockableitemswidget.cpp
)
set(_mailwebview_lib KF5::WebKit Qt5::WebKitWidgets)
- #reactivate
- #add_subdirectory(a11y)
endif()
set(libmessageviewer_viewer_SRCS
diff --git a/messageviewer/src/viewer/mailwebview.h b/messageviewer/src/viewer/mailwebview.h
index 946f9f7..67d0887 100644
--- a/messageviewer/src/viewer/mailwebview.h
+++ b/messageviewer/src/viewer/mailwebview.h
@@ -21,7 +21,7 @@
#define MESSAGEVIEWER_MAILWEBVIEW_H
#include "messageviewer/messageviewersettings.h"
-
+#include "messageviewer_export.h"
#ifdef KDEPIM_NO_WEBKIT
# include <QTextBrowser>
#else
@@ -41,9 +41,9 @@ class ScamDetection;
/// MailWebView extends KWebView so that it can emit the popupMenu() signal
#ifdef KDEPIM_NO_WEBKIT
-class MailWebView : public QTextBrowser // krazy:exclude=qclasses
+class MESSAGEVIEWER_EXPORT MailWebView : public QTextBrowser // krazy:exclude=qclasses
#else
-class MailWebView : public KWebView
+class MESSAGEVIEWER_EXPORT MailWebView : public KWebView
#endif
{
Q_OBJECT
diff --git a/messageviewer/src/viewer/viewer.cpp b/messageviewer/src/viewer/viewer.cpp
index 8f72565..a2064093 100644
--- a/messageviewer/src/viewer/viewer.cpp
+++ b/messageviewer/src/viewer/viewer.cpp
@@ -32,6 +32,7 @@
#include "viewer/mailwebview.h"
#include "viewer/mimeparttree/mimetreemodel.h"
#include "viewer/mimeparttree/mimeparttreeview.h"
+#include "widgets/zoomactionmenu.h"
#include "adblock/adblockmanager.h"
#include <Akonadi/KMime/MessageParts>
@@ -578,31 +579,31 @@ void Viewer::copySelectionToClipboard()
void Viewer::setZoomFactor(qreal zoomFactor)
{
Q_D(Viewer);
- d->setZoomFactor(zoomFactor);
+ d->mZoomActionMenu->setZoomFactor(zoomFactor);
}
void Viewer::slotZoomReset()
{
Q_D(Viewer);
- d->slotZoomReset();
+ d->mZoomActionMenu->slotZoomReset();
}
void Viewer::slotZoomIn()
{
Q_D(Viewer);
- d->slotZoomIn();
+ d->mZoomActionMenu->slotZoomIn();
}
void Viewer::slotZoomOut()
{
Q_D(Viewer);
- d->slotZoomOut();
+ d->mZoomActionMenu->slotZoomOut();
}
void Viewer::setZoomTextOnly(bool textOnly)
{
Q_D(Viewer);
- d->setZoomTextOnly(textOnly);
+ d->mZoomActionMenu->setZoomTextOnly(textOnly);
}
bool Viewer::zoomTextOnly() const
diff --git a/messageviewer/src/viewer/viewer_p.cpp b/messageviewer/src/viewer/viewer_p.cpp
index fb10581..f831d10 100644
--- a/messageviewer/src/viewer/viewer_p.cpp
+++ b/messageviewer/src/viewer/viewer_p.cpp
@@ -148,17 +148,13 @@
#include <QStandardPaths>
#include <header/headerstyleplugin.h>
#include <viewerplugins/viewerplugininterface.h>
+#include <widgets/zoomactionmenu.h>
using namespace boost;
using namespace MailTransport;
using namespace MessageViewer;
using namespace MessageCore;
-namespace {
-qreal zoomBy() {
- return 20;
-}
-}
static QAtomicInt _k_attributeInitialized;
ViewerPrivate::ViewerPrivate(Viewer *aParent, QWidget *mainWindow,
@@ -187,10 +183,6 @@ ViewerPrivate::ViewerPrivate(Viewer *aParent, QWidget *mainWindow,
mSelectEncodingAction(0),
mToggleFixFontAction(0),
mToggleDisplayModeAction(0),
- mZoomTextOnlyAction(0),
- mZoomInAction(0),
- mZoomOutAction(0),
- mZoomResetAction(0),
mToggleMimePartTreeAction(0),
mSpeakTextAction(0),
mCanStartDrag(false),
@@ -208,12 +200,12 @@ ViewerPrivate::ViewerPrivate(Viewer *aParent, QWidget *mainWindow,
mPreviouslyViewedItem(-1),
mScamDetectionWarning(0),
mOpenAttachmentFolderWidget(Q_NULLPTR),
- mZoomFactor(100),
mSliderContainer(0),
mShareServiceManager(Q_NULLPTR),
mHeaderStylePlugin(Q_NULLPTR),
mHeaderStyleMenuManager(Q_NULLPTR),
- mViewerPluginToolManager(Q_NULLPTR)
+ mViewerPluginToolManager(Q_NULLPTR),
+ mZoomActionMenu(Q_NULLPTR)
{
mMimePartTree = 0;
if (!mainWindow) {
@@ -231,7 +223,6 @@ ViewerPrivate::ViewerPrivate(Viewer *aParent, QWidget *mainWindow,
mHtmlLoadExternalGlobalSetting = false;
mHtmlMailGlobalSetting = false;
- mZoomTextOnly = false;
mUpdateReaderWinTimer.setObjectName(QStringLiteral("mUpdateReaderWinTimer"));
mResizeTimer.setObjectName(QStringLiteral("mResizeTimer"));
@@ -1101,10 +1092,10 @@ bool ViewerPrivate::eventFilter(QObject *, QEvent *e)
if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
const int numDegrees = me->delta() / 8;
const int numSteps = numDegrees / 15;
- const qreal factor = mZoomFactor + numSteps * 10;
+ const qreal factor = mZoomActionMenu->zoomFactor() + numSteps * 10;
if (factor >= 10 && factor <= 300) {
- mZoomFactor = factor;
- setZoomFactor(factor / 100.0);
+ mZoomActionMenu->setZoomFactor(factor);
+ mZoomActionMenu->setWebViewerZoomFactor(factor / 100.0);
}
return true;
}
@@ -1127,8 +1118,7 @@ void ViewerPrivate::readConfig()
mHtmlMailGlobalSetting = GlobalSettings::self()->htmlMail();
mHtmlLoadExternalGlobalSetting = GlobalSettings::self()->htmlLoadExternal();
- mZoomTextOnly = GlobalSettings::self()->zoomTextOnly();
- setZoomTextOnly(mZoomTextOnly);
+ mZoomActionMenu->setZoomTextOnly(GlobalSettings::self()->zoomTextOnly());
readGravatarConfig();
if (mHeaderStyleMenuManager) {
mHeaderStyleMenuManager->readConfig();
@@ -1179,7 +1169,7 @@ void ViewerPrivate::writeConfig(bool sync)
if (attachmentStrategy()) {
GlobalSettings::self()->setAttachmentStrategy(QLatin1String(attachmentStrategy()->name()));
}
- GlobalSettings::self()->setZoomTextOnly(mZoomTextOnly);
+ GlobalSettings::self()->setZoomTextOnly(mZoomActionMenu->zoomTextOnly());
saveSplitterSizes();
if (sync) {
@@ -1519,6 +1509,9 @@ void ViewerPrivate::createActions()
if (!ac) {
return;
}
+ mZoomActionMenu = new MessageViewer::ZoomActionMenu(mViewer, this);
+ mZoomActionMenu->setActionCollection(ac);
+ mZoomActionMenu->createZoomActions();
// attachment style
KActionMenu *attachmentMenu = new KActionMenu(i18nc("View->", "&Attachments"), this);
@@ -1608,24 +1601,6 @@ void ViewerPrivate::createActions()
connect(mToggleFixFontAction, &QAction::triggered, this, &ViewerPrivate::slotToggleFixedFont);
ac->setDefaultShortcut(mToggleFixFontAction, QKeySequence(Qt::Key_X));
- // Zoom actions
- mZoomTextOnlyAction = new KToggleAction(i18n("Zoom Text Only"), this);
- ac->addAction(QStringLiteral("toggle_zoomtextonly"), mZoomTextOnlyAction);
- connect(mZoomTextOnlyAction, &QAction::triggered, this, &ViewerPrivate::slotZoomTextOnly);
- mZoomInAction = new QAction(QIcon::fromTheme(QStringLiteral("zoom-in")), i18n("&Zoom In"), this);
- ac->addAction(QStringLiteral("zoom_in"), mZoomInAction);
- connect(mZoomInAction, &QAction::triggered, this, &ViewerPrivate::slotZoomIn);
- ac->setDefaultShortcut(mZoomInAction, QKeySequence(Qt::CTRL | Qt::Key_Plus));
-
- mZoomOutAction = new QAction(QIcon::fromTheme(QStringLiteral("zoom-out")), i18n("Zoom &Out"), this);
- ac->addAction(QStringLiteral("zoom_out"), mZoomOutAction);
- connect(mZoomOutAction, &QAction::triggered, this, &ViewerPrivate::slotZoomOut);
- ac->setDefaultShortcut(mZoomOutAction, QKeySequence(Qt::CTRL | Qt::Key_Minus));
-
- mZoomResetAction = new QAction(i18n("Reset"), this);
- ac->addAction(QStringLiteral("zoom_reset"), mZoomResetAction);
- connect(mZoomResetAction, &QAction::triggered, this, &ViewerPrivate::slotZoomReset);
- ac->setDefaultShortcut(mZoomResetAction, QKeySequence(Qt::CTRL | Qt::Key_0));
// Show message structure viewer
mToggleMimePartTreeAction = new KToggleAction(i18n("Show Message Structure"), this);
@@ -2884,61 +2859,7 @@ void ViewerPrivate::slotMessageRendered()
void ViewerPrivate::setZoomFactor(qreal zoomFactor)
{
-#ifndef KDEPIM_NO_WEBKIT
- mViewer->setZoomFactor(zoomFactor);
-#endif
-}
-
-void ViewerPrivate::slotZoomIn()
-{
-#ifndef KDEPIM_NO_WEBKIT
- if (mZoomFactor >= 300) {
- return;
- }
- mZoomFactor += zoomBy();
- if (mZoomFactor > 300) {
- mZoomFactor = 300;
- }
- mViewer->setZoomFactor(mZoomFactor / 100.0);
-#endif
-}
-
-void ViewerPrivate::slotZoomOut()
-{
-#ifndef KDEPIM_NO_WEBKIT
- if (mZoomFactor <= 10) {
- return;
- }
- mZoomFactor -= zoomBy();
- if (mZoomFactor < 10) {
- mZoomFactor = 10;
- }
- mViewer->setZoomFactor(mZoomFactor / 100.0);
-#endif
-}
-
-void ViewerPrivate::setZoomTextOnly(bool textOnly)
-{
- mZoomTextOnly = textOnly;
- if (mZoomTextOnlyAction) {
- mZoomTextOnlyAction->setChecked(mZoomTextOnly);
- }
-#ifndef KDEPIM_NO_WEBKIT
- mViewer->settings()->setAttribute(QWebSettings::ZoomTextOnly, mZoomTextOnly);
-#endif
-}
-
-void ViewerPrivate::slotZoomTextOnly()
-{
- setZoomTextOnly(!mZoomTextOnly);
-}
-
-void ViewerPrivate::slotZoomReset()
-{
-#ifndef KDEPIM_NO_WEBKIT
- mZoomFactor = 100;
- mViewer->setZoomFactor(1.0);
-#endif
+ mZoomActionMenu->setWebViewerZoomFactor(zoomFactor);
}
void ViewerPrivate::goOnline()
diff --git a/messageviewer/src/viewer/viewer_p.h b/messageviewer/src/viewer/viewer_p.h
index 6240f41..2f845ef 100644
--- a/messageviewer/src/viewer/viewer_p.h
+++ b/messageviewer/src/viewer/viewer_p.h
@@ -76,7 +76,7 @@ class OpenAttachmentFolderWidget;
class HeaderStyleMenuManager;
class ViewerPluginToolManager;
class ViewerPluginInterface;
-
+class ZoomActionMenu;
/**
\brief Private class for the Viewer, the main widget in the messageviewer library.
@@ -270,8 +270,6 @@ public:
/** show window containing information about a vCard. */
void showVCard(KMime::Content *msgPart);
- void setZoomTextOnly(bool textOnly);
-
void saveMainFrameScreenshotInFile(const QString &filename);
private:
@@ -524,7 +522,6 @@ public Q_SLOTS:
/** Toggle display mode between HTML and plain text. */
void slotToggleHtmlMode();
- void slotZoomTextOnly();
void slotLoadExternalReference();
/**
@@ -552,9 +549,6 @@ public Q_SLOTS:
/** Re-parse the current message. */
void update(MessageViewer::Viewer::UpdateMode updateMode = Viewer::Delayed);
- void slotZoomIn();
- void slotZoomOut();
- void slotZoomReset();
void slotSpeakText();
void slotCopyImageLocation();
void slotSaveMessageDisplayFormat();
@@ -639,10 +633,6 @@ public:
KSelectAction *mSelectEncodingAction;
KToggleAction *mToggleFixFontAction;
KToggleAction *mToggleDisplayModeAction;
- KToggleAction *mZoomTextOnlyAction;
- QAction *mZoomInAction;
- QAction *mZoomOutAction;
- QAction *mZoomResetAction;
KToggleAction *mToggleMimePartTreeAction;
QAction *mSpeakTextAction;
QAction *mCopyImageLocation;
@@ -681,7 +671,6 @@ public:
ScamDetectionWarningWidget *mScamDetectionWarning;
MessageViewer::OpenAttachmentFolderWidget *mOpenAttachmentFolderWidget;
- qreal mZoomFactor;
Viewer::DisplayFormatMessage mDisplayFormatMessageOverwrite;
PimCommon::SlideContainer *mSliderContainer;
PimCommon::ShareServiceUrlManager *mShareServiceManager;
@@ -689,6 +678,7 @@ public:
HeaderStylePlugin *mHeaderStylePlugin;
HeaderStyleMenuManager *mHeaderStyleMenuManager;
ViewerPluginToolManager *mViewerPluginToolManager;
+ ZoomActionMenu *mZoomActionMenu;
};
}
diff --git a/messageviewer/src/widgets/zoomactionmenu.cpp b/messageviewer/src/widgets/zoomactionmenu.cpp
index c9382b1..45756f9 100644
--- a/messageviewer/src/widgets/zoomactionmenu.cpp
+++ b/messageviewer/src/widgets/zoomactionmenu.cpp
@@ -16,13 +16,29 @@
*/
#include "zoomactionmenu.h"
+#include <KLocalizedString>
+#include <KToggleAction>
+#include <KActionCollection>
+#include <viewer/mailwebview.h>
using namespace MessageViewer;
+namespace {
+qreal zoomBy() {
+ return 20;
+}
+}
-ZoomActionMenu::ZoomActionMenu(QObject *parent)
- : KActionMenu(parent)
+ZoomActionMenu::ZoomActionMenu(MessageViewer::MailWebView *mailViewer, QObject *parent)
+ : KActionMenu(parent),
+ mZoomFactor(100),
+ mZoomTextOnlyAction(Q_NULLPTR),
+ mZoomInAction(Q_NULLPTR),
+ mZoomOutAction(Q_NULLPTR),
+ mZoomResetAction(Q_NULLPTR),
+ mActionCollection(Q_NULLPTR),
+ mMailWebViewer(mailViewer),
+ mZoomTextOnly(false)
{
-
}
ZoomActionMenu::~ZoomActionMenu()
@@ -30,3 +46,125 @@ ZoomActionMenu::~ZoomActionMenu()
}
+void ZoomActionMenu::setActionCollection(KActionCollection *ac)
+{
+ mActionCollection = ac;
+}
+
+void ZoomActionMenu::createZoomActions()
+{
+ // Zoom actions
+ mZoomTextOnlyAction = new KToggleAction(i18n("Zoom Text Only"), this);
+ mActionCollection->addAction(QStringLiteral("toggle_zoomtextonly"), mZoomTextOnlyAction);
+ connect(mZoomTextOnlyAction, &QAction::triggered, this, &ZoomActionMenu::slotZoomTextOnly);
+
+ mZoomInAction = new QAction(QIcon::fromTheme(QStringLiteral("zoom-in")), i18n("&Zoom In"), this);
+ mActionCollection->addAction(QStringLiteral("zoom_in"), mZoomInAction);
+ connect(mZoomInAction, &QAction::triggered, this, &ZoomActionMenu::slotZoomIn);
+ mActionCollection->setDefaultShortcut(mZoomInAction, QKeySequence(Qt::CTRL | Qt::Key_Plus));
+
+ mZoomOutAction = new QAction(QIcon::fromTheme(QStringLiteral("zoom-out")), i18n("Zoom &Out"), this);
+ mActionCollection->addAction(QStringLiteral("zoom_out"), mZoomOutAction);
+ connect(mZoomOutAction, &QAction::triggered, this, &ZoomActionMenu::slotZoomOut);
+ mActionCollection->setDefaultShortcut(mZoomOutAction, QKeySequence(Qt::CTRL | Qt::Key_Minus));
+
+ mZoomResetAction = new QAction(i18n("Reset"), this);
+ mActionCollection->addAction(QStringLiteral("zoom_reset"), mZoomResetAction);
+ connect(mZoomResetAction, &QAction::triggered, this, &ZoomActionMenu::slotZoomReset);
+ mActionCollection->setDefaultShortcut(mZoomResetAction, QKeySequence(Qt::CTRL | Qt::Key_0));
+
+}
+
+KToggleAction *ZoomActionMenu::zoomTextOnlyAction() const
+{
+ return mZoomTextOnlyAction;
+}
+
+QAction *ZoomActionMenu::zoomInAction() const
+{
+ return mZoomInAction;
+}
+
+QAction *ZoomActionMenu::zoomOutAction() const
+{
+ return mZoomOutAction;
+}
+
+QAction *ZoomActionMenu::zoomResetAction() const
+{
+ return mZoomResetAction;
+}
+
+void ZoomActionMenu::setZoomFactor(qreal zoomFactor)
+{
+ mZoomFactor = zoomFactor;
+}
+
+void ZoomActionMenu::setWebViewerZoomFactor(qreal zoomFactor)
+{
+#ifndef KDEPIM_NO_WEBKIT
+ mMailWebViewer->setZoomFactor(zoomFactor);
+#endif
+}
+
+void ZoomActionMenu::slotZoomIn()
+{
+#ifndef KDEPIM_NO_WEBKIT
+ if (mZoomFactor >= 300) {
+ return;
+ }
+ mZoomFactor += zoomBy();
+ if (mZoomFactor > 300) {
+ mZoomFactor = 300;
+ }
+ mMailWebViewer->setZoomFactor(mZoomFactor / 100.0);
+#endif
+}
+
+void ZoomActionMenu::slotZoomOut()
+{
+#ifndef KDEPIM_NO_WEBKIT
+ if (mZoomFactor <= 10) {
+ return;
+ }
+ mZoomFactor -= zoomBy();
+ if (mZoomFactor < 10) {
+ mZoomFactor = 10;
+ }
+ mMailWebViewer->setZoomFactor(mZoomFactor / 100.0);
+#endif
+}
+
+void ZoomActionMenu::setZoomTextOnly(bool textOnly)
+{
+ mZoomTextOnly = textOnly;
+ if (mZoomTextOnlyAction) {
+ mZoomTextOnlyAction->setChecked(mZoomTextOnly);
+ }
+#ifndef KDEPIM_NO_WEBKIT
+ mMailWebViewer->settings()->setAttribute(QWebSettings::ZoomTextOnly, mZoomTextOnly);
+#endif
+}
+
+void ZoomActionMenu::slotZoomTextOnly()
+{
+ setZoomTextOnly(!mZoomTextOnly);
+}
+
+void ZoomActionMenu::slotZoomReset()
+{
+#ifndef KDEPIM_NO_WEBKIT
+ mZoomFactor = 100;
+ mMailWebViewer->setZoomFactor(1.0);
+#endif
+}
+
+bool ZoomActionMenu::zoomTextOnly() const
+{
+ return mZoomTextOnly;
+}
+
+qreal ZoomActionMenu::zoomFactor() const
+{
+ return mZoomFactor;
+}
diff --git a/messageviewer/src/widgets/zoomactionmenu.h b/messageviewer/src/widgets/zoomactionmenu.h
index 87e2529..6fb01cb 100644
--- a/messageviewer/src/widgets/zoomactionmenu.h
+++ b/messageviewer/src/widgets/zoomactionmenu.h
@@ -19,15 +19,52 @@
#define ZOOMACTIONMENU_H
#include <KActionMenu>
-
+class KToggleAction;
+class KActionCollection;
namespace MessageViewer
{
+class MailWebView;
class ZoomActionMenu : public KActionMenu
{
Q_OBJECT
public:
- explicit ZoomActionMenu(QObject *parent = Q_NULLPTR);
+ explicit ZoomActionMenu(MessageViewer::MailWebView *mailViewer, QObject *parent = Q_NULLPTR);
~ZoomActionMenu();
+
+ void createZoomActions();
+ KToggleAction *zoomTextOnlyAction() const;
+
+ QAction *zoomInAction() const;
+
+ QAction *zoomOutAction() const;
+
+ QAction *zoomResetAction() const;
+
+ void setActionCollection(KActionCollection *ac);
+
+ void setZoomFactor(qreal zoomFactor);
+ qreal zoomFactor() const;
+
+ void setWebViewerZoomFactor(qreal zoomFactor);
+ bool zoomTextOnly() const;
+
+public Q_SLOTS:
+ void slotZoomIn();
+ void slotZoomOut();
+ void setZoomTextOnly(bool textOnly);
+ void slotZoomTextOnly();
+ void slotZoomReset();
+
+private:
+
+ qreal mZoomFactor;
+ KToggleAction *mZoomTextOnlyAction;
+ QAction *mZoomInAction;
+ QAction *mZoomOutAction;
+ QAction *mZoomResetAction;
+ KActionCollection *mActionCollection;
+ MessageViewer::MailWebView *mMailWebViewer;
+ bool mZoomTextOnly;
};
}