From 544094302a51b919b1eea86b313ec10d47533a08 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Fri, 15 Jan 2010 17:20:51 +0100 Subject: A new approach for choosing previews : a bar appears, then you browse to the page you want to preview, and then you click a button --- src/protocolhandler.cpp | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index c90afd19..a9339cfa 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -108,36 +108,9 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra // "about" handling if ( _url.protocol() == QLatin1String("about") ) { - if( _url == KUrl("about:home") ) - { - switch(ReKonfig::newTabStartPage()) - { - case 0: // favorites - _url = KUrl("about:favorites"); - break; - case 1: // closed tabs - _url = KUrl("about:closedTabs"); - break; - case 2: // history - _url = KUrl("about:history"); - break; - case 3: // bookmarks - _url = KUrl("about:bookmarks"); - break; - default: // unuseful - break; - } - } - if( _url == KUrl("about:closedTabs") - || _url == KUrl("about:history") - || _url == KUrl("about:bookmarks") - || _url == KUrl("about:favorites") - ) - { - NewTabPage p(frame); - p.generate(_url); - return true; - } + NewTabPage p(frame); + p.generate(_url); + return true; } return false; -- cgit v1.2.1 From 067b99a053b6f8b1ccab507be8e828b2f72a1e43 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 10 Feb 2010 10:57:57 +0100 Subject: Fix copyright for 0.4 beta release --- src/protocolhandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index a9339cfa..995c1448 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -2,7 +2,7 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 by Andrea Diamantini +* Copyright (C) 2010 by Andrea Diamantini * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as -- cgit v1.2.1 From f364b998624e403a33dd1b79983f80b2d058da26 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 16 Feb 2010 02:12:45 +0100 Subject: Fixes focus && let Protocol handler to just load on demand the KDirLister class (and delete on finish) --- src/protocolhandler.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index 995c1448..af2e9904 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -36,6 +36,7 @@ #include "mainwindow.h" #include "mainview.h" #include "urlbar.h" +#include "webtab.h" #include "historymanager.h" // KDE Includes @@ -63,10 +64,9 @@ ProtocolHandler::ProtocolHandler(QObject *parent) : QObject(parent) - , _lister(new KDirLister) + , _lister(0) , _frame(0) { - connect( _lister, SIGNAL(newItems(const KFileItemList &)), this, SLOT(showResults(const KFileItemList &))); } @@ -154,8 +154,10 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr QFileInfo fileInfo( _url.path() ); if(fileInfo.isDir()) { + _lister = new KDirLister; + connect( _lister, SIGNAL(newItems(const KFileItemList &)), this, SLOT(showResults(const KFileItemList &))); _lister->openUrl(_url); - Application::instance()->mainWindow()->mainView()->urlBar()->setUrl(_url); + return true; } } @@ -166,6 +168,10 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr QString ProtocolHandler::dirHandling(const KFileItemList &list) { + if (!_lister) + { + return QString("rekonq error, sorry :("); + } KFileItem mainItem = _lister->rootItem(); KUrl rootUrl = mainItem.url(); @@ -254,14 +260,14 @@ void ProtocolHandler::showResults(const KFileItemList &list) return; } - if ( list.isEmpty() ) - return; - QString html = dirHandling(list); _frame->setHtml(html); + Application::instance()->mainWindow()->currentTab()->setFocus(); Application::instance()->mainWindow()->mainView()->urlBar()->setUrl(_url); Application::historyManager()->addHistoryEntry( _url.prettyUrl() ); + + delete _lister; } @@ -277,7 +283,11 @@ void ProtocolHandler::slotMostLocalUrlResult(KJob *job) KIO::StatJob *statJob = static_cast(job); KIO::UDSEntry entry = statJob->statResult(); if( entry.isDir() ) + { + _lister = new KDirLister; + connect( _lister, SIGNAL(newItems(const KFileItemList &)), this, SLOT(showResults(const KFileItemList &))); _lister->openUrl(_url); + } else emit downloadUrl(_url); } -- cgit v1.2.1 From 4dcd02b5317896be0adbe479a4594dac4f048286 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 18 Feb 2010 02:10:51 +0100 Subject: Working around about: protocol.. - honor rekonq settings on about:home page - loads about:blank :) pages --- src/protocolhandler.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index af2e9904..a80f0a46 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -108,6 +108,33 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra // "about" handling if ( _url.protocol() == QLatin1String("about") ) { + if( _url == KUrl("about:blank") ) + { + frame->setHtml( QString() ); + return true; + } + + if( _url == KUrl("about:home") ) + { + switch(ReKonfig::newTabStartPage()) + { + case 0: // favorites + _url = KUrl("about:favorites"); + break; + case 1: // closed tabs + _url = KUrl("about:closedTabs"); + break; + case 2: // history + _url = KUrl("about:history"); + break; + case 3: // bookmarks + _url = KUrl("about:bookmarks"); + break; + default: // unuseful + break; + } + } + NewTabPage p(frame); p.generate(_url); return true; @@ -149,7 +176,7 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr } // "file" handling. This is quite trivial :) - if(_url.protocol() == QLatin1String("file") ) + if( _url.protocol() == QLatin1String("file") ) { QFileInfo fileInfo( _url.path() ); if(fileInfo.isDir()) -- cgit v1.2.1 From 060909220bad6842828f2583213dc96c285b5fd9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 19 Feb 2010 12:37:46 +0100 Subject: change setHtml( string ) to setHtml( string, url ) to let webviews return an url on webview->url() calls --- src/protocolhandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index a80f0a46..1a533a6e 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -110,7 +110,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra { if( _url == KUrl("about:blank") ) { - frame->setHtml( QString() ); + frame->setHtml( QString() , _url ); return true; } @@ -288,7 +288,7 @@ void ProtocolHandler::showResults(const KFileItemList &list) } QString html = dirHandling(list); - _frame->setHtml(html); + _frame->setHtml( html, _url ); Application::instance()->mainWindow()->currentTab()->setFocus(); Application::instance()->mainWindow()->mainView()->urlBar()->setUrl(_url); -- cgit v1.2.1 From 2f21d0ed14647ee361538f7adcf7c8013d47c872 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 21 Feb 2010 00:46:45 +0100 Subject: A stupid regression caused by me. When I'll decide to implement some unit tests for this, we'll no more see things like this :) --- src/protocolhandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index 1a533a6e..ffeea562 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -108,10 +108,10 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra // "about" handling if ( _url.protocol() == QLatin1String("about") ) { + // let webkit manage the about:blank url... if( _url == KUrl("about:blank") ) { - frame->setHtml( QString() , _url ); - return true; + return false; } if( _url == KUrl("about:home") ) -- cgit v1.2.1 From 09ba3b9c585ad397c3168d1fb44f7f4dc75f0447 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Mar 2010 00:52:07 +0100 Subject: Fix choice between history & bookmarks in the new tab first page. No more reloading pages on accepting configuration --- src/protocolhandler.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index ffeea562..70d69107 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -124,12 +124,12 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra case 1: // closed tabs _url = KUrl("about:closedTabs"); break; - case 2: // history - _url = KUrl("about:history"); - break; - case 3: // bookmarks + case 2: // bookmarks _url = KUrl("about:bookmarks"); break; + case 3: // history + _url = KUrl("about:history"); + break; default: // unuseful break; } -- cgit v1.2.1 From f51c660a207364b9b5ff400a29e8ff1dba721e61 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 19 Mar 2010 11:00:18 +0100 Subject: abp (Ad Block Plus) fake protocol support This will let rekonq to automatically add abp subscriptions from the adblockplus.org site (or wherever someone provides abp urls) Anyway, consider that the raccomended way to manage adblock (by me and by abp developers) is just adding the EasyList subscription. rekonq just does it by default!! --- src/protocolhandler.cpp | 84 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 75 insertions(+), 9 deletions(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index 70d69107..9d1560ed 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -38,6 +38,7 @@ #include "urlbar.h" #include "webtab.h" #include "historymanager.h" +#include "adblockmanager.h" // KDE Includes #include @@ -52,6 +53,7 @@ #include #include #include +#include // Qt Includes #include @@ -61,6 +63,9 @@ #include #include +// Defines +#define QL1S(x) QLatin1String(x) + ProtocolHandler::ProtocolHandler(QObject *parent) : QObject(parent) @@ -87,11 +92,11 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra return false; // "http(s)" (fast) handling - if( _url.protocol() == QLatin1String("http") || _url.protocol() == QLatin1String("https") ) + if( _url.protocol() == QL1S("http") || _url.protocol() == QL1S("https") ) return false; // javascript handling - if( _url.protocol() == QLatin1String("javascript") ) + if( _url.protocol() == QL1S("javascript") ) { QString scriptSource = _url.authority(); QVariant result = frame->evaluateJavaScript(scriptSource); @@ -99,14 +104,21 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra } // "mailto" handling - if ( _url.protocol() == QLatin1String("mailto") ) + if ( _url.protocol() == QL1S("mailto") ) { KToolInvocation::invokeMailer(_url); return true; } + // "abp" handling + if ( _url.protocol() == QL1S("abp") ) + { + abpHandling(); + return true; + } + // "about" handling - if ( _url.protocol() == QLatin1String("about") ) + if ( _url.protocol() == QL1S("about") ) { // let webkit manage the about:blank url... if( _url == KUrl("about:blank") ) @@ -152,12 +164,12 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr kDebug() << "URL PROTOCOL: " << _url; // "http(s)" (fast) handling - if( _url.protocol() == QLatin1String("http") || _url.protocol() == QLatin1String("https") ) + if( _url.protocol() == QL1S("http") || _url.protocol() == QL1S("https") ) return false; // "mailto" handling: It needs to be handled both here(mail links clicked) // and in prehandling (mail url launched) - if ( _url.protocol() == QLatin1String("mailto") ) + if ( _url.protocol() == QL1S("mailto") ) { KToolInvocation::invokeMailer(_url); return true; @@ -168,7 +180,7 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr // My idea is: webkit cannot handle in any way ftp. So we have surely to return true here. // We start trying to guess what the url represent: it's a dir? show its contents (and download them). // it's a file? download it. It's another thing? beat me, but I don't know what to do... - if( _url.protocol() == QLatin1String("ftp") ) + if( _url.protocol() == QL1S("ftp") ) { KIO::StatJob *job = KIO::stat(_url); connect(job, SIGNAL(result(KJob*)), this, SLOT( slotMostLocalUrlResult(KJob*) )); @@ -176,7 +188,7 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr } // "file" handling. This is quite trivial :) - if( _url.protocol() == QLatin1String("file") ) + if( _url.protocol() == QL1S("file") ) { QFileInfo fileInfo( _url.path() ); if(fileInfo.isDir()) @@ -269,7 +281,7 @@ QString ProtocolHandler::dirHandling(const KFileItemList &list) msg += ""; - QString html = QString(QLatin1String(file.readAll())) + QString html = QString(QL1S(file.readAll())) .arg(title) .arg(msg) ; @@ -319,3 +331,57 @@ void ProtocolHandler::slotMostLocalUrlResult(KJob *job) emit downloadUrl(_url); } } + + +/** + * abp scheme (easy) explanation + * + */ +void ProtocolHandler::abpHandling() +{ + kDebug() << _url; + + QString path = _url.path(); + if( path != QL1S("subscribe") ) + return; + + QMap map = _url.queryItems( KUrl::CaseInsensitiveKeys ); + + QString location = map.value( QL1S("location") ); + kDebug() << location; + + QString title = map.value( QL1S("title") ); + kDebug() << title; + + QString requireslocation = map.value( QL1S("requireslocation") ); + kDebug() << requireslocation; + + QString requirestitle = map.value( QL1S("requirestitle") ); + kDebug() << requirestitle; + + QString info; + if( requirestitle.isEmpty() || requireslocation.isEmpty() ) + { + info = title; + } + else + { + info = i18n("\n %1,\n %2 (required by %3)\n", title, requirestitle, title); + } + + if ( KMessageBox::questionYesNo( 0, + i18n("Do you want to add the following subscriptions to your adblock settings?\n") + info, + i18n("Add automatic subscription to the adblock"), + KGuiItem(i18n("Add")), + KGuiItem(i18n("Discard")) + ) + ) + { + if( !requireslocation.isEmpty() && !requirestitle.isEmpty() ) + { + Application::adblockManager()->addSubscription( requirestitle, requireslocation ); + } + Application::adblockManager()->addSubscription( title, location ); + Application::adblockManager()->loadSettings(false); + } +} -- cgit v1.2.1 From a6ef003dd4c1b6ad08eca4f5adaa4679bbc20bce Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 20 Mar 2010 22:54:21 +0100 Subject: Downloads Page This commit implements the downloads history page. While it is in an horrible shape, its slots seem working well It needs just some love.. --- src/protocolhandler.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index 9d1560ed..faba894b 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -142,6 +142,8 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra case 3: // history _url = KUrl("about:history"); break; + case 4: // downloads + _url = KUrl("about:downloads"); default: // unuseful break; } -- cgit v1.2.1 From 352168759ea96b35296eaf33790fbe073b69f69b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 5 Apr 2010 01:31:13 +0200 Subject: This commit is the first implementation of a new new new urlbar Here are its features: - KLineEdit based - ability to easily add "icons" :) - SSL informations shown (a-la firefox) - smoother animation - cleaner code - data QString, not KUrl based (Users type string, not urls!!!) --- src/protocolhandler.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index faba894b..f6867e81 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -305,7 +305,6 @@ void ProtocolHandler::showResults(const KFileItemList &list) _frame->setHtml( html, _url ); Application::instance()->mainWindow()->currentTab()->setFocus(); - Application::instance()->mainWindow()->mainView()->urlBar()->setUrl(_url); Application::historyManager()->addHistoryEntry( _url.prettyUrl() ); delete _lister; -- cgit v1.2.1 From 43dc2695d62fd2e4fc01aff608bb2af3e8335040 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 8 Apr 2010 02:53:38 +0200 Subject: This is a really big commit, implementing the new urlbar - removed previous SSL animation, we have now a nice yellow lock :) - faster and cleaner animations - reenabled the old stacked widget, to avoid stupid refreshes and fix some regressions - implemented some "right icons": KGet, SSL, RSS. For now, just SSL is full featured - clean up the box :) Some old & unuseful files removed, some icons added - Pano's request: grey text shown everytime in the empty bar Again and again: this is not the first, but the second implementation of the new urlbar UI. About me this is clearly better than the first or the previous. But it needs love :D BUG: 230125 BUG: 231015 CCBUG: 228040 BUG: 227272 --- src/protocolhandler.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index f6867e81..1458bdf5 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -85,16 +85,14 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra _url = request.url(); _frame = frame; - kDebug() << "URL PROTOCOL: " << _url; - - // relative urls - if(_url.isRelative()) - return false; - // "http(s)" (fast) handling if( _url.protocol() == QL1S("http") || _url.protocol() == QL1S("https") ) return false; - + + // relative urls + if(_url.isRelative()) + return false; + // javascript handling if( _url.protocol() == QL1S("javascript") ) { @@ -148,7 +146,9 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra break; } } - + + Application::instance()->mainWindow()->mainView()->urlBar()->clearRightIcons(); + NewTabPage p(frame); p.generate(_url); return true; -- cgit v1.2.1 From c05b14ad0f8358171f4dc199e61dc0a259d0aa65 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 14 Apr 2010 11:59:43 +0200 Subject: Proper solutions are always the best ones :) Fix duplicated right icons. CCBUG: 234320 --- src/protocolhandler.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/protocolhandler.cpp') diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index 1458bdf5..c97bc475 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -146,8 +146,6 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra break; } } - - Application::instance()->mainWindow()->mainView()->urlBar()->clearRightIcons(); NewTabPage p(frame); p.generate(_url); -- cgit v1.2.1