diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2013-03-16 15:07:54 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2013-03-17 11:35:20 +0100 |
commit | 6ddb1b2a0fb39c758c975652b242bbfa8feaea57 (patch) | |
tree | accd70bbbe38cf26a405ac3c4b3634deab71fc5d /src | |
parent | open url as webapp option (diff) | |
download | rekonq-6ddb1b2a0fb39c758c975652b242bbfa8feaea57.tar.xz |
Support "open in webapp" && "install webapp" links
And now... :D
Diffstat (limited to 'src')
-rw-r--r-- | src/application.cpp | 24 | ||||
-rw-r--r-- | src/application.h | 4 | ||||
-rw-r--r-- | src/webtab/protocolhandler.cpp | 23 |
3 files changed, 46 insertions, 5 deletions
diff --git a/src/application.cpp b/src/application.cpp index 7fe23f20..6b9b9490 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -803,9 +803,17 @@ void Application::clearPrivateData() } -void Application::createWebAppShortcut() +void Application::createWebAppShortcut(const QString & urlString, const QString & titleString) { - KUrl u = rekonqWindow()->currentWebWindow()->url(); + KUrl u; + if (urlString.isEmpty()) + { + u = rekonqWindow()->currentWebWindow()->url(); + } + else + { + u = KUrl(urlString); + } QString h = u.host(); QPointer<KDialog> dialog = new KDialog(rekonqWindow()); @@ -819,7 +827,17 @@ void Application::createWebAppShortcut() QWidget widget; wAppWidget.setupUi(&widget); - QString webAppTitle = rekonqWindow()->currentWebWindow()->title().remove('&'); + QString webAppTitle; + if (titleString.isEmpty()) + { + webAppTitle = rekonqWindow()->currentWebWindow()->title(); + } + else + { + webAppTitle = titleString; + } + webAppTitle = webAppTitle.remove('&'); + wAppWidget.nameLineEdit->setText(webAppTitle); wAppWidget.kcfg_createDesktopAppShortcut->setChecked(ReKonfig::createDesktopAppShortcut()); wAppWidget.kcfg_createMenuAppShortcut->setChecked(ReKonfig::createMenuAppShortcut()); diff --git a/src/application.h b/src/application.h index e1801345..e9efc0fb 100644 --- a/src/application.h +++ b/src/application.h @@ -123,6 +123,8 @@ public Q_SLOTS: WebTab *newWebApp(); + void createWebAppShortcut(const QString & urlString = QString(), const QString & titleString = QString()); + protected: // This is used to track which window was activated most recently bool eventFilter(QObject *watched, QEvent *event); @@ -138,8 +140,6 @@ private Q_SLOTS: void queryQuit(); - void createWebAppShortcut(); - void newPrivateBrowsingWindow(); void pageCreated(WebPage *); diff --git a/src/webtab/protocolhandler.cpp b/src/webtab/protocolhandler.cpp index e9f6a77c..4b456112 100644 --- a/src/webtab/protocolhandler.cpp +++ b/src/webtab/protocolhandler.cpp @@ -31,7 +31,10 @@ #include "rekonq.h" // Local Includes +#include "application.h" + #include "historymanager.h" + #include "webpage.h" #include "webtab.h" #include "urlbar.h" @@ -142,6 +145,26 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra return false; } + kDebug() << "FN: " << _url.fileName(); + kDebug() << "DIR: " << _url.directory(); + + if (_url.directory() == QL1S("webapp")) + { + if (_url.fileName() == QL1S("launch")) + { + QString value = _url.queryItemValue(QL1S("url")); + rApp->loadUrl(KUrl(value), Rekonq::WebApp); + return true; + } + if (_url.fileName() == QL1S("install")) + { + QString urlValue = _url.queryItemValue(QL1S("url")); + QString titleValue = _url.queryItemValue(QL1S("title")); + rApp->createWebAppShortcut(urlValue, titleValue); + return true; + } + } + if (encodedUrl == QByteArray("about:home")) { switch (ReKonfig::newTabStartPage()) |