Use KRecentDirs to "remember" the right directory for saving
This commit is contained in:
parent
fa9bc0918e
commit
a560b6f7c8
1 changed files with 9 additions and 4 deletions
|
@ -46,6 +46,7 @@
|
||||||
#include <KIO/FileCopyJob>
|
#include <KIO/FileCopyJob>
|
||||||
#include <KIO/MimetypeJob>
|
#include <KIO/MimetypeJob>
|
||||||
#include <KIOFileWidgets/KFileWidget>
|
#include <KIOFileWidgets/KFileWidget>
|
||||||
|
#include <KIOFileWidgets/KRecentDirs>
|
||||||
|
|
||||||
#ifdef WITH_KFILEMETADATA
|
#ifdef WITH_KFILEMETADATA
|
||||||
#include <KFileMetaData/kfilemetadata/usermetadata.h>
|
#include <KFileMetaData/kfilemetadata/usermetadata.h>
|
||||||
|
@ -493,9 +494,8 @@ void DanbooruMainWindow::slotHandleDownload(const QUrl &url, const QVariant tags
|
||||||
saveDialog->setAcceptMode(QFileDialog::AcceptSave);
|
saveDialog->setAcceptMode(QFileDialog::AcceptSave);
|
||||||
saveDialog->setFileMode(QFileDialog::AnyFile);
|
saveDialog->setFileMode(QFileDialog::AnyFile);
|
||||||
saveDialog->setDirectoryUrl(KFileWidget::getStartUrl(
|
saveDialog->setDirectoryUrl(KFileWidget::getStartUrl(
|
||||||
QUrl(QStringLiteral("kfiledialog://danbooru-client")), recentClass));
|
QUrl(QStringLiteral("kfiledialog:///danbooru-client")).toLocalFile(),
|
||||||
|
recentClass));
|
||||||
|
|
||||||
|
|
||||||
saveDialog->setOption(QFileDialog::DontConfirmOverwrite, false);
|
saveDialog->setOption(QFileDialog::DontConfirmOverwrite, false);
|
||||||
|
|
||||||
|
@ -518,13 +518,18 @@ void DanbooruMainWindow::slotHandleDownload(const QUrl &url, const QVariant tags
|
||||||
saveDialog->selectFile(remoteFile);
|
saveDialog->selectFile(remoteFile);
|
||||||
saveDialog->open();
|
saveDialog->open();
|
||||||
|
|
||||||
connect(saveDialog, &QFileDialog::finished, [this, tagList, saveDialog, url](int result) {
|
connect(saveDialog, &QFileDialog::finished, [this, tagList, saveDialog, url, recentClass](int result) {
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
||||||
// TODO: KRecentDirs
|
// TODO: KRecentDirs
|
||||||
|
|
||||||
QUrl localFile = saveDialog->selectedUrls().at(0);
|
QUrl localFile = saveDialog->selectedUrls().at(0);
|
||||||
|
|
||||||
|
if (!recentClass.isEmpty()) {
|
||||||
|
KRecentDirs::add(recentClass, QFileInfo(localFile.toLocalFile()).absoluteFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
if (!localFile.isEmpty()) {
|
if (!localFile.isEmpty()) {
|
||||||
|
|
||||||
KIO::FileCopyJob *job = KIO::file_copy(url, localFile, -1, KIO::DefaultFlags);
|
KIO::FileCopyJob *job = KIO::file_copy(url, localFile, -1, KIO::DefaultFlags);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue