Improve settings code reability
Application::SetSettings relies on Application::GetSettings to initialize the application's settings if this hasn't happened. This means that GetSettings is being used not to get the app's settings, but to initialize the settings! I have corrected this by introducing a private static function InitSettings(). Note that I assert if it attempts to initialize already initialized settings, because the (Get|Set)Settings does the check for you. Also changed a local variable from nGet to nDragMode in Desktop::SystemSettingsChanging to make it easier to read the code. Whilst this is minor, a variable name of "nGet" seems very sloppy. Change-Id: I04975217c2028b3489179997db4287957578cc93 Reviewed-on: https://gerrit.libreoffice.org/7586 Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com> Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
This commit is contained in:
committed by
Norbert Thiebaud
parent
930202b0b2
commit
4959f369d9
@@ -1951,8 +1951,8 @@ void Desktop::SystemSettingsChanging( AllSettings& rSettings )
|
||||
sal_uInt32 nDragFullOptions = hStyleSettings.GetDragFullOptions();
|
||||
|
||||
SvtTabAppearanceCfg aAppearanceCfg;
|
||||
sal_uInt16 nGet = aAppearanceCfg.GetDragMode();
|
||||
switch ( nGet )
|
||||
sal_uInt16 nDragMode = aAppearanceCfg.GetDragMode();
|
||||
switch ( nDragMode )
|
||||
{
|
||||
case DragFullWindow:
|
||||
nDragFullOptions |= DRAGFULL_OPTION_ALL;
|
||||
|
@@ -780,6 +780,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
static void InitSettings();
|
||||
|
||||
DECL_STATIC_LINK( Application, PostEventHandler, void* );
|
||||
};
|
||||
|
||||
|
@@ -519,7 +519,7 @@ void Application::SetSettings( const AllSettings& rSettings )
|
||||
ImplSVData* pSVData = ImplGetSVData();
|
||||
if ( !pSVData->maAppData.mpSettings )
|
||||
{
|
||||
GetSettings();
|
||||
InitSettings();
|
||||
*pSVData->maAppData.mpSettings = rSettings;
|
||||
ResMgr::SetDefaultLocale( rSettings.GetUILanguageTag() );
|
||||
}
|
||||
@@ -618,14 +618,23 @@ const AllSettings& Application::GetSettings()
|
||||
ImplSVData* pSVData = ImplGetSVData();
|
||||
if ( !pSVData->maAppData.mpSettings )
|
||||
{
|
||||
pSVData->maAppData.mpCfgListener = new LocaleConfigurationListener;
|
||||
pSVData->maAppData.mpSettings = new AllSettings();
|
||||
pSVData->maAppData.mpSettings->GetSysLocale().GetOptions().AddListener( pSVData->maAppData.mpCfgListener );
|
||||
InitSettings();
|
||||
}
|
||||
|
||||
return *(pSVData->maAppData.mpSettings);
|
||||
}
|
||||
|
||||
void Application::InitSettings()
|
||||
{
|
||||
ImplSVData* pSVData = ImplGetSVData();
|
||||
|
||||
assert(!pSVData->maAppData.mpSettings); // initialization should not happen twice!
|
||||
|
||||
pSVData->maAppData.mpCfgListener = new LocaleConfigurationListener;
|
||||
pSVData->maAppData.mpSettings = new AllSettings();
|
||||
pSVData->maAppData.mpSettings->GetSysLocale().GetOptions().AddListener( pSVData->maAppData.mpCfgListener );
|
||||
}
|
||||
|
||||
void Application::NotifyAllWindows( DataChangedEvent& rDCEvt )
|
||||
{
|
||||
ImplSVData* pSVData = ImplGetSVData();
|
||||
|
Reference in New Issue
Block a user