summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-08-01 10:46:15 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:04 +0100
commit76af6dc385cb275da7af92933ec14c0177b229d6 (patch)
tree95658c2e0019f082a4aad695d2d14a9edfe49ba9 /src
parentCopy webtab related files from rekonq repo (diff)
downloadrekonq-76af6dc385cb275da7af92933ec14c0177b229d6.tar.xz
Let WebView compile and work
WARNING: Not everything compiles yet...
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt17
-rw-r--r--src/download/.downloadmanager.cpp.kate-swpbin64 -> 0 bytes
-rw-r--r--src/webtab/networkaccessmanager.cpp105
-rw-r--r--src/webtab/networkaccessmanager.h8
-rw-r--r--src/webtab/protocolhandler.cpp26
-rw-r--r--src/webtab/webpage.cpp81
-rw-r--r--src/webtab/webpage.h15
-rw-r--r--src/webtab/webtab.cpp55
-rw-r--r--src/webtab/webtab.h5
-rw-r--r--src/webtab/webview.cpp113
-rw-r--r--src/webtab/webview.h4
-rw-r--r--src/webwindow/webwindow.h10
12 files changed, 268 insertions, 171 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 25b97871..b89125ac 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -71,6 +71,20 @@ set(rekonq_KDEINIT_SRCS
useragent/useragentmanager.cpp
useragent/useragentwidget.cpp
#----------------------------------------
+ webtab/clicktoflash.cpp
+# webtab/messagebar.cpp
+ webtab/networkaccessmanager.cpp
+# webtab/previewselectorbar.cpp
+ webtab/protocolhandler.cpp
+# webtab/searchenginebar.cpp
+ webtab/sslinfodialog.cpp
+ webtab/walletbar.cpp
+ webtab/webpage.cpp
+ webtab/webpluginfactory.cpp
+ webtab/websslinfo.cpp
+ webtab/webview.cpp
+# webtab/webtab.cpp
+ #----------------------------------------
webwindow/networkaccessmanager.cpp
webwindow/webpage.cpp
webwindow/webwindow.cpp
@@ -119,6 +133,8 @@ KDE4_ADD_UI_FILES( rekonq_KDEINIT_SRCS
sync/sync_host_type.ui
# ----------------------------------------
useragent/useragentsettings.ui
+ # ----------------------------------------
+ webtab/sslinfo.ui
)
@@ -135,6 +151,7 @@ INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/urlbar
${CMAKE_CURRENT_SOURCE_DIR}/tabwindow
${CMAKE_CURRENT_SOURCE_DIR}/useragent
+ ${CMAKE_CURRENT_SOURCE_DIR}/webtab
${CMAKE_CURRENT_SOURCE_DIR}/webwindow
${CMAKE_CURRENT_BINARY_DIR}
${KDE4_INCLUDES}
diff --git a/src/download/.downloadmanager.cpp.kate-swp b/src/download/.downloadmanager.cpp.kate-swp
deleted file mode 100644
index 3dec0e40..00000000
--- a/src/download/.downloadmanager.cpp.kate-swp
+++ /dev/null
Binary files differ
diff --git a/src/webtab/networkaccessmanager.cpp b/src/webtab/networkaccessmanager.cpp
index dc10da1b..e817faca 100644
--- a/src/webtab/networkaccessmanager.cpp
+++ b/src/webtab/networkaccessmanager.cpp
@@ -32,16 +32,18 @@
// Local Includes
#include "adblockmanager.h"
-#include "application.h"
-#include "webpage.h"
// KDE Includes
#include <KLocale>
#include <KProtocolManager>
+#include <KRun>
// Qt Includes
#include <QNetworkReply>
#include <QTimer>
+#include <QWebElement>
+#include <QWebFrame>
+#include <QWidget>
class NullNetworkReply : public QNetworkReply
@@ -54,7 +56,7 @@ public:
setUrl(req.url());
setHeader(QNetworkRequest::ContentLengthHeader, 0);
setHeader(QNetworkRequest::ContentTypeHeader, "text/plain");
- setError(QNetworkReply::ContentAccessDenied, i18n("Null reply"));
+ setError(QNetworkReply::ContentAccessDenied, i18n("Blocked by ad filter"));
setAttribute(QNetworkRequest::User, QNetworkReply::ContentAccessDenied);
QTimer::singleShot(0, this, SIGNAL(finished()));
}
@@ -76,6 +78,34 @@ protected:
// ----------------------------------------------------------------------------------------------
+#define HIDABLE_ELEMENTS QL1S("audio,img,embed,object,iframe,frame,video")
+
+
+static void hideBlockedElements(const QUrl& url, QWebElementCollection& collection)
+{
+ for (QWebElementCollection::iterator it = collection.begin(); it != collection.end(); ++it)
+ {
+ const QUrl baseUrl ((*it).webFrame()->baseUrl());
+ QString src = (*it).attribute(QL1S("src"));
+
+ if (src.isEmpty())
+ src = (*it).evaluateJavaScript(QL1S("this.src")).toString();
+
+ if (src.isEmpty())
+ continue;
+ const QUrl resolvedUrl (baseUrl.resolved(src));
+ if (url == resolvedUrl)
+ {
+ //kDebug() << "*** HIDING ELEMENT: " << (*it).tagName() << resolvedUrl;
+ (*it).removeFromDocument();
+ }
+ }
+}
+
+
+// ----------------------------------------------------------------------------------------------
+
+
NetworkAccessManager::NetworkAccessManager(QObject *parent)
: AccessManager(parent)
{
@@ -92,29 +122,64 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent)
}
-QNetworkReply *NetworkAccessManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
+QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData)
{
- WebPage *parentPage = qobject_cast<WebPage *>(parent());
+ bool blocked = false;
+
+ // Handle GET operations with AdBlock
+ if (op == QNetworkAccessManager::GetOperation)
+ blocked = AdBlockManager::self()->blockRequest(req);
+
+ if (!blocked)
+ {
+ if (KProtocolInfo::isHelperProtocol(req.url()))
+ {
+ (void) new KRun(req.url(), qobject_cast<QWidget*>(req.originatingObject()));
+ return new NullNetworkReply(req, this);
+ }
- // NOTE: This to get sure we are NOT serving unused requests
- if (!parentPage)
- return new NullNetworkReply(request, this);
+ // set our "nice" accept-language header...
+ QNetworkRequest request = req;
+ request.setRawHeader("Accept-Language", _acceptLanguage);
- QNetworkReply *reply = 0;
+ return KIO::AccessManager::createRequest(op, request, outgoingData);
+ }
- // set our "nice" accept-language header...
- QNetworkRequest req = request;
- req.setRawHeader("Accept-Language", _acceptLanguage);
+ QWebFrame* frame = qobject_cast<QWebFrame*>(req.originatingObject());
+ if (frame)
+ {
+ if (!m_blockedRequests.contains(frame))
+ connect(frame, SIGNAL(loadFinished(bool)), this, SLOT(slotFinished(bool)));
+ m_blockedRequests.insert(frame, req.url());
+ }
- // Handle GET operations with AdBlock
- if (op == QNetworkAccessManager::GetOperation)
- reply = rApp->adblockManager()->block(req, parentPage);
+ return new NullNetworkReply(req, this);
+}
+
+
+void NetworkAccessManager::slotFinished(bool ok)
+{
+ if (!ok)
+ return;
+
+ if(!AdBlockManager::self()->isEnabled())
+ return;
+
+ if(!AdBlockManager::self()->isHidingElements())
+ return;
+
+ QWebFrame* frame = qobject_cast<QWebFrame*>(sender());
+ if (!frame)
+ return;
- if (!reply)
- reply = AccessManager::createRequest(op, req, outgoingData);
+ QList<QUrl> urls = m_blockedRequests.values(frame);
+ if (urls.isEmpty())
+ return;
- if (parentPage->hasNetworkAnalyzerEnabled())
- emit networkData(op, req, reply);
+ QWebElementCollection collection = frame->findAllElements(HIDABLE_ELEMENTS);
+ if (frame->parentFrame())
+ collection += frame->parentFrame()->findAllElements(HIDABLE_ELEMENTS);
- return reply;
+ Q_FOREACH(const QUrl& url, urls)
+ hideBlockedElements(url, collection);
}
diff --git a/src/webtab/networkaccessmanager.h b/src/webtab/networkaccessmanager.h
index 5c877bdf..1c9c3905 100644
--- a/src/webtab/networkaccessmanager.h
+++ b/src/webtab/networkaccessmanager.h
@@ -38,6 +38,9 @@
// Qt Includes
#include <QByteArray>
+// Forward Declarations
+class QWebFrame;
+
class REKONQ_TESTS_EXPORT NetworkAccessManager : public KIO::Integration::AccessManager
{
@@ -49,10 +52,11 @@ public:
protected:
virtual QNetworkReply *createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData = 0);
-Q_SIGNALS:
- void networkData(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QNetworkReply *reply);
+private Q_SLOTS:
+ void slotFinished(bool);
private:
+ QMultiHash<QWebFrame*, QUrl> m_blockedRequests;
QByteArray _acceptLanguage;
};
diff --git a/src/webtab/protocolhandler.cpp b/src/webtab/protocolhandler.cpp
index 186b93d3..8618667b 100644
--- a/src/webtab/protocolhandler.cpp
+++ b/src/webtab/protocolhandler.cpp
@@ -33,12 +33,10 @@
// Local Includes
#include "application.h"
#include "historymanager.h"
-#include "mainview.h"
-#include "mainwindow.h"
-#include "newtabpage.h"
-#include "urlbar.h"
+#include "tabwindow.h"
+#include "webwindow.h"
+// #include "newtabpage.h"
#include "webpage.h"
-#include "webtab.h"
// KDE Includes
#include <KIO/Job>
@@ -94,7 +92,7 @@ ProtocolHandler::ProtocolHandler(QObject *parent)
, _lister(new KDirLister(this))
, _frame(0)
{
- _lister->setMainWindow(rApp->mainWindow());
+ _lister->setMainWindow(rApp->tabWindow());
}
@@ -164,8 +162,8 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra
WebPage *page = qobject_cast<WebPage *>(frame->page());
page->setIsOnRekonqPage(true);
- NewTabPage p(frame);
- p.generate(_url);
+// FIXME NewTabPage p(frame);
+// p.generate(_url);
return true;
}
@@ -183,7 +181,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra
if (_url.protocol() == QL1S("apt"))
{
kDebug() << "APT URL: " << _url;
- (void)new KRun(_url, rApp->mainWindow(), 0, _url.isLocalFile());
+ (void)new KRun(_url, rApp->tabWindow(), 0, _url.isLocalFile());
return true;
}
@@ -192,7 +190,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra
return false;
// Error Message, for those protocols we cannot handle
- KMessageBox::error(rApp->mainWindow(), i18nc("@info", "rekonq does not know how to handle this protocol: %1", _url.protocol()));
+ KMessageBox::error(rApp->tabWindow(), i18nc("@info", "rekonq does not know how to handle this protocol: %1", _url.protocol()));
return true;
}
@@ -246,7 +244,7 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr
// Try KRunning it...
if (KProtocolInfo::isKnownProtocol(_url))
{
- (void)new KRun(_url, rApp->mainWindow(), 0, _url.isLocalFile());
+ (void)new KRun(_url, rApp->tabWindow(), 0, _url.isLocalFile());
return true;
}
@@ -269,9 +267,9 @@ void ProtocolHandler::showResults(const KFileItemList &list)
_frame->setHtml(html);
qobject_cast<WebPage *>(_frame->page())->setIsOnRekonqPage(true);
- rApp->mainWindow()->mainView()->currentUrlBar()->setQUrl(_url);
- rApp->mainWindow()->currentTab()->setFocus();
- rApp->historyManager()->addHistoryEntry(_url, _url.prettyUrl());
+// FIXME rApp->mainWindow()->mainView()->currentUrlBar()->setQUrl(_url);
+// rApp->mainWindow()->currentTab()->setFocus();
+ HistoryManager::self()->addHistoryEntry(_url, _url.prettyUrl());
}
}
diff --git a/src/webtab/webpage.cpp b/src/webtab/webpage.cpp
index 59262862..8697a9b5 100644
--- a/src/webtab/webpage.cpp
+++ b/src/webtab/webpage.cpp
@@ -38,20 +38,16 @@
#include "rekonq.h"
// Local Includes
-#include "adblockmanager.h"
-#include "application.h"
#include "downloadmanager.h"
#include "historymanager.h"
#include "iconmanager.h"
-#include "mainview.h"
-#include "mainwindow.h"
+#include "tabwindow.h"
#include "networkaccessmanager.h"
-#include "urlbar.h"
#include "webpluginfactory.h"
#include "websnap.h"
#include "webtab.h"
#include "searchengine.h"
-#include "sslwidget.h"
+// #include "sslwidget.h"
#include "sslinfodialog.h"
// KDE Includes
@@ -163,7 +159,7 @@ WebPage::WebPage(QWidget *parent)
// protocol handler signals
connect(&_protHandler, SIGNAL(downloadUrl(KUrl)), this, SLOT(downloadUrl(KUrl)));
- connect(rApp->iconManager(), SIGNAL(iconChanged()), mainFrame(), SIGNAL(iconChanged()));
+ connect(IconManager::self(), SIGNAL(iconChanged()), mainFrame(), SIGNAL(iconChanged()));
}
@@ -178,18 +174,6 @@ WebPage::~WebPage()
}
-bool WebPage::hasNetworkAnalyzerEnabled() const
-{
- return _networkAnalyzer;
-};
-
-
-void WebPage::enableNetworkAnalyzer(bool b)
-{
- _networkAnalyzer = b;
-};
-
-
bool WebPage::isOnRekonqPage() const
{
return _isOnRekonqPage;
@@ -308,16 +292,9 @@ WebPage *WebPage::createWindow(QWebPage::WebWindowType type)
if (type == QWebPage::WebModalDialog)
kDebug() << "Modal Dialog";
- WebTab *w = 0;
- if (ReKonfig::openLinksInNewWindow())
- {
- w = rApp->newMainWindow()->mainView()->currentWebTab();
- }
- else
- {
- w = rApp->mainWindow()->mainView()->newWebTab(!ReKonfig::openNewTabsInBackground());
- }
- return w->page();
+ WebPage* p = new WebPage;
+ emit pageCreated(p);
+ return p;
}
@@ -388,7 +365,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
}
else
{
- KParts::BrowserOpenOrSaveQuestion dlg(rApp->mainWindow(), replyUrl, _mimeType);
+ KParts::BrowserOpenOrSaveQuestion dlg(view(), replyUrl, _mimeType);
if (!_suggestedFileName.isEmpty())
dlg.setSuggestedFileName(_suggestedFileName);
@@ -403,7 +380,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
switch (dlg.askEmbedOrSave())
{
case KParts::BrowserOpenOrSaveQuestion::Save:
- rApp->downloadManager()->downloadResource(reply->url(), KIO::MetaData(), view(), !hideDialog, _suggestedFileName);
+ DownloadManager::self()->downloadResource(reply->url(), KIO::MetaData(), view(), !hideDialog, _suggestedFileName);
return;
case KParts::BrowserOpenOrSaveQuestion::Cancel:
@@ -425,9 +402,9 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
tempFile.open();
KUrl destUrl;
destUrl.setPath(tempFile.fileName());
- KIO::Job *job = KIO::file_copy(_loadingUrl, destUrl, 0600, KIO::Overwrite);
- job->ui()->setWindow(rApp->mainWindow());
- connect(job, SIGNAL(result(KJob*)), this, SLOT(copyToTempFileResult(KJob*)));
+// KIO::Job *job = KIO::file_copy(_loadingUrl, destUrl, 0600, KIO::Overwrite);
+// job->ui()->setWindow(view());
+// connect(job, SIGNAL(result(KJob*)), this, SLOT(copyToTempFileResult(KJob*)));
return;
}
@@ -441,10 +418,10 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
WebTab *tab = qobject_cast<WebTab *>(view->parent());
tab->setPart(pa, replyUrl);
- UrlBar *bar = tab->urlBar();
- bar->setQUrl(replyUrl);
-
- rApp->mainWindow()->updateHistoryActions();
+// UrlBar *bar = tab->urlBar();
+// bar->setQUrl(replyUrl);
+//
+// rApp->mainWindow()->updateHistoryActions();
}
else
{
@@ -460,9 +437,6 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
void WebPage::loadStarted()
{
- _hasAdBlockedElements = false;
- rApp->adblockManager()->clearElementsLists();
-
// set zoom factor
QString val;
KSharedConfig::Ptr config = KGlobal::config();
@@ -480,10 +454,7 @@ void WebPage::loadFinished(bool ok)
Q_UNUSED(ok);
// Provide site icon. Can this be moved to loadStarted??
- rApp->iconManager()->provideIcon(mainFrame(), _loadingUrl);
-
- // Apply adblock manager hiding rules
- rApp->adblockManager()->applyHidingRules(this);
+ IconManager::self()->provideIcon(mainFrame(), _loadingUrl);
// KWallet Integration
QStringList list = ReKonfig::walletBlackList();
@@ -564,10 +535,10 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply)
WebView *view = qobject_cast<WebView *>(parent());
WebTab *tab = qobject_cast<WebTab *>(view->parent());
- UrlBar *bar = tab->urlBar();
- bar->setQUrl(_loadingUrl);
-
- rApp->mainWindow()->updateHistoryActions();
+// FIXME UrlBar *bar = tab->urlBar();
+// bar->setQUrl(_loadingUrl);
+//
+// rApp->mainWindow()->updateHistoryActions();
}
}
break;
@@ -692,7 +663,7 @@ QString WebPage::errorPage(QNetworkReply *reply)
void WebPage::downloadRequest(const QNetworkRequest &request)
{
- rApp->downloadManager()->downloadResource(request.url(),
+ DownloadManager::self()->downloadResource(request.url(),
request.attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap(),
view());
}
@@ -700,7 +671,7 @@ void WebPage::downloadRequest(const QNetworkRequest &request)
void WebPage::downloadUrl(const KUrl &url)
{
- rApp->downloadManager()->downloadResource(url, KIO::MetaData(), view());
+ DownloadManager::self()->downloadResource(url, KIO::MetaData(), view());
}
@@ -724,7 +695,7 @@ void WebPage::downloadAllContentsWithKGet()
contents << baseUrl.resolved(relativeUrl).toString();
}
- rApp->downloadManager()->downloadLinksWithKGet(QVariant(contents.toList()));
+ DownloadManager::self()->downloadLinksWithKGet(QVariant(contents.toList()));
}
@@ -732,8 +703,8 @@ void WebPage::showSSLInfo(QPoint pos)
{
if (mainFrame()->url().scheme() == QL1S("https"))
{
- SSLWidget *widget = new SSLWidget(mainFrame()->url(), _sslInfo, view());
- widget->showAt(pos);
+// SSLWidget *widget = new SSLWidget(mainFrame()->url(), _sslInfo, view());
+// widget->showAt(pos);
}
else
{
@@ -750,7 +721,7 @@ void WebPage::copyToTempFileResult(KJob* job)
if (job->error())
job->uiDelegate()->showErrorMessage();
else
- (void)KRun::runUrl(static_cast<KIO::FileCopyJob *>(job)->destUrl(), _mimeType, rApp->mainWindow());
+ (void)KRun::runUrl(static_cast<KIO::FileCopyJob *>(job)->destUrl(), _mimeType, view());
}
diff --git a/src/webtab/webpage.h b/src/webtab/webpage.h
index abc9f64c..1985e047 100644
--- a/src/webtab/webpage.h
+++ b/src/webtab/webpage.h
@@ -52,9 +52,6 @@ public:
explicit WebPage(QWidget *parent = 0);
~WebPage();
- bool hasNetworkAnalyzerEnabled() const;
- void enableNetworkAnalyzer(bool b);
-
bool isOnRekonqPage() const;
void setIsOnRekonqPage(bool b);
@@ -62,16 +59,6 @@ public:
QString suggestedFileName();
- inline bool hasAdBlockedElements() const
- {
- return _hasAdBlockedElements;
- };
-
- inline void setHasAdBlockedElements(bool b)
- {
- _hasAdBlockedElements = b;
- };
-
bool hasSslValid() const;
public Q_SLOTS:
@@ -86,6 +73,8 @@ protected:
virtual bool acceptNavigationRequest(QWebFrame *frame,
const QNetworkRequest &request,
NavigationType type);
+Q_SIGNALS:
+ void pageCreated(WebPage *);
private Q_SLOTS:
void handleUnsupportedContent(QNetworkReply *reply);
diff --git a/src/webtab/webtab.cpp b/src/webtab/webtab.cpp
index 457e9006..13d2da93 100644
--- a/src/webtab/webtab.cpp
+++ b/src/webtab/webtab.cpp
@@ -56,6 +56,10 @@
#include <KWebView>
#include <KDebug>
#include <KBuildSycocaProgressDialog>
+#include <kdeprintdialog.h>
+
+#include <KParts/Part>
+#include <KParts/BrowserExtension>
// Qt Includes
#include <QVBoxLayout>
@@ -133,6 +137,12 @@ WebPage *WebTab::page()
}
+WebWindow *WebTab::webWindow()
+{
+ WebWindow *w = qobject_cast<WebWindow *>(parent());
+ return w;
+}
+
KUrl WebTab::url()
{
if (page() && page()->isOnRekonqPage())
@@ -417,3 +427,48 @@ void WebTab::showSearchEngineBar()
qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, seBar);
seBar->animatedShow();
}
+
+
+void WebTab::printFrame()
+{
+ if (page()->isOnRekonqPage())
+ {
+ // trigger print part action instead of ours..
+ KParts::ReadOnlyPart *p = part();
+ if (p)
+ {
+ KParts::BrowserExtension *ext = p->browserExtension();
+ if (ext)
+ {
+ KParts::BrowserExtension::ActionSlotMap *actionSlotMap = KParts::BrowserExtension::actionSlotMapPtr();
+
+ connect(this, SIGNAL(triggerPartPrint()), ext, actionSlotMap->value("print"));
+ emit triggerPartPrint();
+
+ return;
+ }
+ }
+ }
+
+ QWebFrame *printFrame = 0;
+ if (frame == 0)
+ {
+ printFrame = page()->mainFrame();
+ }
+ else
+ {
+ printFrame = frame;
+ }
+
+ QPrinter printer;
+ printer.setDocName(printFrame->title());
+ QPrintDialog *printDialog = KdePrint::createPrintDialog(&printer, this);
+
+ if (printDialog) //check if the Dialog was created
+ {
+ if (printDialog->exec())
+ printFrame->print(&printer);
+
+ delete printDialog;
+ }
+}
diff --git a/src/webtab/webtab.h b/src/webtab/webtab.h
index 39c23fb9..be7791c4 100644
--- a/src/webtab/webtab.h
+++ b/src/webtab/webtab.h
@@ -60,7 +60,8 @@ public:
WebView *view();
WebPage *page();
-
+ WebWindow *webWindow();
+
inline UrlBar *urlBar() const
{
return m_urlBar;
@@ -108,6 +109,8 @@ private Q_SLOTS:
void showSearchEngineBar();
+ void printFrame();
+
private:
KUrl extractOpensearchUrl(QWebElement e);
diff --git a/src/webtab/webview.cpp b/src/webtab/webview.cpp
index 00112d61..5c83ab84 100644
--- a/src/webtab/webview.cpp
+++ b/src/webtab/webview.cpp
@@ -32,15 +32,16 @@
// Auto Includes
#include "rekonq.h"
-// Local Includes
+// App Includes
#include "application.h"
+
+// Local Includes
#include "adblockmanager.h"
#include "bookmarkmanager.h"
#include "iconmanager.h"
-#include "mainview.h"
-#include "mainwindow.h"
+
+#include "webwindow.h"
#include "searchengine.h"
-#include "urlbar.h"
#include "webpage.h"
#include "webtab.h"
@@ -57,6 +58,7 @@
#include <QFile>
#include <QTimer>
+#include <QApplication>
#include <QClipboard>
#include <QContextMenuEvent>
#include <QLabel>
@@ -92,7 +94,6 @@ WebView::WebView(QWidget* parent)
connect(m_smoothScrollTimer, SIGNAL(timeout()), this, SLOT(scrollTick()));
m_smoothScrollTimer->setInterval(16);
- connect(this, SIGNAL(iconChanged()), this, SLOT(changeWindowIcon()));
connect(this, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
}
@@ -129,20 +130,6 @@ void WebView::loadStarted()
}
-void WebView::changeWindowIcon()
-{
- if (ReKonfig::useFavicon())
- {
- MainWindow *const mainWindow = rApp->mainWindow();
- if (url() == mainWindow->currentTab()->url())
- {
- const int index = mainWindow->mainView()->currentIndex();
- mainWindow->changeWindowIcon(index);
- }
- }
-}
-
-
WebPage *WebView::page()
{
if (!m_page)
@@ -157,7 +144,8 @@ WebPage *WebView::page()
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
QWebHitTestResult result = page()->mainFrame()->hitTestContent(event->pos());
- MainWindow *mainwindow = rApp->mainWindow();
+ WebTab *tab = qobject_cast<WebTab *>(parent());
+ WebWindow *webwin = tab->webWindow();
KMenu menu(this);
QAction *a;
@@ -211,7 +199,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(pageAction(KWebPage::Forward));
}
- menu.addAction(mainwindow->actionByName("view_redisplay"));
+ menu.addAction(webwin->actionByName("view_redisplay"));
menu.addSeparator();
@@ -220,7 +208,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
frameMenu->addAction(pageAction(KWebPage::OpenFrameInNewWindow));
a = new KAction(KIcon("document-print-frame"), i18n("Print Frame"), this);
- connect(a, SIGNAL(triggered()), this, SLOT(printFrame()));
+ connect(a, SIGNAL(triggered()), tab, SLOT(printFrame()));
frameMenu->addAction(a);
menu.addAction(frameMenu);
@@ -230,7 +218,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
// Page Actions
menu.addAction(pageAction(KWebPage::SelectAll));
- menu.addAction(mainwindow->actionByName(KStandardAction::name(KStandardAction::SaveAs)));
+ menu.addAction(webwin->actionByName(KStandardAction::name(KStandardAction::SaveAs)));
if (!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetList())
{
@@ -239,13 +227,13 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
menu.addAction(a);
}
- menu.addAction(mainwindow->actionByName("page_source"));
+ menu.addAction(webwin->actionByName("page_source"));
menu.addAction(inspectAction);
- if (mainwindow->isFullScreen())
+ if (isFullScreen())
{
menu.addSeparator();
- menu.addAction(mainwindow->actionByName("fullscreen"));
+ menu.addAction(webwin->actionByName("fullscreen"));
}
}
@@ -301,7 +289,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(slotCopyImageLocation()));
menu.addAction(a);
- if (rApp->adblockManager()->isEnabled())
+ if (AdBlockManager::self()->isEnabled())
{
a = new KAction(KIcon("preferences-web-browser-adblock"), i18n("Block image"), this);
a->setData(result.imageUrl());
@@ -330,8 +318,9 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
a->setText(i18n("Copy"));
menu.addAction(a);
- if (selectedText().contains('.') && selectedText().indexOf('.') < selectedText().length()
- && !selectedText().trimmed().contains(" ")
+ if (selectedText().contains('.')
+ && selectedText().indexOf('.') < selectedText().length()
+ && !selectedText().trimmed().contains(" ")
)
{
QString text = selectedText();
@@ -366,7 +355,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
if (defaultEngine) // check if a default engine is set
{
a = new KAction(i18nc("Search selected text with the default search engine", "Search with %1", defaultEngine->name()), this);
- a->setIcon(rApp->iconManager()->iconForUrl(SearchEngine::buildQuery(defaultEngine, "")));
+ a->setIcon(IconManager::self()->iconForUrl(SearchEngine::buildQuery(defaultEngine, "")));
a->setData(defaultEngine->entryPath());
connect(a, SIGNAL(triggered(bool)), this, SLOT(search()));
menu.addAction(a);
@@ -378,14 +367,14 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
Q_FOREACH(const KService::Ptr & engine, SearchEngine::favorites())
{
a = new KAction(i18nc("@item:inmenu Search, %1 = search engine", "With %1", engine->name()), this);
- a->setIcon(rApp->iconManager()->iconForUrl(SearchEngine::buildQuery(engine, "")));
+ a->setIcon(IconManager::self()->iconForUrl(SearchEngine::buildQuery(engine, "")));
a->setData(engine->entryPath());
connect(a, SIGNAL(triggered(bool)), this, SLOT(search()));
searchMenu->addAction(a);
}
a = new KAction(KIcon("edit-find"), i18n("On Current Page"), this);
- connect(a, SIGNAL(triggered()), rApp->mainWindow(), SLOT(findSelectedText()));
+ connect(a, SIGNAL(triggered()), webwin, SLOT(findSelectedText()));
searchMenu->addAction(a);
if (!searchMenu->menu()->isEmpty())
@@ -405,7 +394,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
}
else
{
- a = mainwindow->actionByName(KStandardAction::name(KStandardAction::AddBookmark));
+ a = webwin->actionByName(KStandardAction::name(KStandardAction::AddBookmark));
menu.addAction(a);
}
menu.addAction(sendByMailAction);
@@ -463,18 +452,18 @@ void WebView::mousePressEvent(QMouseEvent *event)
case 1: // Load Clipboard URL
if (weCanDoMiddleClickActions)
{
- const QString clipboardContent = rApp->clipboard()->text();
+ const QString clipboardContent = QApplication::clipboard()->text();
if (clipboardContent.isEmpty())
break;
if (QUrl::fromUserInput(clipboardContent).isValid())
- loadUrl(clipboardContent, Rekonq::CurrentTab);
+ load(KUrl(clipboardContent));
else // Search with default Engine
{
KService::Ptr defaultEngine = SearchEngine::defaultEngine();
if (defaultEngine) // check if a default engine is set
- loadUrl(KUrl(SearchEngine::buildQuery(defaultEngine, clipboardContent)), Rekonq::CurrentTab);
+ load(KUrl(SearchEngine::buildQuery(defaultEngine, clipboardContent)));
}
}
break;
@@ -507,18 +496,20 @@ void WebView::mouseMoveEvent(QMouseEvent *event)
return;
}
- MainWindow *w = rApp->mainWindow();
- if (w->isFullScreen())
+ WebTab *tab = qobject_cast<WebTab *>(parent());
+ WebWindow *webwin = tab->webWindow();
+ if (webwin->isFullScreen())
{
- if (event->pos().y() >= 0 && event->pos().y() <= 4)
- {
- w->setWidgetsVisible(true);
- }
- else
- {
- if (!w->mainView()->currentUrlBar()->hasFocus())
- w->setWidgetsVisible(false);
- }
+ // FIXME
+// if (event->pos().y() >= 0 && event->pos().y() <= 4)
+// {
+// webwin->setWidgetsVisible(true);
+// }
+// else
+// {
+// if (!webwin->urlBar()->hasFocus())
+// webwin->setWidgetsVisible(false);
+// }
}
KWebView::mouseMoveEvent(event);
}
@@ -530,14 +521,14 @@ void WebView::dropEvent(QDropEvent *event)
if (event->mimeData()->hasFormat(BookmarkManager::bookmark_mime_type()))
{
QByteArray addresses = event->mimeData()->data(BookmarkManager::bookmark_mime_type());
- KBookmark bookmark = rApp->bookmarkManager()->findByAddress(QString::fromLatin1(addresses.data()));
+ KBookmark bookmark = BookmarkManager::self()->findByAddress(QString::fromLatin1(addresses.data()));
if (bookmark.isGroup())
{
- rApp->bookmarkManager()->openFolderinTabs(bookmark.toGroup());
+ BookmarkManager::self()->openFolderinTabs(bookmark.toGroup());
}
else
{
- emit loadUrl(bookmark.url(), Rekonq::CurrentTab);
+ load(bookmark.url());
}
}
else if (event->mimeData()->hasUrls() && event->source() != this && !isEditable) //dropped links
@@ -588,12 +579,6 @@ void WebView::search()
}
-void WebView::printFrame()
-{
- rApp->mainWindow()->printRequested(page()->currentFrame());
-}
-
-
void WebView::viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
{
KAction *a = qobject_cast<KAction*>(sender());
@@ -605,7 +590,7 @@ void WebView::viewImage(Qt::MouseButtons buttons, Qt::KeyboardModifiers modifier
}
else
{
- emit loadUrl(url, Rekonq::CurrentTab);
+ load(url);
}
}
@@ -651,8 +636,8 @@ void WebView::bookmarkLink()
KAction *a = qobject_cast<KAction*>(sender());
KUrl url(a->data().toUrl());
- rApp->bookmarkManager()->rootGroup().addBookmark(url.prettyUrl(), url);
- rApp->bookmarkManager()->emitChanged();
+ BookmarkManager::self()->rootGroup().addBookmark(url.prettyUrl(), url);
+ BookmarkManager::self()->emitChanged();
}
@@ -912,7 +897,9 @@ void WebView::wheelEvent(QWheelEvent *event)
void WebView::inspect()
{
- QAction *a = rApp->mainWindow()->actionByName("web_inspector");
+ WebTab *tab = qobject_cast<WebTab *>(parent());
+ WebWindow *webwin = tab->webWindow();
+ QAction *a = webwin->actionByName("web_inspector");
if (a && !a->isChecked())
a->trigger();
pageAction(QWebPage::InspectElement)->trigger();
@@ -1181,9 +1168,9 @@ bool WebView::checkForAccessKey(QKeyEvent *event)
}
while (frame && frame != page()->mainFrame());
QMouseEvent pevent(QEvent::MouseButtonPress, p, Qt::LeftButton, 0, 0);
- rApp->sendEvent(this, &pevent);
+ QApplication::sendEvent(this, &pevent);
QMouseEvent revent(QEvent::MouseButtonRelease, p, Qt::LeftButton, 0, 0);
- rApp->sendEvent(this, &revent);
+ QApplication::sendEvent(this, &revent);
handled = true;
}
@@ -1226,7 +1213,7 @@ void WebView::blockImage()
return;
QString imageUrl = action->data().toString();
- rApp->adblockManager()->addCustomRule(imageUrl);
+ AdBlockManager::self()->addCustomRule(imageUrl);
}
diff --git a/src/webtab/webview.h b/src/webtab/webview.h
index 0141925c..f4fbfd28 100644
--- a/src/webtab/webview.h
+++ b/src/webtab/webview.h
@@ -92,8 +92,6 @@ protected:
private Q_SLOTS:
void search();
- void printFrame();
-
void openLinkInNewWindow();
void openLinkInNewTab();
void bookmarkLink();
@@ -109,7 +107,6 @@ private Q_SLOTS:
void setupSmoothScrolling(int posY);
void stopSmoothScrolling();
- void changeWindowIcon();
void accessKeyShortcut();
void hideAccessKeys();
@@ -121,6 +118,7 @@ private Q_SLOTS:
Q_SIGNALS:
void loadUrl(const KUrl &, const Rekonq::OpenType &);
+
void zoomChanged(int);
void openPreviousInHistory();
void openNextInHistory();
diff --git a/src/webwindow/webwindow.h b/src/webwindow/webwindow.h
index 8e51dcda..bc445afe 100644
--- a/src/webwindow/webwindow.h
+++ b/src/webwindow/webwindow.h
@@ -31,8 +31,12 @@
// Rekonq Includes
#include "rekonq_defines.h"
+// KDE Includes
+// #include <KActionCollection>
+
// Qt Includes
#include <QWidget>
+#include <QAction>
// Forward Declarations
class WebPage;
@@ -63,6 +67,12 @@ public:
bool isLoading();
+ inline QAction *actionByName(const QString &name)
+ {
+ return new QAction(this);
+// FIXME return actionCollection()->action(name);
+ }
+
private:
void init();