support for a country flag icon on the fader tag

This commit is contained in:
Volker Fischer 2015-01-24 15:38:39 +00:00
parent 1d21bb84b1
commit 5c909dc176
8 changed files with 169 additions and 10 deletions

View File

@ -1,7 +1,8 @@
3.3.6
- a licence agreement dialog can be requested by the server
- support for a country flag icon on the fader tag
- a licence agreement dialog can be requested by the server
3.3.5 (2014-07-30)
@ -11,6 +12,7 @@
- added a Linux jamulus.desktop file
3.3.4 (2014-02-25)
- true stereo reverberation effect (previously it was a mono reverberation
@ -28,6 +30,7 @@
- bug fix: the fader level could not be changed if the fader was on solo
3.3.3 (2013-12-30)
- support for storing/recovering the window positions

View File

@ -298,12 +298,9 @@ 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 );
QPixmap CountryFlagPixmap (
CCountyFlagIcons::GetResourceReference ( eCountry ) );
// first check if resource reference was valid
if ( CountryFlagPixmap.isNull() )
@ -322,6 +319,12 @@ void CChannelFader::SetCountryFlag ( const QLocale::Country eCountry )
plblCountryFlag->setVisible ( true );
}
}
else
{
// disable country flag and tool tip
plblCountryFlag->setVisible ( false );
plblCountryFlag->setToolTip ( "" );
}
}
double CChannelFader::CalcFaderGain ( const int value )

View File

@ -96,17 +96,17 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
"and disconnecting the " ) + APP_NAME + tr ( " software." ) );
// fader tag
QString strFaderTag = tr ( "<b>Your Alias/Instrument:</b> Set your name "
QString strFaderTag = tr ( "<b>Your Alias/Instrument/Country:</b> Set your name "
"or an alias here so that the other musicians you want to play with "
"know who you are. Additionally you may set an instrument picture of "
"the instrument you play. "
"the instrument you play and a flag of the country you are living. "
"What you set here will appear at your fader on the mixer board when "
"you are connected to a " ) + APP_NAME + tr ( " server. This tag will "
"also show up at each client which is connected to the same server as "
"you. If the fader tag is empty, the IP address is shown instead." );
QString strFaderTagTT = tr ( "Set your name and/or instrument and/or "
"pseoudonym here so that the other musicians can identify you." ) +
"country here so that the other musicians can identify you." ) +
TOOLTIP_COM_END_TEXT;
lblServerTag->setWhatsThis ( strFaderTag );
@ -117,6 +117,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
butInstPicture->setWhatsThis ( strFaderTag );
butInstPicture->setToolTip ( strFaderTagTT );
butInstPicture->setAccessibleName ( tr ( "Instrument picture button" ) );
butCountryFlag->setWhatsThis ( strFaderTag );
butCountryFlag->setToolTip ( strFaderTagTT );
butCountryFlag->setAccessibleName ( tr ( "Country flag button" ) );
// local audio input fader
QString strAudFader = tr ( "<b>Local Audio Input Fader:</b> With the "
@ -212,11 +215,15 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
MainMixerBoard->vecStoredFaderLevels = pClient->vecStoredFaderLevels;
MainMixerBoard->vecStoredFaderIsSolo = pClient->vecStoredFaderIsSolo;
// init fader tag line edit and instrument picture
// init fader tag line edit, instrument picture and country flag
edtFaderTag->setText ( pClient->ChannelInfo.strName );
butInstPicture->setIcon ( QIcon (
CInstPictures::GetResourceReference ( pClient->ChannelInfo.iInstrument ) ) );
butCountryFlag->setIcon ( QIcon (
CCountyFlagIcons::GetResourceReference ( pClient->ChannelInfo.eCountry ) ) );
// init status label
OnTimerStatus();
@ -333,6 +340,51 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
}
// Country flag icons popup menu -------------------------------------------
pCountryFlagPopupMenu = new QMenu ( this );
// add an entry for all known country flags
for ( int iCurCntry = static_cast<int> ( QLocale::AnyCountry );
iCurCntry < static_cast<int> ( QLocale::LastCountry ); iCurCntry++ )
{
// the "Default" country gets a special icon
QIcon CurFlagIcon;
QString sCurCountryName;
if ( static_cast<QLocale::Country> ( iCurCntry ) == QLocale::AnyCountry )
{
// default icon and name for no flag selected
CurFlagIcon.addFile ( ":/png/flags/res/flags/flagnone.png" );
sCurCountryName = "None";
}
else
{
// get current country enum
QLocale::Country eCountry =
static_cast<QLocale::Country> ( iCurCntry );
// get resource file name
CurFlagIcon.addFile ( CCountyFlagIcons::GetResourceReference ( eCountry ) );
// get the country name
sCurCountryName = QLocale::countryToString ( eCountry );
}
// only add the entry if a flag is available
if ( !CurFlagIcon.isNull() )
{
// create a menu action with text and image
QAction* pCurAction =
new QAction ( CurFlagIcon, sCurCountryName, this );
// add data to identify the action data when it is triggered
pCurAction->setData ( iCurCntry );
pCountryFlagPopupMenu->addAction ( pCurAction );
}
}
// Window positions --------------------------------------------------------
// main window
if ( !pClient->vecWindowPosMain.isEmpty() && !pClient->vecWindowPosMain.isNull() )
@ -382,6 +434,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
QObject::connect ( butInstPicture, SIGNAL ( clicked() ),
this, SLOT ( OnInstPictureBut() ) );
QObject::connect ( butCountryFlag, SIGNAL ( clicked() ),
this, SLOT ( OnCountryFlagBut() ) );
// check boxes
QObject::connect ( chbSettings, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnSettingsStateChanged ( int ) ) );
@ -424,6 +479,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP,
QObject::connect ( pInstrPictPopupMenu, SIGNAL ( triggered ( QAction* ) ),
this, SLOT ( OnInstPicturesMenuTriggered ( QAction* ) ) );
QObject::connect ( pCountryFlagPopupMenu, SIGNAL ( triggered ( QAction* ) ),
this, SLOT ( OnCountryFlagMenuTriggered ( QAction* ) ) );
// other
QObject::connect ( pClient,
SIGNAL ( ConClientListNameMesReceived ( CVector<CChannelInfo> ) ),
@ -685,6 +743,14 @@ void CClientDlg::OnInstPictureBut()
pInstrPictPopupMenu->exec ( this->mapToGlobal ( butInstPicture->pos() ) );
}
void CClientDlg::OnCountryFlagBut()
{
// open a menu which shows all available country flags which
// always appears at the same position relative to the country
// flags button
pCountryFlagPopupMenu->exec ( this->mapToGlobal ( butCountryFlag->pos() ) );
}
void CClientDlg::OnInstPicturesMenuTriggered ( QAction* SelAction )
{
// get selected instrument
@ -701,6 +767,23 @@ void CClientDlg::OnInstPicturesMenuTriggered ( QAction* SelAction )
CInstPictures::GetResourceReference ( iSelInstrument ) ) );
}
void CClientDlg::OnCountryFlagMenuTriggered ( QAction* SelAction )
{
// get selected country
const QLocale::Country eSelCountry =
static_cast<QLocale::Country> ( SelAction->data().toInt() );
// set the new value in the data base
pClient->ChannelInfo.eCountry = eSelCountry;
// update channel info at the server
pClient->SetRemoteInfo();
// update icon on the instrument selection button
butCountryFlag->setIcon ( QIcon (
CCountyFlagIcons::GetResourceReference ( eSelCountry ) ) );
}
void CClientDlg::OnChatTextReceived ( QString strChatText )
{
ChatDlg.AddChatText ( strChatText );

View File

@ -105,6 +105,7 @@ protected:
QMenu* pViewMenu;
QMenuBar* pMenu;
QMenu* pInstrPictPopupMenu;
QMenu* pCountryFlagPopupMenu;
CClientSettingsDlg ClientSettingsDlg;
CChatDlg ChatDlg;
@ -116,6 +117,7 @@ public slots:
void OnConnectDisconBut();
void OnInstPictureBut();
void OnCountryFlagBut();
void OnTimerSigMet();
void OnTimerBuffersLED();
@ -140,6 +142,7 @@ public slots:
void OnOpenAnalyzerConsole() { ShowAnalyzerConsole(); }
void OnInstPicturesMenuTriggered ( QAction* SelAction );
void OnCountryFlagMenuTriggered ( QAction* SelAction );
void OnSettingsStateChanged ( int value );
void OnChatStateChanged ( int value );

BIN
src/res/flags/flagnone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

View File

@ -107,6 +107,18 @@ void CSettings::Load()
pClient->ChannelInfo.iInstrument = iValue;
}
// country
if ( GetNumericIniSet ( IniXMLDocument, "client", "country",
0, static_cast<int> ( QLocale::LastCountry ), iValue ) )
{
pClient->ChannelInfo.eCountry = static_cast<QLocale::Country> ( iValue );
}
else
{
// if no country is given, use the one from the operating system
pClient->ChannelInfo.eCountry = QLocale::system().country();
}
// audio fader
if ( GetNumericIniSet ( IniXMLDocument, "client", "audfad",
AUD_FADER_IN_MIN, AUD_FADER_IN_MAX, iValue ) )
@ -371,6 +383,10 @@ void CSettings::Save()
SetNumericIniSet ( IniXMLDocument, "client", "instrument",
pClient->ChannelInfo.iInstrument );
// country
SetNumericIniSet ( IniXMLDocument, "client", "country",
static_cast<int> ( pClient->ChannelInfo.eCountry ) );
// audio fader
SetNumericIniSet ( IniXMLDocument, "client", "audfad",
pClient->GetAudioInFader() );

