From 8b9bfd7c0d1d52f6ecdc0bdaaca9241040e9eb4a Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 8 May 2011 15:05:52 +0200 Subject: [PATCH] When downloading a file from a blank tab with no history (fe. from target="_blank" link), the blank tab will be closed after starting download --- src/downloads/downloaditem.cpp | 2 ++ src/webview/webpage.h | 1 + src/webview/webview.h | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/downloads/downloaditem.cpp b/src/downloads/downloaditem.cpp index 0e4dfd1c5..7a85a0f34 100644 --- a/src/downloads/downloaditem.cpp +++ b/src/downloads/downloaditem.cpp @@ -92,6 +92,8 @@ DownloadItem::DownloadItem(QListWidgetItem* item, QNetworkReply* reply, QString m_downloadPage = webPage->mainFrame()->url(); else if (webPage->history()->canGoBack()) m_downloadPage = webPage->history()->backItem().url(); + else if (webPage->history()->count() == 0) + webPage->getView()->closeTab(); } } diff --git a/src/webview/webpage.h b/src/webview/webpage.h index d87a289b7..6476bf860 100644 --- a/src/webview/webpage.h +++ b/src/webview/webpage.h @@ -45,6 +45,7 @@ public: void populateNetworkRequest(QNetworkRequest &request); ~WebPage(); + WebView* getView() { return m_view; } void setSSLCertificate(const QSslCertificate &cert); QSslCertificate sslCertificate(); QString userAgentForUrl(const QUrl &url) const; diff --git a/src/webview/webview.h b/src/webview/webview.h index ad6d3220f..e31c2a74b 100644 --- a/src/webview/webview.h +++ b/src/webview/webview.h @@ -69,6 +69,7 @@ public slots: void slotReload(){ if (page()) {emit ipChanged(m_currentIp); page()->triggerAction(QWebPage::Reload);} } void iconChanged(); void selectAll(); + void closeTab(); void zoomIn(); void zoomOut(); @@ -90,7 +91,6 @@ private slots: void linkHovered(const QString &link, const QString &title, const QString &content); void openUrlInNewWindow(); void openUrlInNewTab(); - void closeTab(); void downloadLinkToDisk(); void sendLinkByMail(); void bookmarkLink();