diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 1ec1bd14..a92c108b 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -60,6 +60,17 @@ CChannelFader::CChannelFader ( QWidget* pNW ) QVBoxLayout* pPanGrid = new QVBoxLayout ( ); QHBoxLayout* pPanInfoGrid = new QHBoxLayout ( ); + // define the popup menu for the group checkbox + pGroupPopupMenu = new QMenu ( "", pcbGroup ); + pGroupPopupMenu->addAction ( tr ( "No grouping" ), this, SLOT ( OnGroupMenuGrpNone() ) ); + pGroupPopupMenu->addAction ( tr ( "Assign to group" ) + " 1", this, SLOT ( OnGroupMenuGrp1() ) ); + pGroupPopupMenu->addAction ( tr ( "Assign to group" ) + " 2", this, SLOT ( OnGroupMenuGrp2() ) ); + pGroupPopupMenu->addAction ( tr ( "Assign to group" ) + " 3", this, SLOT ( OnGroupMenuGrp3() ) ); + pGroupPopupMenu->addAction ( tr ( "Assign to group" ) + " 4", this, SLOT ( OnGroupMenuGrp4() ) ); +#if ( MAX_NUM_FADER_GROUPS != 4 ) +# error "MAX_NUM_FADER_GROUPS must be set to 4, see implementation in CChannelFader()" +#endif + // setup channel level plbrChannelLevel->setContentsMargins ( 0, 3, 2, 3 ); @@ -183,6 +194,9 @@ CChannelFader::CChannelFader ( QWidget* pNW ) QObject::connect ( pcbSolo, &QCheckBox::stateChanged, this, &CChannelFader::soloStateChanged ); + + QObject::connect ( pcbGroup, &QCheckBox::stateChanged, + this, &CChannelFader::OnGroupStateChanged ); } void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign ) @@ -319,7 +333,6 @@ void CChannelFader::Reset() // reset mute/solo/group check boxes and level meter pcbMute->setChecked ( false ); pcbSolo->setChecked ( false ); - pcbGroup->setChecked ( false ); plbrChannelLevel->SetValue ( 0 ); plbrChannelLevel->ClipReset(); @@ -341,6 +354,9 @@ void CChannelFader::Reset() bOtherChannelIsSolo = false; bIsMyOwnFader = false; + + iGroupID = INVALID_INDEX; + UpdateGroupCheckState(); } void CChannelFader::SetFaderLevel ( const double dLevel, @@ -441,6 +457,49 @@ void CChannelFader::OnMuteStateChanged ( int value ) SetMute ( static_cast ( value ) == Qt::Checked ); } +void CChannelFader::SetGroupID ( const int iNGroupID ) +{ + iGroupID = iNGroupID; + +// TODO different skins, different text; also prolem with skin update + if ( iNGroupID != INVALID_INDEX ) + { + pcbGroup->setText ( tr ( "Grp" ) + QString::number ( iNGroupID + 1 ) ); + } + else + { + pcbGroup->setText ( tr ( "Grp" ) ); + } + + UpdateGroupCheckState(); +} + +void CChannelFader::UpdateGroupCheckState() +{ + // update the group checkbox according the current group ID setting + pcbGroup->blockSignals ( true ); // make sure no signals as fired + if ( iGroupID == INVALID_INDEX ) + { + pcbGroup->setCheckState ( Qt::Unchecked ); + } + else + { + pcbGroup->setCheckState ( Qt::Checked ); + } + pcbGroup->blockSignals ( false ); +} + +void CChannelFader::OnGroupStateChanged ( int ) +{ + // we want a popup menu shown if the user presses the group checkbox but + // we want to make sure that the checkbox state represents the current group + // setting and not the current click state since the user might not click + // on the menu but at one other place and then the popup menu disappears but + // the checkobx state would be on an invalid state + UpdateGroupCheckState(); + pGroupPopupMenu->popup ( QCursor::pos() ); +} + void CChannelFader::SetMute ( const bool bState ) { if ( bState ) diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index bbde40e6..83d93113 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -36,6 +36,7 @@ #include #include #include +#include #include "global.h" #include "util.h" #include "levelmeter.h" @@ -57,7 +58,7 @@ public: bool IsVisible() { return !pFrame->isHidden(); } bool IsSolo() { return pcbSolo->isChecked(); } bool IsMute() { return pcbMute->isChecked(); } - int GetGroupID() { return pcbGroup->isChecked() ? 0 : INVALID_INDEX; } + int GetGroupID() { return iGroupID; } void SetGUIDesign ( const EGUIDesign eNewDesign ); void SetDisplayChannelLevel ( const bool eNDCL ); bool GetDisplayChannelLevel(); @@ -67,7 +68,7 @@ public: void SetPanValue ( const int iPan ); void SetFaderIsSolo ( const bool bIsSolo ); void SetFaderIsMute ( const bool bIsMute ); - void SetGroupID ( const int iGroupID ) { pcbGroup->setChecked ( iGroupID != INVALID_INDEX ); } + void SetGroupID ( const int iNGroupID ); void SetRemoteFaderIsMute ( const bool bIsMute ); void SetFaderLevel ( const double dLevel, const bool bIsGroupUpdate = false ); @@ -81,6 +82,7 @@ public: void UpdateSoloState ( const bool bNewOtherSoloState ); protected: + void UpdateGroupCheckState(); double CalcFaderGain ( const double dValue ); void SetMute ( const bool bState ); void SetupFaderTag ( const ESkillLevel eSkillLevel ); @@ -103,6 +105,7 @@ protected: QCheckBox* pcbMute; QCheckBox* pcbSolo; QCheckBox* pcbGroup; + QMenu* pGroupPopupMenu; QGroupBox* pLabelInstBox; QLabel* plblLabel; @@ -114,11 +117,19 @@ protected: bool bOtherChannelIsSolo; bool bIsMyOwnFader; double dPreviousFaderLevel; + int iGroupID; public slots: void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value, false ); } void OnPanValueChanged ( int value ) { SendPanValueToServer ( value ); } void OnMuteStateChanged ( int value ); + void OnGroupStateChanged ( int ); + + void OnGroupMenuGrpNone() { SetGroupID ( INVALID_INDEX ); } + void OnGroupMenuGrp1() { SetGroupID ( 0 ); } + void OnGroupMenuGrp2() { SetGroupID ( 1 ); } + void OnGroupMenuGrp3() { SetGroupID ( 2 ); } + void OnGroupMenuGrp4() { SetGroupID ( 3 ); } signals: void gainValueChanged ( double value, diff --git a/src/global.h b/src/global.h index dc4fea5a..99c27370 100755 --- a/src/global.h +++ b/src/global.h @@ -152,8 +152,8 @@ LED bar: lbr #define AUD_MIX_FADER_MAX 100 #define AUD_MIX_PAN_MAX 100 -// maximum number of fader groups -#define MAX_NUM_FADER_GROUPS 10 +// maximum number of fader groups (must be consistent to audiomixerboard implementation) +#define MAX_NUM_FADER_GROUPS 4 // maximum number of recognized sound cards installed in the system #define MAX_NUMBER_SOUND_CARDS 129 // e.g. 16 inputs, 8 outputs + default entry (MacOS)