D18352: Remember last output save directory
Kurt Hindenburg
noreply at phabricator.kde.org
Thu Apr 4 22:20:02 BST 2019
hindenburg added a comment.
This was what I was thinking about - it seems to work - let me know if you have concerns.
diff --git a/src/SaveHistoryTask.cpp b/src/SaveHistoryTask.cpp
index a202914d..4f31e3a8 100644
--- a/src/SaveHistoryTask.cpp
+++ b/src/SaveHistoryTask.cpp
@@ -26,6 +26,9 @@
#include <KMessageBox>
#include <KLocalizedString>
+#include <KSharedConfig>
+#include <KConfig>
+#include <KConfigGroup>
#include "SessionManager.h"
#include "Emulation.h"
@@ -45,9 +48,7 @@ void SaveHistoryTask::execute()
// three then providing a URL for each one will be tedious
// TODO - show a warning ( preferably passive ) if saving the history output fails
- QFileDialog* dialog = new QFileDialog(QApplication::activeWindow(),
- QString(),
- QDir::homePath());
+ QFileDialog* dialog = new QFileDialog(QApplication::activeWindow());
dialog->setAcceptMode(QFileDialog::AcceptSave);
QStringList mimeTypes {
@@ -56,6 +57,15 @@ void SaveHistoryTask::execute()
};
dialog->setMimeTypeFilters(mimeTypes);
+ KSharedConfigPtr konsoleConfig = KSharedConfig::openConfig();
+ const auto group = konsoleConfig->group("KFileDialog Settings");
+ const auto list = group.readPathEntry("Recent URLs", QStringList());
+ if (list.isEmpty()) {
+ dialog->setDirectory(QDir::homePath());
+ } else {
+ dialog->setDirectoryUrl(QUrl(list.at(0)));
+ }
+
// iterate over each session in the task and display a dialog to allow the user to choose where
// to save that session's history.
// then start a KIO job to transfer the data from the history to the chosen URL
REPOSITORY
R319 Konsole
REVISION DETAIL
https://phabricator.kde.org/D18352
To: guotao, #konsole
Cc: hindenburg, ngraham, mglb, konsole-devel, gennad, thsurrel, maximilianocuria
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/konsole-devel/attachments/20190404/b123d277/attachment.html>
More information about the konsole-devel
mailing list