2011-04-25 18:16:31 +02:00
|
|
|
/******************************************************************************\
|
2020-01-01 15:41:43 +01:00
|
|
|
* Copyright (c) 2004-2020
|
2011-04-25 18:16:31 +02:00
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Volker Fischer
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
2020-06-08 22:58:11 +02:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2011-04-25 18:16:31 +02:00
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2019-07-09 08:52:38 +02:00
|
|
|
#pragma once
|
2011-04-25 18:16:31 +02:00
|
|
|
|
2013-01-02 21:41:04 +01:00
|
|
|
#include <QDomDocument>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QTextStream>
|
2011-04-25 18:16:31 +02:00
|
|
|
#include "global.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "server.h"
|
2020-05-23 21:23:20 +02:00
|
|
|
#include "util.h"
|
2011-04-25 18:16:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Classes ********************************************************************/
|
|
|
|
class CSettings
|
|
|
|
{
|
|
|
|
public:
|
2020-07-06 18:39:35 +02:00
|
|
|
CSettings() :
|
2020-07-09 18:19:33 +02:00
|
|
|
vecWindowPosMain ( ), // empty array
|
|
|
|
strLanguage ( "" ),
|
|
|
|
strFileName ( "" ) {}
|
2011-04-25 18:16:31 +02:00
|
|
|
|
2011-05-21 18:53:01 +02:00
|
|
|
void Load();
|
|
|
|
void Save();
|
2011-04-25 18:16:31 +02:00
|
|
|
|
2020-07-06 18:39:35 +02:00
|
|
|
// common settings
|
2020-07-09 18:19:33 +02:00
|
|
|
QByteArray vecWindowPosMain;
|
|
|
|
QString strLanguage;
|
2020-07-06 18:39:35 +02:00
|
|
|
|
2011-05-21 18:53:01 +02:00
|
|
|
protected:
|
2020-06-29 20:43:41 +02:00
|
|
|
virtual void ReadFromXML ( const QDomDocument& IniXMLDocument ) = 0;
|
|
|
|
virtual void WriteToXML ( QDomDocument& IniXMLDocument ) = 0;
|
|
|
|
|
2020-06-29 19:16:36 +02:00
|
|
|
void SetFileName ( const QString& sNFiName,
|
|
|
|
const QString& sDefaultFileName );
|
2011-04-25 18:16:31 +02:00
|
|
|
|
2013-12-15 11:54:17 +01:00
|
|
|
// 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.
|
2013-12-14 23:09:59 +01:00
|
|
|
QString ToBase64 ( const QByteArray strIn ) const
|
|
|
|
{ return QString::fromLatin1 ( strIn.toBase64() ); }
|
2013-12-15 11:54:17 +01:00
|
|
|
QString ToBase64 ( const QString strIn ) const
|
|
|
|
{ return ToBase64 ( strIn.toUtf8() ); }
|
|
|
|
QByteArray FromBase64ToByteArray ( const QString strIn ) const
|
2013-12-14 23:09:59 +01:00
|
|
|
{ return QByteArray::fromBase64 ( strIn.toLatin1() ); }
|
2013-12-15 11:54:17 +01:00
|
|
|
QString FromBase64ToString ( const QString strIn ) const
|
|
|
|
{ return QString::fromUtf8 ( FromBase64ToByteArray ( strIn ) ); }
|
2013-12-14 23:09:59 +01:00
|
|
|
|
2011-04-25 18:16:31 +02:00
|
|
|
// init file access function for read/write
|
2013-02-11 16:06:00 +01:00
|
|
|
void SetNumericIniSet ( QDomDocument& xmlFile,
|
|
|
|
const QString& strSection,
|
|
|
|
const QString& strKey,
|
|
|
|
const int iValue = 0 );
|
|
|
|
|
|
|
|
bool GetNumericIniSet ( const QDomDocument& xmlFile,
|
|
|
|
const QString& strSection,
|
|
|
|
const QString& strKey,
|
|
|
|
const int iRangeStart,
|
|
|
|
const int iRangeStop,
|
|
|
|
int& iValue );
|
|
|
|
|
|
|
|
void SetFlagIniSet ( QDomDocument& xmlFile,
|
|
|
|
const QString& strSection,
|
|
|
|
const QString& strKey,
|
|
|
|
const bool bValue = false );
|
|
|
|
|
|
|
|
bool GetFlagIniSet ( const QDomDocument& xmlFile,
|
|
|
|
const QString& strSection,
|
|
|
|
const QString& strKey,
|
|
|
|
bool& bValue );
|
2011-04-25 18:16:31 +02:00
|
|
|
|
|
|
|
// actual working function for init-file access
|
2013-02-11 16:06:00 +01:00
|
|
|
QString GetIniSetting( const QDomDocument& xmlFile,
|
|
|
|
const QString& sSection,
|
|
|
|
const QString& sKey,
|
|
|
|
const QString& sDefaultVal = "" );
|
|
|
|
|
|
|
|
void PutIniSetting ( QDomDocument& xmlFile,
|
|
|
|
const QString& sSection,
|
|
|
|
const QString& sKey,
|
|
|
|
const QString& sValue = "" );
|
2011-04-25 18:16:31 +02:00
|
|
|
|
2020-06-29 20:43:41 +02:00
|
|
|
QString strFileName;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CClientSettings : public CSettings
|
|
|
|
{
|
|
|
|
public:
|
2020-07-04 19:55:04 +02:00
|
|
|
CClientSettings ( CClient* pNCliP, const QString& sNFiName ) :
|
2020-07-06 18:39:35 +02:00
|
|
|
CSettings ( ),
|
2020-07-04 19:55:04 +02:00
|
|
|
vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ),
|
|
|
|
vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ),
|
|
|
|
vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX / 2 ),
|
|
|
|
vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ),
|
|
|
|
vecStoredFaderIsMute ( MAX_NUM_STORED_FADER_SETTINGS, false ),
|
|
|
|
vecStoredFaderGroupID ( MAX_NUM_STORED_FADER_SETTINGS, INVALID_INDEX ),
|
2020-07-04 20:23:00 +02:00
|
|
|
vstrIPAddress ( MAX_NUM_SERVER_ADDR_ITEMS, "" ),
|
2020-07-04 19:55:04 +02:00
|
|
|
iNewClientFaderLevel ( 100 ),
|
|
|
|
bConnectDlgShowAllMusicians ( true ),
|
|
|
|
vecWindowPosSettings ( ), // empty array
|
|
|
|
vecWindowPosChat ( ), // empty array
|
|
|
|
vecWindowPosProfile ( ), // empty array
|
|
|
|
vecWindowPosConnect ( ), // empty array
|
|
|
|
bWindowWasShownSettings ( false ),
|
|
|
|
bWindowWasShownChat ( false ),
|
|
|
|
bWindowWasShownProfile ( false ),
|
|
|
|
bWindowWasShownConnect ( false ),
|
|
|
|
pClient ( pNCliP )
|
2020-06-29 20:43:41 +02:00
|
|
|
{ SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME ); }
|
|
|
|
|
2020-07-06 18:39:35 +02:00
|
|
|
// general settings
|
2020-07-04 19:55:04 +02:00
|
|
|
CVector<QString> vecStoredFaderTags;
|
|
|
|
CVector<int> vecStoredFaderLevels;
|
|
|
|
CVector<int> vecStoredPanValues;
|
|
|
|
CVector<int> vecStoredFaderIsSolo;
|
|
|
|
CVector<int> vecStoredFaderIsMute;
|
|
|
|
CVector<int> vecStoredFaderGroupID;
|
2020-07-04 20:23:00 +02:00
|
|
|
CVector<QString> vstrIPAddress;
|
2020-07-04 19:55:04 +02:00
|
|
|
int iNewClientFaderLevel;
|
|
|
|
bool bConnectDlgShowAllMusicians;
|
|
|
|
|
|
|
|
// window position/state settings
|
|
|
|
QByteArray vecWindowPosSettings;
|
|
|
|
QByteArray vecWindowPosChat;
|
|
|
|
QByteArray vecWindowPosProfile;
|
|
|
|
QByteArray vecWindowPosConnect;
|
|
|
|
bool bWindowWasShownSettings;
|
|
|
|
bool bWindowWasShownChat;
|
|
|
|
bool bWindowWasShownProfile;
|
|
|
|
bool bWindowWasShownConnect;
|
|
|
|
|
2020-06-29 20:43:41 +02:00
|
|
|
protected:
|
|
|
|
virtual void ReadFromXML ( const QDomDocument& IniXMLDocument ) override;
|
|
|
|
virtual void WriteToXML ( QDomDocument& IniXMLDocument ) override;
|
|
|
|
|
2020-07-11 10:40:59 +02:00
|
|
|
void ReadFaderSettingsFromXML ( const QDomDocument& IniXMLDocument );
|
|
|
|
void WriteFaderSettingsToXML ( QDomDocument& IniXMLDocument );
|
|
|
|
|
2020-06-29 20:43:41 +02:00
|
|
|
CClient* pClient;
|
|
|
|
};
|
|
|
|
|
2011-04-25 18:16:31 +02:00
|
|
|
|
2020-06-29 20:43:41 +02:00
|
|
|
class CServerSettings : public CSettings
|
|
|
|
{
|
|
|
|
public:
|
2020-07-04 22:20:50 +02:00
|
|
|
CServerSettings ( CServer* pNSerP, const QString& sNFiName ) :
|
2020-07-09 18:19:33 +02:00
|
|
|
CSettings ( ),
|
|
|
|
pServer ( pNSerP )
|
2020-06-29 20:43:41 +02:00
|
|
|
{ SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME_SERVER); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void ReadFromXML ( const QDomDocument& IniXMLDocument ) override;
|
|
|
|
virtual void WriteToXML ( QDomDocument& IniXMLDocument ) override;
|
|
|
|
|
|
|
|
CServer* pServer;
|
2011-04-25 18:16:31 +02:00
|
|
|
};
|