From bef3506a38b65066ff77a6cf72558ca5a46c2a69 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Mon, 30 Mar 2020 19:53:30 +0200 Subject: [PATCH] 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 --- src/audiomixerboard.cpp | 22 ++++++++++++++++------ src/audiomixerboard.h | 4 +++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 8cd770f6..bdff8f11 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -464,19 +464,20 @@ double CChannelFader::CalcFaderGain ( const int value ) * CAudioMixerBoard * \******************************************************************************/ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) : - QGroupBox ( parent ), + QScrollArea ( parent ), vecStoredFaderTags ( MAX_NUM_STORED_FADER_SETTINGS, "" ), vecStoredFaderLevels ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_FADER_MAX ), vecStoredFaderIsSolo ( MAX_NUM_STORED_FADER_SETTINGS, false ), iNewClientFaderLevel ( 100 ), 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) SetServerName ( "" ); - // add hboxlayout - pMainLayout = new QHBoxLayout ( this ); - // create all mixer controls and make them invisible vecpChanFader.Init ( MAX_NUM_CHANNELS ); @@ -489,6 +490,15 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) : // insert horizontal spacer 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 ------------------------------------------------------------- // CODE TAG: MAX_NUM_CHANNELS_TAG @@ -601,11 +611,11 @@ void CAudioMixerBoard::SetServerName ( const QString& strNewServerName ) // set title text of the group box if ( strNewServerName.isEmpty() ) { - setTitle ( "Server" ); + pGroupBox->setTitle ( "Server" ); } else { - setTitle ( strNewServerName ); + pGroupBox->setTitle ( strNewServerName ); } } diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index b8a3c0cb..a8c7e101 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -25,6 +25,7 @@ #pragma once #include +#include #include #include #include @@ -89,7 +90,7 @@ signals: }; -class CAudioMixerBoard : public QGroupBox +class CAudioMixerBoard : public QScrollArea { Q_OBJECT @@ -121,6 +122,7 @@ protected: const double dValue ); CVector vecpChanFader; + QGroupBox* pGroupBox; QHBoxLayout* pMainLayout; bool bNoFaderVisible;