summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHarald Sitter <sitter@kde.org>2013-04-10 08:25:07 +0200
committerHarald Sitter <sitter@kde.org>2013-04-10 08:25:07 +0200
commitf80a8adb5e94d7cf9ebdc76759e5fe78bf5891de (patch)
tree1afcb6b1da1e26571dedea75ba829cbfdaff316a /src
parentAlways show the open link in new tab/window contextual actions (diff)
downloadrekonq-f80a8adb5e94d7cf9ebdc76759e5fe78bf5891de.tar.xz
downloads should by default go to the configured downloads directory
also fixed a yoda-style comment about not using getSaveFileName REVIEW: 109927
Diffstat (limited to 'src')
-rw-r--r--src/download/downloadmanager.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/download/downloadmanager.cpp b/src/download/downloadmanager.cpp
index 1189ec18..7bd217ee 100644
--- a/src/download/downloadmanager.cpp
+++ b/src/download/downloadmanager.cpp
@@ -36,6 +36,8 @@
#include <KStandardDirs>
#include <KToolInvocation>
#include <KFileDialog>
+#include <krecentdirs.h>
+
#include <kio/scheduler.h>
@@ -220,9 +222,29 @@ bool DownloadManager::downloadResource(const KUrl &srcUrl, const KIO::MetaData &
if (forceDirRequest || ReKonfig::askDownloadPath())
{
// follow bug:184202 fixes
- // NOTE: Please, NO MORE use here getSaveFileName as it seems it cannot properly
- // handle remote urls
- destUrl = KFileDialog::getSaveUrl(fileName, QString(), parent);
+
+ // Downloads should default to the default download directory. At the
+ // same time when the user has been using a different directory
+ // previously, it should be used instead.
+ // To enable this behavior we inject the default download path into
+ // KRecentDirs (which is internally used by KFileDialog to get the
+ // most recently used directory of a fileclass).
+ // If a user then uses a different directory it will replace the
+ // downloads directory in KRecentDirs and become the new default when
+ // trying to save a file. Also see KFileDialog, KFileWidget and
+ // KRecentDirs documentation.
+
+ // If this is the first invocation insert the defaults downloads directory.
+ static const QString fileClass = QL1S(":download");
+ if (KRecentDirs::list(fileClass).count() <= 1) // Always has one entry by default.
+ KRecentDirs::add(fileClass, KGlobalSettings::downloadPath());
+
+ const KUrl startDir(QString("kfiledialog:///download/%1").arg(fileName));
+
+ // NOTE: We used to use getSaveFileName here but it proved unable to
+ // handle remote URLs, which we need to handle here, making the use of
+ // getSaveUrl deliberate.
+ destUrl = KFileDialog::getSaveUrl(startDir, QString(), parent);
}
else
{