From 505c7b43e2b1e831a99d23a6d12ce649782064ea Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 22 May 2009 15:09:02 +0200 Subject: Fixing CMakeLists to find webkitkde --- CMakeLists.txt | 49 ++++++++++++++++++++++++++++++++++++++++++++----- src/main.cpp | 2 +- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de3f8109..5924fbb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ PROJECT( rekonq ) # rekonq info SET(REKONQ_MAJOR_VERSION "0") SET(REKONQ_MINOR_VERSION "1") -SET(REKONQ_PATCH_VERSION "0") +SET(REKONQ_PATCH_VERSION "1") SET(REKONQ_VERSION_STR "${REKONQ_MAJOR_VERSION}.${REKONQ_MINOR_VERSION}.${REKONQ_PATCH_VERSION}" @@ -30,6 +30,8 @@ FIND_PACKAGE(Qt4 REQUIRED) SET(KDE_MIN_VERSION 4.2.0) FIND_PACKAGE(KDE4 REQUIRED) +FIND_PACKAGE(KdeWebKit REQUIRED) + INCLUDE(MacroOptionalFindPackage) INCLUDE(FindPackageHandleStandardArgs) INCLUDE(KDE4Defaults) @@ -44,6 +46,7 @@ MESSAGE(STATUS " rekonq ${REKONQ_VERSION_STR} dependencies results <${REKONQ_SI # Require shared libraries results. +# ----------------- Qt SET(QT_VERS_STR "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}" ) @@ -62,15 +65,51 @@ ENDIF(QT_FOUND) MESSAGE(STATUS "----------------------------------------------------------------------------------") MESSAGE(STATUS "") -# Optional plugins results. -IF(QT_FOUND) +# -------------- KDE +SET(KDE_VERS_STR + "${KDE_VERSION_MAJOR}.${KDE_VERSION_MINOR}.${KDE_VERSION_PATCH}" + ) + +IF(KDE4_FOUND) + MESSAGE(STATUS " KDE Desktop Environment............... YES") + MESSAGE(STATUS " KDE version ${KDE_VERS_STR} found! ") +ELSE(KDE4_FOUND) + MESSAGE(STATUS " KDE Desktop Environment............... NO") + MESSAGE(STATUS "") + MESSAGE(SEND_ERROR " rekonq needs at least KDE ${KDE_MIN_VERSION}. Please install it and try compiling again.") + MESSAGE(STATUS " KDE website is at http://www.kde.org") + MESSAGE(STATUS "") +ENDIF(KDE4_FOUND) + +MESSAGE(STATUS "----------------------------------------------------------------------------------") +MESSAGE(STATUS "") + + +# ---------------- KdeWebkit +IF(KDEWEBKIT_FOUND) + MESSAGE(STATUS " KDE Webkit library found............... YES") +ELSE(KDEWEBKIT_FOUND) + MESSAGE(STATUS " KDE Webkit library found............... NO") + MESSAGE(STATUS "") + MESSAGE(SEND_ERROR " rekonq needs, from version 0.2, KDEWEBKIT to be compiled. Please install it and try compiling again.") + MESSAGE(STATUS " You can actually retrieve it from playground/libs/webkitkde KDE svn") + MESSAGE(STATUS "") +ENDIF(KDEWEBKIT_FOUND) + +MESSAGE(STATUS "----------------------------------------------------------------------------------") +MESSAGE(STATUS "") + + +##### FINAL RESULTS ##### + +IF(QT_FOUND AND KDE_FOUND AND KDEWEBKIT_FOUND) MESSAGE(STATUS " rekonq will be compiled....... YES") SET(REKONQ_CAN_BE_COMPILED true) -ELSE(QT_FOUND) +ELSE(QT_FOUND AND KDE_FOUND AND KDEWEBKIT_FOUND) MESSAGE(FATAL_ERROR " rekonq will NOT be compiled!") SET(REKONQ_CAN_BE_COMPILED false) -ENDIF(QT_FOUND) +ENDIF(QT_FOUND AND KDE_FOUND AND KDEWEBKIT_FOUND) MESSAGE(STATUS "----------------------------------------------------------------------------------") MESSAGE(STATUS "") diff --git a/src/main.cpp b/src/main.cpp index 600961c5..38c30b53 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,7 +29,7 @@ static const char description[] = I18N_NOOP("Webkit Based Browser for KDE"); -static const char version[] = "0.1"; +static const char version[] = "0.1.1"; int main(int argc, char **argv) -- cgit v1.2.1 From f0fd61b5e50c3495acd977d594c5507ffdd5fbd9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 22 May 2009 15:14:03 +0200 Subject: CMakeLists.. --- CMakeLists.txt | 7 ++++--- src/CMakeLists.txt | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5924fbb8..393910cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,13 +103,13 @@ MESSAGE(STATUS "") ##### FINAL RESULTS ##### -IF(QT_FOUND AND KDE_FOUND AND KDEWEBKIT_FOUND) +IF(QT_FOUND AND KDE4_FOUND AND KDEWEBKIT_FOUND) MESSAGE(STATUS " rekonq will be compiled....... YES") SET(REKONQ_CAN_BE_COMPILED true) -ELSE(QT_FOUND AND KDE_FOUND AND KDEWEBKIT_FOUND) +ELSE(QT_FOUND AND KDE4_FOUND AND KDEWEBKIT_FOUND) MESSAGE(FATAL_ERROR " rekonq will NOT be compiled!") SET(REKONQ_CAN_BE_COMPILED false) -ENDIF(QT_FOUND AND KDE_FOUND AND KDEWEBKIT_FOUND) +ENDIF(QT_FOUND AND KDE4_FOUND AND KDEWEBKIT_FOUND) MESSAGE(STATUS "----------------------------------------------------------------------------------") MESSAGE(STATUS "") @@ -129,6 +129,7 @@ IF(REKONQ_CAN_BE_COMPILED) ADD_SUBDIRECTORY( src ) ADD_SUBDIRECTORY( icons ) ADD_SUBDIRECTORY( data ) +# ADD_SUBDIRECTORY( i18n ) # ADD_SUBDIRECTORY( doc ) ENDIF(REKONQ_CAN_BE_COMPILED) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a64cc747..dd7414a5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,18 +41,19 @@ KDE4_ADD_KCFG_FILES( rekonq_SRCS rekonq.kcfgc ) ### ------------------------------------------ -ADD_DEFINITIONS( ${KDE4_DEFINITIONS} ) +ADD_DEFINITIONS( ${KDE4_DEFINITIONS} ${KDEWEBKIT_DEFINITIONS} ) KDE4_ADD_EXECUTABLE( rekonq ${rekonq_SRCS} ) TARGET_LINK_LIBRARIES( rekonq ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARY} - ${QT_QTWEBKIT_LIBRARY} +# ${QT_QTWEBKIT_LIBRARY} ${QT_QTUITOOLS_LIBRARY} ${KDE4_KUTILS_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} + ${KDEWEBKIT_LIBRARIES} ) INSTALL( TARGETS rekonq ${INSTALL_TARGETS_DEFAULT_ARGS} ) -- cgit v1.2.1 From d361249be9ec31d575713739f032394383052705 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 22 May 2009 15:42:00 +0200 Subject: Compiles && link with webkitKDE modulo the load method --- src/CMakeLists.txt | 5 +++++ src/mainview.cpp | 2 +- src/webview.cpp | 13 ++++++++----- src/webview.h | 10 ++++++---- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dd7414a5..7fba4466 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,6 +41,11 @@ KDE4_ADD_KCFG_FILES( rekonq_SRCS rekonq.kcfgc ) ### ------------------------------------------ +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${KDEWEBKIT_INCLUDE_DIR} + ) + ADD_DEFINITIONS( ${KDE4_DEFINITIONS} ${KDEWEBKIT_DEFINITIONS} ) KDE4_ADD_EXECUTABLE( rekonq ${rekonq_SRCS} ) diff --git a/src/mainview.cpp b/src/mainview.cpp index 8f3bf197..8f35fdd8 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -658,7 +658,7 @@ void MainView::loadUrl(const KUrl &url) if (webView) { - webView->load(loadingUrl); +// webView->load(loadingUrl,0L,0L); FIXME NOW!! webView->setFocus(); } } diff --git a/src/webview.cpp b/src/webview.cpp index 01fd0d00..1e713f5a 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -44,6 +44,9 @@ #include #include +#include +#include + // Qt Includes #include #include @@ -64,7 +67,7 @@ WebPage::WebPage(QObject *parent) - : QWebPage(parent) + : KWebPage(parent) , m_keyboardModifiers(Qt::NoModifier) , m_pressedButtons(Qt::NoButton) { @@ -151,7 +154,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r { webView = Application::instance()->newWebView(); webView->setFocus(); - webView->load(request); +// webView->load(request); FIXME NOW!! m_keyboardModifiers = Qt::NoModifier; m_pressedButtons = Qt::NoButton; return false; @@ -169,7 +172,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r { webView = Application::instance()->newWebView(); webView->setFocus(); - webView->load(request); +// webView->load(request); FIXME NOW!! return false; } } @@ -178,7 +181,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r } -QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) +KWebPage *WebPage::createWindow(QWebPage::WebWindowType type) { kDebug() << "creating window as new tab.. "; @@ -291,7 +294,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) WebView::WebView(QWidget* parent) - : QWebView(parent) + : KWebView(parent) , m_page(new WebPage(this)) , m_progress(0) { diff --git a/src/webview.h b/src/webview.h index eba02505..6cddf77f 100644 --- a/src/webview.h +++ b/src/webview.h @@ -27,6 +27,9 @@ // KDE Includes #include +#include +#include + // Qt Includes #include @@ -44,7 +47,7 @@ class QNetworkReply; class QSslError; -class WebPage : public QWebPage +class WebPage : public KWebPage { Q_OBJECT @@ -60,7 +63,7 @@ protected: const QNetworkRequest &request, NavigationType type); - QWebPage *createWindow(QWebPage::WebWindowType type); + KWebPage *createWindow(QWebPage::WebWindowType type); QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, @@ -85,7 +88,7 @@ private: #include -class WebView : public QWebView +class WebView : public KWebView { Q_OBJECT @@ -130,4 +133,3 @@ private: }; #endif - -- cgit v1.2.1 From b487c807711cfee057e522eda9f578c5e8a8d54f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 22 May 2009 16:07:36 +0200 Subject: Access Manager Porting. Compiles && links --- src/networkaccessmanager.cpp | 17 ++++++++++++++++- src/networkaccessmanager.h | 14 +++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 6f0e2a3e..3fe42cbb 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -40,6 +40,7 @@ // Qt Includes #include +#include #include #include @@ -48,11 +49,12 @@ #include #include #include +#include #include NetworkAccessManager::NetworkAccessManager(QObject *parent) - : QNetworkAccessManager(parent) + : AccessManager(parent) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), SLOT(authenticationRequired(QNetworkReply*, QAuthenticator*))); @@ -73,6 +75,19 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) } +NetworkAccessManager::~NetworkAccessManager() +{ +// FIXME: implement me!! +} + + +QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData) +{ +// FIXME: implement me!! + return put(req,outgoingData); +} + + void NetworkAccessManager::loadSettings() { QNetworkProxy proxy; diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h index 7da2f54f..a61a3483 100644 --- a/src/networkaccessmanager.h +++ b/src/networkaccessmanager.h @@ -22,20 +22,28 @@ #ifndef NETWORKACCESSMANAGER_H #define NETWORKACCESSMANAGER_H -// Qt Includes -#include +// KDE Includes +#include +class QNetworkRequest; +class QIODevice; -class NetworkAccessManager : public QNetworkAccessManager +using namespace KIO; + +class NetworkAccessManager : public AccessManager { Q_OBJECT public: NetworkAccessManager(QObject *parent = 0); + ~NetworkAccessManager(); public slots: void loadSettings(); +protected: + QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData = 0); + private slots: void authenticationRequired(QNetworkReply *reply, QAuthenticator *auth); void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); -- cgit v1.2.1 From 2e66b40db71b99220754c126a8e4e3606c3505f2 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 23 May 2009 01:22:31 +0200 Subject: Fixing new AccessManager. Removed webpage createPlugin slot --- src/CMakeLists.txt | 2 +- src/networkaccessmanager.cpp | 13 ------------- src/networkaccessmanager.h | 6 ++---- src/webview.cpp | 20 +------------------- src/webview.h | 6 +----- 5 files changed, 5 insertions(+), 42 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7fba4466..615a68e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,7 +54,7 @@ TARGET_LINK_LIBRARIES( rekonq ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARY} # ${QT_QTWEBKIT_LIBRARY} - ${QT_QTUITOOLS_LIBRARY} +# ${QT_QTUITOOLS_LIBRARY} ${KDE4_KUTILS_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 3fe42cbb..2c42f5d2 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -75,19 +75,6 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) } -NetworkAccessManager::~NetworkAccessManager() -{ -// FIXME: implement me!! -} - - -QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData) -{ -// FIXME: implement me!! - return put(req,outgoingData); -} - - void NetworkAccessManager::loadSettings() { QNetworkProxy proxy; diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h index a61a3483..ae356743 100644 --- a/src/networkaccessmanager.h +++ b/src/networkaccessmanager.h @@ -36,20 +36,18 @@ class NetworkAccessManager : public AccessManager public: NetworkAccessManager(QObject *parent = 0); - ~NetworkAccessManager(); public slots: void loadSettings(); -protected: - QNetworkReply *createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData = 0); - private slots: void authenticationRequired(QNetworkReply *reply, QAuthenticator *auth); void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); + #ifndef QT_NO_OPENSSL void sslErrors(QNetworkReply *reply, const QList &error); #endif + }; #endif // NETWORKACCESSMANAGER_H diff --git a/src/webview.cpp b/src/webview.cpp index 1e713f5a..6887c29b 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -63,7 +63,7 @@ #include #include -#include +// #include WebPage::WebPage(QObject *parent) @@ -78,11 +78,6 @@ WebPage::WebPage(QObject *parent) } -WebPage::~WebPage() -{ -} - - bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { QString scheme = request.url().scheme(); @@ -197,19 +192,6 @@ KWebPage *WebPage::createWindow(QWebPage::WebWindowType type) } -QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) -{ - kDebug() << "creating PLUGIN for rekonq "; - kDebug() << "classId = " << classId; - kDebug() << "url = " << url; - kDebug() << "Param Names = " << paramNames; - kDebug() << "Param Values = " << paramValues; - - QUiLoader loader; - return loader.createWidget(classId, view()); -} - - void WebPage::handleUnsupportedContent(QNetworkReply *reply) { // create convenience fake api:// protocol for KDE apidox search and Qt docs diff --git a/src/webview.h b/src/webview.h index 6cddf77f..eff5f98b 100644 --- a/src/webview.h +++ b/src/webview.h @@ -56,7 +56,7 @@ signals: public: WebPage(QObject *parent = 0); - ~WebPage(); + protected: bool acceptNavigationRequest(QWebFrame *frame, @@ -64,10 +64,6 @@ protected: NavigationType type); KWebPage *createWindow(QWebPage::WebWindowType type); - QObject *createPlugin(const QString &classId, - const QUrl &url, - const QStringList ¶mNames, - const QStringList ¶mValues); private slots: void handleUnsupportedContent(QNetworkReply *reply); -- cgit v1.2.1 From e6752ba908497ae0c3756315b75509efb2fdbf26 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 23 May 2009 01:28:39 +0200 Subject: splitted web classes --- src/CMakeLists.txt | 1 + src/mainview.h | 1 + src/webpage.cpp | 270 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/webpage.h | 80 ++++++++++++++++ src/webview.cpp | 212 +---------------------------------------- src/webview.h | 35 +------ 6 files changed, 354 insertions(+), 245 deletions(-) create mode 100644 src/webpage.cpp create mode 100644 src/webpage.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 615a68e5..cbb1421d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,6 +22,7 @@ SET( rekonq_SRCS panelhistory.cpp lineedit.cpp stackedurlbar.cpp + webpage.cpp ) KDE4_ADD_UI_FILES( rekonq_SRCS diff --git a/src/mainview.h b/src/mainview.h index 16d450d3..ceb8d1bf 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -26,6 +26,7 @@ // Local Includes #include "webview.h" +#include "webpage.h" #include "application.h" // KDE Includes diff --git a/src/webpage.cpp b/src/webpage.cpp new file mode 100644 index 00000000..5fae4be3 --- /dev/null +++ b/src/webpage.cpp @@ -0,0 +1,270 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2008 Benjamin C. Meyer +* Copyright (C) 2009 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 published by the Free Software Foundation; +* either version 2, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* ============================================================ */ + + +// Self Includes +#include "webpage.h" +#include "webpage.moc" + +// Auto Includes +#include "rekonq.h" + +// Local Includes +#include "application.h" +#include "mainwindow.h" +#include "mainview.h" +#include "cookiejar.h" +#include "networkaccessmanager.h" +#include "download.h" +#include "history.h" + +// KDE Includes +#include +#include +#include +#include +#include + +#include +#include + +// Qt Includes +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +// #include + + +WebPage::WebPage(QObject *parent) + : KWebPage(parent) + , m_keyboardModifiers(Qt::NoModifier) + , m_pressedButtons(Qt::NoButton) +{ + setNetworkAccessManager(Application::networkAccessManager()); + + setForwardUnsupportedContent(true); + connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *))); +} + + +bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) +{ + QString scheme = request.url().scheme(); + if (scheme == QLatin1String("mailto")) + { + KToolInvocation::invokeMailer(request.url()); + return false; + } + + WebView *webView; + + switch (type) + { + // user activated a submit button for an HTML form. + case QWebPage::NavigationTypeFormSubmitted: + kDebug() << "NavigationTypeFormSubmitted"; + kDebug() << request.url(); + break; + + // An HTML form was submitted a second time. + case QWebPage::NavigationTypeFormResubmitted: + kDebug() << "NavigationTypeFormResubmitted"; + break; + + // A navigation to another document using a method not listed above. + case QWebPage::NavigationTypeOther: + kDebug() << "NavigationTypeOther"; + break; + + // user clicked on a link or pressed return on a focused link. + case QWebPage::NavigationTypeLinkClicked: + kDebug() << "NavigationTypeLinkClicked"; + break; + + // Navigation to a previously shown document in the back or forward history is requested. + case QWebPage::NavigationTypeBackOrForward: + kDebug() << "NavigationTypeBackOrForward"; + break; + + // user activated the reload action. + case QWebPage::NavigationTypeReload: + kDebug() << "NavigationTypeReload"; + +#if QT_VERSION <= 040500 + // HACK Ported from Arora + // A short term hack until QtWebKit can get a reload without cache QAction + // *FYI* currently type is never NavigationTypeReload + // See: https://bugs.webkit.org/show_bug.cgi?id=24283 + if (qApp->keyboardModifiers() & Qt::ShiftModifier) + { + kDebug() << "Arora hack"; + QNetworkRequest newRequest(request); + newRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, + QNetworkRequest::AlwaysNetwork); + mainFrame()->load(request); + return false; + } +#endif + + break; + + // should be nothing.. + default: + kDebug() << "Default NON extant case.."; + break; + } + + if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) + { + webView = Application::instance()->newWebView(); + webView->setFocus(); +// webView->load(request); FIXME NOW!! + m_keyboardModifiers = Qt::NoModifier; + m_pressedButtons = Qt::NoButton; + return false; + } + + if (frame == mainFrame()) + { + m_loadingUrl = request.url(); + emit loadingUrl(m_loadingUrl); + } + else + { + // if frame doesn't exists (perhaps) we are pointing to a blank target.. + if (!frame) + { + webView = Application::instance()->newWebView(); + webView->setFocus(); +// webView->load(request); FIXME NOW!! + return false; + } + } + + return QWebPage::acceptNavigationRequest(frame, request, type); +} + + +KWebPage *WebPage::createWindow(QWebPage::WebWindowType type) +{ + kDebug() << "creating window as new tab.. "; + + // added to manage web modal dialogs + if (type == QWebPage::WebModalDialog) + { + // FIXME : need a "real" implementation.. + kDebug() << "Modal Dialog ---------------------------------------"; + } + + WebView *w = Application::instance()->newWebView(); + return w->page(); +} + + +void WebPage::handleUnsupportedContent(QNetworkReply *reply) +{ + // create convenience fake api:// protocol for KDE apidox search and Qt docs + if (reply->url().scheme() == "api") + { + QString path; + QString className = reply->url().host().toLower(); + if (className[0] == 'k') + { + path = QString("http://api.kde.org/new.classmapper.php?class=%1").arg(className); + } + else if (className[0] == 'q') + { + path = QString("http://doc.trolltech.com/4.5/%1.html").arg(className); + } + KUrl url(path); + + Application::instance()->mainWindow()->loadUrl(url); + return; + } + + if (reply->error() == QNetworkReply::NoError) + { + // st iframe unwanted download fix + if (reply->header(QNetworkRequest::ContentTypeHeader).isValid()) + { + KUrl srcUrl = reply->url(); + Application::downloadManager()->newDownload(srcUrl); + } + else + { + kDebug() << "invalid content type header"; + } + return; + } + + // display "not found" page + QString notfoundFilePath = KStandardDirs::locate("data", "rekonq/htmls/notfound.html"); + QFile file(notfoundFilePath); + bool isOpened = file.open(QIODevice::ReadOnly); + if (!isOpened) + { + kWarning() << "Couldn't open the notfound.html file"; + return; + } + QString title = i18n("Error loading page: ") + reply->url().toString(); + + QString imagePath = KIconLoader::global()->iconPath("rekonq", KIconLoader::NoGroup, false); + + QString html = QString(QLatin1String(file.readAll())) + .arg(title) + .arg("file://" + imagePath) + .arg(reply->errorString()) + .arg(reply->url().toString()); + + QList frames; + frames.append(mainFrame()); + while (!frames.isEmpty()) + { + QWebFrame *firstFrame = frames.takeFirst(); + if (firstFrame->url() == reply->url()) + { + firstFrame->setHtml(html, reply->url()); + return; + } + QList children = firstFrame->childFrames(); + foreach(QWebFrame *frame, children) + { + frames.append(frame); + } + } + if (m_loadingUrl == reply->url()) + { + mainFrame()->setHtml(html, reply->url()); + // Don't put error pages to the history. + Application::historyManager()->removeHistoryEntry(reply->url(), mainFrame()->title()); + } +} diff --git a/src/webpage.h b/src/webpage.h new file mode 100644 index 00000000..cdb1d04f --- /dev/null +++ b/src/webpage.h @@ -0,0 +1,80 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved +* Copyright (C) 2008 Benjamin C. Meyer +* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2009 by Paweł Prażak +* +* +* This program is free software; you can redistribute it +* and/or modify it under the terms of the GNU General +* Public License as published by the Free Software Foundation; +* either version 2, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* ============================================================ */ + + +#ifndef WEBPAGE_H +#define WEBPAGE_H + +// KDE Includes +#include + +#include +#include + +// Qt Includes +#include + +// Forward Declarations +class MainWindow; +class Application; + +class KActionCollection; + +class QWebFrame; +class QAuthenticator; +class QMouseEvent; +class QNetworkProxy; +class QNetworkReply; +class QSslError; + + +class WebPage : public KWebPage +{ + Q_OBJECT + +signals: + void loadingUrl(const QUrl &url); // WARNING has to be QUrl!! + +public: + WebPage(QObject *parent = 0); + + +protected: + bool acceptNavigationRequest(QWebFrame *frame, + const QNetworkRequest &request, + NavigationType type); + + KWebPage *createWindow(QWebPage::WebWindowType type); + +private slots: + void handleUnsupportedContent(QNetworkReply *reply); + +private: + friend class WebView; + + // set the webview mousepressedevent + Qt::KeyboardModifiers m_keyboardModifiers; + Qt::MouseButtons m_pressedButtons; + KUrl m_loadingUrl; +}; + +#endif diff --git a/src/webview.cpp b/src/webview.cpp index 6887c29b..2f9e794e 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -36,6 +36,7 @@ #include "networkaccessmanager.h" #include "download.h" #include "history.h" +#include "webpage.h" // KDE Includes #include @@ -63,217 +64,6 @@ #include #include -// #include - - -WebPage::WebPage(QObject *parent) - : KWebPage(parent) - , m_keyboardModifiers(Qt::NoModifier) - , m_pressedButtons(Qt::NoButton) -{ - setNetworkAccessManager(Application::networkAccessManager()); - - setForwardUnsupportedContent(true); - connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *))); -} - - -bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) -{ - QString scheme = request.url().scheme(); - if (scheme == QLatin1String("mailto")) - { - KToolInvocation::invokeMailer(request.url()); - return false; - } - - WebView *webView; - - switch (type) - { - // user activated a submit button for an HTML form. - case QWebPage::NavigationTypeFormSubmitted: - kDebug() << "NavigationTypeFormSubmitted"; - kDebug() << request.url(); - break; - - // An HTML form was submitted a second time. - case QWebPage::NavigationTypeFormResubmitted: - kDebug() << "NavigationTypeFormResubmitted"; - break; - - // A navigation to another document using a method not listed above. - case QWebPage::NavigationTypeOther: - kDebug() << "NavigationTypeOther"; - break; - - // user clicked on a link or pressed return on a focused link. - case QWebPage::NavigationTypeLinkClicked: - kDebug() << "NavigationTypeLinkClicked"; - break; - - // Navigation to a previously shown document in the back or forward history is requested. - case QWebPage::NavigationTypeBackOrForward: - kDebug() << "NavigationTypeBackOrForward"; - break; - - // user activated the reload action. - case QWebPage::NavigationTypeReload: - kDebug() << "NavigationTypeReload"; - -#if QT_VERSION <= 040500 - // HACK Ported from Arora - // A short term hack until QtWebKit can get a reload without cache QAction - // *FYI* currently type is never NavigationTypeReload - // See: https://bugs.webkit.org/show_bug.cgi?id=24283 - if (qApp->keyboardModifiers() & Qt::ShiftModifier) - { - kDebug() << "Arora hack"; - QNetworkRequest newRequest(request); - newRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, - QNetworkRequest::AlwaysNetwork); - mainFrame()->load(request); - return false; - } -#endif - - break; - - // should be nothing.. - default: - kDebug() << "Default NON extant case.."; - break; - } - - if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) - { - webView = Application::instance()->newWebView(); - webView->setFocus(); -// webView->load(request); FIXME NOW!! - m_keyboardModifiers = Qt::NoModifier; - m_pressedButtons = Qt::NoButton; - return false; - } - - if (frame == mainFrame()) - { - m_loadingUrl = request.url(); - emit loadingUrl(m_loadingUrl); - } - else - { - // if frame doesn't exists (perhaps) we are pointing to a blank target.. - if (!frame) - { - webView = Application::instance()->newWebView(); - webView->setFocus(); -// webView->load(request); FIXME NOW!! - return false; - } - } - - return QWebPage::acceptNavigationRequest(frame, request, type); -} - - -KWebPage *WebPage::createWindow(QWebPage::WebWindowType type) -{ - kDebug() << "creating window as new tab.. "; - - // added to manage web modal dialogs - if (type == QWebPage::WebModalDialog) - { - // FIXME : need a "real" implementation.. - kDebug() << "Modal Dialog ---------------------------------------"; - } - - WebView *w = Application::instance()->newWebView(); - return w->page(); -} - - -void WebPage::handleUnsupportedContent(QNetworkReply *reply) -{ - // create convenience fake api:// protocol for KDE apidox search and Qt docs - if (reply->url().scheme() == "api") - { - QString path; - QString className = reply->url().host().toLower(); - if (className[0] == 'k') - { - path = QString("http://api.kde.org/new.classmapper.php?class=%1").arg(className); - } - else if (className[0] == 'q') - { - path = QString("http://doc.trolltech.com/4.5/%1.html").arg(className); - } - KUrl url(path); - - Application::instance()->mainWindow()->loadUrl(url); - return; - } - - if (reply->error() == QNetworkReply::NoError) - { - // st iframe unwanted download fix - if (reply->header(QNetworkRequest::ContentTypeHeader).isValid()) - { - KUrl srcUrl = reply->url(); - Application::downloadManager()->newDownload(srcUrl); - } - else - { - kDebug() << "invalid content type header"; - } - return; - } - - // display "not found" page - QString notfoundFilePath = KStandardDirs::locate("data", "rekonq/htmls/notfound.html"); - QFile file(notfoundFilePath); - bool isOpened = file.open(QIODevice::ReadOnly); - if (!isOpened) - { - kWarning() << "Couldn't open the notfound.html file"; - return; - } - QString title = i18n("Error loading page: ") + reply->url().toString(); - - QString imagePath = KIconLoader::global()->iconPath("rekonq", KIconLoader::NoGroup, false); - - QString html = QString(QLatin1String(file.readAll())) - .arg(title) - .arg("file://" + imagePath) - .arg(reply->errorString()) - .arg(reply->url().toString()); - - QList frames; - frames.append(mainFrame()); - while (!frames.isEmpty()) - { - QWebFrame *firstFrame = frames.takeFirst(); - if (firstFrame->url() == reply->url()) - { - firstFrame->setHtml(html, reply->url()); - return; - } - QList children = firstFrame->childFrames(); - foreach(QWebFrame *frame, children) - { - frames.append(frame); - } - } - if (m_loadingUrl == reply->url()) - { - mainFrame()->setHtml(html, reply->url()); - // Don't put error pages to the history. - Application::historyManager()->removeHistoryEntry(reply->url(), mainFrame()->title()); - } -} - - -// ----------------------------------------------------------------------------------------------------------------- - WebView::WebView(QWidget* parent) : KWebView(parent) diff --git a/src/webview.h b/src/webview.h index eff5f98b..cef46a80 100644 --- a/src/webview.h +++ b/src/webview.h @@ -45,40 +45,7 @@ class QMouseEvent; class QNetworkProxy; class QNetworkReply; class QSslError; - - -class WebPage : public KWebPage -{ - Q_OBJECT - -signals: - void loadingUrl(const QUrl &url); // WARNING has to be QUrl!! - -public: - WebPage(QObject *parent = 0); - - -protected: - bool acceptNavigationRequest(QWebFrame *frame, - const QNetworkRequest &request, - NavigationType type); - - KWebPage *createWindow(QWebPage::WebWindowType type); - -private slots: - void handleUnsupportedContent(QNetworkReply *reply); - -private: - friend class WebView; - - // set the webview mousepressedevent - Qt::KeyboardModifiers m_keyboardModifiers; - Qt::MouseButtons m_pressedButtons; - KUrl m_loadingUrl; -}; - - -// ---------------------------------------------------------------------------------------------------- +class WebPage; // Qt Includes #include -- cgit v1.2.1 From ca917ecc5a7b3fc69fcb5682466c421d56627aec Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 23 May 2009 01:42:26 +0200 Subject: Initial kdewebkit porting. STEP 1 DONE --- src/mainview.cpp | 2 +- src/webpage.cpp | 4 ++-- src/webview.cpp | 6 ++++++ src/webview.h | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mainview.cpp b/src/mainview.cpp index 8f35fdd8..8f3bf197 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -658,7 +658,7 @@ void MainView::loadUrl(const KUrl &url) if (webView) { -// webView->load(loadingUrl,0L,0L); FIXME NOW!! + webView->load(loadingUrl); webView->setFocus(); } } diff --git a/src/webpage.cpp b/src/webpage.cpp index 5fae4be3..51a02771 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -147,7 +147,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r { webView = Application::instance()->newWebView(); webView->setFocus(); -// webView->load(request); FIXME NOW!! + webView->load(request.url()); m_keyboardModifiers = Qt::NoModifier; m_pressedButtons = Qt::NoButton; return false; @@ -165,7 +165,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r { webView = Application::instance()->newWebView(); webView->setFocus(); -// webView->load(request); FIXME NOW!! + webView->load(request.url()); return false; } } diff --git a/src/webview.cpp b/src/webview.cpp index 2f9e794e..a635adb7 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -80,6 +80,12 @@ WebView::WebView(QWidget* parent) } +void WebView::load(const KUrl &url) +{ + QWebView::load(url); +} + + void WebView::contextMenuEvent(QContextMenuEvent *event) { QWebHitTestResult result = page()->mainFrame()->hitTestContent(event->pos()); diff --git a/src/webview.h b/src/webview.h index cef46a80..d2dc2bad 100644 --- a/src/webview.h +++ b/src/webview.h @@ -64,6 +64,9 @@ public: QString lastStatusBarText() const { return m_statusBarText; } int progress() const { return m_progress; } +public Q_SLOTS: + void load(const KUrl &url); + signals: // switching tabs void ctrlTabPressed(); -- cgit v1.2.1 From fca022bc0c708f82871850eaab94839c37c2013f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 25 May 2009 00:05:16 +0200 Subject: no inline functions, as suggested --- src/bookmarks.cpp | 6 ++++++ src/bookmarks.h | 5 +---- src/mainview.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ src/mainview.h | 14 +++++++------- src/mainwindow.cpp | 6 ++++++ src/mainwindow.h | 5 +---- src/urlbar.cpp | 18 ++++++++++++++++++ src/urlbar.h | 16 +++------------- src/webview.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/webview.h | 13 ++++++------- 10 files changed, 127 insertions(+), 35 deletions(-) diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index eb500985..9490ed0f 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -66,6 +66,12 @@ void BookmarkOwner::openBookmark(const KBookmark & bookmark, } +bool BookmarkOwner::supportsTabs() const +{ + return true; +} + + QString BookmarkOwner::currentUrl() const { return Application::instance()->mainWindow()->currentTab()->url().url(); diff --git a/src/bookmarks.h b/src/bookmarks.h index fef91413..8b4cf8e5 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -93,10 +93,7 @@ public: /** * This function returns whether the owner supports tabs. */ - virtual bool supportsTabs() const - { - return true; - } + virtual bool supportsTabs() const; /** * Called if the user wants to open every bookmark in this folder in a new tab. diff --git a/src/mainview.cpp b/src/mainview.cpp index 8f3bf197..9ba711ed 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -108,6 +108,49 @@ void MainView::postLaunch() m_recentlyClosedTabsAction->setEnabled(false); } + +UrlBar *MainView::currentUrlBar() const +{ + return urlBar(-1); +} + + +TabBar *MainView::tabBar() const +{ + return m_tabBar; +} + + +StackedUrlBar *MainView::urlBarStack() const +{ + return m_urlBars; +} + + +WebView *MainView::currentWebView() const +{ + return webView(currentIndex()); +} + + +int MainView::webViewIndex(WebView *webView) const +{ + return indexOf(webView); +} + + +KAction *MainView::recentlyClosedTabsAction() const +{ + return m_recentlyClosedTabsAction; +} + + +void MainView::setMakeBackTab(bool b) +{ + m_makeBackTab = b; +} + + void MainView::showTabBar() { if (ReKonfig::alwaysShowTabBar()) diff --git a/src/mainview.h b/src/mainview.h index ceb8d1bf..435ccc40 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -66,17 +66,17 @@ public: public: UrlBar *urlBar(int index) const; - UrlBar *currentUrlBar() const { return urlBar(-1); } + UrlBar *currentUrlBar() const; WebView *webView(int index) const; QList tabs(); // ? // inlines - TabBar *tabBar() const { return m_tabBar; } - StackedUrlBar *urlBarStack() const { return m_urlBars; } - WebView *currentWebView() const { return webView(currentIndex()); } - int webViewIndex(WebView *webView) const { return indexOf(webView); } - KAction *recentlyClosedTabsAction() const { return m_recentlyClosedTabsAction; } - void setMakeBackTab(bool b) { m_makeBackTab = b; } + TabBar *tabBar() const; + StackedUrlBar *urlBarStack() const; + WebView *currentWebView() const; + int webViewIndex(WebView *webView) const; + KAction *recentlyClosedTabsAction() const; + void setMakeBackTab(bool b); /** * show and hide TabBar if user doesn't choose diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 83ff514b..39455d92 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -143,6 +143,12 @@ MainWindow::~MainWindow() } +SidePanel *MainWindow::sidePanel() +{ + return m_sidePanel; +} + + void MainWindow::postLaunch() { // setup history menu: this has to be done AFTER setupGUI!! diff --git a/src/mainwindow.h b/src/mainwindow.h index 61d8f27b..a4574612 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -73,10 +73,7 @@ private: void setupHistoryMenu(); void setupToolBars(); void setupSidePanel(); - SidePanel *sidePanel() - { - return m_sidePanel; - } + SidePanel *sidePanel(); public slots: void slotHome(); diff --git a/src/urlbar.cpp b/src/urlbar.cpp index e2756aa6..e1971ced 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -81,6 +81,24 @@ UrlBar::~UrlBar() } +void UrlBar::selectAll() const +{ + lineEdit()->selectAll(); +} + + +KUrl UrlBar::url() const +{ + return m_currentUrl; +} + + +KLineEdit *UrlBar::lineEdit() const +{ + return m_lineEdit; +} + + void UrlBar::setupLineEdit() { // Make m_lineEdit background transparent diff --git a/src/urlbar.h b/src/urlbar.h index d8fb9029..02d709bb 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -49,15 +49,8 @@ public: UrlBar(QWidget *parent = 0); ~UrlBar(); - void selectAll() const - { - lineEdit()->selectAll(); - } - KUrl url() const - { - return m_currentUrl; - } - + void selectAll() const; + KUrl url() const; QSize sizeHint() const; signals: @@ -80,10 +73,7 @@ protected: private: void setupLineEdit(); - KLineEdit *lineEdit() const - { - return m_lineEdit; - } + KLineEdit *lineEdit() const; static QLinearGradient generateGradient(const QColor &color, int height); diff --git a/src/webview.cpp b/src/webview.cpp index a635adb7..374a06a8 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -80,12 +80,48 @@ WebView::WebView(QWidget* parent) } +WebPage *WebView::webPage() const +{ + return m_page; +} + + +KUrl WebView::url() const +{ + return KUrl(QWebView::url()); +} + + +QString WebView::lastStatusBarText() const +{ + return m_statusBarText; +} + + +int WebView::progress() const +{ + return m_progress; +} + + void WebView::load(const KUrl &url) { QWebView::load(url); } +void WebView::setProgress(int progress) +{ + m_progress = progress; +} + + +void WebView::setStatusBarText(const QString &string) +{ + m_statusBarText = string; +} + + void WebView::contextMenuEvent(QContextMenuEvent *event) { QWebHitTestResult result = page()->mainFrame()->hitTestContent(event->pos()); diff --git a/src/webview.h b/src/webview.h index d2dc2bad..56693597 100644 --- a/src/webview.h +++ b/src/webview.h @@ -58,11 +58,10 @@ class WebView : public KWebView public: WebView(QWidget *parent = 0); - // inline - WebPage *webPage() const { return m_page; } - KUrl url() const { return KUrl(QWebView::url()); } - QString lastStatusBarText() const { return m_statusBarText; } - int progress() const { return m_progress; } + WebPage *webPage() const; + KUrl url() const; + QString lastStatusBarText() const; + int progress() const; public Q_SLOTS: void load(const KUrl &url); @@ -85,9 +84,9 @@ protected: void keyPressEvent(QKeyEvent *event); private slots: - void setProgress(int progress) { m_progress = progress; } + void setProgress(int progress); void loadFinished(); - void setStatusBarText(const QString &string) { m_statusBarText = string; } + void setStatusBarText(const QString &string); void downloadRequested(const QNetworkRequest &request); void openLinkInNewTab(); -- cgit v1.2.1 From 2ad17fa1cb5309172899cd8159d247071d6cd3e4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 25 May 2009 10:51:21 +0200 Subject: Refactored page/setNewPage KWebPage methods --- src/mainview.cpp | 32 ++++++++++---------------------- src/webview.cpp | 4 ++-- src/webview.h | 4 +++- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/mainview.cpp b/src/mainview.cpp index 9ba711ed..1b2d4769 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -58,9 +58,6 @@ #include #include -#include - - MainView::MainView(QWidget *parent) : KTabWidget(parent) @@ -179,8 +176,7 @@ void MainView::showTabBar() void MainView::slotWebReload() { WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Reload); + QAction *action = webView->page()->action(QWebPage::Reload); action->trigger(); } @@ -188,8 +184,7 @@ void MainView::slotWebReload() void MainView::slotWebStop() { WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Stop); + QAction *action = webView->page()->action(QWebPage::Stop); action->trigger(); } @@ -197,8 +192,7 @@ void MainView::slotWebStop() void MainView::slotWebBack() { WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Back); + QAction *action = webView->page()->action(QWebPage::Back); action->trigger(); } @@ -206,8 +200,7 @@ void MainView::slotWebBack() void MainView::slotWebForward() { WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Forward); + QAction *action = webView->page()->action(QWebPage::Forward); action->trigger(); } @@ -215,8 +208,7 @@ void MainView::slotWebForward() void MainView::slotWebUndo() { WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Undo); + QAction *action = webView->page()->action(QWebPage::Undo); action->trigger(); } @@ -224,8 +216,7 @@ void MainView::slotWebUndo() void MainView::slotWebRedo() { WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Redo); + QAction *action = webView->page()->action(QWebPage::Redo); action->trigger(); } @@ -233,8 +224,7 @@ void MainView::slotWebRedo() void MainView::slotWebCut() { WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Cut); + QAction *action = webView->page()->action(QWebPage::Cut); action->trigger(); } @@ -242,8 +232,7 @@ void MainView::slotWebCut() void MainView::slotWebCopy() { WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Copy); + QAction *action = webView->page()->action(QWebPage::Copy); action->trigger(); } @@ -251,8 +240,7 @@ void MainView::slotWebCopy() void MainView::slotWebPaste() { WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Paste); + QAction *action = webView->page()->action(QWebPage::Paste); action->trigger(); } @@ -575,7 +563,7 @@ void MainView::webViewLoadProgress(int progress) return; } - double totalBytes = static_cast(webView->webPage()->totalBytes() / 1024); + double totalBytes = static_cast(webView->page()->totalBytes() / 1024); QString message = i18n("Loading %1% (%2 %3)...", progress, totalBytes, QLatin1String("kB")); emit showStatusBarMessage(message); diff --git a/src/webview.cpp b/src/webview.cpp index 374a06a8..92995a93 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -80,9 +80,9 @@ WebView::WebView(QWidget* parent) } -WebPage *WebView::webPage() const +void WebView::setNewPage() { - return m_page; + setPage(new WebPage(this)); } diff --git a/src/webview.h b/src/webview.h index 56693597..19fd9517 100644 --- a/src/webview.h +++ b/src/webview.h @@ -58,7 +58,6 @@ class WebView : public KWebView public: WebView(QWidget *parent = 0); - WebPage *webPage() const; KUrl url() const; QString lastStatusBarText() const; int progress() const; @@ -83,6 +82,9 @@ protected: */ void keyPressEvent(QKeyEvent *event); + // to reimplement from KWebView + virtual void setNewPage(); + private slots: void setProgress(int progress); void loadFinished(); -- cgit v1.2.1 From 7aad2cdabf718b113284d5835a821c059dff5f72 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 25 May 2009 12:27:17 +0200 Subject: Fixing CMakelists.txt's --- CMakeLists.txt | 3 +- src/CMakeLists.txt | 5 --- src/mainwindow.cpp | 92 ++++++++++++++++++++++++++++++++---------------------- src/mainwindow.h | 2 +- 4 files changed, 57 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 393910cc..a5920fcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,12 +118,13 @@ MESSAGE(STATUS "") IF(REKONQ_CAN_BE_COMPILED) - INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} + INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES} ${QT4_INCLUDES} ${QT_QTNETWORK_INCLUDE_DIR} ${QT_QTWEBKIT_INCLUDE_DIR} + ${KDEWEBKIT_INCLUDE_DIR} ) ADD_SUBDIRECTORY( src ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cbb1421d..064fc0e6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,11 +42,6 @@ KDE4_ADD_KCFG_FILES( rekonq_SRCS rekonq.kcfgc ) ### ------------------------------------------ -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/.. - ${KDEWEBKIT_INCLUDE_DIR} - ) - ADD_DEFINITIONS( ${KDE4_DEFINITIONS} ${KDEWEBKIT_DEFINITIONS} ) KDE4_ADD_EXECUTABLE( rekonq ${rekonq_SRCS} ) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 39455d92..71415b08 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -89,9 +89,9 @@ MainWindow::MainWindow() : KXmlGuiWindow() , m_view(new MainView(this)) - , m_findBar(new FindBar(this)) , m_searchBar(new SearchBar(this)) , m_sidePanel(0) + , m_prova(0) { // updating rekonq configuration slotUpdateConfiguration(); @@ -104,7 +104,6 @@ MainWindow::MainWindow() QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_view); - layout->addWidget(m_findBar); centralWidget->setLayout(layout); // central widget @@ -173,7 +172,7 @@ void MainWindow::postLaunch() connect(m_view, SIGNAL(currentChanged(int)), this, SLOT(slotUpdateActions())); // Find Bar signal - connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(slotFind(const QString &))); +// connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(slotFind(const QString &))); // bookmarks loading connect(Application::bookmarkProvider(), SIGNAL(openUrl(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); @@ -631,51 +630,68 @@ void MainWindow::slotFind(const QString & search) void MainWindow::slotViewFindBar() { - m_findBar->showFindBar(); +// // creating a centralWidget containing panel, m_view and the hidden findbar +// QWidget *centralWidget = new QWidget; +// centralWidget->setContentsMargins(0, 0, 0, 0); +// +// // setting layout +// QVBoxLayout *layout = new QVBoxLayout; +// layout->setContentsMargins(0, 0, 0, 0); +// layout->addWidget(m_view); +// centralWidget->setLayout(layout); +// +// // m_findBar->showFindBar(); +// // m_findBar->show(); + QWidget *w = centralWidget(); + QLayout *l = w->layout(); + QWidget *searchBarWidget = currentTab()->searchBar(); + searchBarWidget->show(); + l->addWidget(searchBarWidget); + w->setLayout(l); } void MainWindow::slotFindNext() { - if (!currentTab() && m_lastSearch.isEmpty()) - return; - - QWebPage::FindFlags options; - if (m_findBar->matchCase()) - { - options = QWebPage::FindCaseSensitively | QWebPage::FindWrapsAroundDocument; - } - else - { - options = QWebPage::FindWrapsAroundDocument; - } - - if (!currentTab()->findText(m_lastSearch, options)) - { - slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); - } +// if (!currentTab() && m_lastSearch.isEmpty()) +// return; +// +// QWebPage::FindFlags options; +// if (m_findBar->matchCase()) +// { +// options = QWebPage::FindCaseSensitively | QWebPage::FindWrapsAroundDocument; +// } +// else +// { +// options = QWebPage::FindWrapsAroundDocument; +// } +// +// if (!currentTab()->findText(m_lastSearch, options)) +// { +// slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); +// } } void MainWindow::slotFindPrevious() { - if (!currentTab() && m_lastSearch.isEmpty()) - return; - - QWebPage::FindFlags options; - if (m_findBar->matchCase()) - { - options = QWebPage::FindCaseSensitively | QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; - } - else - { - options = QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; - } - - if (!currentTab()->findText(m_lastSearch, options)) - { - slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); - } +// if (!currentTab() && m_lastSearch.isEmpty()) +// return; +// +// QWebPage::FindFlags options; +// if (m_findBar->matchCase()) +// { +// options = QWebPage::FindCaseSensitively | QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; +// } +// else +// { +// options = QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; +// } +// +// if (!currentTab()->findText(m_lastSearch, options)) +// { +// slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); +// } } diff --git a/src/mainwindow.h b/src/mainwindow.h index a4574612..93c8ca84 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -129,9 +129,9 @@ private slots: private: MainView *m_view; - FindBar *m_findBar; SearchBar *m_searchBar; SidePanel *m_sidePanel; + QWidget *m_prova; KMenu *m_historyBackMenu; KMenu *m_windowMenu; -- cgit v1.2.1 From 974058301ed0911bc8bd15a957548ce0771851aa Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 25 May 2009 16:47:37 +0200 Subject: WebkitKDE porting. I'm working on a big refactoring of the webview/webpage classes. This is (obviously) a work in progress. Perhaps ~50% of the porting.. --- src/webpage.cpp | 78 +++++++-------------------------- src/webpage.h | 13 +++--- src/webview.cpp | 134 +++++++++++++++++++------------------------------------- src/webview.h | 17 +++---- 4 files changed, 73 insertions(+), 169 deletions(-) diff --git a/src/webpage.cpp b/src/webpage.cpp index 51a02771..664c812b 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -66,18 +66,16 @@ WebPage::WebPage(QObject *parent) : KWebPage(parent) - , m_keyboardModifiers(Qt::NoModifier) - , m_pressedButtons(Qt::NoButton) { - setNetworkAccessManager(Application::networkAccessManager()); - setForwardUnsupportedContent(true); - connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *))); + setNetworkAccessManager(Application::networkAccessManager()); } bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { + + // TODO: implement ioslaves protocols QString scheme = request.url().scheme(); if (scheme == QLatin1String("mailto")) { @@ -85,7 +83,6 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r return false; } - WebView *webView; switch (type) { @@ -118,23 +115,6 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r // user activated the reload action. case QWebPage::NavigationTypeReload: kDebug() << "NavigationTypeReload"; - -#if QT_VERSION <= 040500 - // HACK Ported from Arora - // A short term hack until QtWebKit can get a reload without cache QAction - // *FYI* currently type is never NavigationTypeReload - // See: https://bugs.webkit.org/show_bug.cgi?id=24283 - if (qApp->keyboardModifiers() & Qt::ShiftModifier) - { - kDebug() << "Arora hack"; - QNetworkRequest newRequest(request); - newRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, - QNetworkRequest::AlwaysNetwork); - mainFrame()->load(request); - return false; - } -#endif - break; // should be nothing.. @@ -143,33 +123,6 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r break; } - if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) - { - webView = Application::instance()->newWebView(); - webView->setFocus(); - webView->load(request.url()); - m_keyboardModifiers = Qt::NoModifier; - m_pressedButtons = Qt::NoButton; - return false; - } - - if (frame == mainFrame()) - { - m_loadingUrl = request.url(); - emit loadingUrl(m_loadingUrl); - } - else - { - // if frame doesn't exists (perhaps) we are pointing to a blank target.. - if (!frame) - { - webView = Application::instance()->newWebView(); - webView->setFocus(); - webView->load(request.url()); - return false; - } - } - return QWebPage::acceptNavigationRequest(frame, request, type); } @@ -190,7 +143,7 @@ KWebPage *WebPage::createWindow(QWebPage::WebWindowType type) } -void WebPage::handleUnsupportedContent(QNetworkReply *reply) +void WebPage::slotHandleUnsupportedContent(QNetworkReply *reply) { // create convenience fake api:// protocol for KDE apidox search and Qt docs if (reply->url().scheme() == "api") @@ -213,17 +166,18 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) if (reply->error() == QNetworkReply::NoError) { - // st iframe unwanted download fix - if (reply->header(QNetworkRequest::ContentTypeHeader).isValid()) - { - KUrl srcUrl = reply->url(); - Application::downloadManager()->newDownload(srcUrl); - } - else - { - kDebug() << "invalid content type header"; - } - return; + return slotDownloadRequested(reply->request(), reply); +// // st iframe unwanted download fix +// if (reply->header(QNetworkRequest::ContentTypeHeader).isValid()) +// { +// KUrl srcUrl = reply->url(); +// Application::downloadManager()->newDownload(srcUrl); +// } +// else +// { +// kDebug() << "invalid content type header"; +// } +// return; } // display "not found" page diff --git a/src/webpage.h b/src/webpage.h index cdb1d04f..87fd3549 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -51,11 +51,8 @@ class WebPage : public KWebPage { Q_OBJECT -signals: - void loadingUrl(const QUrl &url); // WARNING has to be QUrl!! - public: - WebPage(QObject *parent = 0); + explicit WebPage(QObject *parent = 0); protected: @@ -65,15 +62,15 @@ protected: KWebPage *createWindow(QWebPage::WebWindowType type); -private slots: - void handleUnsupportedContent(QNetworkReply *reply); +protected Q_SLOTS: + virtual void slotHandleUnsupportedContent(QNetworkReply *reply); private: friend class WebView; // set the webview mousepressedevent - Qt::KeyboardModifiers m_keyboardModifiers; - Qt::MouseButtons m_pressedButtons; +// Qt::KeyboardModifiers m_keyboardModifiers; +// Qt::MouseButtons m_pressedButtons; KUrl m_loadingUrl; }; diff --git a/src/webview.cpp b/src/webview.cpp index 92995a93..16f7b6e5 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -74,9 +74,8 @@ WebView::WebView(QWidget* parent) connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&))); connect(this, SIGNAL(loadProgress(int)), this, SLOT(setProgress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished())); - connect(page(), SIGNAL(loadingUrl(const QUrl&)), this, SIGNAL(urlChanged(const QUrl &))); - connect(page(), SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequested(const QNetworkRequest &))); - page()->setForwardUnsupportedContent(true); + + connect(this, SIGNAL(openUrlInNewTab(const KUrl &)), this, SLOT(load(const KUrl &))); } @@ -132,14 +131,13 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) addBookmarkAction->setData(QVariant()); KMenu menu(this); - QAction *a; // link actions bool linkIsEmpty = result.linkUrl().isEmpty(); if (!linkIsEmpty) { - a = new KAction(KIcon("tab-new"), i18n("Open Link in New &Tab"), this); - connect(a, SIGNAL(triggered()), this, SLOT(openLinkInNewTab())); + QAction *a = pageAction(QWebPage::OpenLinkInNewWindow); + a->setText(i18n("Open Link in New &Tab")); menu.addAction(a); } else @@ -152,10 +150,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) // Developer Extras actions if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled)) { - a = pageAction(QWebPage::InspectElement); - a->setIcon(KIcon("tools-report-bug")); - a->setText(i18n("&Inspect Element")); - menu.addAction(a); + menu.addAction(pageAction(QWebPage::InspectElement)); menu.addSeparator(); } @@ -164,28 +159,19 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) if (result.isContentSelected() && result.isContentEditable()) { - a = pageAction(QWebPage::Cut); - a->setIcon(KIcon("edit-cut")); - a->setText(i18n("Cu&t")); - menu.addAction(a); + menu.addAction(pageAction(QWebPage::Cut)); b = true; } if (result.isContentSelected()) { - a = pageAction(QWebPage::Copy); - a->setIcon(KIcon("edit-copy")); - a->setText(i18n("&Copy")); - menu.addAction(a); + menu.addAction(pageAction(QWebPage::Copy)); b = true; } if (result.isContentEditable()) { - a = pageAction(QWebPage::Paste); - a->setIcon(KIcon("edit-paste")); - a->setText(i18n("&Paste")); - menu.addAction(a); + menu.addAction(pageAction(QWebPage::Paste)); b = true; } @@ -197,31 +183,15 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) // save/copy link actions if (!linkIsEmpty) { - a = pageAction(QWebPage::DownloadLinkToDisk); - a->setIcon(KIcon("folder-downloads")); - a->setText(i18n("&Save Link As...")); - menu.addAction(a); - - a = pageAction(QWebPage::CopyLinkToClipboard); - a->setIcon(KIcon("insert-link")); - a->setText(i18n("&Copy Link Location")); - menu.addAction(a); - + menu.addAction(pageAction(QWebPage::DownloadLinkToDisk)); + menu.addAction(pageAction(QWebPage::CopyLinkToClipboard)); menu.addSeparator(); if (!result.pixmap().isNull()) { // TODO Add "View Image" && remove copy_this_image action - a = pageAction(QWebPage::DownloadImageToDisk); - a->setIcon(KIcon("folder-image")); - a->setText(i18n("&Save Image As...")); - menu.addAction(a); - - a = pageAction(QWebPage::CopyImageToClipboard); - a->setIcon(KIcon("insert-image")); - a->setText(i18n("&Copy This Image")); - menu.addAction(a); - + menu.addAction(pageAction(QWebPage::DownloadImageToDisk)); + menu.addAction(pageAction(QWebPage::CopyImageToClipboard)); menu.addSeparator(); } } @@ -248,24 +218,10 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) } -void WebView::wheelEvent(QWheelEvent *event) -{ - if (QApplication::keyboardModifiers() & Qt::ControlModifier) - { - int numDegrees = event->delta() / 8; - int numSteps = numDegrees / 15; - setTextSizeMultiplier(textSizeMultiplier() + numSteps * 0.1); - event->accept(); - return; - } - QWebView::wheelEvent(event); -} - - -void WebView::openLinkInNewTab() -{ - pageAction(QWebPage::OpenLinkInNewWindow)->trigger(); -} +// void WebView::openLinkInNewTab() +// { +// pageAction(QWebPage::OpenLinkInNewWindow)->trigger(); +// } void WebView::loadFinished() @@ -279,35 +235,35 @@ void WebView::loadFinished() } -void WebView::mousePressEvent(QMouseEvent *event) -{ - m_page->m_pressedButtons = event->buttons(); - m_page->m_keyboardModifiers = event->modifiers(); - QWebView::mousePressEvent(event); -} - - -void WebView::mouseReleaseEvent(QMouseEvent *event) -{ - QWebView::mouseReleaseEvent(event); - if (!event->isAccepted() && (m_page->m_pressedButtons & Qt::MidButton)) - { - KUrl url(QApplication::clipboard()->text(QClipboard::Selection)); - if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) - { - setUrl(url); - } - } -} - - -void WebView::downloadRequested(const QNetworkRequest &request) -{ - KUrl srcUrl = request.url(); - QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); - KUrl destUrl = KUrl(path); - Application::downloadManager()->newDownload(srcUrl); -} +// void WebView::mousePressEvent(QMouseEvent *event) +// { +// m_page->m_pressedButtons = event->buttons(); +// m_page->m_keyboardModifiers = event->modifiers(); +// QWebView::mousePressEvent(event); +// } +// +// +// void WebView::mouseReleaseEvent(QMouseEvent *event) +// { +// QWebView::mouseReleaseEvent(event); +// if (!event->isAccepted() && (m_page->m_pressedButtons & Qt::MidButton)) +// { +// KUrl url(QApplication::clipboard()->text(QClipboard::Selection)); +// if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) +// { +// setUrl(url); +// } +// } +// } + + +// void WebView::downloadRequested(const QNetworkRequest &request) +// { +// KUrl srcUrl = request.url(); +// QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); +// KUrl destUrl = KUrl(path); +// Application::downloadManager()->newDownload(srcUrl); +// } void WebView::keyPressEvent(QKeyEvent *event) diff --git a/src/webview.h b/src/webview.h index 19fd9517..ab69f799 100644 --- a/src/webview.h +++ b/src/webview.h @@ -32,6 +32,7 @@ // Qt Includes #include +#include // Forward Declarations class MainWindow; @@ -45,10 +46,6 @@ class QMouseEvent; class QNetworkProxy; class QNetworkReply; class QSslError; -class WebPage; - -// Qt Includes -#include class WebView : public KWebView @@ -56,7 +53,7 @@ class WebView : public KWebView Q_OBJECT public: - WebView(QWidget *parent = 0); + explicit WebView(QWidget *parent = 0); KUrl url() const; QString lastStatusBarText() const; @@ -71,10 +68,9 @@ signals: void shiftCtrlTabPressed(); protected: - void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); +// void mousePressEvent(QMouseEvent *event); +// void mouseReleaseEvent(QMouseEvent *event); void contextMenuEvent(QContextMenuEvent *event); - void wheelEvent(QWheelEvent *event); /** * Filters (SHIFT + ) CTRL + TAB events and emit (shift)ctrlTabPressed() @@ -89,8 +85,9 @@ private slots: void setProgress(int progress); void loadFinished(); void setStatusBarText(const QString &string); - void downloadRequested(const QNetworkRequest &request); - void openLinkInNewTab(); + +// void downloadRequested(const QNetworkRequest &request); +// void open LinkInNewTab(); private: WebPage *m_page; -- cgit v1.2.1 From f5ff5c8f644aded6d8c09a7aa122eba46d5bf28e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 25 May 2009 16:50:35 +0200 Subject: Working on adopting WebView search bar.. --- src/mainwindow.cpp | 1 - src/mainwindow.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 71415b08..83f64926 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -91,7 +91,6 @@ MainWindow::MainWindow() , m_view(new MainView(this)) , m_searchBar(new SearchBar(this)) , m_sidePanel(0) - , m_prova(0) { // updating rekonq configuration slotUpdateConfiguration(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 93c8ca84..87003005 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -43,7 +43,6 @@ class KActionMenu; class KIcon; class KMenu; -class FindBar; class HistoryMenu; class SidePanel; class WebView; @@ -131,7 +130,6 @@ private: MainView *m_view; SearchBar *m_searchBar; SidePanel *m_sidePanel; - QWidget *m_prova; KMenu *m_historyBackMenu; KMenu *m_windowMenu; -- cgit v1.2.1 From ccb09a51449cfac70cedf33875e317b4005263f4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 26 May 2009 14:29:42 +0200 Subject: Fixing Compilation --- src/networkaccessmanager.cpp | 4 ++-- src/networkaccessmanager.h | 2 +- src/webpage.cpp | 1 + src/webpage.h | 3 ++- src/webview.h | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 2c42f5d2..ddab6ffe 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -63,7 +63,7 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) #ifndef QT_NO_OPENSSL connect(this, SIGNAL(sslErrors(QNetworkReply*, const QList&)), - SLOT(sslErrors(QNetworkReply*, const QList&))); + SLOT(slotSSLErrors(QNetworkReply*, const QList&))); #endif loadSettings(); @@ -159,7 +159,7 @@ void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &prox #ifndef QT_NO_OPENSSL -void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList &error) +void NetworkAccessManager::slotSSLErrors(QNetworkReply *reply, const QList &error) { MainWindow *mainWindow = Application::instance()->mainWindow(); diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h index ae356743..8416d6a2 100644 --- a/src/networkaccessmanager.h +++ b/src/networkaccessmanager.h @@ -45,7 +45,7 @@ private slots: void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); #ifndef QT_NO_OPENSSL - void sslErrors(QNetworkReply *reply, const QList &error); + void slotSSLErrors(QNetworkReply *reply, const QList &error); #endif }; diff --git a/src/webpage.cpp b/src/webpage.cpp index 664c812b..bfc128b8 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -34,6 +34,7 @@ #include "networkaccessmanager.h" #include "download.h" #include "history.h" +#include "webview.h" // KDE Includes #include diff --git a/src/webpage.h b/src/webpage.h index 87fd3549..abb25171 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -44,7 +44,8 @@ class QAuthenticator; class QMouseEvent; class QNetworkProxy; class QNetworkReply; -class QSslError; + +class WebView; class WebPage : public KWebPage diff --git a/src/webview.h b/src/webview.h index ab69f799..ae420de4 100644 --- a/src/webview.h +++ b/src/webview.h @@ -45,7 +45,7 @@ class QAuthenticator; class QMouseEvent; class QNetworkProxy; class QNetworkReply; -class QSslError; +class WebPage; class WebView : public KWebView -- cgit v1.2.1 From 6ce525e98335a4ab0225b29a451473bdc3a5ae19 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 26 May 2009 14:33:28 +0200 Subject: load AccessManager Proxy fix --- src/networkaccessmanager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index ddab6ffe..d0c9833b 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -77,9 +77,9 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) void NetworkAccessManager::loadSettings() { - QNetworkProxy proxy; if (ReKonfig::isProxyEnabled()) { + QNetworkProxy proxy; if (ReKonfig::proxyType() == 0) { proxy.setType(QNetworkProxy::Socks5Proxy); @@ -92,8 +92,9 @@ void NetworkAccessManager::loadSettings() proxy.setPort(ReKonfig::proxyPort()); proxy.setUser(ReKonfig::proxyUserName()); proxy.setPassword(ReKonfig::proxyPassword()); + + setProxy(proxy); } - setProxy(proxy); } -- cgit v1.2.1 From 65887b14f377e6db3fb439a90ca7abd69403f88c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 26 May 2009 15:06:40 +0200 Subject: managing Network Reply Errors. STEP 1 --- src/webpage.cpp | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/webpage.h | 2 ++ 2 files changed, 102 insertions(+) diff --git a/src/webpage.cpp b/src/webpage.cpp index bfc128b8..e941d2d5 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -69,7 +69,107 @@ WebPage::WebPage(QObject *parent) : KWebPage(parent) { setForwardUnsupportedContent(true); + setNetworkAccessManager(Application::networkAccessManager()); + connect(networkAccessManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*))); +} + + +void WebPage::manageNetworkErrors(QNetworkReply* reply) +{ + switch(reply->error()) + { + + case QNetworkReply::NoError: + kDebug() << "NoError"; + return; + break; + + case QNetworkReply::ConnectionRefusedError: + kDebug() << "ConnectionRefusedError"; + break; + + case QNetworkReply::RemoteHostClosedError: + kDebug() << "RemoteHostClosedError"; + break; + + case QNetworkReply::HostNotFoundError: + kDebug() << "HostNotFoundError"; + break; + + case QNetworkReply::TimeoutError: + kDebug() << "TimeoutError"; + break; + + case QNetworkReply::OperationCanceledError: + kDebug() << "OperationCanceledError"; + break; + + case QNetworkReply::SslHandshakeFailedError: + kDebug() << "SslHandshakeFailedError"; + break; + + case QNetworkReply::ProxyConnectionRefusedError: + kDebug() << "ProxyConnectionRefusedError"; + break; + + case QNetworkReply::ProxyConnectionClosedError: + kDebug() << "ProxyConnectionClosedError"; + break; + + case QNetworkReply::ProxyNotFoundError: + kDebug() << "ProxyNotFoundError"; + break; + + case QNetworkReply::ProxyTimeoutError: + kDebug() << "ProxyTimeoutError"; + break; + + case QNetworkReply::ProxyAuthenticationRequiredError: + kDebug() << "ProxyAuthenticationRequiredError"; + break; + + case QNetworkReply::ContentAccessDenied: + kDebug() << "ContentAccessDenied"; + break; + + case QNetworkReply::ContentOperationNotPermittedError: + kDebug() << "ContentOperationNotPermittedError"; + break; + + case QNetworkReply::ContentNotFoundError: + kDebug() << "ContentNotFoundError"; + break; + + case QNetworkReply::AuthenticationRequiredError: + kDebug() << "AuthenticationRequiredError"; + break; + + case QNetworkReply::ProtocolUnknownError: + kDebug() << "ProtocolUnknownError"; + break; + + case QNetworkReply::ProtocolInvalidOperationError: + kDebug() << "ProtocolInvalidOperationError"; + break; + + case QNetworkReply::UnknownNetworkError: + kDebug() << "UnknownNetworkError"; + break; + + case QNetworkReply::UnknownProxyError: + kDebug() << "UnknownProxyError"; + break; + + case QNetworkReply::UnknownContentError: + kDebug() << "UnknownContentError"; + break; + + case QNetworkReply::ProtocolFailure: + kDebug() << "ProtocolFailure"; + break; + + }; } diff --git a/src/webpage.h b/src/webpage.h index abb25171..ba440663 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -55,6 +55,8 @@ class WebPage : public KWebPage public: explicit WebPage(QObject *parent = 0); +public slots: + void manageNetworkErrors(QNetworkReply* reply); protected: bool acceptNavigationRequest(QWebFrame *frame, -- cgit v1.2.1 From 93ead7b8158019d1ea5a73cd3350f44dde8a20e6 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 27 May 2009 19:40:47 +0200 Subject: Network Reply Error. STEP 2 --- src/webpage.cpp | 46 ++++++++++++++++++++++++++-------------------- src/webpage.h | 2 ++ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/webpage.cpp b/src/webpage.cpp index e941d2d5..4c361f7b 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -170,6 +170,7 @@ void WebPage::manageNetworkErrors(QNetworkReply* reply) break; }; + viewErrorPage(reply); } @@ -280,7 +281,12 @@ void WebPage::slotHandleUnsupportedContent(QNetworkReply *reply) // } // return; } + viewErrorPage(reply); +} + +void WebPage::viewErrorPage(QNetworkReply *reply) +{ // display "not found" page QString notfoundFilePath = KStandardDirs::locate("data", "rekonq/htmls/notfound.html"); QFile file(notfoundFilePath); @@ -300,26 +306,26 @@ void WebPage::slotHandleUnsupportedContent(QNetworkReply *reply) .arg(reply->errorString()) .arg(reply->url().toString()); - QList frames; - frames.append(mainFrame()); - while (!frames.isEmpty()) - { - QWebFrame *firstFrame = frames.takeFirst(); - if (firstFrame->url() == reply->url()) - { - firstFrame->setHtml(html, reply->url()); - return; - } - QList children = firstFrame->childFrames(); - foreach(QWebFrame *frame, children) - { - frames.append(frame); - } - } - if (m_loadingUrl == reply->url()) - { +// QList frames; +// frames.append(mainFrame()); +// while (!frames.isEmpty()) +// { +// QWebFrame *firstFrame = frames.takeFirst(); +// if (firstFrame->url() == reply->url()) +// { +// firstFrame->setHtml(html, reply->url()); +// return; +// } +// QList children = firstFrame->childFrames(); +// foreach(QWebFrame *frame, children) +// { +// frames.append(frame); +// } +// } +// if (m_loadingUrl == reply->url()) +// { mainFrame()->setHtml(html, reply->url()); // Don't put error pages to the history. Application::historyManager()->removeHistoryEntry(reply->url(), mainFrame()->title()); - } -} +// } +} \ No newline at end of file diff --git a/src/webpage.h b/src/webpage.h index ba440663..5fd69702 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -69,6 +69,8 @@ protected Q_SLOTS: virtual void slotHandleUnsupportedContent(QNetworkReply *reply); private: + void viewErrorPage(QNetworkReply *); + friend class WebView; // set the webview mousepressedevent -- cgit v1.2.1 From 93f6dee31f4078c868f4f24df695b32e32225276 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 28 May 2009 01:42:04 +0200 Subject: cosmetic --- CMakeLists.txt | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5920fcb..78c4d740 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,7 @@ INCLUDE(MacroLibrary) MESSAGE(STATUS "") MESSAGE(STATUS "----------------------------------------------------------------------------------") MESSAGE(STATUS " rekonq ${REKONQ_VERSION_STR} dependencies results <${REKONQ_SITE}>") +MESSAGE(STATUS "") # Require shared libraries results. @@ -52,23 +53,21 @@ SET(QT_VERS_STR ) IF(QT_FOUND) - MESSAGE(STATUS " Qt library found............... YES") + MESSAGE(STATUS " Qt library found...................... YES") MESSAGE(STATUS " Qt version ${QT_VERS_STR} found! ") ELSE(QT_FOUND) - MESSAGE(STATUS " Qt library found............... NO") + MESSAGE(STATUS " Qt library found...................... NO") MESSAGE(STATUS "") MESSAGE(SEND_ERROR " rekonq needs at least Qt ${QT_MIN_VERSION}. Please install it and try compiling again.") MESSAGE(STATUS " Qt website is at http://www.qtsoftware.com") MESSAGE(STATUS "") ENDIF(QT_FOUND) -MESSAGE(STATUS "----------------------------------------------------------------------------------") -MESSAGE(STATUS "") - +MESSAGE(STATUS "") # ----------------------------------------------------------- # -------------- KDE SET(KDE_VERS_STR - "${KDE_VERSION_MAJOR}.${KDE_VERSION_MINOR}.${KDE_VERSION_PATCH}" + "${KDE_VERSION_MAJOR}.${KDE_VERSION_MINOR}.${KDE_VERSION_RELEASE}" ) IF(KDE4_FOUND) @@ -82,21 +81,20 @@ ELSE(KDE4_FOUND) MESSAGE(STATUS "") ENDIF(KDE4_FOUND) -MESSAGE(STATUS "----------------------------------------------------------------------------------") -MESSAGE(STATUS "") - +MESSAGE(STATUS "") # ---------------------------------------------------------- # ---------------- KdeWebkit IF(KDEWEBKIT_FOUND) - MESSAGE(STATUS " KDE Webkit library found............... YES") + MESSAGE(STATUS " KDE Webkit library found.............. YES") ELSE(KDEWEBKIT_FOUND) - MESSAGE(STATUS " KDE Webkit library found............... NO") + MESSAGE(STATUS " KDE Webkit library found.............. NO") MESSAGE(STATUS "") MESSAGE(SEND_ERROR " rekonq needs, from version 0.2, KDEWEBKIT to be compiled. Please install it and try compiling again.") MESSAGE(STATUS " You can actually retrieve it from playground/libs/webkitkde KDE svn") MESSAGE(STATUS "") ENDIF(KDEWEBKIT_FOUND) +MESSAGE(STATUS "") MESSAGE(STATUS "----------------------------------------------------------------------------------") MESSAGE(STATUS "") @@ -104,13 +102,14 @@ MESSAGE(STATUS "") ##### FINAL RESULTS ##### IF(QT_FOUND AND KDE4_FOUND AND KDEWEBKIT_FOUND) - MESSAGE(STATUS " rekonq will be compiled....... YES") + MESSAGE(STATUS " rekonq will be compiled............... YES") SET(REKONQ_CAN_BE_COMPILED true) ELSE(QT_FOUND AND KDE4_FOUND AND KDEWEBKIT_FOUND) MESSAGE(FATAL_ERROR " rekonq will NOT be compiled!") SET(REKONQ_CAN_BE_COMPILED false) ENDIF(QT_FOUND AND KDE4_FOUND AND KDEWEBKIT_FOUND) +MESSAGE(STATUS "") MESSAGE(STATUS "----------------------------------------------------------------------------------") MESSAGE(STATUS "") -- cgit v1.2.1 From fe335721c90d0de6f99de7f3e66832a3e8e8dfa1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 28 May 2009 01:42:20 +0200 Subject: Lot of work to do in mainview. Removed status/tool/geometry change view signals --- src/mainview.cpp | 16 ++++------------ src/mainview.h | 7 ------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/mainview.cpp b/src/mainview.cpp index 1b2d4769..d8d1c2b5 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -364,16 +364,8 @@ WebView *MainView::newWebView(Rekonq::OpenType type) // connecting webPage signals with mainview connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); - connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)), - this, SIGNAL(geometryChangeRequested(const QRect &))); connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *))); - connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), - this, SIGNAL(menuBarVisibilityChangeRequested(bool))); - connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), - this, SIGNAL(statusBarVisibilityChangeRequested(bool))); - connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), - this, SIGNAL(toolBarVisibilityChangeRequested(bool))); addTab(webView, i18n("(Untitled)")); @@ -491,10 +483,10 @@ void MainView::slotCloseTab(int index) if (tab->isModified()) { int risp = KMessageBox::questionYesNo(this , - i18n("You have modified this page and when closing it you would lose the modification.\n" - "Do you really want to close this page?\n"), - i18n("Do you really want to close this page?") - ); + i18n("You have modified this page and when closing it you would lose the modification.\n" + "Do you really want to close this page?\n"), + i18n("Do you really want to close this page?") + ); if (risp == KMessageBox::No) return; } diff --git a/src/mainview.h b/src/mainview.h index 435ccc40..ff43576f 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -19,8 +19,6 @@ * ============================================================ */ - - #ifndef TABWIDGET_H #define TABWIDGET_H @@ -68,7 +66,6 @@ public: UrlBar *urlBar(int index) const; UrlBar *currentUrlBar() const; WebView *webView(int index) const; - QList tabs(); // ? // inlines TabBar *tabBar() const; @@ -98,10 +95,6 @@ signals: void linkHovered(const QString &link); void loadProgress(int progress); - void geometryChangeRequested(const QRect &geometry); - void menuBarVisibilityChangeRequested(bool visible); - void statusBarVisibilityChangeRequested(bool visible); - void toolBarVisibilityChangeRequested(bool visible); void printRequested(QWebFrame *frame); public slots: -- cgit v1.2.1 From 8c5f265d22bd4590612b426ebb9d984b8e49f24c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 28 May 2009 01:55:25 +0200 Subject: working on error messages & openLinkInNewTab slot --- src/webpage.cpp | 243 ++++++++++++-------------------------------------------- src/webpage.h | 9 +-- src/webview.cpp | 42 ++-------- src/webview.h | 5 +- 4 files changed, 61 insertions(+), 238 deletions(-) diff --git a/src/webpage.cpp b/src/webpage.cpp index 4c361f7b..cfbc32cf 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -62,8 +62,6 @@ #include #include -// #include - WebPage::WebPage(QObject *parent) : KWebPage(parent) @@ -75,105 +73,6 @@ WebPage::WebPage(QObject *parent) } -void WebPage::manageNetworkErrors(QNetworkReply* reply) -{ - switch(reply->error()) - { - - case QNetworkReply::NoError: - kDebug() << "NoError"; - return; - break; - - case QNetworkReply::ConnectionRefusedError: - kDebug() << "ConnectionRefusedError"; - break; - - case QNetworkReply::RemoteHostClosedError: - kDebug() << "RemoteHostClosedError"; - break; - - case QNetworkReply::HostNotFoundError: - kDebug() << "HostNotFoundError"; - break; - - case QNetworkReply::TimeoutError: - kDebug() << "TimeoutError"; - break; - - case QNetworkReply::OperationCanceledError: - kDebug() << "OperationCanceledError"; - break; - - case QNetworkReply::SslHandshakeFailedError: - kDebug() << "SslHandshakeFailedError"; - break; - - case QNetworkReply::ProxyConnectionRefusedError: - kDebug() << "ProxyConnectionRefusedError"; - break; - - case QNetworkReply::ProxyConnectionClosedError: - kDebug() << "ProxyConnectionClosedError"; - break; - - case QNetworkReply::ProxyNotFoundError: - kDebug() << "ProxyNotFoundError"; - break; - - case QNetworkReply::ProxyTimeoutError: - kDebug() << "ProxyTimeoutError"; - break; - - case QNetworkReply::ProxyAuthenticationRequiredError: - kDebug() << "ProxyAuthenticationRequiredError"; - break; - - case QNetworkReply::ContentAccessDenied: - kDebug() << "ContentAccessDenied"; - break; - - case QNetworkReply::ContentOperationNotPermittedError: - kDebug() << "ContentOperationNotPermittedError"; - break; - - case QNetworkReply::ContentNotFoundError: - kDebug() << "ContentNotFoundError"; - break; - - case QNetworkReply::AuthenticationRequiredError: - kDebug() << "AuthenticationRequiredError"; - break; - - case QNetworkReply::ProtocolUnknownError: - kDebug() << "ProtocolUnknownError"; - break; - - case QNetworkReply::ProtocolInvalidOperationError: - kDebug() << "ProtocolInvalidOperationError"; - break; - - case QNetworkReply::UnknownNetworkError: - kDebug() << "UnknownNetworkError"; - break; - - case QNetworkReply::UnknownProxyError: - kDebug() << "UnknownProxyError"; - break; - - case QNetworkReply::UnknownContentError: - kDebug() << "UnknownContentError"; - break; - - case QNetworkReply::ProtocolFailure: - kDebug() << "ProtocolFailure"; - break; - - }; - viewErrorPage(reply); -} - - bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { @@ -185,44 +84,23 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r return false; } - - switch (type) + // create convenience fake api:// protocol for KDE apidox search and Qt docs + if (scheme == QLatin1String("api")) { - // user activated a submit button for an HTML form. - case QWebPage::NavigationTypeFormSubmitted: - kDebug() << "NavigationTypeFormSubmitted"; - kDebug() << request.url(); - break; - - // An HTML form was submitted a second time. - case QWebPage::NavigationTypeFormResubmitted: - kDebug() << "NavigationTypeFormResubmitted"; - break; - - // A navigation to another document using a method not listed above. - case QWebPage::NavigationTypeOther: - kDebug() << "NavigationTypeOther"; - break; - - // user clicked on a link or pressed return on a focused link. - case QWebPage::NavigationTypeLinkClicked: - kDebug() << "NavigationTypeLinkClicked"; - break; - - // Navigation to a previously shown document in the back or forward history is requested. - case QWebPage::NavigationTypeBackOrForward: - kDebug() << "NavigationTypeBackOrForward"; - break; - - // user activated the reload action. - case QWebPage::NavigationTypeReload: - kDebug() << "NavigationTypeReload"; - break; - - // should be nothing.. - default: - kDebug() << "Default NON extant case.."; - break; + QString path; + QString className = request.url().host().toLower(); + if (className[0] == 'k') + { + path = QString("http://api.kde.org/new.classmapper.php?class=%1").arg(className); + } + else if (className[0] == 'q') + { + path = QString("http://doc.trolltech.com/4.5/%1.html").arg(className); + } + KUrl url(path); + + Application::instance()->mainWindow()->loadUrl(url); + return false; } return QWebPage::acceptNavigationRequest(frame, request, type); @@ -245,42 +123,24 @@ KWebPage *WebPage::createWindow(QWebPage::WebWindowType type) } -void WebPage::slotHandleUnsupportedContent(QNetworkReply *reply) -{ - // create convenience fake api:// protocol for KDE apidox search and Qt docs - if (reply->url().scheme() == "api") - { - QString path; - QString className = reply->url().host().toLower(); - if (className[0] == 'k') - { - path = QString("http://api.kde.org/new.classmapper.php?class=%1").arg(className); - } - else if (className[0] == 'q') - { - path = QString("http://doc.trolltech.com/4.5/%1.html").arg(className); - } - KUrl url(path); +// FIXME: implement here (perhaps) mimetype discerning && file loading (KToolInvocation??) +// void WebPage::slotHandleUnsupportedContent(QNetworkReply *reply) +// { +// +// if (reply->error() == QNetworkReply::NoError) +// { +// return slotDownloadRequested(reply->request(), reply); +// } +// +// viewErrorPage(reply); +// } - Application::instance()->mainWindow()->loadUrl(url); + +void WebPage::manageNetworkErrors(QNetworkReply* reply) +{ + if(reply->error() == QNetworkReply::NoError) return; - } - if (reply->error() == QNetworkReply::NoError) - { - return slotDownloadRequested(reply->request(), reply); -// // st iframe unwanted download fix -// if (reply->header(QNetworkRequest::ContentTypeHeader).isValid()) -// { -// KUrl srcUrl = reply->url(); -// Application::downloadManager()->newDownload(srcUrl); -// } -// else -// { -// kDebug() << "invalid content type header"; -// } -// return; - } viewErrorPage(reply); } @@ -306,26 +166,27 @@ void WebPage::viewErrorPage(QNetworkReply *reply) .arg(reply->errorString()) .arg(reply->url().toString()); -// QList frames; -// frames.append(mainFrame()); -// while (!frames.isEmpty()) -// { -// QWebFrame *firstFrame = frames.takeFirst(); -// if (firstFrame->url() == reply->url()) -// { -// firstFrame->setHtml(html, reply->url()); -// return; -// } -// QList children = firstFrame->childFrames(); -// foreach(QWebFrame *frame, children) -// { -// frames.append(frame); -// } -// } -// if (m_loadingUrl == reply->url()) -// { + // test + QList frames; + frames.append(mainFrame()); + while (!frames.isEmpty()) + { + QWebFrame *firstFrame = frames.takeFirst(); + if (firstFrame->url() == reply->url()) + { + firstFrame->setHtml(html, reply->url()); + return; + } + QList children = firstFrame->childFrames(); + foreach(QWebFrame *frame, children) + { + frames.append(frame); + } + } + if (m_loadingUrl == reply->url()) + { mainFrame()->setHtml(html, reply->url()); // Don't put error pages to the history. Application::historyManager()->removeHistoryEntry(reply->url(), mainFrame()->title()); -// } -} \ No newline at end of file + } +} diff --git a/src/webpage.h b/src/webpage.h index 5fd69702..1f8777bd 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -65,17 +65,12 @@ protected: KWebPage *createWindow(QWebPage::WebWindowType type); -protected Q_SLOTS: - virtual void slotHandleUnsupportedContent(QNetworkReply *reply); +// protected Q_SLOTS: +// virtual void slotHandleUnsupportedContent(QNetworkReply *reply); private: void viewErrorPage(QNetworkReply *); - friend class WebView; - - // set the webview mousepressedevent -// Qt::KeyboardModifiers m_keyboardModifiers; -// Qt::MouseButtons m_pressedButtons; KUrl m_loadingUrl; }; diff --git a/src/webview.cpp b/src/webview.cpp index 16f7b6e5..4f6ba097 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -75,7 +75,7 @@ WebView::WebView(QWidget* parent) connect(this, SIGNAL(loadProgress(int)), this, SLOT(setProgress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished())); - connect(this, SIGNAL(openUrlInNewTab(const KUrl &)), this, SLOT(load(const KUrl &))); + connect(this, SIGNAL(openUrlInNewTab(const KUrl &)), this, SLOT(openLinkInNewTab(const KUrl &))); } @@ -218,10 +218,11 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) } -// void WebView::openLinkInNewTab() -// { -// pageAction(QWebPage::OpenLinkInNewWindow)->trigger(); -// } +void WebView::openLinkInNewTab(const KUrl &url) +{ + Application::instance()->newWebView(); + load(url); +} void WebView::loadFinished() @@ -235,37 +236,6 @@ void WebView::loadFinished() } -// void WebView::mousePressEvent(QMouseEvent *event) -// { -// m_page->m_pressedButtons = event->buttons(); -// m_page->m_keyboardModifiers = event->modifiers(); -// QWebView::mousePressEvent(event); -// } -// -// -// void WebView::mouseReleaseEvent(QMouseEvent *event) -// { -// QWebView::mouseReleaseEvent(event); -// if (!event->isAccepted() && (m_page->m_pressedButtons & Qt::MidButton)) -// { -// KUrl url(QApplication::clipboard()->text(QClipboard::Selection)); -// if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) -// { -// setUrl(url); -// } -// } -// } - - -// void WebView::downloadRequested(const QNetworkRequest &request) -// { -// KUrl srcUrl = request.url(); -// QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); -// KUrl destUrl = KUrl(path); -// Application::downloadManager()->newDownload(srcUrl); -// } - - void WebView::keyPressEvent(QKeyEvent *event) { if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_Tab)) diff --git a/src/webview.h b/src/webview.h index ae420de4..2ac018d7 100644 --- a/src/webview.h +++ b/src/webview.h @@ -68,8 +68,6 @@ signals: void shiftCtrlTabPressed(); protected: -// void mousePressEvent(QMouseEvent *event); -// void mouseReleaseEvent(QMouseEvent *event); void contextMenuEvent(QContextMenuEvent *event); /** @@ -86,8 +84,7 @@ private slots: void loadFinished(); void setStatusBarText(const QString &string); -// void downloadRequested(const QNetworkRequest &request); -// void open LinkInNewTab(); + void openLinkInNewTab(const KUrl &); private: WebPage *m_page; -- cgit v1.2.1 From 0c0d4ef4e837e43785a300317a37039cfc46b177 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 28 May 2009 10:03:58 +0200 Subject: Fixing loadInNewTab slot --- src/webview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/webview.cpp b/src/webview.cpp index 4f6ba097..216c2bd1 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -220,8 +220,8 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) void WebView::openLinkInNewTab(const KUrl &url) { - Application::instance()->newWebView(); - load(url); + WebView *that = Application::instance()->newWebView(); + that->load(url); } -- cgit v1.2.1 From 0a8fa0648731b81e5b552a817d204b0a36348dba Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 28 May 2009 11:38:08 +0200 Subject: Using my own FindBar, for now.. --- src/findbar.cpp | 11 ++--- src/findbar.h | 2 +- src/mainwindow.cpp | 125 ++++++++++++++++++++++------------------------------- src/mainwindow.h | 3 +- 4 files changed, 61 insertions(+), 80 deletions(-) diff --git a/src/findbar.cpp b/src/findbar.cpp index 0e312e04..283453a8 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -113,13 +113,14 @@ void FindBar::clear() } -void FindBar::showFindBar() +void FindBar::show() { // show findbar if not visible - if (!isVisible()) - { - show(); - } + if (isVisible()) + return; + + QWidget::show(); + // set focus to findbar if user select showFindBar shortcut m_lineEdit->setFocus(); m_lineEdit->selectAll(); diff --git a/src/findbar.h b/src/findbar.h index a8a78970..739a573e 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -50,7 +50,7 @@ public: public slots: void clear(); - void showFindBar(); + void show(); protected Q_SLOTS: void keyPressEvent(QKeyEvent* event); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 83f64926..db5a768c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -90,6 +90,7 @@ MainWindow::MainWindow() : KXmlGuiWindow() , m_view(new MainView(this)) , m_searchBar(new SearchBar(this)) + , m_findBar(new FindBar(this)) , m_sidePanel(0) { // updating rekonq configuration @@ -103,6 +104,7 @@ MainWindow::MainWindow() QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_view); + layout->addWidget(m_findBar); centralWidget->setLayout(layout); // central widget @@ -157,11 +159,6 @@ void MainWindow::postLaunch() connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int))); connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); - // FIXME: these slots will be commented out until rekonq will have just ONE mainwindow -// connect(m_view, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(geometryChangeRequested(const QRect &))); -// connect(m_view, SIGNAL(menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT(setVisible(bool))); -// connect(m_view, SIGNAL(statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT(setVisible(bool))); - // status bar messages connect(m_view, SIGNAL(showStatusBarMessage(const QString&)), statusBar(), SLOT(showMessage(const QString&))); connect(m_view, SIGNAL(linkHovered(const QString&)), statusBar(), SLOT(showMessage(const QString&))); @@ -171,7 +168,7 @@ void MainWindow::postLaunch() connect(m_view, SIGNAL(currentChanged(int)), this, SLOT(slotUpdateActions())); // Find Bar signal -// connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(slotFind(const QString &))); + connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(slotFind(const QString &))); // bookmarks loading connect(Application::bookmarkProvider(), SIGNAL(openUrl(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); @@ -225,7 +222,7 @@ void MainWindow::setupActions() KStandardAction::printPreview(this, SLOT(slotFilePrintPreview()), actionCollection()); KStandardAction::print(this, SLOT(slotFilePrint()), actionCollection()); KStandardAction::quit(this , SLOT(close()), actionCollection()); - KStandardAction::find(this, SLOT(slotViewFindBar()) , actionCollection()); + KStandardAction::find(m_findBar, SLOT(show()) , actionCollection()); KStandardAction::findNext(this, SLOT(slotFindNext()) , actionCollection()); KStandardAction::findPrev(this, SLOT(slotFindPrevious()) , actionCollection()); @@ -618,6 +615,7 @@ void MainWindow::slotPrivateBrowsing(bool enable) } } + void MainWindow::slotFind(const QString & search) { if (!currentTab()) @@ -627,70 +625,47 @@ void MainWindow::slotFind(const QString & search) } -void MainWindow::slotViewFindBar() +void MainWindow::slotFindNext() { -// // creating a centralWidget containing panel, m_view and the hidden findbar -// QWidget *centralWidget = new QWidget; -// centralWidget->setContentsMargins(0, 0, 0, 0); -// -// // setting layout -// QVBoxLayout *layout = new QVBoxLayout; -// layout->setContentsMargins(0, 0, 0, 0); -// layout->addWidget(m_view); -// centralWidget->setLayout(layout); -// -// // m_findBar->showFindBar(); -// // m_findBar->show(); - QWidget *w = centralWidget(); - QLayout *l = w->layout(); - QWidget *searchBarWidget = currentTab()->searchBar(); - searchBarWidget->show(); - l->addWidget(searchBarWidget); - w->setLayout(l); -} + if (!currentTab() && m_lastSearch.isEmpty()) + return; + QWebPage::FindFlags options; + if (m_findBar->matchCase()) + { + options = QWebPage::FindCaseSensitively | QWebPage::FindWrapsAroundDocument; + } + else + { + options = QWebPage::FindWrapsAroundDocument; + } -void MainWindow::slotFindNext() -{ -// if (!currentTab() && m_lastSearch.isEmpty()) -// return; -// -// QWebPage::FindFlags options; -// if (m_findBar->matchCase()) -// { -// options = QWebPage::FindCaseSensitively | QWebPage::FindWrapsAroundDocument; -// } -// else -// { -// options = QWebPage::FindWrapsAroundDocument; -// } -// -// if (!currentTab()->findText(m_lastSearch, options)) -// { -// slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); -// } + if (!currentTab()->findText(m_lastSearch, options)) + { + slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); + } } void MainWindow::slotFindPrevious() { -// if (!currentTab() && m_lastSearch.isEmpty()) -// return; -// -// QWebPage::FindFlags options; -// if (m_findBar->matchCase()) -// { -// options = QWebPage::FindCaseSensitively | QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; -// } -// else -// { -// options = QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; -// } -// -// if (!currentTab()->findText(m_lastSearch, options)) -// { -// slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); -// } + if (!currentTab() && m_lastSearch.isEmpty()) + return; + + QWebPage::FindFlags options; + if (m_findBar->matchCase()) + { + options = QWebPage::FindCaseSensitively | QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; + } + else + { + options = QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; + } + + if (!currentTab()->findText(m_lastSearch, options)) + { + slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); + } } @@ -801,10 +776,10 @@ void MainWindow::slotToggleInspector(bool enable) if (enable) { int result = KMessageBox::questionYesNo(this, - i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n" - "Do you want to reload all pages?"), - i18n("Web Inspector") - ); + i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n" + "Do you want to reload all pages?"), + i18n("Web Inspector") + ); if (result == KMessageBox::Yes) { @@ -931,12 +906,16 @@ bool MainWindow::queryClose() int answer = KMessageBox::questionYesNoCancel( this, - i18np("Are you sure you want to close the window?\n" "You have 1 tab open","Are you sure you want to close the window?\n" "You have %1 tabs open" , m_view->count()), - i18n("Are you sure you want to close the window?"), - KStandardGuiItem::quit(), - KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")), - KStandardGuiItem::cancel(), - "confirmClosingMultipleTabs" + i18np( "Are you sure you want to close the window?\n" + "You have 1 tab open", + "Are you sure you want to close the window?\n" + "You have %1 tabs open", + m_view->count()), + i18n("Are you sure you want to close the window?"), + KStandardGuiItem::quit(), + KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")), + KStandardGuiItem::cancel(), + "confirmClosingMultipleTabs" ); switch (answer) diff --git a/src/mainwindow.h b/src/mainwindow.h index 87003005..7d0b2e5c 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -44,6 +44,7 @@ class KIcon; class KMenu; class HistoryMenu; +class FindBar; class SidePanel; class WebView; @@ -117,7 +118,6 @@ private slots: void slotViewTextSmaller(); void slotViewPageSource(); void slotViewFullScreen(bool enable); - void slotViewFindBar(); // Tools Menu slots void slotToggleInspector(bool enable); @@ -129,6 +129,7 @@ private slots: private: MainView *m_view; SearchBar *m_searchBar; + FindBar *m_findBar; SidePanel *m_sidePanel; KMenu *m_historyBackMenu; -- cgit v1.2.1 From aec95ee71d1e47580e66cbdc11d61dca815a8d0b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 28 May 2009 12:04:06 +0200 Subject: cosmetic --- src/networkaccessmanager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index d0c9833b..7f05bf1c 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -168,7 +168,9 @@ void NetworkAccessManager::slotSSLErrors(QNetworkReply *reply, const QListurl().toString() + "\n\n" + QString(errors) + "\n\n"); + int ret = KMessageBox::warningContinueCancel(mainWindow, + i18n("SSL Errors:\n\n") + reply->url().toString() + "\n\n" + QString(errors) + "\n\n"); + if (ret == KMessageBox::Yes) reply->ignoreSslErrors(); } -- cgit v1.2.1