added support for country flag icon

This commit is contained in:
Volker Fischer 2015-01-23 21:38:24 +00:00
parent bc17803f15
commit 1d21bb84b1
2 changed files with 71 additions and 33 deletions

View file

@ -40,8 +40,9 @@ CChannelFader::CChannelFader ( QWidget* pNW,
pcbMute = new QCheckBox ( "Mute", pFrame ); pcbMute = new QCheckBox ( "Mute", pFrame );
pcbSolo = new QCheckBox ( "Solo", pFrame ); pcbSolo = new QCheckBox ( "Solo", pFrame );
QGroupBox* pLabelInstBox = new QGroupBox ( pFrame ); QGroupBox* pLabelInstBox = new QGroupBox ( pFrame );
pLabel = new QLabel ( "", pFrame ); plblLabel = new QLabel ( "", pFrame );
pInstrument = new QLabel ( pFrame ); plblInstrument = new QLabel ( pFrame );
plblCountryFlag = new QLabel ( pFrame );
QHBoxLayout* pLabelGrid = new QHBoxLayout ( pLabelInstBox ); QHBoxLayout* pLabelGrid = new QHBoxLayout ( pLabelInstBox );
// setup slider // setup slider
@ -59,9 +60,9 @@ CChannelFader::CChannelFader ( QWidget* pNW,
" background-color: white; }" ); " background-color: white; }" );
// setup fader tag label (black bold text which is centered) // setup fader tag label (black bold text which is centered)
pLabel->setTextFormat ( Qt::PlainText ); plblLabel->setTextFormat ( Qt::PlainText );
pLabel->setAlignment ( Qt::AlignHCenter ); plblLabel->setAlignment ( Qt::AlignHCenter );
pLabel->setStyleSheet ( plblLabel->setStyleSheet (
"QLabel { color: black;" "QLabel { color: black;"
" font: bold; }" ); " font: bold; }" );
@ -71,8 +72,9 @@ CChannelFader::CChannelFader ( QWidget* pNW,
pLabelGrid->setSpacing ( 2 ); // only minimal space between picture and text pLabelGrid->setSpacing ( 2 ); // only minimal space between picture and text
// add user controls to the grids // add user controls to the grids
pLabelGrid->addWidget ( pInstrument ); pLabelGrid->addWidget ( plblInstrument );
pLabelGrid->addWidget ( pLabel, 0 ); pLabelGrid->addWidget ( plblLabel, 0, Qt::AlignVCenter );
pLabelGrid->addWidget ( plblCountryFlag, 0, Qt::AlignRight );
pMainGrid->addWidget ( pFader, 0, Qt::AlignHCenter ); pMainGrid->addWidget ( pFader, 0, Qt::AlignHCenter );
pMainGrid->addWidget ( pcbMute, 0, Qt::AlignLeft ); pMainGrid->addWidget ( pcbMute, 0, Qt::AlignLeft );
@ -103,13 +105,15 @@ CChannelFader::CChannelFader ( QWidget* pNW,
pcbSolo->setAccessibleName ( tr ( "Solo button" ) ); pcbSolo->setAccessibleName ( tr ( "Solo button" ) );
QString strFaderText = tr ( "<b>Fader Tag:</b> The fader tag " QString strFaderText = tr ( "<b>Fader Tag:</b> The fader tag "
"identifies the connected client. The tag name and the picture of your " "identifies the connected client. The tag name, the picture of your "
"instrument can be set in the main window." ); "instrument and a flag of your country can be set in the main window." );
pInstrument->setWhatsThis ( strFaderText ); plblInstrument->setWhatsThis ( strFaderText );
pInstrument->setAccessibleName ( tr ( "Mixer channel instrument picture" ) ); plblInstrument->setAccessibleName ( tr ( "Mixer channel instrument picture" ) );
pLabel->setWhatsThis ( strFaderText ); plblLabel->setWhatsThis ( strFaderText );
pLabel->setAccessibleName ( tr ( "Mixer channel label (fader tag)" ) ); plblLabel->setAccessibleName ( tr ( "Mixer channel label (fader tag)" ) );
plblCountryFlag->setWhatsThis ( strFaderText );
plblCountryFlag->setAccessibleName ( tr ( "Mixer channel country flag" ) );
// Connections ------------------------------------------------------------- // Connections -------------------------------------------------------------
@ -168,9 +172,12 @@ void CChannelFader::Reset()
pcbMute->setChecked ( false ); pcbMute->setChecked ( false );
pcbSolo->setChecked ( false ); pcbSolo->setChecked ( false );
// clear instrument picture and label text // clear instrument picture, country flag, tool tips and label text
pInstrument->setVisible ( false ); plblInstrument->setVisible ( false );
pLabel->setText ( "" ); plblInstrument->setToolTip ( "" );
plblCountryFlag->setVisible ( false );
plblCountryFlag->setToolTip ( "" );
plblLabel->setText ( "" );
strReceivedName = ""; strReceivedName = "";
bOtherChannelIsSolo = false; bOtherChannelIsSolo = false;
@ -249,8 +256,7 @@ void CChannelFader::SetText ( const CChannelInfo& ChanInfo )
// store original received name // store original received name
strReceivedName = ChanInfo.strName; strReceivedName = ChanInfo.strName;
// break text at predefined position, if text is too short, break anyway to // break text at predefined position
// make sure we have two lines for fader tag
const int iBreakPos = MAX_LEN_FADER_TAG / 2; const int iBreakPos = MAX_LEN_FADER_TAG / 2;
QString strModText = GenFaderText ( ChanInfo ); QString strModText = GenFaderText ( ChanInfo );
@ -259,14 +265,8 @@ void CChannelFader::SetText ( const CChannelInfo& ChanInfo )
{ {
strModText.insert ( iBreakPos, QString ( "\n" ) ); strModText.insert ( iBreakPos, QString ( "\n" ) );
} }
else
{
// insert line break at the beginning of the string -> make sure
// if we only have one line that the text appears at the bottom line
strModText.prepend ( QString ( "\n" ) );
}
pLabel->setText ( strModText ); plblLabel->setText ( strModText );
} }
void CChannelFader::SetInstrumentPicture ( const int iInstrument ) void CChannelFader::SetInstrumentPicture ( const int iInstrument )
@ -279,16 +279,48 @@ void CChannelFader::SetInstrumentPicture ( const int iInstrument )
if ( CInstPictures::IsNotUsedInstrument ( iInstrument ) || if ( CInstPictures::IsNotUsedInstrument ( iInstrument ) ||
strCurResourceRef.isEmpty() ) strCurResourceRef.isEmpty() )
{ {
// disable instrument picture // disable instrument picture and tool tip
pInstrument->setVisible ( false ); plblInstrument->setVisible ( false );
plblInstrument->setToolTip ( "" );
} }
else else
{ {
// set correct picture // set correct picture and tool tip text
pInstrument->setPixmap ( QPixmap ( strCurResourceRef ) ); plblInstrument->setPixmap ( QPixmap ( strCurResourceRef ) );
plblInstrument->setToolTip ( CInstPictures::GetName ( iInstrument ) );
// enable instrument picture // enable instrument picture
pInstrument->setVisible ( true ); plblInstrument->setVisible ( true );
}
}
void CChannelFader::SetCountryFlag ( const QLocale::Country eCountry )
{
if ( eCountry != QLocale::AnyCountry )
{
// get the resource reference string for this country flag
const QString strCurResourceRef = ":/png/flags/res/flags/" +
QLocale ( QLocale::AnyLanguage, eCountry ).bcp47Name() + ".png";
// try to load the country flag icon
QPixmap CountryFlagPixmap ( strCurResourceRef );
// first check if resource reference was valid
if ( CountryFlagPixmap.isNull() )
{
// disable country flag and tool tip
plblCountryFlag->setVisible ( false );
plblCountryFlag->setToolTip ( "" );
}
else
{
// set correct picture and tool tip text
plblCountryFlag->setPixmap ( CountryFlagPixmap );
plblCountryFlag->setToolTip ( QLocale::countryToString ( eCountry ) );
// enable country flag
plblCountryFlag->setVisible ( true );
}
} }
} }
@ -486,6 +518,10 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelInfo>& vecChanInf
// update instrument picture // update instrument picture
vecpChanFader[i]-> vecpChanFader[i]->
SetInstrumentPicture ( vecChanInfo[j].iInstrument ); SetInstrumentPicture ( vecChanInfo[j].iInstrument );
// update country flag
vecpChanFader[i]->
SetCountryFlag ( vecChanInfo[j].eCountry );
} }
bFaderIsUsed = true; bFaderIsUsed = true;

