better default settings file name handling

This commit is contained in:
Volker Fischer 2020-06-29 19:16:36 +02:00
parent 31bae6836e
commit a192acacf9
3 changed files with 15 additions and 14 deletions

View File

@ -4,10 +4,14 @@
3.5.8git
TODO bug fix: incorrect selection of UI language (#408)
TODO improve settings management -> move settings class in client/server classes, move actual settings variables
TODO add new register message which contains version and, e.g., max number of clients
TODO bug fix: grouping faders in the client should be proportional (see discussion in #202)
TODO https://github.com/corrados/jamulus/issues/341#issuecomment-647172946
- generate .qm on compile time with lrelease

View File

@ -36,6 +36,7 @@ void CSettings::Load()
// prepare file name for loading initialization data from XML file and read
// data from file if possible
QFile file ( strFileName );
if ( file.open ( QIODevice::ReadOnly ) )
{
QTextStream in ( &file );
@ -690,11 +691,13 @@ void CSettings::Save()
// Help functions **************************************************************
void CSettings::SetFileName ( const QString& sNFiName )
void CSettings::SetFileName ( const QString& sNFiName,
const QString& sDefaultFileName )
{
// return the file name with complete path, take care if given file name is
// empty
strFileName = sNFiName;
if ( strFileName.isEmpty() )
{
// we use the Qt default setting file paths for the different OSs by
@ -713,14 +716,7 @@ void CSettings::SetFileName ( const QString& sNFiName )
}
// append the actual file name
if ( bIsClient )
{
strFileName = sConfigDir + "/" + DEFAULT_INI_FILE_NAME;
}
else
{
strFileName = sConfigDir + "/" + DEFAULT_INI_FILE_NAME_SERVER;
}
strFileName = sConfigDir + "/" + sDefaultFileName;
}
}

View File

@ -40,18 +40,19 @@ class CSettings
{
public:
CSettings ( CClient* pNCliP, const QString& sNFiName ) :
pClient ( pNCliP ), bIsClient ( true )
{ SetFileName ( sNFiName ); }
pClient ( pNCliP ), bIsClient ( true ), strFileName ( "" )
{ SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME ); }
CSettings ( CServer* pNSerP, const QString& sNFiName ) :
pServer ( pNSerP ), bIsClient ( false )
{ SetFileName ( sNFiName ); }
pServer ( pNSerP ), bIsClient ( false ), strFileName ( "" )
{ SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME_SERVER); }
void Load();
void Save();
protected:
void SetFileName ( const QString& sNFiName );
void SetFileName ( const QString& sNFiName,
const QString& sDefaultFileName );
// The following functions implement the conversion from the general string
// to base64 (which should be used for binary data in XML files). This