From e832ac09bbb61b954bc30a040467cdc0d84d2efc Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Mon, 20 Jul 2020 19:26:05 +0200 Subject: [PATCH] improve compact skin by using smaller font size if the name is too long --- ChangeLog | 3 +-- src/audiomixerboard.cpp | 45 +++++++++++++++++++++++++++++++++++------ src/audiomixerboard.h | 1 + 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index ef5149ce..2e61f016 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,10 +9,9 @@ - if network name/address contains spaces, they are removed now, coded by dingodoppelt (#462) +- improve compact skin by using smaller font size if the name is too long -TODO improve compact channels: smaller font size of name is too long - diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 8e92f139..b82a0d48 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -28,7 +28,8 @@ /******************************************************************************\ * CChanneFader * \******************************************************************************/ -CChannelFader::CChannelFader ( QWidget* pNW ) +CChannelFader::CChannelFader ( QWidget* pNW ) : + eDesign ( GD_STANDARD ) { // create new GUI control objects and store pointers to them (note that // QWidget takes the ownership of the pMainGrid so that this only has @@ -91,7 +92,6 @@ CChannelFader::CChannelFader ( QWidget* pNW ) // setup fader tag label (black bold text which is centered) plblLabel->setTextFormat ( Qt::PlainText ); plblLabel->setAlignment ( Qt::AlignHCenter | Qt::AlignVCenter ); - plblLabel->setStyleSheet ( "QLabel { color: black; font: bold; }" ); // set margins of the layouts to zero to get maximum space for the controls pMainGrid->setContentsMargins ( 0, 0, 0, 0 ); @@ -203,6 +203,8 @@ CChannelFader::CChannelFader ( QWidget* pNW ) void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign ) { + eDesign = eNewDesign; + switch ( eNewDesign ) { case GD_ORIGINAL: @@ -601,14 +603,45 @@ void CChannelFader::SetChannelInfos ( const CChannelInfo& cChanInfo ) // Label text -------------------------------------------------------------- - // break text at predefined position - const int iBreakPos = MAX_LEN_FADER_TAG / 2; QString strModText = cChanInfo.strName; - if ( strModText.length() > iBreakPos ) + // apply break position and font size depending on the selected design as + // well as the length of the name + if ( ( eDesign == GD_SLIMFADER ) && ( strModText.length() > 6 ) ) { - strModText.insert ( iBreakPos, QString ( "\n" ) ); + // in slim mode, if the text is longer than 6 character, use a small font + plblLabel->setStyleSheet ( "QLabel { color: black; font: 6pt bold; }" ); + + // break at every 4th character + for ( int iInsPos = 4; iInsPos <= strModText.size() - 1; iInsPos += 4 + 1 ) + { + strModText.insert ( iInsPos, "\n" ); + } + } + else + { + plblLabel->setStyleSheet ( "QLabel { color: black; font: bold; }" ); + + // break text at predefined position + int iBreakPos; + + if ( eDesign == GD_SLIMFADER ) + { + // for slim design if the text is shorter than 6 characters, break + // at half of the 6 characters + iBreakPos = 3; + } + else + { + // default break position (used for other skins than slim) + iBreakPos = MAX_LEN_FADER_TAG / 2; + } + + if ( strModText.length() > iBreakPos ) + { + strModText.insert ( iBreakPos, QString ( "\n" ) ); + } } plblLabel->setText ( strModText ); diff --git a/src/audiomixerboard.h b/src/audiomixerboard.h index aa1bc510..9819b5ad 100755 --- a/src/audiomixerboard.h +++ b/src/audiomixerboard.h @@ -121,6 +121,7 @@ protected: int iGroupID; QString strGroupBaseText; int iInstrPicMaxWidth; + EGUIDesign eDesign; public slots: void OnLevelValueChanged ( int value ) { SendFaderLevelToServer ( value, false ); }