summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-07-26 18:51:13 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-07-26 18:51:13 +0200
commitc2cf251dfe808e1a4e336dbf1cddc645d63c2e2f (patch)
treef038c3a38a7532cf15f1d988ac4ad9b6954228e3 /src
parentFixing a bit GooWiki actions and updating TODO (diff)
downloadrekonq-c2cf251dfe808e1a4e336dbf1cddc645d63c2e2f.tar.xz
A lot of fixes here:
- CTRL + click browsing - mouse wheel gestures - cleaning a bit web* classes This has been possible restoring some code from rekonq 0.1 web classes implementation.
Diffstat (limited to 'src')
-rw-r--r--src/application.cpp2
-rw-r--r--src/mainview.cpp9
-rw-r--r--src/webpage.cpp30
-rw-r--r--src/webpage.h37
-rw-r--r--src/webview.cpp17
-rw-r--r--src/webview.h2
6 files changed, 84 insertions, 13 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 60d5ee48..cc34d946 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -97,7 +97,7 @@ int Application::newInstance()
{
for (int i = 0; i < args->count(); ++i)
{
- loadUrl(args->arg(i), Rekonq::NewTab);
+ loadUrl(args->arg(i), Rekonq::NewTab);
}
args->clear();
}
diff --git a/src/mainview.cpp b/src/mainview.cpp
index f059e42b..bc33c1c0 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -309,9 +309,12 @@ void MainView::slotCurrentChanged(int index)
this, SIGNAL(loadProgress(int)));
}
- connect(webView->page(), SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&)));
- connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&)));
- connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int)));
+ connect(webView->page(), SIGNAL(statusBarMessage(const QString&)),
+ this, SIGNAL(showStatusBarMessage(const QString&)));
+ connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)),
+ this, SIGNAL(linkHovered(const QString&)));
+ connect(webView, SIGNAL(loadProgress(int)),
+ this, SIGNAL(loadProgress(int)));
emit setCurrentTitle(webView->title());
m_urlBars->setCurrentIndex(index);
diff --git a/src/webpage.cpp b/src/webpage.cpp
index bb6f0d9c..771b7f04 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -73,6 +73,8 @@
WebPage::WebPage(QObject *parent)
: QWebPage(parent)
+ , m_keyboardModifiers(Qt::NoModifier)
+ , m_pressedButtons(Qt::NoButton)
{
setForwardUnsupportedContent(true);
@@ -84,6 +86,34 @@ WebPage::WebPage(QObject *parent)
}
+bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)
+{
+ if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton)
+ {
+ Application::instance()->loadUrl(request.url(), Rekonq::NewTab);
+ m_keyboardModifiers = Qt::NoModifier;
+ m_pressedButtons = Qt::NoButton;
+ return false;
+ }
+
+ if (frame == mainFrame())
+ {
+ return QWebPage::acceptNavigationRequest(frame, request, type);
+ }
+ else
+ {
+ // if frame doesn't exists (perhaps) we are pointing to a blank target..
+ if (!frame)
+ {
+ Application::instance()->loadUrl(request.url(), Rekonq::NewTab);
+ return false;
+ }
+ }
+
+ return QWebPage::acceptNavigationRequest(frame, request, type);
+}
+
+
WebPage *WebPage::createWindow(QWebPage::WebWindowType type)
{
kDebug() << "WebPage createWindow slot";
diff --git a/src/webpage.h b/src/webpage.h
index cdfb8f00..6a74c7bf 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -50,21 +50,42 @@ public slots:
protected:
WebPage *createWindow(WebWindowType type);
virtual WebPage *newWindow(WebWindowType type);
-
- QString chooseFile(QWebFrame *frame, const QString &suggestedFile);
- void javaScriptAlert(QWebFrame *frame, const QString &msg);
- bool javaScriptConfirm(QWebFrame *frame, const QString &msg);
- bool javaScriptPrompt(QWebFrame *frame, const QString &msg, const QString &defaultValue, QString *result);
+ virtual bool acceptNavigationRequest(QWebFrame *frame,
+ const QNetworkRequest &request,
+ NavigationType type);
+
+ QString chooseFile(QWebFrame *frame,
+ const QString &suggestedFile);
+
+ void javaScriptAlert(QWebFrame *frame,
+ const QString &msg);
+
+ bool javaScriptConfirm(QWebFrame *frame,
+ const QString &msg);
+
+ bool javaScriptPrompt(QWebFrame *frame,
+ const QString &msg,
+ const QString &defaultValue, QString *result);
+
+ QObject *createPlugin(const QString &classId,
+ const QUrl &url,
+ const QStringList &paramNames,
+ const QStringList &paramValues);
- QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
-
-protected Q_SLOTS:
+
+protected Q_SLOTS:
virtual void slotHandleUnsupportedContent(QNetworkReply *reply);
virtual void slotDownloadRequested(const QNetworkRequest &request);
private:
+ friend class WebView;
+
void viewErrorPage(QNetworkReply *);
+
+ // keyboard/mouse modifiers
+ Qt::KeyboardModifiers m_keyboardModifiers;
+ Qt::MouseButtons m_pressedButtons;
};
#endif
diff --git a/src/webview.cpp b/src/webview.cpp
index f001f664..e39cdacb 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -298,6 +298,9 @@ void WebView::keyPressEvent(QKeyEvent *event)
void WebView::mousePressEvent(QMouseEvent *event)
{
+ m_page->m_pressedButtons = event->buttons();
+ m_page->m_keyboardModifiers = event->modifiers();
+
switch(event->button())
{
case Qt::XButton1:
@@ -312,6 +315,20 @@ void WebView::mousePressEvent(QMouseEvent *event)
}
+void WebView::wheelEvent(QWheelEvent *event)
+{
+ if (QApplication::keyboardModifiers() & Qt::ControlModifier)
+ {
+ int numDegrees = event->delta() / 8;
+ int numSteps = numDegrees / 15;
+ setTextSizeMultiplier(textSizeMultiplier() + numSteps * 0.1);
+ event->accept();
+ return;
+ }
+ QWebView::wheelEvent(event);
+}
+
+
void WebView::slotGooWikiSearch()
{
KAction *a = qobject_cast<KAction*>(sender());
diff --git a/src/webview.h b/src/webview.h
index ea80ef1a..ffdc874c 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -58,8 +58,8 @@ protected:
* to make switch tab
*/
void keyPressEvent(QKeyEvent *event);
+ void wheelEvent(QWheelEvent *event);
-
private slots:
void setProgress(int progress);
void loadFinished();