From a192acacf9588121cb6ecb561b76c65340adcafd Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Mon, 29 Jun 2020 19:16:36 +0200 Subject: [PATCH] better default settings file name handling --- ChangeLog | 4 ++++ src/settings.cpp | 14 +++++--------- src/settings.h | 11 ++++++----- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b24a8bb..ea1b5898 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/settings.cpp b/src/settings.cpp index 0920d18b..bb63c38c 100755 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -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; } } diff --git a/src/settings.h b/src/settings.h index b56f6aab..ab02d432 100755 --- a/src/settings.h +++ b/src/settings.h @@ -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