From 7278462e12a6e41bb0e9496520e7a00d97856ce6 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Mon, 3 Aug 2015 13:19:51 +0200 Subject: remember user settings Change-Id: I69c4672646365ca4cbeb04d6956741ffe365ad35 --- fpicker/source/office/RemoteFilesDialog.cxx | 33 +++++++++++++++++++++++++++++ fpicker/source/office/RemoteFilesDialog.hxx | 6 ++++++ 2 files changed, 39 insertions(+) (limited to 'fpicker') diff --git a/fpicker/source/office/RemoteFilesDialog.cxx b/fpicker/source/office/RemoteFilesDialog.cxx index cdb38ec996e2..dde7eebcb81c 100644 --- a/fpicker/source/office/RemoteFilesDialog.cxx +++ b/fpicker/source/office/RemoteFilesDialog.cxx @@ -249,6 +249,9 @@ RemoteFilesDialog::RemoteFilesDialog( vcl::Window* pParent, WinBits nBits ) m_pContainer->Show(); m_pContainer->Enable( false ); + m_sIniKey = "RemoteFilesDialog"; + InitSize(); + m_pName_ed->SetGetFocusHdl( LINK( this, RemoteFilesDialog, FileNameGetFocusHdl ) ); m_pName_ed->SetModifyHdl( LINK( this, RemoteFilesDialog, FileNameModifyHdl ) ); @@ -273,6 +276,17 @@ void RemoteFilesDialog::dispose() { m_pFileView->SetSelectHdl( Link<>() ); + // save window state + if( !m_sIniKey.isEmpty() ) + { + SvtViewOptions aDlgOpt( E_DIALOG, m_sIniKey ); + aDlgOpt.SetWindowState( OStringToOUString( GetWindowState(), osl_getThreadTextEncoding() ) ); + OUString sUserData = m_pFileView->GetConfigString(); + aDlgOpt.SetUserItem( OUString( "UserData" ), + makeAny( sUserData ) ); + } + + // save services std::shared_ptr< comphelper::ConfigurationChanges > batch( comphelper::ConfigurationChanges::create( m_context ) ); officecfg::Office::Common::Misc::FilePickerLastService::set( m_sLastServiceUrl, batch ); @@ -381,6 +395,25 @@ OUString lcl_GetServiceType( ServicePtr pService ) } } +void RemoteFilesDialog::InitSize() +{ + if( m_sIniKey.isEmpty() ) + return; + + // initialize from config + SvtViewOptions aDlgOpt( E_DIALOG, m_sIniKey ); + + if( aDlgOpt.Exists() ) + { + SetWindowState( OUStringToOString( aDlgOpt.GetWindowState(), osl_getThreadTextEncoding() ) ); + + Any aUserData = aDlgOpt.GetUserItem( OUString( "UserData" ) ); + OUString sCfgStr; + if( aUserData >>= sCfgStr ) + m_pFileView->SetConfigString( sCfgStr ); + } +} + void RemoteFilesDialog::FillServicesListbox() { m_pServices_lb->Clear(); diff --git a/fpicker/source/office/RemoteFilesDialog.hxx b/fpicker/source/office/RemoteFilesDialog.hxx index 2bb7c353c1bd..ea6af5f281aa 100644 --- a/fpicker/source/office/RemoteFilesDialog.hxx +++ b/fpicker/source/office/RemoteFilesDialog.hxx @@ -19,6 +19,8 @@ #include #include +#include + #include #include #include @@ -121,6 +123,8 @@ private: bool m_bIsConnected; bool m_bServiceChanged; + OUString m_sIniKey; + OUString m_sPath; OUString m_sStdDir; OUString m_sLastServiceUrl; @@ -147,6 +151,8 @@ private: std::vector< ServicePtr > m_aServices; std::vector< std::pair< OUString, OUString > > m_aFilters; + void InitSize(); + void FillServicesListbox(); /* If failure returns < 0 */ -- cgit