put the scroll area inside the group box because the title of the group box should always be visible

This commit is contained in:
Volker Fischer 2020-05-20 22:28:52 +02:00
parent f580215605
commit f467d2259c
3 changed files with 34 additions and 22 deletions

View file

@ -66,7 +66,7 @@ CChannelFader::CChannelFader ( QWidget* pNW,
pFader->setTickPosition ( QSlider::TicksBothSides ); pFader->setTickPosition ( QSlider::TicksBothSides );
pFader->setRange ( 0, AUD_MIX_FADER_MAX ); pFader->setRange ( 0, AUD_MIX_FADER_MAX );
pFader->setTickInterval ( AUD_MIX_FADER_MAX / 9 ); pFader->setTickInterval ( AUD_MIX_FADER_MAX / 9 );
pFader->setMinimumHeight ( 90 ); pFader->setMinimumHeight ( 75 );
// setup panning control // setup panning control
pPan->setRange ( 0, AUD_MIX_PAN_MAX ); pPan->setRange ( 0, AUD_MIX_PAN_MAX );
@ -572,7 +572,7 @@ double CChannelFader::CalcFaderGain ( const int value )
* CAudioMixerBoard * * CAudioMixerBoard *
\******************************************************************************/ \******************************************************************************/
CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) : CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) :
QScrollArea ( parent ), QGroupBox ( 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 ),
vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX / 2 ), vecStoredPanValues ( MAX_NUM_STORED_FADER_SETTINGS, AUD_MIX_PAN_MAX / 2 ),
@ -583,8 +583,10 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags ) :
strServerName ( "" ) strServerName ( "" )
{ {
// add group box and hboxlayout // add group box and hboxlayout
pGroupBox = new QGroupBox(); // will be added to the scroll area which is then the parent QHBoxLayout* pGroupBoxLayout = new QHBoxLayout ( this );
pMainLayout = new QHBoxLayout ( pGroupBox ); QWidget* pMixerWidget = new QWidget(); // will be added to the scroll area which is then the parent
pScrollArea = new CMixerBoardScrollArea ( this );
pMainLayout = new QHBoxLayout ( pMixerWidget );
// set title text (default: no server given) // set title text (default: no server given)
SetServerName ( "" ); SetServerName ( "" );
@ -601,11 +603,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 ) );
// set margins of the layout to zero to get maximum space for the controls
pGroupBoxLayout->setContentsMargins ( 0, 0, 0, 1 ); // note: to avoid problems at the botton, use a small margin for that
// add the group box to the scroll area // add the group box to the scroll area
setMinimumWidth ( 200 ); // at least two faders shall be visible pScrollArea->setMinimumWidth ( 200 ); // at least two faders shall be visible
setWidget ( pGroupBox ); pScrollArea->setWidget ( pMixerWidget );
setWidgetResizable ( true ); // make sure it fills the entire scroll area pScrollArea->setWidgetResizable ( true ); // make sure it fills the entire scroll area
setFrameShape ( QFrame::NoFrame ); pScrollArea->setFrameShape ( QFrame::NoFrame );
pGroupBoxLayout->addWidget ( pScrollArea );
// Connections ------------------------------------------------------------- // Connections -------------------------------------------------------------
@ -646,7 +652,7 @@ void CAudioMixerBoard::SetServerName ( const QString& strNewServerName )
if ( strServerName.isEmpty() ) if ( strServerName.isEmpty() )
{ {
// no connection or connection was reset: show default title // no connection or connection was reset: show default title
pGroupBox->setTitle ( tr ( "Server" ) ); setTitle ( tr ( "Server" ) );
} }
else else
{ {
@ -655,7 +661,7 @@ void CAudioMixerBoard::SetServerName ( const QString& strNewServerName )
// list was received, the connection was successful and the title is updated // list was received, the connection was successful and the title is updated
// with the correct server name. Make sure to choose a "try to connect" title // with the correct server name. Make sure to choose a "try to connect" title
// which is most striking (we use filled blocks and upper case letters). // which is most striking (we use filled blocks and upper case letters).
pGroupBox->setTitle ( u8"\u2588\u2588\u2588\u2588\u2588 " + tr ( "T R Y I N G T O C O N N E C T" ) + u8" \u2588\u2588\u2588\u2588\u2588" ); setTitle ( u8"\u2588\u2588\u2588\u2588\u2588 " + tr ( "T R Y I N G T O C O N N E C T" ) + u8" \u2588\u2588\u2588\u2588\u2588" );
} }
} }
@ -692,14 +698,6 @@ void CAudioMixerBoard::SetPanIsSupported()
} }
} }
void CAudioMixerBoard::resizeEvent ( QResizeEvent* event )
{
// if after a resize of the main window a vertical scroll bar is required, make
// sure that the fader label is visible (scroll down completely)
ensureVisible ( 0, 2000 ); // use a large value here
QScrollArea::resizeEvent ( event );
}
void CAudioMixerBoard::HideAll() void CAudioMixerBoard::HideAll()
{ {
// make all controls invisible // make all controls invisible
@ -727,7 +725,7 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelInfo>& vecChanInf
// in the audio mixer board to show a "try to connect" before // in the audio mixer board to show a "try to connect" before
if ( bNoFaderVisible ) if ( bNoFaderVisible )
{ {
pGroupBox->setTitle ( tr ( "Personal Mix at the Server: " ) + strServerName ); setTitle ( tr ( "Personal Mix at the Server: " ) + strServerName );
} }
// get number of connected clients // get number of connected clients

View file

@ -129,7 +129,7 @@ class CAudioMixerBoardSlots<0> {};
class CAudioMixerBoard : class CAudioMixerBoard :
public QScrollArea, public QGroupBox,
public CAudioMixerBoardSlots<MAX_NUM_CHANNELS> public CAudioMixerBoardSlots<MAX_NUM_CHANNELS>
{ {
Q_OBJECT Q_OBJECT
@ -158,7 +158,20 @@ public:
int iNewClientFaderLevel; int iNewClientFaderLevel;
protected: protected:
void resizeEvent ( QResizeEvent* event ); class CMixerBoardScrollArea : public QScrollArea
{
public:
CMixerBoardScrollArea ( QWidget* parent = nullptr ) : QScrollArea ( parent ) {}
protected:
virtual void resizeEvent ( QResizeEvent* event )
{
// if after a resize of the main window a vertical scroll bar is required, make
// sure that the fader label is visible (scroll down completely)
ensureVisible ( 0, 2000 ); // use a large value here
QScrollArea::resizeEvent ( event );
}
};
bool GetStoredFaderSettings ( const CChannelInfo& ChanInfo, bool GetStoredFaderSettings ( const CChannelInfo& ChanInfo,
int& iStoredFaderLevel, int& iStoredFaderLevel,
@ -173,7 +186,7 @@ protected:
const double dValue ); const double dValue );
CVector<CChannelFader*> vecpChanFader; CVector<CChannelFader*> vecpChanFader;
QGroupBox* pGroupBox; CMixerBoardScrollArea* pScrollArea;
QHBoxLayout* pMainLayout; QHBoxLayout* pMainLayout;
bool bDisplayChannelLevels; bool bDisplayChannelLevels;
bool bNoFaderVisible; bool bNoFaderVisible;

View file

@ -1171,6 +1171,7 @@ void CClientDlg::SetGUIDesign ( const EGUIDesign eNewDesign )
"QRadioButton { color: rgb(220, 220, 220);" "QRadioButton { color: rgb(220, 220, 220);"
" font: bold; }" " font: bold; }"
"QScrollArea { background: transparent; }" "QScrollArea { background: transparent; }"
".QWidget { background: transparent; }" // note: matches instances of QWidget, but not of its subclasses
"QGroupBox { background: transparent; }" "QGroupBox { background: transparent; }"
"QGroupBox::title { color: rgb(220, 220, 220); }" "QGroupBox::title { color: rgb(220, 220, 220); }"
"QCheckBox::indicator { width: 38px;" "QCheckBox::indicator { width: 38px;"