bug fix: support for correct utf-8 storage of names in the ini-file

This commit is contained in:
Volker Fischer 2013-12-15 10:54:17 +00:00
parent a0c318eeec
commit 9a2efd25fe
3 changed files with 36 additions and 22 deletions

View File

@ -6,6 +6,8 @@
- the solo state of a mixer fader is not exclusive any more and the solo
state is preserved if the number of mixer faders changes
- bug fix: support for correct utf-8 storage of names in the ini-file
3.3.2

View File

@ -69,9 +69,9 @@ void CSettings::Load()
// stored fader tags
for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_LEVELS; iIdx++ )
{
pClient->vecStoredFaderTags[iIdx] =
pClient->vecStoredFaderTags[iIdx] = FromBase64ToString (
GetIniSetting ( IniXMLDocument, "client",
QString ( "storedfadertag%1" ).arg ( iIdx ), "" );
QString ( "storedfadertag%1_base64" ).arg ( iIdx ), "" ) );
}
// stored fader levels
@ -81,13 +81,12 @@ void CSettings::Load()
0, AUD_MIX_FADER_MAX, iValue ) )
{
pClient->vecStoredFaderLevels[iIdx] = iValue;
}
}
// name
pClient->ChannelInfo.strName =
GetIniSetting ( IniXMLDocument, "client", "name" );
pClient->ChannelInfo.strName = FromBase64ToString (
GetIniSetting ( IniXMLDocument, "client", "name_base64" ) );
// instrument
if ( GetNumericIniSet ( IniXMLDocument, "client", "instrument",
@ -236,20 +235,20 @@ void CSettings::Load()
}
// window position of the main window
pClient->vecWindowPosMain = FromBase64 (
GetIniSetting ( IniXMLDocument, "client", "winposmain" ) );
pClient->vecWindowPosMain = FromBase64ToByteArray (
GetIniSetting ( IniXMLDocument, "client", "winposmain_base64" ) );
// window position of the settings window
pClient->vecWindowPosSettings = FromBase64 (
GetIniSetting ( IniXMLDocument, "client", "winposset" ) );
pClient->vecWindowPosSettings = FromBase64ToByteArray (
GetIniSetting ( IniXMLDocument, "client", "winposset_base64" ) );
// window position of the chat window
pClient->vecWindowPosChat = FromBase64 (
GetIniSetting ( IniXMLDocument, "client", "winposchat" ) );
pClient->vecWindowPosChat = FromBase64ToByteArray (
GetIniSetting ( IniXMLDocument, "client", "winposchat_base64" ) );
// window position of the connect window
pClient->vecWindowPosConnect = FromBase64 (
GetIniSetting ( IniXMLDocument, "client", "winposcon" ) );
pClient->vecWindowPosConnect = FromBase64ToByteArray (
GetIniSetting ( IniXMLDocument, "client", "winposcon_base64" ) );
// visibility state of the settings window
if ( GetFlagIniSet ( IniXMLDocument, "client", "winvisset", bValue ) )
@ -335,8 +334,8 @@ void CSettings::Save()
for ( iIdx = 0; iIdx < MAX_NUM_STORED_FADER_LEVELS; iIdx++ )
{
PutIniSetting ( IniXMLDocument, "client",
QString ( "storedfadertag%1" ).arg ( iIdx ),
pClient->vecStoredFaderTags[iIdx] );
QString ( "storedfadertag%1_base64" ).arg ( iIdx ),
ToBase64 ( pClient->vecStoredFaderTags[iIdx] ) );
}
// stored fader levels
@ -348,8 +347,8 @@ void CSettings::Save()
}
// name
PutIniSetting ( IniXMLDocument, "client", "name",
pClient->ChannelInfo.strName );
PutIniSetting ( IniXMLDocument, "client", "name_base64",
ToBase64 ( pClient->ChannelInfo.strName ) );
// instrument
SetNumericIniSet ( IniXMLDocument, "client", "instrument",
@ -428,19 +427,19 @@ void CSettings::Save()
pClient->GetUseDefaultCentralServerAddress() );
// window position of the main window
PutIniSetting ( IniXMLDocument, "client", "winposmain",
PutIniSetting ( IniXMLDocument, "client", "winposmain_base64",
ToBase64 ( pClient->vecWindowPosMain ) );
// window position of the settings window
PutIniSetting ( IniXMLDocument, "client", "winposset",
PutIniSetting ( IniXMLDocument, "client", "winposset_base64",
ToBase64 ( pClient->vecWindowPosSettings ) );
// window position of the chat window
PutIniSetting ( IniXMLDocument, "client", "winposchat",
PutIniSetting ( IniXMLDocument, "client", "winposchat_base64",
ToBase64 ( pClient->vecWindowPosChat ) );
// window position of the connect window
PutIniSetting ( IniXMLDocument, "client", "winposcon",
PutIniSetting ( IniXMLDocument, "client", "winposcon_base64",
ToBase64 ( pClient->vecWindowPosConnect ) );
// visibility state of the settings window

View File

@ -53,10 +53,23 @@ public:
protected:
void SetFileName ( const QString& sNFiName );
// The following functions implement the conversion from the general string
// to base64 (which should be used for binary data in XML files). This
// enables arbitrary utf8 characters to be used as the names in the GUI.
//
// ATTENTION: The "FromBase64[...]" functions must be used with caution!
// The reason is that if the FromBase64ToByteArray() is used to
// assign the stored value to a QString, this is incorrect but
// will not generate a compile error since there is a default
// conversion available for QByteArray to QString.
QString ToBase64 ( const QByteArray strIn ) const
{ return QString::fromLatin1 ( strIn.toBase64() ); }
QByteArray FromBase64 ( const QString strIn ) const
QString ToBase64 ( const QString strIn ) const
{ return ToBase64 ( strIn.toUtf8() ); }
QByteArray FromBase64ToByteArray ( const QString strIn ) const
{ return QByteArray::fromBase64 ( strIn.toLatin1() ); }
QString FromBase64ToString ( const QString strIn ) const
{ return QString::fromUtf8 ( FromBase64ToByteArray ( strIn ) ); }
// init file access function for read/write
void SetNumericIniSet ( QDomDocument& xmlFile,