From 55344f49d92409105d1339536de3172fe6c2b0c6 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 8 Dec 2010 17:27:44 +0100 Subject: =?UTF-8?q?merge=20first=20Google=20Code-In=20submission:=20add=20?= =?UTF-8?q?the=20percentage=20of=20the=20website=E2=80=99s=20zoom=20to=20t?= =?UTF-8?q?he=20zoombar=20http://www.google-melange.com/gci/task/show/goog?= =?UTF-8?q?le/gci2010/kde/t129157984557?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit slightly changed the attached patch, (e.g. percentage -> m_percentage) as noted on the mailinglist --- src/zoombar.cpp | 9 +++++++-- src/zoombar.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/zoombar.cpp b/src/zoombar.cpp index 55006b48..a895466a 100644 --- a/src/zoombar.cpp +++ b/src/zoombar.cpp @@ -47,7 +47,6 @@ #include #include - ZoomBar::ZoomBar(QWidget *parent) : QWidget(parent) ,m_zoomIn(new QToolButton(this)) @@ -72,6 +71,9 @@ ZoomBar::ZoomBar(QWidget *parent) QLabel *label = new QLabel(i18n("Zoom:")); layout->addWidget(label); + //Show the current zoom percentage of the page + m_percentage = new QLabel(i18nc("percentage of the website zoom", "100%"), this); + m_zoomSlider->setTracking(true); m_zoomSlider->setRange(1, 19); // divide by 10 to obtain a qreal for zoomFactor() m_zoomSlider->setValue(10); @@ -85,9 +87,10 @@ ZoomBar::ZoomBar(QWidget *parent) // layout->setSpacing(0); // layout->setMargin(0); layout->addWidget(m_zoomOut); - layout->addWidget(m_zoomSlider); + layout->addWidget(m_zoomSlider, 8); layout->addWidget(m_zoomIn); layout->addWidget(m_zoomNormal); + layout->addWidget(m_percentage, 5); layout->addStretch(); @@ -131,6 +134,7 @@ void ZoomBar::show() { emit visibilityChanged(true); QWidget::show(); + m_zoomSlider->setValue(Application::instance()->mainWindow()->currentTab()->view()->zoomFactor()*10); } } @@ -176,6 +180,7 @@ void ZoomBar::updateSlider(int webview) void ZoomBar::setValue(int value) { m_zoomSlider->setValue(value); + m_percentage->setText(i18nc("percentage of the website zoom", "%1%", QString::number(value*10))); // Don't allox max +1 values Application::instance()->mainWindow()->currentTab()->view()->setZoomFactor(QVariant(m_zoomSlider->value()).toReal() / 10); } diff --git a/src/zoombar.h b/src/zoombar.h index d45aab19..533946f8 100644 --- a/src/zoombar.h +++ b/src/zoombar.h @@ -34,6 +34,7 @@ // Qt Includes #include +#include // Forward Declarations class MainWindow; @@ -70,6 +71,7 @@ private: QToolButton *m_zoomOut; QToolButton *m_zoomNormal; QSlider *m_zoomSlider; + QLabel *m_percentage; }; #endif -- cgit v1.2.1