From cab1fa4ca9ececd7045c99a8103088287fb55306 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 22 May 2011 11:05:36 +0200 Subject: [PATCH] Every WebPage chooseFile dialog is now saving last location to speed up uploading multiple files --- src/webview/webpage.cpp | 16 ++++++++++++++++ src/webview/webpage.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/webview/webpage.cpp b/src/webview/webpage.cpp index 035dd595b..9395af6c6 100644 --- a/src/webview/webpage.cpp +++ b/src/webview/webpage.cpp @@ -32,6 +32,7 @@ WebPage::WebPage(WebView* parent, QupZilla* mainClass) ,p_QupZilla(mainClass) ,m_view(parent) ,m_blockAlerts(false) + ,m_lastUploadLocation(QDir::homePath()) // ,m_isOpeningNextWindowAsNewTab(false) { setForwardUnsupportedContent(true); @@ -386,6 +387,21 @@ void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg) _view->setFocus(); } +QString WebPage::chooseFile(QWebFrame *originatingFrame, const QString &oldFile) +{ + QString suggFileName; + if (oldFile.isEmpty()) + suggFileName = m_lastUploadLocation; + else + suggFileName = oldFile; + QString fileName = QFileDialog::getOpenFileName(originatingFrame->page()->view(), tr("Choose file..."), suggFileName); + + if (!fileName.isEmpty()) + m_lastUploadLocation = fileName; + + return fileName; +} + WebPage::~WebPage() { setNetworkAccessManager(0); diff --git a/src/webview/webpage.h b/src/webview/webpage.h index 6f4ae0e85..b986a8d96 100644 --- a/src/webview/webpage.h +++ b/src/webview/webpage.h @@ -67,6 +67,8 @@ private: virtual bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output = 0); bool acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest &request, NavigationType type); + QString chooseFile(QWebFrame *originatingFrame, const QString &oldFile); + QupZilla* p_QupZilla; QNetworkRequest m_lastRequest; QWebPage::NavigationType m_lastRequestType; @@ -75,6 +77,7 @@ private: QList m_SslCerts; QList m_adBlockedEntries; bool m_blockAlerts; + QString m_lastUploadLocation; // bool m_isOpeningNextWindowAsNewTab; };