mirror of
https://github.com/LMMS/lmms.git
synced 2026-05-17 19:24:52 -04:00
DataFile: added nested LocaleHelper class
In order to address issues with differently coded floating points in strings provide a helper class which can be instantiated when loading or saving data.
This commit is contained in:
@@ -61,6 +61,38 @@ DataFile::typeDescStruct
|
||||
|
||||
|
||||
|
||||
DataFile::LocaleHelper::LocaleHelper( Mode mode )
|
||||
{
|
||||
switch( mode )
|
||||
{
|
||||
case ModeLoad:
|
||||
// set a locale for which QString::fromFloat() returns valid values if
|
||||
// floating point separator is a comma - otherwise we would fail to load
|
||||
// older projects made by people from various countries due to their
|
||||
// locale settings
|
||||
QLocale::setDefault( QLocale::German );
|
||||
break;
|
||||
|
||||
case ModeSave:
|
||||
// set default locale to C so that floating point decimals are rendered to
|
||||
// strings with periods as decimal point instead of commas in some countries
|
||||
QLocale::setDefault( QLocale::C );
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
DataFile::LocaleHelper::~LocaleHelper()
|
||||
{
|
||||
// revert to original locale
|
||||
QLocale::setDefault( QLocale::system() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
DataFile::DataFile( Type type ) :
|
||||
QDomDocument( "lmms-project" ),
|
||||
m_content(),
|
||||
|
||||
Reference in New Issue
Block a user