added a scroll area to the mixer board so that a large number of clients can be supported, thanks to doloopuntil for his example code

This commit is contained in:
Volker Fischer 2020-03-30 19:53:30 +02:00
parent e99e5b2720
commit bef3506a38
2 changed files with 19 additions and 7 deletions

View file

@ -464,19 +464,20 @@ double CChannelFader::CalcFaderGain ( const int value )
* CAudioMixerBoard * * CAudioMixerBoard *
\******************************************************************************/ \******************************************************************************/
CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) : CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) :
QGroupBox ( parent ), QScrollArea ( parent ),
vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ), vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ),
vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ), vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ),
vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ), vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ),
iNewClientFaderLevel ( 100 ), iNewClientFaderLevel ( 100 ),
bNoFaderVisible ( true ) bNoFaderVisible ( true )
{ {
// add group box and hboxlayout
pGroupBox = new QGroupBox(); // will be added to the scroll area which is then the parent
pMainLayout = new QHBoxLayout ( pGroupBox );
// set title text (default: no server given) // set title text (default: no server given)
SetServerName ( "" ); SetServerName ( "" );
// add hboxlayout
pMainLayout = new QHBoxLayout ( this );
// create all mixer controls and make them invisible // create all mixer controls and make them invisible
vecpChanFader.Init ( MAX_NUM_CHANNELS ); vecpChanFader.Init ( MAX_NUM_CHANNELS );
@ -489,6 +490,15 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) :
// insert horizontal spacer // insert horizontal spacer
pMainLayout->addItem ( new QSpacerItem ( 0, 0, QSizePolicy::Expanding ) ); pMainLayout->addItem ( new QSpacerItem ( 0, 0, QSizePolicy::Expanding ) );
// add the group box to the scroll area
setMinimumWidth ( 200 ); // at least two faders shall be visible
setWidget ( pGroupBox );
setWidgetResizable ( true ); // make sure it fills the entire scroll area
setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
setHorizontalScrollBarPolicy ( Qt::ScrollBarAsNeeded );
setStyleSheet ( "background: transparent;" );
setFrameShape ( QFrame::NoFrame );
// Connections ------------------------------------------------------------- // Connections -------------------------------------------------------------
// CODE TAG: MAX_NUM_CHANNELS_TAG // CODE TAG: MAX_NUM_CHANNELS_TAG
@ -601,11 +611,11 @@ void CAudioMixerBoard::SetServerName ( const QString& strNewServerName )
// set title text of the group box // set title text of the group box
if ( strNewServerName.isEmpty() ) if ( strNewServerName.isEmpty() )
{ {
setTitle ( "Server" ); pGroupBox->setTitle ( "Server" );
} }
else else
{ {
setTitle ( strNewServerName ); pGroupBox->setTitle ( strNewServerName );
} }
} }

View file

@ -25,6 +25,7 @@
#pragma once #pragma once
#include <QFrame> #include <QFrame>
#include <QScrollArea>
#include <QGroupBox> #include <QGroupBox>
#include <QLabel> #include <QLabel>
#include <QCheckBox> #include <QCheckBox>
@ -89,7 +90,7 @@ signals:
}; };
class CAudioMixerBoard : public QGroupBox class CAudioMixerBoard : public QScrollArea
{ {
Q_OBJECT Q_OBJECT
@ -121,6 +122,7 @@ protected:
const double dValue ); const double dValue );
CVector<CChannelFader*> vecpChanFader; CVector<CChannelFader*> vecpChanFader;
QGroupBox* pGroupBox;
QHBoxLayout* pMainLayout; QHBoxLayout* pMainLayout;
bool bNoFaderVisible; bool bNoFaderVisible;