summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-07-15 22:52:46 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-07-15 22:52:46 +0200
commitf7cabde3b757d606b4546080946ced207851bf0d (patch)
tree63489155e2889c508913d47958bdb14b416ab305
parentrekonq 0.1.8: closing to 0.2 release (diff)
downloadrekonq-f7cabde3b757d606b4546080946ced207851bf0d.tar.xz
Going back to simpler QtWebKit.
Seems more fast and stable, for now..
-rw-r--r--src/webpage.cpp97
-rw-r--r--src/webpage.h18
-rw-r--r--src/webview.cpp19
-rw-r--r--src/webview.h8
4 files changed, 122 insertions, 20 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 133a263c..e8e956ed 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -45,6 +45,9 @@
#include <KDE/KParts/BrowserRun>
#include <KDE/KMimeTypeTrader>
#include <KDE/KRun>
+#include <KDE/KFileDialog>
+#include <KDE/KInputDialog>
+#include <KDE/KMessageBox>
#include <kdewebkit/kwebpage.h>
#include <kdewebkit/kwebview.h>
@@ -65,9 +68,10 @@
#include <QtWebKit/QWebSettings>
#include <QtWebKit/QWebView>
+#include <QUiLoader>
WebPage::WebPage(QObject *parent)
- : KWebPage(parent)
+ : QWebPage(parent)
{
setForwardUnsupportedContent(true);
@@ -76,7 +80,7 @@ WebPage::WebPage(QObject *parent)
}
-KWebPage *WebPage::createWindow(QWebPage::WebWindowType type)
+QWebPage *WebPage::createWindow(QWebPage::WebWindowType type)
{
kDebug() << "creating window as new tab.. ";
@@ -113,7 +117,7 @@ void WebPage::slotHandleUnsupportedContent(QNetworkReply *reply)
switch (res)
{
case KParts::BrowserRun::Save:
- slotDownloadRequested(reply->request(), reply);
+ slotDownloadRequested(reply->request());
return;
case KParts::BrowserRun::Cancel:
return;
@@ -182,3 +186,90 @@ void WebPage::viewErrorPage(QNetworkReply *reply)
Application::historyManager()->removeHistoryEntry(reply->url(), mainFrame()->title());
}
}
+
+
+void WebPage::javaScriptAlert(QWebFrame *frame, const QString &msg)
+{
+ KMessageBox::error(frame->page()->view(), msg, i18n("JavaScript"));
+}
+
+
+bool WebPage::javaScriptConfirm(QWebFrame *frame, const QString &msg)
+{
+ return (KMessageBox::warningYesNo(frame->page()->view(), msg, i18n("JavaScript"), KStandardGuiItem::ok(), KStandardGuiItem::cancel())
+ == KMessageBox::Yes);
+}
+
+
+bool WebPage::javaScriptPrompt(QWebFrame *frame, const QString &msg, const QString &defaultValue, QString *result)
+{
+ bool ok = false;
+ *result = KInputDialog::getText(i18n("JavaScript"), msg, defaultValue, &ok, frame->page()->view());
+ return ok;
+}
+
+
+QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues)
+{
+ kDebug() << "create Plugin requested:";
+ kDebug() << "classid:" << classId;
+ kDebug() << "url:" << url;
+ kDebug() << "paramNames:" << paramNames << " paramValues:" << paramValues;
+
+ QUiLoader loader;
+ return loader.createWidget(classId, view());
+}
+
+
+void WebPage::slotDownloadRequested(const QNetworkRequest &request)
+{
+ const KUrl url(request.url());
+ kDebug() << url;
+
+// const QString fileName = d->getFileNameForDownload(request, reply);
+//
+// // parts of following code are based on khtml_ext.cpp
+// // DownloadManager <-> konqueror integration
+// // find if the integration is enabled
+// // the empty key means no integration
+// // only use download manager for non-local urls!
+// bool downloadViaKIO = true;
+// if (!url.isLocalFile()) {
+// KConfigGroup cfg = KSharedConfig::openConfig("konquerorrc", KConfig::NoGlobals)->group("HTML Settings");
+// const QString downloadManger = cfg.readPathEntry("DownloadManager", QString());
+// if (!downloadManger.isEmpty()) {
+// // then find the download manager location
+// kDebug() << "Using: " << downloadManger << " as Download Manager";
+// QString cmd = KStandardDirs::findExe(downloadManger);
+// if (cmd.isEmpty()) {
+// QString errMsg = i18n("The Download Manager (%1) could not be found in your $PATH.", downloadManger);
+// QString errMsgEx = i18n("Try to reinstall it. \n\nThe integration with Konqueror will be disabled.");
+// KMessageBox::detailedSorry(view(), errMsg, errMsgEx);
+// cfg.writePathEntry("DownloadManager", QString());
+// cfg.sync();
+// } else {
+// downloadViaKIO = false;
+// cmd += ' ' + KShell::quoteArg(url.url());
+// kDebug() << "Calling command" << cmd;
+// KRun::runCommand(cmd, view());
+// }
+// }
+// }
+//
+// if (downloadViaKIO) {
+// const QString destUrl = KFileDialog::getSaveFileName(url.fileName(), QString(), view());
+// if (destUrl.isEmpty()) return;
+// KIO::Job *job = KIO::file_copy(url, KUrl(destUrl), -1, KIO::Overwrite);
+// //job->setMetaData(metadata); //TODO: add metadata from request
+// job->addMetaData("MaxCacheSize", "0"); // Don't store in http cache.
+// job->addMetaData("cache", "cache"); // Use entry from cache if available.
+// job->uiDelegate()->setAutoErrorHandlingEnabled(true);
+// }
+}
+
+WebPage *WebPage::newWindow(WebWindowType type)
+{
+ Q_UNUSED(type);
+ return 0;
+}
+
diff --git a/src/webpage.h b/src/webpage.h
index c43212b6..1e25958c 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -37,7 +37,7 @@ class QWebFrame;
class QNetworkReply;
-class WebPage : public KWebPage
+class WebPage : public QWebPage
{
Q_OBJECT
@@ -48,11 +48,21 @@ public slots:
void manageNetworkErrors(QNetworkReply* reply);
protected:
- KWebPage *createWindow(QWebPage::WebWindowType type);
-
+ QWebPage *createWindow(QWebPage::WebWindowType type);
+ virtual WebPage *newWindow(WebWindowType type);
+
+// QString chooseFile(QWebFrame *frame, const QString &suggestedFile);
+
+ void javaScriptAlert(QWebFrame *frame, const QString &msg);
+ bool javaScriptConfirm(QWebFrame *frame, const QString &msg);
+ bool javaScriptPrompt(QWebFrame *frame, const QString &msg, const QString &defaultValue, QString *result);
+
+ QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
+
protected Q_SLOTS:
virtual void slotHandleUnsupportedContent(QNetworkReply *reply);
-
+ virtual void slotDownloadRequested(const QNetworkRequest &request);
+
private:
void viewErrorPage(QNetworkReply *);
diff --git a/src/webview.cpp b/src/webview.cpp
index f0aa6641..114a1be4 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -65,11 +65,12 @@
WebView::WebView(QWidget* parent)
- : KWebView(parent)
+ : QWebView(parent)
, m_page(new WebPage(this))
, m_progress(0)
{
setPage(m_page);
+
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()));
@@ -78,10 +79,10 @@ WebView::WebView(QWidget* parent)
}
-void WebView::setNewPage()
-{
- setPage(new WebPage(this));
-}
+// void WebView::setNewPage()
+// {
+// setPage(new WebPage(this));
+// }
KUrl WebView::url() const
@@ -102,10 +103,10 @@ int WebView::progress() const
}
-void WebView::load(const KUrl &url)
-{
- QWebView::load(url);
-}
+// void WebView::load(const KUrl &url)
+// {
+// QWebView::load(url);
+// }
void WebView::setProgress(int progress)
diff --git a/src/webview.h b/src/webview.h
index d8a6f3d6..c12582d4 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -40,7 +40,7 @@
class WebPage;
-class WebView : public KWebView
+class WebView : public QWebView
{
Q_OBJECT
@@ -51,8 +51,8 @@ public:
QString lastStatusBarText() const;
int progress() const;
-public Q_SLOTS:
- void load(const KUrl &url);
+// public Q_SLOTS:
+// void load(const KUrl &url);
signals:
// switching tabs
@@ -69,7 +69,7 @@ protected:
void keyPressEvent(QKeyEvent *event);
// to reimplement from KWebView
- virtual void setNewPage();
+// virtual void setNewPage();
private slots:
void setProgress(int progress);