Skip to content

Commit aedd894

Browse files
committed
Remove duplicate code for MIDI strings
1 parent 9a2257f commit aedd894

File tree

5 files changed

+61
-78
lines changed

5 files changed

+61
-78
lines changed

src/clientsettingsdlg.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,22 +1330,7 @@ void CClientSettingsDlg::OnAudioPanValueChanged ( int value )
13301330
UpdateAudioFaderSlider();
13311331
}
13321332

1333-
void CClientSettingsDlg::ApplyMIDIMappingFromSettings()
1334-
{
1335-
QString midiMap = QString ( "%1;f%2*%3;p%4*%5;s%6*%7;m%8*%9;o%10" )
1336-
.arg ( pSettings->midiChannel )
1337-
.arg ( pSettings->midiFaderOffset )
1338-
.arg ( pSettings->midiFaderCount )
1339-
.arg ( pSettings->midiPanOffset )
1340-
.arg ( pSettings->midiPanCount )
1341-
.arg ( pSettings->midiSoloOffset )
1342-
.arg ( pSettings->midiSoloCount )
1343-
.arg ( pSettings->midiMuteOffset )
1344-
.arg ( pSettings->midiMuteCount )
1345-
.arg ( pSettings->midiMuteMyself );
1346-
1347-
pClient->ApplyMIDIMapping ( midiMap );
1348-
}
1333+
void CClientSettingsDlg::ApplyMIDIMappingFromSettings() { pClient->ApplyMIDIMapping ( pSettings->GetMIDIMapString() ); }
13491334

13501335
void CClientSettingsDlg::ResetMidiLearn()
13511336
{

src/clientsettingsdlg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class CClientSettingsDlg : public CBaseDlg, private Ui_CClientSettingsDlgBase
6060
void UpdateDisplay();
6161
void UpdateSoundDeviceChannelSelectionFrame();
6262

63-
void SetEnableFeedbackDetection ( bool enable );
63+
void SetEnableFeedbackDetection ( bool enable );
6464

6565
protected:
6666
void UpdateJitterBufferFrame();

src/main.cpp

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -662,14 +662,12 @@ int main ( int argc, char** argv )
662662

663663
if ( !strServerListFileName.isEmpty() )
664664
{
665-
qInfo() << "Note:"
666-
<< "Server list persistence file will only take effect when running as a directory.";
665+
qInfo() << "Note:" << "Server list persistence file will only take effect when running as a directory.";
667666
}
668667

669668
if ( !strServerListFilter.isEmpty() )
670669
{
671-
qInfo() << "Note:"
672-
<< "Server list filter will only take effect when running as a directory.";
670+
qInfo() << "Note:" << "Server list filter will only take effect when running as a directory.";
673671
}
674672
}
675673
else
@@ -821,7 +819,7 @@ int main ( int argc, char** argv )
821819
bIsClient = true; // Client only - TODO: maybe a switch in interface to change to server?
822820

823821
// bUseMultithreading = true;
824-
QApplication* pApp = new QApplication ( argc, argv );
822+
QApplication* pApp = new QApplication ( argc, argv );
825823
# else
826824
QCoreApplication* pApp = bUseGUI ? new QApplication ( argc, argv ) : new QCoreApplication ( argc, argv );
827825
# endif
@@ -865,10 +863,10 @@ int main ( int argc, char** argv )
865863
Q_INIT_RESOURCE ( resources );
866864

867865
#ifndef SERVER_ONLY
868-
//### TEST: BEGIN ###//
869-
// activate the following line to activate the test bench,
870-
// CTestbench Testbench ( "127.0.0.1", DEFAULT_PORT_NUMBER );
871-
//### TEST: END ###//
866+
// ### TEST: BEGIN ###//
867+
// activate the following line to activate the test bench,
868+
// CTestbench Testbench ( "127.0.0.1", DEFAULT_PORT_NUMBER );
869+
// ### TEST: END ###//
872870
#endif
873871

874872
#ifdef NO_JSON_RPC
@@ -877,7 +875,7 @@ int main ( int argc, char** argv )
877875
qWarning() << "No JSON-RPC support in this build.";
878876
}
879877
#else
880-
CRpcServer* pRpcServer = nullptr;
878+
CRpcServer* pRpcServer = nullptr;
881879