View file

@ -49,9 +49,10 @@ public:
void SetText ( const CChannelInfo& ChanInfo ); void SetText ( const CChannelInfo& ChanInfo );
QString GetReceivedName() { return strReceivedName; } QString GetReceivedName() { return strReceivedName; }
void SetInstrumentPicture ( const int iInstrument ); void SetInstrumentPicture ( const int iInstrument );
void SetCountryFlag ( const QLocale::Country eCountry );
void Show() { pFrame->show(); } void Show() { pFrame->show(); }
void Hide() { pFrame->hide(); } void Hide() { pFrame->hide(); }
bool IsVisible() { return pLabel->isVisible(); } bool IsVisible() { return plblLabel->isVisible(); }
bool IsSolo() { return pcbSolo->isChecked(); } bool IsSolo() { return pcbSolo->isChecked(); }
void SetGUIDesign ( const EGUIDesign eNewDesign ); void SetGUIDesign ( const EGUIDesign eNewDesign );
@ -71,8 +72,9 @@ protected:
QSlider* pFader; QSlider* pFader;
QCheckBox* pcbMute; QCheckBox* pcbMute;
QCheckBox* pcbSolo; QCheckBox* pcbSolo;
QLabel* pLabel; QLabel* plblLabel;
QLabel* pInstrument; QLabel* plblInstrument;
QLabel* plblCountryFlag;
QString strReceivedName; QString strReceivedName;