diff options
author | Yoann Laissus <yoann.laissus@gmail.com> | 2010-05-30 16:50:36 +0200 |
---|---|---|
committer | Yoann Laissus <yoann.laissus@gmail.com> | 2010-05-30 16:53:42 +0200 |
commit | 8765137a9ec0547b9edf3cb3b9ebae88a7043c2e (patch) | |
tree | ab87713795436cca9a903ca1f21d36bc192ba333 | |
parent | Merge branch 'master' of gitorious.org:rekonq/mainline (diff) | |
download | rekonq-8765137a9ec0547b9edf3cb3b9ebae88a7043c2e.tar.xz |
- Sync mouse wheel zoom and the slider
- Fix mouse wheel zoom limits (slider's max and min)
-rw-r--r-- | src/mainview.cpp | 1 | ||||
-rw-r--r-- | src/mainwindow.cpp | 2 | ||||
-rw-r--r-- | src/mainwindow.h | 4 | ||||
-rw-r--r-- | src/webview.cpp | 17 | ||||
-rw-r--r-- | src/webview.h | 2 |
5 files changed, 23 insertions, 3 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp index 84dc70af..0b17ef2a 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -329,6 +329,7 @@ WebTab *MainView::newWebTab(bool focused, bool nearParent) connect(tab->view(), SIGNAL(iconChanged()), this, SLOT(webViewIconChanged())); connect(tab->view(), SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &))); connect(tab->view(), SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &))); + connect(tab->view(), SIGNAL(zoomChanged(qreal)), m_parentWindow, SLOT(setZoomSliderFactor(qreal))); // connecting webPage signals with mainview connect(tab->view()->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d5b81c1e..dc29d2eb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -906,7 +906,7 @@ void MainWindow::setZoomFactor(int factor) void MainWindow::setZoomSliderFactor(qreal factor) { - m_zoomSlider->setValue(factor*10); + m_zoomSlider->setValue(factor * 10); } diff --git a/src/mainwindow.h b/src/mainwindow.h index ffc91086..8acbef56 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -78,8 +78,6 @@ public: virtual QSize sizeHint() const; void setWidgetsVisible(bool makeFullScreen); - void setZoomSliderFactor(qreal factor); - private: void setupActions(); void setupTools(); @@ -103,6 +101,8 @@ public slots: void updateActions(); + void setZoomSliderFactor(qreal factor); + signals: // switching tabs void ctrlTabPressed(); diff --git a/src/webview.cpp b/src/webview.cpp index a26cf63f..061dd256 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -496,6 +496,23 @@ void WebView::keyPressEvent(QKeyEvent *event) KWebView::keyPressEvent(event); } +void WebView::wheelEvent(QWheelEvent *event) +{ + // Sync with the zoom slider + if (event->modifiers() == Qt::ControlModifier) + { + emit zoomChanged(zoomFactor()); + } + + KWebView::wheelEvent(event); + + // Limits of the slider + if (zoomFactor() > 1.9) + setZoomFactor(1.9); + else if (zoomFactor() < 0.1) + setZoomFactor(0.1); +} + void WebView::inspect() { diff --git a/src/webview.h b/src/webview.h index bac12e99..a4ba676c 100644 --- a/src/webview.h +++ b/src/webview.h @@ -56,6 +56,7 @@ protected: void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); void keyPressEvent(QKeyEvent *event); + void wheelEvent(QWheelEvent *event); private slots: void search(); @@ -73,6 +74,7 @@ private slots: signals: void loadUrl(const KUrl &, const Rekonq::OpenType &); + void zoomChanged(qreal); private: QPoint _mousePos; |