diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-07-08 05:50:25 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-07-12 14:31:20 +0200 |
commit | d157c1bd70d630a58db33910d550bb8dee9fe62e (patch) | |
tree | 6a7d4a63cc524fcbbdcdfd8c4271fcbb7cd3c983 /sd/source | |
parent | c62bb20032cef7479e9293e84a8d57a2c74399d0 (diff) |
tdf#126665 Remember last used file picker directory
This introduces internal tracking of last used directories.
Each caller of the file picker can pass a "context". The selected
directory will then be saved & restored when opening the file picker
with the same context again.
After ffa636ba74b04b3258ec9a696bc4eac33581fa24 , the Windows file picker
no longer tracks the last used directory itself.
This is a replacement and an improvement at the same time, since there is not
one global last used directory, but one per context.
Change-Id: I10650cfb9359922690954fa65c89b4e47477e2c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118597
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/dlg/PhotoAlbumDialog.cxx | 30 | ||||
-rw-r--r-- | sd/source/ui/dlg/filedlg.cxx | 11 | ||||
-rw-r--r-- | sd/source/ui/dlg/tpaction.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/func/fuinsfil.cxx | 1 |
4 files changed, 8 insertions, 40 deletions
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx index 14e43dd75229..9c00afe4cdc4 100644 --- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx +++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx @@ -20,7 +20,6 @@ #include <unotools/pathoptions.hxx> #include <unotools/ucbstreamhelper.hxx> -#include <officecfg/Office/Impress.hxx> #include <vcl/graphicfilter.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> @@ -500,35 +499,16 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, FileHdl, weld::Button&, void) ::sfx2::FileDialogHelper aDlg( css::ui::dialogs::TemplateDescription::FILEOPEN_PREVIEW, FileDialogFlags::Graphic | FileDialogFlags::MultiSelection, m_xDialog.get()); - // Read configuration - OUString sUrl(officecfg::Office::Impress::Pictures::Path::get()); - - INetURLObject aFile( SvtPathOptions().GetUserConfigPath() ); - if (!sUrl.isEmpty()) - aDlg.SetDisplayDirectory(sUrl); - else - aDlg.SetDisplayDirectory( aFile.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); + aDlg.SetContext(sfx2::FileDialogHelper::ImpressPhotoDialog); if ( aDlg.Execute() == ERRCODE_NONE ) { const Sequence< OUString > aFilesArr = aDlg.GetSelectedFiles(); - if( aFilesArr.hasElements() ) + for ( const auto& rFile : aFilesArr ) { - sUrl = aDlg.GetDisplayDirectory(); - // Write out configuration - { - std::shared_ptr< comphelper::ConfigurationChanges > batch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Impress::Pictures::Path::set(sUrl, batch); - batch->commit(); - } - - for ( const auto& rFile : aFilesArr ) - { - // Store full path, show filename only. Use INetURLObject to display spaces in filename correctly - INetURLObject aUrl(rFile); - m_xImagesLst->append(aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE), aUrl.GetLastName(INetURLObject::DecodeMechanism::WithCharset), ""); - } + // Store full path, show filename only. Use INetURLObject to display spaces in filename correctly + INetURLObject aUrl(rFile); + m_xImagesLst->append(aUrl.GetMainURL(INetURLObject::DecodeMechanism::NONE), aUrl.GetLastName(INetURLObject::DecodeMechanism::WithCharset), ""); } } EnableDisableButtons(); diff --git a/sd/source/ui/dlg/filedlg.cxx b/sd/source/ui/dlg/filedlg.cxx index 05c4243dc539..a545f6dc946f 100644 --- a/sd/source/ui/dlg/filedlg.cxx +++ b/sd/source/ui/dlg/filedlg.cxx @@ -34,7 +34,6 @@ #include <filedlg.hxx> #include <sdresid.hxx> #include <strings.hrc> -#include <officecfg/Office/Impress.hxx> // ----------- SdFileDialog_Imp --------------------------- @@ -214,6 +213,7 @@ SdOpenSoundFileDialog::SdOpenSoundFileDialog(weld::Window *pParent) { OUString aDescr = SdResId(STR_ALL_FILES); mpImpl->AddFilter( aDescr, "*.*"); + mpImpl->SetContext(sfx2::FileDialogHelper::DrawImpressOpenSound); // setup filter #if defined UNX @@ -233,9 +233,6 @@ SdOpenSoundFileDialog::SdOpenSoundFileDialog(weld::Window *pParent) aDescr = SdResId(STR_MIDI_FILE); mpImpl->AddFilter( aDescr, "*.mid" ); #endif - - // Restore last selected path - mpImpl->SetDisplayDirectory(officecfg::Office::Impress::Sound::Path::get()); } SdOpenSoundFileDialog::~SdOpenSoundFileDialog() @@ -249,12 +246,6 @@ ErrCode SdOpenSoundFileDialog::Execute() OUString SdOpenSoundFileDialog::GetPath() const { - // Save last selected path - std::shared_ptr<comphelper::ConfigurationChanges> batch( - comphelper::ConfigurationChanges::create()); - officecfg::Office::Impress::Sound::Path::set(mpImpl->GetPath(), batch); - batch->commit(); - return mpImpl->GetPath(); } diff --git a/sd/source/ui/dlg/tpaction.cxx b/sd/source/ui/dlg/tpaction.cxx index 63fd24cb91aa..4cd0cf68af9d 100644 --- a/sd/source/ui/dlg/tpaction.cxx +++ b/sd/source/ui/dlg/tpaction.cxx @@ -401,11 +401,7 @@ void SdTPAction::OpenFileDialog() sfx2::FileDialogHelper aFileDialog( ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION, FileDialogFlags::NONE, GetFrameWeld()); - - if (bDocument && aFile.isEmpty()) - aFile = SvtPathOptions().GetWorkPath(); - - aFileDialog.SetDisplayDirectory( aFile ); + aFileDialog.SetContext(sfx2::FileDialogHelper::ImpressClickAction); // The following is a workaround for #i4306#: // The addition of the implicitly existing "all files" diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx index ff890dfb5ec7..aec950b0c779 100644 --- a/sd/source/ui/func/fuinsfil.cxx +++ b/sd/source/ui/func/fuinsfil.cxx @@ -133,6 +133,7 @@ void FuInsertFile::DoExecute( SfxRequest& rReq ) sfx2::FileDialogHelper aFileDialog( ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::Insert, mpWindow ? mpWindow->GetFrameWeld() : nullptr); + aFileDialog.SetContext(sfx2::FileDialogHelper::DrawImpressInsertFile); Reference< XFilePicker > xFilePicker( aFileDialog.GetFilePicker() ); Reference< XFilterManager > xFilterManager( xFilePicker, UNO_QUERY ); OUString aOwnCont; |