From 3e23035758ac6934b7022f13cdb1efef28ceca99 Mon Sep 17 00:00:00 2001 From: ngocdh Date: Wed, 2 Jun 2021 11:20:02 +0200 Subject: [PATCH] Update audiomixerboard.h getismyownfader move own fader to 1st position Own fader first with menu action --- src/audiomixerboard.cpp | 19 +++++++++++++++++++ src/audiomixerboard.h | 1 + src/clientdlg.cpp | 9 +++++++++ src/clientdlg.h | 5 +++++ src/settings.cpp | 9 +++++++++ src/settings.h | 2 ++ 6 files changed, 45 insertions(+) diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 3080eb538d..6c2720b696 100644 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -1070,9 +1070,15 @@ void CAudioMixerBoard::ChangeFaderOrder ( const EChSortType eChSortType ) // create a pair list of lower strings and fader ID for each channel QList> PairList; int iNumVisibleFaders = 0; + int iMyFader = -1; for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) { + if ( vecpChanFader[i]->GetIsMyOwnFader() ) + { + iMyFader = i; + } + if ( eChSortType == ST_BY_NAME ) { PairList << QPair ( vecpChanFader[i]->GetReceivedName().toLower(), i ); @@ -1117,6 +1123,19 @@ void CAudioMixerBoard::ChangeFaderOrder ( const EChSortType eChSortType ) // sort the channels according to the first of the pair std::stable_sort ( PairList.begin(), PairList.end() ); + // move my fader to first position + if ( pSettings->bOwnFaderFirst ) + { + for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) + { + if ( iMyFader == PairList[i].second ) + { + PairList.move ( i, 0 ); + break; + } + } + } + // we want to distribute iNumVisibleFaders across the first row, then the next, etc // up to iNumMixerPanelRows. So row wants to start at 0 until we get to some number, // then increase, where "some number" means we get no more than iNumMixerPanelRows. diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index 01299268b7..b77267f8c4 100644 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -84,6 +84,7 @@ class CChannelFader : public QObject int GetRunningNewClientCnt() { return iRunningNewClientCnt; } void SetChannelLevel ( const uint16_t iLevel ); void SetIsMyOwnFader() { bIsMyOwnFader = true; } + bool GetIsMyOwnFader() { return bIsMyOwnFader; } void UpdateSoloState ( const bool bNewOtherSoloState ); protected: diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 5dd45642d6..4966a8ba48 100644 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -308,6 +308,12 @@ CClientDlg::CClientDlg ( CClient* pNCliP, // View menu -------------------------------------------------------------- QMenu* pViewMenu = new QMenu ( tr ( "&View" ), this ); + // own fader first option: works from server version 3.5.5 which supports sending client ID back to client + QAction* OwnFaderFirstAction = + pViewMenu->addAction ( tr ( "O&wn Fader First" ), this, SLOT ( OnOwnFaderFirst() ), QKeySequence ( Qt::CTRL + Qt::Key_W ) ); + + pViewMenu->addSeparator(); + QAction* NoSortAction = pViewMenu->addAction ( tr ( "N&o User Sorting" ), this, SLOT ( OnNoSortChannels() ), QKeySequence ( Qt::CTRL + Qt::Key_O ) ); @@ -325,6 +331,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP, QAction* ByCityAction = pViewMenu->addAction ( tr ( "Sort Users by &City" ), this, SLOT ( OnSortChannelsByCity() ), QKeySequence ( Qt::CTRL + Qt::Key_T ) ); + OwnFaderFirstAction->setCheckable ( true ); + OwnFaderFirstAction->setChecked ( pSettings->bOwnFaderFirst ); + // the sorting menu entries shall be checkable and exclusive QActionGroup* SortActionGroup = new QActionGroup ( this ); SortActionGroup->setExclusive ( true ); diff --git a/src/clientdlg.h b/src/clientdlg.h index cba05e8b59..6fdd398a7d 100644 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -159,6 +159,11 @@ public slots: void OnOpenAdvancedSettings(); void OnOpenChatDialog() { ShowChatWindow(); } void OnOpenAnalyzerConsole() { ShowAnalyzerConsole(); } + void OnOwnFaderFirst() + { + pSettings->bOwnFaderFirst = !pSettings->bOwnFaderFirst; + MainMixerBoard->SetFaderSorting ( pSettings->eChannelSortType ); + } void OnNoSortChannels() { MainMixerBoard->SetFaderSorting ( ST_NO_SORT ); } void OnSortChannelsByName() { MainMixerBoard->SetFaderSorting ( ST_BY_NAME ); } void OnSortChannelsByInstrument() { MainMixerBoard->SetFaderSorting ( ST_BY_INSTRUMENT ); } diff --git a/src/settings.cpp b/src/settings.cpp index 73e09b1948..918ab3ed52 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -270,6 +270,12 @@ void CClientSettings::ReadSettingsFromXML ( const QDomDocument& IniXMLDocument, eChannelSortType = static_cast ( iValue ); } + // own fader first sorting + if ( GetFlagIniSet ( IniXMLDocument, "client", "ownfaderfirst", bValue ) ) + { + bOwnFaderFirst = bValue; + } + // number of mixer panel rows if ( GetNumericIniSet ( IniXMLDocument, "client", "numrowsmixpan", 1, 8, iValue ) ) { @@ -624,6 +630,9 @@ void CClientSettings::WriteSettingsToXML ( QDomDocument& IniXMLDocument ) // fader channel sorting SetNumericIniSet ( IniXMLDocument, "client", "channelsort", static_cast ( eChannelSortType ) ); + // own fader first sorting + SetFlagIniSet ( IniXMLDocument, "client", "ownfaderfirst", bOwnFaderFirst ); + // number of mixer panel rows SetNumericIniSet ( IniXMLDocument, "client", "numrowsmixpan", iNumMixerPanelRows ); diff --git a/src/settings.h b/src/settings.h index 685719eb02..b790de4dd1 100644 --- a/src/settings.h +++ b/src/settings.h @@ -133,6 +133,7 @@ class CClientSettings : public CSettings bWindowWasShownSettings ( false ), bWindowWasShownChat ( false ), bWindowWasShownConnect ( false ), + bOwnFaderFirst ( false ), pClient ( pNCliP ) { SetFileName ( sNFiName, DEFAULT_INI_FILE_NAME ); @@ -167,6 +168,7 @@ class CClientSettings : public CSettings bool bWindowWasShownSettings; bool bWindowWasShownChat; bool bWindowWasShownConnect; + bool bOwnFaderFirst; protected: // No CommandLineOptions used when reading Client inifile