summaryrefslogtreecommitdiff
path: root/src/webtab
diff options
context:
space:
mode:
Diffstat (limited to 'src/webtab')
-rw-r--r--src/webtab/webtab.cpp44
-rw-r--r--src/webtab/webtab.h8
2 files changed, 52 insertions, 0 deletions
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<PreviewSelectorBar> m_previewSelectorBar;
KParts::ReadOnlyPart *m_part;
+
+ int m_zoomFactor;
};
#endif