882880
if ( iJsonRpcPortNumber != INVALID_PORT )
883881
{
@@ -924,18 +922,7 @@ int main ( int argc, char** argv )
924922
{
925923
CClientSettings tmpSettings ( nullptr, strIniFileName );
926924
tmpSettings.Load ( CommandLineOptions );
927-
928-
strMIDISetup = QString ( "%1;f%2*%3;p%4*%5;s%6*%7;m%8*%9;o%10" )
929-
.arg ( tmpSettings.midiChannel )
930-
.arg ( tmpSettings.midiFaderOffset )
931-
.arg ( tmpSettings.midiFaderCount )
932-
.arg ( tmpSettings.midiPanOffset )
933-
.arg ( tmpSettings.midiPanCount )
934-
.arg ( tmpSettings.midiSoloOffset )
935-
.arg ( tmpSettings.midiSoloCount )
936-
.arg ( tmpSettings.midiMuteOffset )
937-
.arg ( tmpSettings.midiMuteCount )
938-
.arg ( tmpSettings.midiMuteMyself );
925+
strMIDISetup = tmpSettings.GetMIDIMapString();
939926
}
940927

941928
CClient Client ( iPortNumber,

src/settings.cpp

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -517,27 +517,27 @@ void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument,
517517

518518
// custom directories
519519

520-
//### TODO: BEGIN ###//
521-
// compatibility to old version (< 3.6.1)
520+
// ### TODO: BEGIN ###//
521+
// compatibility to old version (< 3.6.1)
522522
QString strDirectoryAddress = GetIniSetting ( IniXMLDocument, "client", "centralservaddr", "" );
523-
//### TODO: END ###//
523+
// ### TODO: END ###//
524524

525525
for ( iIdx = 0; iIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIdx++ )
526526
{
527-
//### TODO: BEGIN ###//
528-
// compatibility to old version (< 3.8.2)
527+
// ### TODO: BEGIN ###//
528+
// compatibility to old version (< 3.8.2)
529529
strDirectoryAddress = GetIniSetting ( IniXMLDocument, "client", QString ( "centralservaddr%1" ).arg ( iIdx ), strDirectoryAddress );
530-
//### TODO: END ###//
530+
// ### TODO: END ###//
531531

532532
vstrDirectoryAddress[iIdx] = GetIniSetting ( IniXMLDocument, "client", QString ( "directoryaddress%1" ).arg ( iIdx ), strDirectoryAddress );
533533
strDirectoryAddress = "";
534534
}
535535

536536
// directory type
537537

538-
//### TODO: BEGIN ###//
539-
// compatibility to old version (<3.4.7)
540-
// only the case that "centralservaddr" was set in old ini must be considered
538+
// ### TODO: BEGIN ###//
539+
// compatibility to old version (<3.4.7)
540+
// only the case that "centralservaddr" was set in old ini must be considered
541541
if ( !vstrDirectoryAddress[0].isEmpty() && GetFlagIniSet ( IniXMLDocument, "client", "defcentservaddr", bValue ) && !bValue )
542542
{
543543
eDirectoryType = AT_CUSTOM;
@@ -547,7 +547,7 @@ void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument,
547547
{
548548
eDirectoryType = static_cast<EDirectoryType> ( iValue );
549549
}
550-
//### TODO: END ###//
550+
// ### TODO: END ###//
551551

552552
else if ( GetNumericIniSet ( IniXMLDocument, "client", "directorytype", 0, static_cast<int> ( AT_CUSTOM ), iValue ) )
553553
{
@@ -824,6 +824,21 @@ void CClientSettings::WriteSettingsToXML ( QDomDocument& IniXMLDocument, bool is
824824
WriteFaderSettingsToXML ( IniXMLDocument );
825825
}
826826

827+
QString CClientSettings::GetMIDIMapString() const
828+
{
829+
return QString ( "%1;f%2*%3;p%4*%5;s%6*%7;m%8*%9;o%10" )
830+
.arg ( midiChannel )
831+
.arg ( midiFaderOffset )
832+
.arg ( midiFaderCount )
833+
.arg ( midiPanOffset )
834+
.arg ( midiPanCount )
835+
.arg ( midiSoloOffset )
836+
.arg ( midiSoloCount )
837+
.arg ( midiMuteOffset )
838+
.arg ( midiMuteCount )
839+
.arg ( midiMuteMyself );
840+
}
841+
827842
void CClientSettings::WriteFaderSettingsToXML ( QDomDocument& IniXMLDocument )
828843
{
829844
int iIdx;
@@ -912,10 +927,10 @@ void CServerSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument,
912927
// Server GUI defaults to ""
913928
QString directoryAddress = "";
914929

915-
//### TODO: BEGIN ###//
916-
// compatibility to old version < 3.8.2
930+
// ### TODO: BEGIN ###//
931+
// compatibility to old version < 3.8.2
917932
directoryAddress = GetIniSetting ( IniXMLDocument, "server", "centralservaddr", directoryAddress );
918-
//### TODO: END ###//
933+
// ### TODO: END ###//
919934

920935
directoryAddress = GetIniSetting ( IniXMLDocument, "server", "directoryaddress", directoryAddress );
921936

@@ -935,20 +950,20 @@ void CServerSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument,
935950
}
936951
else
937952
{
938-
//### TODO: BEGIN ###//
939-
// compatibility to old version < 3.4.7
953+
// ### TODO: BEGIN ###//
954+
// compatibility to old version < 3.4.7
940955
if ( GetFlagIniSet ( IniXMLDocument, "server", "defcentservaddr", bValue ) )
941956
{
942957
directoryType = bValue ? AT_DEFAULT : AT_CUSTOM;
943958
}
944959
else
945960
{
946-
//### TODO: END ###//
961+
// ### TODO: END ###//
947962

948963
// if "directorytype" itself is set, use it (note "AT_NONE", "AT_DEFAULT" and "AT_CUSTOM" are min/max directory type here)
949964

950-
//### TODO: BEGIN ###//
951-
// compatibility to old version < 3.8.2
965+
// ### TODO: BEGIN ###//
966+
// compatibility to old version < 3.8.2
952967
if ( GetNumericIniSet ( IniXMLDocument,
953968
"server",
954969
"centservaddrtype",
@@ -958,7 +973,7 @@ void CServerSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument,
958973
{
959974
directoryType = static_cast<EDirectoryType> ( iValue );
960975
}
961-
//### TODO: END ###//
976+
// ### TODO: END ###//
962977

963978
else
964979
{
@@ -974,14 +989,14 @@ void CServerSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument,
974989
}
975990
}
976991

977-
//### TODO: BEGIN ###//
978-
// compatibility to old version < 3.9.0
979-
// override type to AT_NONE if servlistenabled exists and is false
992+
// ### TODO: BEGIN ###//
993+
// compatibility to old version < 3.9.0
994+
// override type to AT_NONE if servlistenabled exists and is false
980995
if ( GetFlagIniSet ( IniXMLDocument, "server", "servlistenabled", bValue ) && !bValue )
981996
{
982997
directoryType = AT_NONE;
983998
}
984-
//### TODO: END ###//
999+
// ### TODO: END ###//
9851000
}
9861001

9871002
pServer->SetDirectoryType ( directoryType );

src/settings.h

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,7 @@ class CSettings : public QObject
6060
if ( pGApp != nullptr )
6161
{
6262
# ifndef QT_NO_SESSIONMANAGER
63-
QObject::connect (
64-
pGApp,
65-
&QGuiApplication::saveStateRequest,
66-
this,
67-
[=] ( QSessionManager& ) { Save ( false ); },
68-
Qt::DirectConnection );
63+
QObject::connect ( pGApp, &QGuiApplication::saveStateRequest, this, [=] ( QSessionManager& ) { Save ( false ); }, Qt::DirectConnection );
6964

7065
# endif
7166
QObject::connect ( pGApp, &QGuiApplication::applicationStateChanged, this, [=] ( Qt::ApplicationState state ) {
@@ -202,16 +197,17 @@ class CClientSettings : public CSettings
202197
bool bOwnFaderFirst;
203198

204199
// MIDI settings
205-
int midiChannel = 0; // Default MIDI channel 0
206-
int midiMuteMyself = 0;
207-
int midiFaderOffset = 70;
208-
int midiFaderCount = 0;
209-
int midiPanOffset = 0;
210-
int midiPanCount = 0;
211-
int midiSoloOffset = 0;
212-
int midiSoloCount = 0;
213-
int midiMuteOffset = 0;
214-
int midiMuteCount = 0;
200+
int midiChannel = 0; // Default MIDI channel 0
201+
int midiMuteMyself = 0;
202+
int midiFaderOffset = 70;
203+
int midiFaderCount = 0;
204+
int midiPanOffset = 0;
205+
int midiPanCount = 0;
206+
int midiSoloOffset = 0;
207+
int midiSoloCount = 0;
208+
int midiMuteOffset = 0;
209+
int midiMuteCount = 0;
210+
QString GetMIDIMapString() const;
215211

216212
protected:
217213
virtual void WriteSettingsToXML ( QDomDocument& IniXMLDocument, bool isAboutToQuit ) override;

0 commit comments

Comments
 (0)