@ -26,12 +26,17 @@
# include <KMessageBox>
# include <KLocalizedString>
# include <KSharedConfig>
# include <KConfig>
# include <KConfigGroup>
# include "SessionManager.h"
# include "Emulation.h"
namespace Konsole {
QString SaveHistoryTask : : _saveDialogRecentURL ;
SaveHistoryTask : : SaveHistoryTask ( QObject * parent )
: SessionTask ( parent )
{
@ -45,9 +50,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 +59,20 @@ void SaveHistoryTask::execute()
} ;
dialog - > setMimeTypeFilters ( mimeTypes ) ;
KSharedConfigPtr konsoleConfig = KSharedConfig : : openConfig ( ) ;
auto group = konsoleConfig - > group ( " SaveHistory Settings " ) ;
if ( _saveDialogRecentURL . isEmpty ( ) ) {
const auto list = group . readPathEntry ( " Recent URLs " , QStringList ( ) ) ;
if ( list . isEmpty ( ) ) {
dialog - > setDirectory ( QDir : : homePath ( ) ) ;
} else {
dialog - > setDirectoryUrl ( QUrl ( list . at ( 0 ) ) ) ;
}
} else {
dialog - > setDirectoryUrl ( QUrl ( _saveDialogRecentURL ) ) ;
}
// 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
@ -76,6 +93,10 @@ void SaveHistoryTask::execute()
continue ;
}
// Save selected URL for next time
_saveDialogRecentURL = url . adjusted ( QUrl : : RemoveFilename | QUrl : : StripTrailingSlash ) . toString ( ) ;
group . writePathEntry ( " Recent URLs " , _saveDialogRecentURL ) ;
KIO : : TransferJob * job = KIO : : put ( url ,
- 1 , // no special permissions
// overwrite existing files