[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/base/kwebkitpart/src
From:       Dawit Alemayehu <adawit () kde ! org>
Date:       2010-07-10 3:56:26
Message-ID: 20100710040628.3DD95AC867 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1148203 by adawit:

Make RMB option to 'Open...' better at detecting urls by using the
KURIFilter class. You can now highlight "www.kde.org" and you will be
offered to open the link.


 M  +10 -4     webview.cpp  


--- trunk/extragear/base/kwebkitpart/src/webview.cpp #1148202:1148203
@@ -275,12 +275,15 @@
 
     d->addSearchActions(selectActions, this);
 
-    const QString selectedTextURL = selectedText().simplified();
-    if (selectedTextURL.contains("://") && KUrl(selectedTextURL).isValid()) {
+    KUriFilterData data (selectedText().simplified().left(256));
+    data.setCheckForExecutables(false);
+    if (KUriFilter::self()->filterUri(data, QStringList() << "kshorturifilter") &&
+        data.uri().isValid() && data.uriType() == KUriFilterData::NetProtocol) {
         KAction *action = new KAction(i18nc("open selected url", "Open '%1'",
-                                            \
KStringHandler::rsqueeze(selectedTextURL, 18)), this); +                              \
KStringHandler::rsqueeze(data.uri().url(), 18)), this);  \
d->actionCollection->addAction("openSelection", action);  \
action->setIcon(KIcon("window-new")); +        action->setData(QUrl(data.uri()));
         connect(action, SIGNAL(triggered(bool)), this, SLOT(openSelection()));
         selectActions.append(action);
     }
@@ -440,7 +443,10 @@
 
 void WebView::openSelection()
 {
+    QAction *action = qobject_cast<KAction*>(sender());
+    if (action) {
     KParts::BrowserArguments browserArgs;
     browserArgs.frameName = "_blank";
-    emit d->part->browserExtension()->openUrlRequest(selectedText().simplified(), \
KParts::OpenUrlArguments(), browserArgs); +        emit \
d->part->browserExtension()->openUrlRequest(action->data().toUrl(), \
KParts::OpenUrlArguments(), browserArgs);  }
+}


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic