diff options
-rw-r--r-- | src/webpage.cpp | 21 | ||||
-rw-r--r-- | src/webpage.h | 11 | ||||
-rw-r--r-- | src/webview.cpp | 9 |
3 files changed, 29 insertions, 12 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp index b0397870..9da75a91 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -296,7 +296,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) isLocal ? KMessageBox::sorry(view(), i18n("No service can handle this :(")) - : downloadRequest(reply->request()); + : downloadThings(reply->request(), suggestedFileName); return; } @@ -312,7 +312,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { case KParts::BrowserOpenOrSaveQuestion::Save: kDebug() << "service handling: download!"; - downloadRequest(reply->request()); + downloadThings(reply->request(), suggestedFileName); return; case KParts::BrowserOpenOrSaveQuestion::Cancel: @@ -491,15 +491,28 @@ QString WebPage::errorPage(QNetworkReply *reply) // this code is actually copied from KWebPage::downloadRequest to save // downloads data before. If you have some better ideas about, // feel free to let us know about :) -void WebPage::downloadRequest(const QNetworkRequest &request) +void WebPage::downloadThings(const QNetworkRequest &request, const QString &suggestedFileName) { KUrl destUrl; KUrl srcUrl(request.url()); + + if( !ReKonfig::kgetDownload() && suggestedFileName.isEmpty() ) + { + kDebug() << "Using KWebPage downloadRequest.."; + Application::historyManager()->addDownload(srcUrl.pathOrUrl() , destUrl.pathOrUrl()); + KWebPage::downloadRequest(request); + return; + } + int result = KIO::R_OVERWRITE; do { - destUrl = KFileDialog::getSaveFileName(srcUrl.fileName(), QString(), view()); + QString fName = suggestedFileName.isEmpty() + ? srcUrl.fileName() + : suggestedFileName; + + destUrl = KFileDialog::getSaveFileName(fName, QString(), view()); if (destUrl.isLocalFile()) { diff --git a/src/webpage.h b/src/webpage.h index 9b2243bc..eff4c3fc 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -67,7 +67,6 @@ public: inline void setIsOnRekonqPage(bool b) { _isOnRekonqPage = b; }; public slots: - virtual void downloadRequest(const QNetworkRequest &request); void downloadAllContentsWithKGet(QPoint); protected: @@ -84,7 +83,15 @@ private slots: void showSSLInfo(QPoint); void updateImage(bool ok); -private: + /** + * This new slot is needed to provide integration between rekonq & KGet, + * to better manage file names and to not overwrite KWebPage default behavior on need + * + * @see KWebPage::downloadRequest. + */ + void downloadThings(const QNetworkRequest &request, const QString &suggestedFileName = QString()); + +private: QString errorPage(QNetworkReply *reply); QUrl _loadingUrl; diff --git a/src/webview.cpp b/src/webview.cpp index e7226740..1996d6af 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -76,14 +76,11 @@ WebView::WebView(QWidget* parent) setPage(page); // download system - connect(this, SIGNAL(linkShiftClicked(const KUrl &)), - page, SLOT(downloadUrl(const KUrl &))); - connect(page, SIGNAL(downloadRequested(const QNetworkRequest &)), - page, SLOT(downloadRequest(const QNetworkRequest &))); + connect(this, SIGNAL(linkShiftClicked(const KUrl &)), page, SLOT(downloadUrl(const KUrl &))); + connect(page, SIGNAL(downloadRequested(const QNetworkRequest &)), page, SLOT(downloadThings(const QNetworkRequest &))); // middle click || ctrl + click signal - connect(this, SIGNAL(linkMiddleOrCtrlClicked(const KUrl &)), - this, SLOT(loadUrlInNewTab(const KUrl &))); + connect(this, SIGNAL(linkMiddleOrCtrlClicked(const KUrl &)), this, SLOT(loadUrlInNewTab(const KUrl &))); // loadUrl signal connect(this, SIGNAL(loadUrl(const KUrl &, const Rekonq::OpenType &)), |