View File

@ -670,6 +670,48 @@ QString CInstPictures::GetName ( const int iInstrument )
}
// Country flag icon data base -------------------------------------------------
QString CCountyFlagIcons::GetResourceReference ( const QLocale::Country eCountry )
{
QString strReturn = "";
// special flag for none
if ( eCountry == QLocale::AnyCountry )
{
strReturn = ":/png/flags/res/flags/flagnone.png";
}
else
{
// There is no direct query of the country code in Qt, therefore we use a
// workaround: Get the matching locales properties and split the name of
// that since the second part is the country code
QList<QLocale> vCurLocaleList = QLocale::matchingLocales ( QLocale::AnyLanguage,
QLocale::AnyScript,
eCountry );
// check if the matching locales query was successful
if ( vCurLocaleList.size() > 0 )
{
QStringList vstrLocParts = vCurLocaleList.at ( 0 ).name().split("_");
// the second split contains the name we need
if ( vstrLocParts.size() > 1 )
{
strReturn =
":/png/flags/res/flags/" + vstrLocParts.at ( 1 ).toLower() + ".png";
// check if file actually exists, if not then invalidate reference
if ( !QFile::exists ( strReturn ) )
{
strReturn = "";
}
}
}
}
return strReturn;
}
/******************************************************************************\
* Global Functions Implementation *

View File

@ -662,6 +662,15 @@ protected:
};
// Country flag icon data base -------------------------------------------------
// this is a pure static class
class CCountyFlagIcons
{
public:
static QString GetResourceReference ( const QLocale::Country eCountry );
};
// Info of a channel -----------------------------------------------------------
class CChannelCoreInfo
{