[prev in list] [next in list] [prev in thread] [next in thread]
List: kfm-devel
Subject: [PATCH] Support for bookmarklets
From: Aurélien_Gâteau <aurelien.gateau () free ! fr>
Date: 2009-01-28 21:29:51
Message-ID: 4980CE4F.3070204 () free ! fr
[Download RAW message or body]
Hello,
Attached is a patch which adds support for bookmarklets to Konqueror.
In case you don't know about them, bookmarklets are one-line javascript
bookmarks which can be triggered by the user to do nifty things with the
current web page, for example enforcing a sane combination of
background and foreground colors. One of the most common bookmarklets is
the one provided by Del.icio.us to bookmark pages to their service. You
can find it here:
http://delicious.com/help/bookmarklets
The patch is quite simple, but requires linking libkdeinit_konqueror
with khtml.
What do you think about it? Is it ok to commit?
Aurélien
["konqueror-bookmarklet-1.diff" (text/x-diff)]
Index: src/konqmainwindow.cpp
===================================================================
--- src/konqmainwindow.cpp (révision 917241)
+++ src/konqmainwindow.cpp (copie de travail)
@@ -146,6 +146,8 @@
#include <QtDBus/QtDBus>
#include <kconfiggroup.h>
+#include <khtml_part.h>
+
template class QList<QPixmap*>;
template class QList<KToggleAction*>;
@@ -523,7 +525,7 @@
KMessageBox::error(0, i18n("Malformed URL\n%1", url.url()));
return;
}
- else if ( !KProtocolInfo::isKnownProtocol( url ) && url.protocol() != "about" )
+ else if ( !KProtocolInfo::isKnownProtocol( url ) && url.protocol() != "about" && \
url.protocol() != "javascript" ) {
KMessageBox::error(0, i18n("Protocol not supported\n%1", url.protocol()));
return;
@@ -673,8 +675,19 @@
}
}
}
- }
- else // no known mimeType, use KonqRun
+ } else if (url.protocol() == "javascript") {
+ if (m_currentView) {
+ KHTMLPart* htmlPart = qobject_cast<KHTMLPart*>(m_currentView->part());
+ if (htmlPart) {
+ const QString script = url.prettyUrl().section(':', 1);
+ htmlPart->executeScript(script);
+ } else {
+ KMessageBox::error(0, i18n("The script cannot be executed because the \
current document is not a web page.")); + }
+ } else {
+ KMessageBox::error(0, i18n("The script cannot be executed because no web \
page has been opened.")); + }
+ } else // no known mimeType, use KonqRun
{
bool earlySetLocationBarURL = false;
if (!view && !m_currentView) // no view yet, e.g. starting with url as \
argument
Index: src/CMakeLists.txt
===================================================================
--- src/CMakeLists.txt (révision 917241)
+++ src/CMakeLists.txt (copie de travail)
@@ -83,7 +83,7 @@
kde4_add_app_icon(konqueror_KDEINIT_SRCS \
"${KDE4_ICON_INSTALL_DIR}/oxygen/*/apps/konqueror.png") \
kde4_add_kdeinit_executable(konqueror ${konqueror_KDEINIT_SRCS} \
konqmain.cpp)
-target_link_libraries(kdeinit_konqueror konquerorprivate konq ${KDE4_KPARTS_LIBS} \
${KDE4_KUTILS_LIBS}) +target_link_libraries(kdeinit_konqueror konquerorprivate konq \
${KDE4_KPARTS_LIBS} ${KDE4_KUTILS_LIBS} ${KDE4_KHTML_LIBS}) if (UNIX)
target_link_libraries(kdeinit_konqueror ${X11_LIBRARIES})
endif (UNIX)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic