diff --git a/src/libtomahawk/context/ContextWidget.cpp b/src/libtomahawk/context/ContextWidget.cpp index 0f024f117..4c20c91ca 100644 --- a/src/libtomahawk/context/ContextWidget.cpp +++ b/src/libtomahawk/context/ContextWidget.cpp @@ -114,6 +114,22 @@ ContextWidget::~ContextWidget() } +void +ContextWidget::changeEvent( QEvent* e ) +{ + QWidget::changeEvent( e ); + switch ( e->type() ) + { + case QEvent::LanguageChange: + ui->retranslateUi( this ); + break; + + default: + break; + } +} + + void ContextWidget::layoutViews( bool animate ) { diff --git a/src/libtomahawk/context/ContextWidget.h b/src/libtomahawk/context/ContextWidget.h index 17a471d24..e47a88da6 100644 --- a/src/libtomahawk/context/ContextWidget.h +++ b/src/libtomahawk/context/ContextWidget.h @@ -63,6 +63,7 @@ private slots: protected: void paintEvent( QPaintEvent* e ); void resizeEvent( QResizeEvent* e ); + void changeEvent( QEvent* e ); private: void fadeOut( bool animate ); diff --git a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp index 2bd08e650..5551859c3 100644 --- a/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp +++ b/src/libtomahawk/infosystem/infoplugins/generic/lastfmplugin.cpp @@ -404,22 +404,22 @@ LastFmPlugin::notInCacheSlot( QHash criteria, Tomahawk::InfoSy InfoStringHash c; c[ "type" ] = "tracks"; c[ "id" ] = "chart.getTopTracks"; - c[ "label" ] = "Top Tracks"; + c[ "label" ] = tr( "Top Tracks" ); track_charts.append( c ); c[ "id" ] = "chart.getLovedTracks"; - c[ "label" ] = "Loved Tracks"; + c[ "label" ] = tr( "Loved Tracks" ); track_charts.append( c ); c[ "id" ] = "chart.getHypedTracks"; - c[ "label" ] = "Hyped Tracks"; + c[ "label" ] = tr( "Hyped Tracks" ); track_charts.append( c ); QList< InfoStringHash > artist_charts; c[ "type" ] = "artists"; c[ "id" ] = "chart.getTopArtists"; - c[ "label" ] = "Top Artists"; + c[ "label" ] = tr( "Top Artists" ); artist_charts.append( c ); c[ "id" ] = "chart.getHypedArtists"; - c[ "label" ] = "Hyped Artists"; + c[ "label" ] = tr( "Hyped Artists" ); artist_charts.append( c ); diff --git a/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp b/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp index 715ed0a5f..cc3a7b28b 100644 --- a/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp +++ b/src/libtomahawk/playlist/dynamic/echonest/EchonestControl.cpp @@ -736,29 +736,29 @@ Tomahawk::EchonestControl::calculateSummary() if( selectedType() == "Artist" ) { // magic char is used by EchonestGenerator to split the prefix from the artist name if( static_cast< Echonest::DynamicPlaylist::ArtistTypeEnum >( m_matchData.toInt() ) == Echonest::DynamicPlaylist::ArtistType ) - summary = QString( "only by ~%1" ).arg( m_data.second.toString() ); + summary = tr( "only by ~%1" ).arg( m_data.second.toString() ); else if( static_cast< Echonest::DynamicPlaylist::ArtistTypeEnum >( m_matchData.toInt() ) == Echonest::DynamicPlaylist::ArtistRadioType ) - summary = QString( "similar to ~%1" ).arg( m_data.second.toString() ); + summary = tr( "similar to ~%1" ).arg( m_data.second.toString() ); } else if( selectedType() == "Artist Description" ) { - summary = QString( "with genre ~%1" ).arg( m_data.second.toString() ); + summary = tr( "with genre ~%1" ).arg( m_data.second.toString() ); } else if( selectedType() == "User Radio" ) { QComboBox* b = qobject_cast< QComboBox* >( m_input.data() ); if ( b ) { if ( b->currentText().isEmpty() || b->itemData( b->currentIndex() ).isNull() ) - summary = "from no one"; + summary = tr( "from no one" ); else { QString subSum; - if ( b->currentText() == "My Collection" ) + if ( b->currentText() == tr( "My Collection" ) ) subSum = "my"; else subSum = b->currentText(); - summary = QString( "from %1 radio" ).arg( subSum ); + summary = tr( "from %1 radio" ).arg( subSum ); } } else - summary = "from no one"; + summary = tr( "from no one" ); } else if( selectedType() == "Artist Description" || selectedType() == "Song" ) { summary = QString( "similar to ~%1" ).arg( m_data.second.toString() ); } else if( selectedType() == "Variety" || selectedType() == "Danceability" || selectedType() == "Artist Hotttnesss" || @@ -777,25 +777,25 @@ Tomahawk::EchonestControl::calculateSummary() modifier = "high"; else if( 0.8 <= sliderVal && sliderVal <= 1 ) modifier = "very high"; - summary = QString( "with %1 %2" ).arg( modifier ).arg( selectedType().toLower() ); + summary = tr( "with %1 %2" ).arg( modifier ).arg( selectedType().toLower() ); } else if( selectedType() == "Tempo" ) { - summary = QString( "about %1 BPM" ).arg( m_data.second.toString() ); + summary = tr( "about %1 BPM" ).arg( m_data.second.toString() ); } else if( selectedType() == "Duration" ) { - summary = QString( "about %1 minutes long" ).arg( m_data.second.toInt() / 60 ); + summary = tr( "about %n minute(s) long", "", m_data.second.toInt() / 60 ); } else if( selectedType() == "Loudness" ) { - summary = QString( "about %1 dB" ).arg( m_data.second.toString() ); + summary = tr( "about %1 dB" ).arg( m_data.second.toString() ); } else if( selectedType() == "Latitude" || selectedType() == "Longitude" ) { - summary = QString( "at around %1%2 %3" ).arg( m_data.second.toString() ).arg( QString( QChar( 0x00B0 ) ) ).arg( selectedType().toLower() ); + summary = tr( "at around %1%2 %3" ).arg( m_data.second.toString() ).arg( QString( QChar( 0x00B0 ) ) ).arg( selectedType().toLower() ); } else if( selectedType() == "Key" ) { Q_ASSERT( !m_input.isNull() ); Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) ); QString keyName = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower(); - summary = QString( "in %1" ).arg( keyName ); + summary = tr( "in %1" ).arg( keyName ); } else if( selectedType() == "Mode" ) { Q_ASSERT( !m_input.isNull() ); Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) ); QString modeName = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower(); - summary = QString( "in a %1 key" ).arg( modeName ); + summary = tr( "in a %1 key" ).arg( modeName ); } else if( selectedType() == "Sorting" ) { Q_ASSERT( !m_input.isNull() ); Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) ); @@ -805,17 +805,17 @@ Tomahawk::EchonestControl::calculateSummary() Q_ASSERT( qobject_cast< QComboBox* >( m_match.data() ) ); QString ascdesc = qobject_cast< QComboBox* >( m_match.data() )->currentText().toLower(); - summary = QString( "sorted in %1 %2 order" ).arg( ascdesc ).arg( sortType ); + summary = tr( "sorted in %1 %2 order" ).arg( ascdesc ).arg( sortType ); } else if( selectedType() == "Mood" ) { Q_ASSERT( !m_input.isNull() ); Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) ); QString text = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower(); - summary = QString( "with a %1 mood" ).arg( text ); + summary = tr( "with a %1 mood" ).arg( text ); } else if( selectedType() == "Style" ) { Q_ASSERT( !m_input.isNull() ); Q_ASSERT( qobject_cast< QComboBox* >( m_input.data() ) ); QString text = qobject_cast< QComboBox* >( m_input.data() )->currentText().toLower(); - summary = QString( "in a %1 style" ).arg( text ); + summary = tr( "in a %1 style" ).arg( text ); } m_summary = summary; } diff --git a/src/libtomahawk/playlist/queueview.cpp b/src/libtomahawk/playlist/queueview.cpp index 8ceff7054..6a9984a27 100644 --- a/src/libtomahawk/playlist/queueview.cpp +++ b/src/libtomahawk/playlist/queueview.cpp @@ -60,12 +60,29 @@ QueueView::~QueueView() } +void +QueueView::changeEvent( QEvent* e ) +{ + QWidget::changeEvent( e ); + switch ( e->type() ) + { + case QEvent::LanguageChange: + ui->retranslateUi( this ); + break; + + default: + break; + } +} + + PlaylistView* QueueView::queue() const { return ui->queue; } + bool QueueView::eventFilter( QObject* obj, QEvent* ev ) { @@ -94,6 +111,7 @@ QueueView::eventFilter( QObject* obj, QEvent* ev ) return QObject::eventFilter( obj, ev ); } + void QueueView::hide() { diff --git a/src/libtomahawk/playlist/queueview.h b/src/libtomahawk/playlist/queueview.h index 33e9d95d9..356400b0d 100644 --- a/src/libtomahawk/playlist/queueview.h +++ b/src/libtomahawk/playlist/queueview.h @@ -54,6 +54,9 @@ public slots: virtual void show(); virtual void hide(); +protected: + void changeEvent( QEvent* e ); + private: Ui::QueueView* ui; QTimer* m_dragTimer; diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index 3af30c9f0..6082c3acf 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -486,7 +486,7 @@ TomahawkApp::initLocalCollection() { connect( SourceList::instance(), SIGNAL( ready() ), SLOT( initServent() ) ); - source_ptr src( new Source( 0, "My Collection" ) ); + source_ptr src( new Source( 0, tr( "My Collection" ) ) ); collection_ptr coll( new LocalCollection( src ) ); src->addCollection( coll );