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 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 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 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 TODO https://github.com/corrados/jamulus/issues/341#issuecomment-647172946
- generate .qm on compile time with lrelease - 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 // prepare file name for loading initialization data from XML file and read
// data from file if possible // data from file if possible
QFile file ( strFileName ); QFile file ( strFileName );
if ( file.open ( QIODevice::ReadOnly ) ) if ( file.open ( QIODevice::ReadOnly ) )
{ {
QTextStream in ( &file ); QTextStream in ( &file );
@ -690,11 +691,13 @@ void CSettings::Save()
// Help functions ************************************************************** // 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 // return the file name with complete path, take care if given file name is
// empty // empty
strFileName = sNFiName; strFileName = sNFiName;
if ( strFileName.isEmpty() ) if ( strFileName.isEmpty() )
{ {
// we use the Qt default setting file paths for the different OSs by // 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 // append the actual file name
if ( bIsClient ) strFileName = sConfigDir + "/" + sDefaultFileName;
{
strFileName = sConfigDir + "/" + DEFAULT_INI_FILE_NAME;
}
else
{
strFileName = sConfigDir + "/" + DEFAULT_INI_FILE_NAME_SERVER;
}
} }
} }

View File

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