[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/libs/webkitkde/kdewebkit
From: Dawit Alemayehu <adawit () kde ! org>
Date: 2009-10-31 21:30:44
Message-ID: 1257024644.770600.23042.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1043146 by adawit:
- Fixed navigatation to a url from the clipboard on middle mouse button click.
- Removd compatibility code for Qt < 4.5.
- Updated documentation.
BUG:211302
M +16 -15 kwebview.cpp
M +11 -8 kwebview.h
--- trunk/playground/libs/webkitkde/kdewebkit/kwebview.cpp #1043145:1043146
@@ -33,6 +33,7 @@
#include <kparts/part.h>
#include <kparts/browserextension.h>
#include <kdeversion.h>
+#include <kurifilter.h>
#include <QtGui/QApplication>
#include <QtGui/QClipboard>
@@ -82,11 +83,7 @@
if (QApplication::keyboardModifiers() & Qt::ControlModifier) {
const int numDegrees = event->delta() / 8;
const int numSteps = numDegrees / 15;
-#if QT_VERSION < 0x040500
- setTextSizeMultiplier(textSizeMultiplier() + numSteps * 0.1);
-#else
setZoomFactor(zoomFactor() + numSteps * 0.1);
-#endif
event->accept();
return;
}
@@ -102,11 +99,12 @@
}
void KWebView::mouseReleaseEvent(QMouseEvent *event)
-{
+{
+
const QWebHitTestResult result = \
page()->mainFrame()->hitTestContent(event->pos()); const QUrl url = \
result.linkUrl();
- if (!url.isEmpty()) {
+ if (url.isValid() && !url.isEmpty() && !url.scheme().isEmpty()) {
if ((d->pressedButtons & Qt::MidButton) ||
((d->pressedButtons & Qt::LeftButton) && (d->keyboardModifiers & \
Qt::ControlModifier))) { emit openUrlInNewWindow(url);
@@ -119,17 +117,20 @@
}
}
- QWebView::mouseReleaseEvent(event);
+ const bool isAccepted = event->isAccepted();
+ page()->event(event);
- // just leave if the site has not modified by the user (for example pasted text \
with mouse middle click)
- if (!isModified() && (d->pressedButtons & Qt::MidButton)) {
- const QString \
clipboardText(QApplication::clipboard()->text(QClipboard::Selection));
- KUrl url(clipboardText);
- if (!url.isEmpty() && url.isValid() && clipboardText.contains('.')) { // \
contains '.' -> domain
- if (url.scheme().isEmpty()) {
- url = "http://" + clipboardText;
+ if (!event->isAccepted()) {
+ // Navigate to url in clipboard on middle mouse button click on the page...
+ if (!isModified() && (d->pressedButtons & Qt::MidButton)) {
+ QString \
clipboardText(QApplication::clipboard()->text(QClipboard::Selection).trimmed()); + \
if (KUriFilter::self()->filterUri(clipboardText, QStringList() << "kshorturifilter")) \
{ + kDebug() << "Navigating to" << clipboardText;
+ emit openUrl(KUrl(clipboardText));
}
- emit openUrl(url);
}
}
+
+ event->setAccepted(isAccepted);
+ QWebView::mouseReleaseEvent(event);
}
--- trunk/playground/libs/webkitkde/kdewebkit/kwebview.h #1043145:1043146
@@ -86,22 +86,25 @@
Q_SIGNALS:
/**
- * This signal is emitted when the user wants to navigate to the url @p url.
+ * This signal is emitted when the user wants to navigate to @p url.
*/
void openUrl(const KUrl &url);
/**
- * This signal is emitted when the user clicks on a link with the middle
- * mouse button or clicks on a link with the left mouse button while
- * pressing Ctrl key.
+ * This signal is emitted when the user wants to save @p url.
+ *
+ * It is activated as a result of a shift-click on a link with the left
+ * mouse button.
*/
- void openUrlInNewWindow(const KUrl &url);
+ void saveUrl(const KUrl &url);
/**
- * This signal is emitted when the user presses clicks on a link with
- * the mouse button while pressing the Shift key.
+ * This signal is emitted when the user wants to open @p url in a new window.
+ *
+ * It is activated as a result of a click on a link with the middle mouse
+ * button or a ctrl-click with the left mouse button.
*/
- void saveUrl(const KUrl &url);
+ void openUrlInNewWindow(const KUrl &url);
protected:
/**
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic