From 3e97b8f91c33f6b49a93c59b0bcb267fe47554f9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 16 Oct 2012 19:36:37 +0200 Subject: Zoom actionis restored, yeah! :D --- src/webtab/webtab.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/webtab/webtab.h | 8 ++++++++ 2 files changed, 52 insertions(+) (limited to 'src/webtab') diff --git a/src/webtab/webtab.cpp b/src/webtab/webtab.cpp index 549fa285..036f62c0 100644 --- a/src/webtab/webtab.cpp +++ b/src/webtab/webtab.cpp @@ -68,6 +68,7 @@ WebTab::WebTab(QWidget *parent) , m_webView(0) , m_progress(0) , m_part(0) + , m_zoomFactor(10) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -350,3 +351,46 @@ void WebTab::printFrame() delete printDialog; } } + + +void WebTab::zoomIn() +{ + if (m_zoomFactor == 50) + { + emit infoToShow(i18n("Max zoom reached: ") + QString::number(m_zoomFactor * 10) + QL1S("%")); + return; + } + + if (m_zoomFactor >= 20) + m_zoomFactor+=5; + else + m_zoomFactor++; + + m_webView->setZoomFactor(QVariant(m_zoomFactor).toReal() / 10); + + emit infoToShow(i18n("Zooming: ") + QString::number(m_zoomFactor * 10) + QL1S("%")); +} + + +void WebTab::zoomOut() +{ + if (m_zoomFactor == 1) + { + emit infoToShow(i18n("Min zoom reached: ") + QString::number(m_zoomFactor * 10) + QL1S("%")); + return; + } + + m_zoomFactor--; + m_webView->setZoomFactor(QVariant(m_zoomFactor).toReal() / 10); + + emit infoToShow(i18n("Zooming: ") + QString::number(m_zoomFactor * 10) + QL1S("%")); +} + + +void WebTab::zoomDefault() +{ + m_zoomFactor = 10; + m_webView->setZoomFactor(QVariant(m_zoomFactor).toReal() / 10); + + emit infoToShow(i18n("Default zoom: ") + QString::number(m_zoomFactor * 10) + QL1S("%")); +} diff --git a/src/webtab/webtab.h b/src/webtab/webtab.h index 2773dc12..6a9e844f 100644 --- a/src/webtab/webtab.h +++ b/src/webtab/webtab.h @@ -94,12 +94,18 @@ private Q_SLOTS: void printFrame(); + void zoomIn(); + void zoomOut(); + void zoomDefault(); + Q_SIGNALS: void loadProgressing(); void titleChanged(const QString &); void triggerPartPrint(); + void infoToShow(QString); + private: WebView *m_webView; @@ -109,6 +115,8 @@ private: QWeakPointer m_previewSelectorBar; KParts::ReadOnlyPart *m_part; + + int m_zoomFactor; }; #endif -- cgit v1.2.1