mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
style fixes in EchonestControl & EchonestGenerator
This commit is contained in:
@@ -72,7 +72,8 @@ Tomahawk::EchonestControl::matchSelector()
|
|||||||
void
|
void
|
||||||
Tomahawk::EchonestControl::setSelectedType ( const QString& type )
|
Tomahawk::EchonestControl::setSelectedType ( const QString& type )
|
||||||
{
|
{
|
||||||
if( type != selectedType() ) {
|
if( type != selectedType() )
|
||||||
|
{
|
||||||
if( !m_input.isNull() )
|
if( !m_input.isNull() )
|
||||||
delete m_input.data();
|
delete m_input.data();
|
||||||
if( !m_match.isNull() )
|
if( !m_match.isNull() )
|
||||||
@@ -81,7 +82,7 @@ Tomahawk::EchonestControl::setSelectedType ( const QString& type )
|
|||||||
Tomahawk::DynamicControl::setSelectedType ( type );
|
Tomahawk::DynamicControl::setSelectedType ( type );
|
||||||
updateWidgets();
|
updateWidgets();
|
||||||
updateData();
|
updateData();
|
||||||
// qDebug() << "Setting new type, set data to:" << m_data.first << m_data.second;
|
//qDebug() << "Setting new type, set data to:" << m_data.first << m_data.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +90,8 @@ Tomahawk::EchonestControl::setSelectedType ( const QString& type )
|
|||||||
Echonest::DynamicPlaylist::PlaylistParamData
|
Echonest::DynamicPlaylist::PlaylistParamData
|
||||||
Tomahawk::EchonestControl::toENParam() const
|
Tomahawk::EchonestControl::toENParam() const
|
||||||
{
|
{
|
||||||
if( m_overrideType != -1 ) {
|
if( m_overrideType != -1 )
|
||||||
|
{
|
||||||
Echonest::DynamicPlaylist::PlaylistParamData newData = m_data;
|
Echonest::DynamicPlaylist::PlaylistParamData newData = m_data;
|
||||||
newData.first = static_cast<Echonest::DynamicPlaylist::PlaylistParam>( m_overrideType );
|
newData.first = static_cast<Echonest::DynamicPlaylist::PlaylistParam>( m_overrideType );
|
||||||
return newData;
|
return newData;
|
||||||
@@ -155,7 +157,8 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
m_overrideType = -1;
|
m_overrideType = -1;
|
||||||
|
|
||||||
// make sure the widgets are the proper kind for the selected type, and hook up to their slots
|
// make sure the widgets are the proper kind for the selected type, and hook up to their slots
|
||||||
if( selectedType() == "Artist" ) {
|
if( selectedType() == "Artist" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::Artist;
|
m_currentType = Echonest::DynamicPlaylist::Artist;
|
||||||
|
|
||||||
QComboBox* match = new QComboBox();
|
QComboBox* match = new QComboBox();
|
||||||
@@ -184,7 +187,9 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
m_match = QPointer< QWidget >( match );
|
m_match = QPointer< QWidget >( match );
|
||||||
m_input = QPointer< QWidget >( input );
|
m_input = QPointer< QWidget >( input );
|
||||||
m_data.first = m_currentType;
|
m_data.first = m_currentType;
|
||||||
} else if( selectedType() == "Artist Description" ) {
|
}
|
||||||
|
else if( selectedType() == "Artist Description" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::Description;
|
m_currentType = Echonest::DynamicPlaylist::Description;
|
||||||
|
|
||||||
QLabel* match = new QLabel( tr( "is" ) );
|
QLabel* match = new QLabel( tr( "is" ) );
|
||||||
@@ -203,7 +208,9 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
m_match = QPointer< QWidget >( match );
|
m_match = QPointer< QWidget >( match );
|
||||||
m_input = QPointer< QWidget >( input );
|
m_input = QPointer< QWidget >( input );
|
||||||
m_data.first = m_currentType;
|
m_data.first = m_currentType;
|
||||||
} else if( selectedType() == "User Radio" ) {
|
}
|
||||||
|
else if( selectedType() == "User Radio" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::SourceCatalog;
|
m_currentType = Echonest::DynamicPlaylist::SourceCatalog;
|
||||||
|
|
||||||
QLabel* match = new QLabel( tr( "from user" ) );
|
QLabel* match = new QLabel( tr( "from user" ) );
|
||||||
@@ -231,7 +238,9 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
combo->hide();
|
combo->hide();
|
||||||
m_match = QPointer< QWidget >( match );
|
m_match = QPointer< QWidget >( match );
|
||||||
m_input = QPointer< QWidget >( combo );
|
m_input = QPointer< QWidget >( combo );
|
||||||
} else if( selectedType() == "Song" ) {
|
}
|
||||||
|
else if( selectedType() == "Song" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::SongId;
|
m_currentType = Echonest::DynamicPlaylist::SongId;
|
||||||
|
|
||||||
QLabel* match = new QLabel( tr( "similar to" ) );
|
QLabel* match = new QLabel( tr( "similar to" ) );
|
||||||
@@ -251,7 +260,9 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
m_match = QPointer< QWidget >( match );
|
m_match = QPointer< QWidget >( match );
|
||||||
m_input = QPointer< QWidget >( input );
|
m_input = QPointer< QWidget >( input );
|
||||||
m_data.first = m_currentType;
|
m_data.first = m_currentType;
|
||||||
} else if( selectedType() == "Variety" ) {
|
}
|
||||||
|
else if( selectedType() == "Variety" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::Variety;
|
m_currentType = Echonest::DynamicPlaylist::Variety;
|
||||||
|
|
||||||
QLabel* match = new QLabel( tr( "is" ) );
|
QLabel* match = new QLabel( tr( "is" ) );
|
||||||
@@ -272,7 +283,9 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
m_match = QPointer< QWidget >( match );
|
m_match = QPointer< QWidget >( match );
|
||||||
m_input = QPointer< QWidget >( input );
|
m_input = QPointer< QWidget >( input );
|
||||||
m_data.first = m_currentType;
|
m_data.first = m_currentType;
|
||||||
} else if( selectedType() == "Adventurousness" ) {
|
}
|
||||||
|
else if( selectedType() == "Adventurousness" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::Adventurousness;
|
m_currentType = Echonest::DynamicPlaylist::Adventurousness;
|
||||||
|
|
||||||
QLabel* match = new QLabel( tr( "is" ) );
|
QLabel* match = new QLabel( tr( "is" ) );
|
||||||
@@ -294,50 +307,72 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
m_match = QPointer< QWidget >( match );
|
m_match = QPointer< QWidget >( match );
|
||||||
m_input = QPointer< QWidget >( input );
|
m_input = QPointer< QWidget >( input );
|
||||||
m_data.first = m_currentType;
|
m_data.first = m_currentType;
|
||||||
} else if( selectedType() == "Tempo" ) {
|
}
|
||||||
|
else if( selectedType() == "Tempo" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::MinTempo;
|
m_currentType = Echonest::DynamicPlaylist::MinTempo;
|
||||||
|
|
||||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinTempo, Echonest::DynamicPlaylist::MaxTempo, tr( "0 BPM" ), tr( "500 BPM" ), 500 );
|
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinTempo, Echonest::DynamicPlaylist::MaxTempo, tr( "0 BPM" ), tr( "500 BPM" ), 500 );
|
||||||
} else if( selectedType() == "Duration" ) {
|
}
|
||||||
|
else if( selectedType() == "Duration" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::MinDuration;
|
m_currentType = Echonest::DynamicPlaylist::MinDuration;
|
||||||
|
|
||||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinDuration, Echonest::DynamicPlaylist::MaxDuration, tr( "0 secs" ), tr( "3600 secs" ), 3600 );
|
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinDuration, Echonest::DynamicPlaylist::MaxDuration, tr( "0 secs" ), tr( "3600 secs" ), 3600 );
|
||||||
} else if( selectedType() == "Loudness" ) {
|
}
|
||||||
|
else if( selectedType() == "Loudness" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::MinLoudness;
|
m_currentType = Echonest::DynamicPlaylist::MinLoudness;
|
||||||
|
|
||||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinLoudness, Echonest::DynamicPlaylist::MaxLoudness, tr( "-100 dB" ), tr( "100 dB" ), 100 );
|
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinLoudness, Echonest::DynamicPlaylist::MaxLoudness, tr( "-100 dB" ), tr( "100 dB" ), 100 );
|
||||||
qobject_cast< LabeledSlider* >( m_input.data() )->slider()->setMinimum( -100 );
|
qobject_cast< LabeledSlider* >( m_input.data() )->slider()->setMinimum( -100 );
|
||||||
} else if( selectedType() == "Danceability" ) {
|
}
|
||||||
|
else if( selectedType() == "Danceability" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::MinDanceability;
|
m_currentType = Echonest::DynamicPlaylist::MinDanceability;
|
||||||
|
|
||||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinDanceability, Echonest::DynamicPlaylist::MaxDanceability, tr( "Less" ), tr( "More" ), 10000 );
|
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinDanceability, Echonest::DynamicPlaylist::MaxDanceability, tr( "Less" ), tr( "More" ), 10000 );
|
||||||
} else if( selectedType() == "Energy" ) {
|
}
|
||||||
|
else if( selectedType() == "Energy" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::MinEnergy;
|
m_currentType = Echonest::DynamicPlaylist::MinEnergy;
|
||||||
|
|
||||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinEnergy, Echonest::DynamicPlaylist::MaxEnergy, tr( "Less" ), tr( "More" ), 10000 );
|
setupMinMaxWidgets( Echonest::DynamicPlaylist::MinEnergy, Echonest::DynamicPlaylist::MaxEnergy, tr( "Less" ), tr( "More" ), 10000 );
|
||||||
} else if( selectedType() == "Artist Familiarity" ) {
|
}
|
||||||
|
else if( selectedType() == "Artist Familiarity" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::ArtistMinFamiliarity;
|
m_currentType = Echonest::DynamicPlaylist::ArtistMinFamiliarity;
|
||||||
|
|
||||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::ArtistMinFamiliarity, Echonest::DynamicPlaylist::ArtistMaxFamiliarity, tr( "Less" ), tr( "More" ), 10000 );
|
setupMinMaxWidgets( Echonest::DynamicPlaylist::ArtistMinFamiliarity, Echonest::DynamicPlaylist::ArtistMaxFamiliarity, tr( "Less" ), tr( "More" ), 10000 );
|
||||||
} else if( selectedType() == "Artist Hotttnesss" ) {
|
}
|
||||||
|
else if( selectedType() == "Artist Hotttnesss" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::ArtistMinHotttnesss;
|
m_currentType = Echonest::DynamicPlaylist::ArtistMinHotttnesss;
|
||||||
|
|
||||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::ArtistMinHotttnesss, Echonest::DynamicPlaylist::ArtistMaxHotttnesss, tr( "Less" ), tr( "More" ), 10000 );
|
setupMinMaxWidgets( Echonest::DynamicPlaylist::ArtistMinHotttnesss, Echonest::DynamicPlaylist::ArtistMaxHotttnesss, tr( "Less" ), tr( "More" ), 10000 );
|
||||||
} else if( selectedType() == "Song Hotttnesss" ) {
|
}
|
||||||
|
else if( selectedType() == "Song Hotttnesss" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::SongMinHotttnesss;
|
m_currentType = Echonest::DynamicPlaylist::SongMinHotttnesss;
|
||||||
|
|
||||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::SongMinHotttnesss, Echonest::DynamicPlaylist::SongMaxHotttnesss, tr( "Less" ), tr( "More" ), 10000 );
|
setupMinMaxWidgets( Echonest::DynamicPlaylist::SongMinHotttnesss, Echonest::DynamicPlaylist::SongMaxHotttnesss, tr( "Less" ), tr( "More" ), 10000 );
|
||||||
} else if( selectedType() == "Latitude" ) {
|
}
|
||||||
|
else if( selectedType() == "Latitude" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::ArtistMinLatitude;
|
m_currentType = Echonest::DynamicPlaylist::ArtistMinLatitude;
|
||||||
QString deg = QString( QChar( 0x00B0 ) );
|
QString deg = QString( QChar( 0x00B0 ) );
|
||||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::ArtistMinLatitude, Echonest::DynamicPlaylist::ArtistMaxLatitude, QString( "-180%1" ).arg( deg ), QString( "180%1" ).arg( deg ), 180 );
|
setupMinMaxWidgets( Echonest::DynamicPlaylist::ArtistMinLatitude, Echonest::DynamicPlaylist::ArtistMaxLatitude, QString( "-180%1" ).arg( deg ), QString( "180%1" ).arg( deg ), 180 );
|
||||||
qobject_cast< LabeledSlider* >( m_input.data() )->slider()->setMinimum( -180 );
|
qobject_cast< LabeledSlider* >( m_input.data() )->slider()->setMinimum( -180 );
|
||||||
} else if( selectedType() == "Longitude" ) {
|
}
|
||||||
|
else if( selectedType() == "Longitude" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::ArtistMinLongitude;
|
m_currentType = Echonest::DynamicPlaylist::ArtistMinLongitude;
|
||||||
QString deg = QString( QChar( 0x00B0 ) );
|
QString deg = QString( QChar( 0x00B0 ) );
|
||||||
setupMinMaxWidgets( Echonest::DynamicPlaylist::ArtistMinLongitude, Echonest::DynamicPlaylist::ArtistMaxLongitude, QString( "-180%1" ).arg( deg ), QString( "180%1" ).arg( deg ), 180 );
|
setupMinMaxWidgets( Echonest::DynamicPlaylist::ArtistMinLongitude, Echonest::DynamicPlaylist::ArtistMaxLongitude, QString( "-180%1" ).arg( deg ), QString( "180%1" ).arg( deg ), 180 );
|
||||||
qobject_cast< LabeledSlider* >( m_input.data() )->slider()->setMinimum( -180 );
|
qobject_cast< LabeledSlider* >( m_input.data() )->slider()->setMinimum( -180 );
|
||||||
} else if( selectedType() == "Mode" ) {
|
}
|
||||||
|
else if( selectedType() == "Mode" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::Mode;
|
m_currentType = Echonest::DynamicPlaylist::Mode;
|
||||||
|
|
||||||
QLabel* match = new QLabel( tr( "is" ) );
|
QLabel* match = new QLabel( tr( "is" ) );
|
||||||
@@ -356,7 +391,9 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
combo->hide();
|
combo->hide();
|
||||||
m_match = QPointer< QWidget >( match );
|
m_match = QPointer< QWidget >( match );
|
||||||
m_input = QPointer< QWidget >( combo );
|
m_input = QPointer< QWidget >( combo );
|
||||||
} else if( selectedType() == "Key" ) {
|
}
|
||||||
|
else if( selectedType() == "Key" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::Key;
|
m_currentType = Echonest::DynamicPlaylist::Key;
|
||||||
|
|
||||||
QLabel* match = new QLabel( tr( "is" ) );
|
QLabel* match = new QLabel( tr( "is" ) );
|
||||||
@@ -385,7 +422,9 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
combo->hide();
|
combo->hide();
|
||||||
m_match = QPointer< QWidget >( match );
|
m_match = QPointer< QWidget >( match );
|
||||||
m_input = QPointer< QWidget >( combo );
|
m_input = QPointer< QWidget >( combo );
|
||||||
} else if( selectedType() == "Sorting" ) {
|
}
|
||||||
|
else if( selectedType() == "Sorting" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::Sort;
|
m_currentType = Echonest::DynamicPlaylist::Sort;
|
||||||
|
|
||||||
QComboBox* match = new QComboBox();
|
QComboBox* match = new QComboBox();
|
||||||
@@ -418,7 +457,9 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
combo->hide();
|
combo->hide();
|
||||||
m_match = QPointer< QWidget >( match );
|
m_match = QPointer< QWidget >( match );
|
||||||
m_input = QPointer< QWidget >( combo );
|
m_input = QPointer< QWidget >( combo );
|
||||||
} else if( selectedType() == "Mood" || selectedType() == "Style" || selectedType() == "Genre" ) {
|
}
|
||||||
|
else if( selectedType() == "Mood" || selectedType() == "Style" || selectedType() == "Genre" )
|
||||||
|
{
|
||||||
if( selectedType() == "Mood" )
|
if( selectedType() == "Mood" )
|
||||||
m_currentType = Echonest::DynamicPlaylist::Mood;
|
m_currentType = Echonest::DynamicPlaylist::Mood;
|
||||||
else if ( selectedType() == "Style" )
|
else if ( selectedType() == "Style" )
|
||||||
@@ -443,7 +484,9 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
m_input = QPointer< QWidget >( combo );
|
m_input = QPointer< QWidget >( combo );
|
||||||
|
|
||||||
insertMoodsStylesAndGenres();
|
insertMoodsStylesAndGenres();
|
||||||
} else if( selectedType() == "Song Type" ) {
|
}
|
||||||
|
else if( selectedType() == "Song Type" )
|
||||||
|
{
|
||||||
m_currentType = Echonest::DynamicPlaylist::SongType;
|
m_currentType = Echonest::DynamicPlaylist::SongType;
|
||||||
|
|
||||||
QComboBox* match = new QComboBox();
|
QComboBox* match = new QComboBox();
|
||||||
@@ -465,7 +508,9 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
|
|
||||||
m_match = QPointer< QWidget >( match );
|
m_match = QPointer< QWidget >( match );
|
||||||
m_input = QPointer< QWidget >( combo );
|
m_input = QPointer< QWidget >( combo );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_match = QPointer<QWidget>( new QWidget );
|
m_match = QPointer<QWidget>( new QWidget );
|
||||||
m_input = QPointer<QWidget>( new QWidget );
|
m_input = QPointer<QWidget>( new QWidget );
|
||||||
}
|
}
|
||||||
@@ -504,36 +549,53 @@ Tomahawk::EchonestControl::setupMinMaxWidgets( Echonest::DynamicPlaylist::Playli
|
|||||||
void
|
void
|
||||||
Tomahawk::EchonestControl::updateData()
|
Tomahawk::EchonestControl::updateData()
|
||||||
{
|
{
|
||||||
if( selectedType() == "Artist" ) {
|
if( selectedType() == "Artist" )
|
||||||
|
{
|
||||||
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
|
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
|
||||||
if( combo ) {
|
if( combo )
|
||||||
|
{
|
||||||
m_matchString = combo->currentText();
|
m_matchString = combo->currentText();
|
||||||
m_matchData = combo->itemData( combo->currentIndex() ).toString();
|
m_matchData = combo->itemData( combo->currentIndex() ).toString();
|
||||||
}
|
}
|
||||||
QLineEdit* edit = qobject_cast<QLineEdit*>( m_input.data() );
|
QLineEdit* edit = qobject_cast<QLineEdit*>( m_input.data() );
|
||||||
if( edit && !edit->text().isEmpty() ) {
|
if( edit && !edit->text().isEmpty() )
|
||||||
|
{
|
||||||
m_data.first = m_currentType;
|
m_data.first = m_currentType;
|
||||||
m_data.second = edit->text();
|
m_data.second = edit->text();
|
||||||
}
|
}
|
||||||
} else if( selectedType() == "Artist Description" || selectedType() == "Song" ) {
|
}
|
||||||
|
else if( selectedType() == "Artist Description" || selectedType() == "Song" )
|
||||||
|
{
|
||||||
QLineEdit* edit = qobject_cast<QLineEdit*>( m_input.data() );
|
QLineEdit* edit = qobject_cast<QLineEdit*>( m_input.data() );
|
||||||
if( edit && !edit->text().isEmpty() ) {
|
if( edit && !edit->text().isEmpty() )
|
||||||
|
{
|
||||||
m_data.first = m_currentType;
|
m_data.first = m_currentType;
|
||||||
m_data.second = edit->text();
|
m_data.second = edit->text();
|
||||||
}
|
}
|
||||||
} else if( selectedType() == "Variety" || selectedType() == "Adventurousness" ) {
|
}
|
||||||
|
else if( selectedType() == "Variety" || selectedType() == "Adventurousness" )
|
||||||
|
{
|
||||||
LabeledSlider* s = qobject_cast<LabeledSlider*>( m_input.data() );
|
LabeledSlider* s = qobject_cast<LabeledSlider*>( m_input.data() );
|
||||||
if( s ) {
|
if( s )
|
||||||
|
{
|
||||||
m_data.first = m_currentType;
|
m_data.first = m_currentType;
|
||||||
m_data.second = (qreal)s->slider()->value() / 10000.0;
|
m_data.second = (qreal)s->slider()->value() / 10000.0;
|
||||||
}
|
}
|
||||||
} else if( selectedType() == "Tempo" || selectedType() == "Duration" || selectedType() == "Loudness" || selectedType() == "Latitude" || selectedType() == "Longitude" ) {
|
}
|
||||||
|
else if( selectedType() == "Tempo" || selectedType() == "Duration" || selectedType() == "Loudness" || selectedType() == "Latitude" || selectedType() == "Longitude" )
|
||||||
|
{
|
||||||
updateFromComboAndSlider();
|
updateFromComboAndSlider();
|
||||||
} else if( selectedType() == "Danceability" || selectedType() == "Energy" || selectedType() == "Artist Familiarity" || selectedType() == "Artist Hotttnesss" || selectedType() == "Song Hotttnesss" ) {
|
}
|
||||||
|
else if( selectedType() == "Danceability" || selectedType() == "Energy" || selectedType() == "Artist Familiarity" || selectedType() == "Artist Hotttnesss" || selectedType() == "Song Hotttnesss" )
|
||||||
|
{
|
||||||
updateFromComboAndSlider( true );
|
updateFromComboAndSlider( true );
|
||||||
} else if( selectedType() == "Mode" || selectedType() == "Key" || selectedType() == "Mood" || selectedType() == "Style" || selectedType() == "Genre" || selectedType() == "User Radio" ) {
|
}
|
||||||
|
else if( selectedType() == "Mode" || selectedType() == "Key" || selectedType() == "Mood" || selectedType() == "Style" || selectedType() == "Genre" || selectedType() == "User Radio" )
|
||||||
|
{
|
||||||
updateFromLabelAndCombo();
|
updateFromLabelAndCombo();
|
||||||
} else if( selectedType() == "Sorting" ) {
|
}
|
||||||
|
else if( selectedType() == "Sorting" )
|
||||||
|
{
|
||||||
QComboBox* match = qobject_cast<QComboBox*>( m_match.data() );
|
QComboBox* match = qobject_cast<QComboBox*>( m_match.data() );
|
||||||
QComboBox* input = qobject_cast< QComboBox* >( m_input.data() );
|
QComboBox* input = qobject_cast< QComboBox* >( m_input.data() );
|
||||||
if( match && input ) {
|
if( match && input ) {
|
||||||
@@ -546,10 +608,13 @@ Tomahawk::EchonestControl::updateData()
|
|||||||
m_data.second = enumVal;
|
m_data.second = enumVal;
|
||||||
// qDebug() << "SAVING" << input->currentIndex() << "AS" << enumVal << "(" << input->itemData( input->currentIndex() ).toInt() << "+" << m_matchData.toInt() << ")";
|
// qDebug() << "SAVING" << input->currentIndex() << "AS" << enumVal << "(" << input->itemData( input->currentIndex() ).toInt() << "+" << m_matchData.toInt() << ")";
|
||||||
}
|
}
|
||||||
} else if( selectedType() == "Song Type" ) {
|
}
|
||||||
|
else if( selectedType() == "Song Type" )
|
||||||
|
{
|
||||||
QComboBox* match = qobject_cast<QComboBox*>( m_match.data() );
|
QComboBox* match = qobject_cast<QComboBox*>( m_match.data() );
|
||||||
QComboBox* combo = qobject_cast< QComboBox* >( m_input.data() );
|
QComboBox* combo = qobject_cast< QComboBox* >( m_input.data() );
|
||||||
if ( match && combo ) {
|
if ( match && combo )
|
||||||
|
{
|
||||||
m_matchString = match->currentText();
|
m_matchString = match->currentText();
|
||||||
m_matchData = match->itemData( match->currentIndex() ).toString();
|
m_matchData = match->itemData( match->currentIndex() ).toString();
|
||||||
|
|
||||||
@@ -571,12 +636,14 @@ void
|
|||||||
Tomahawk::EchonestControl::updateFromComboAndSlider( bool smooth )
|
Tomahawk::EchonestControl::updateFromComboAndSlider( bool smooth )
|
||||||
{
|
{
|
||||||
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
|
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
|
||||||
if( combo ) {
|
if( combo )
|
||||||
|
{
|
||||||
m_matchString = combo->currentText();
|
m_matchString = combo->currentText();
|
||||||
m_matchData = combo->itemData( combo->currentIndex() ).toString();
|
m_matchData = combo->itemData( combo->currentIndex() ).toString();
|
||||||
}
|
}
|
||||||
LabeledSlider* ls = qobject_cast<LabeledSlider*>( m_input.data() );
|
LabeledSlider* ls = qobject_cast<LabeledSlider*>( m_input.data() );
|
||||||
if( ls && ls->slider() ) {
|
if( ls && ls->slider() )
|
||||||
|
{
|
||||||
m_data.first = static_cast< Echonest::DynamicPlaylist::PlaylistParam >( combo->itemData( combo->currentIndex() ).toInt() );
|
m_data.first = static_cast< Echonest::DynamicPlaylist::PlaylistParam >( combo->itemData( combo->currentIndex() ).toInt() );
|
||||||
m_data.second = ls->slider()->value() / ( smooth ? 10000. : 1.0 );
|
m_data.second = ls->slider()->value() / ( smooth ? 10000. : 1.0 );
|
||||||
}
|
}
|
||||||
@@ -587,7 +654,8 @@ void
|
|||||||
Tomahawk::EchonestControl::updateFromLabelAndCombo()
|
Tomahawk::EchonestControl::updateFromLabelAndCombo()
|
||||||
{
|
{
|
||||||
QComboBox* s = qobject_cast<QComboBox*>( m_input.data() );
|
QComboBox* s = qobject_cast<QComboBox*>( m_input.data() );
|
||||||
if( s ) {
|
if( s )
|
||||||
|
{
|
||||||
m_data.first = m_currentType;
|
m_data.first = m_currentType;
|
||||||
m_data.second = s->itemData( s->currentIndex() );
|
m_data.second = s->itemData( s->currentIndex() );
|
||||||
}
|
}
|
||||||
@@ -598,18 +666,22 @@ Tomahawk::EchonestControl::updateFromLabelAndCombo()
|
|||||||
void
|
void
|
||||||
Tomahawk::EchonestControl::updateWidgetsFromData()
|
Tomahawk::EchonestControl::updateWidgetsFromData()
|
||||||
{
|
{
|
||||||
if( selectedType() == "Artist" ) {
|
if( selectedType() == "Artist" )
|
||||||
|
{
|
||||||
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
|
QComboBox* combo = qobject_cast<QComboBox*>( m_match.data() );
|
||||||
if( combo )
|
if( combo )
|
||||||
combo->setCurrentIndex( combo->findData( m_matchData ) );
|
combo->setCurrentIndex( combo->findData( m_matchData ) );
|
||||||
QLineEdit* edit = qobject_cast<QLineEdit*>( m_input.data() );
|
QLineEdit* edit = qobject_cast<QLineEdit*>( m_input.data() );
|
||||||
if( edit )
|
if( edit )
|
||||||
edit->setText( m_data.second.toString() );
|
edit->setText( m_data.second.toString() );
|
||||||
} else if( selectedType() == "Artist Description" || selectedType() == "Song" ) {
|
}
|
||||||
|
else if( selectedType() == "Artist Description" || selectedType() == "Song" )
|
||||||
|
{
|
||||||
QLineEdit* edit = qobject_cast<QLineEdit*>( m_input.data() );
|
QLineEdit* edit = qobject_cast<QLineEdit*>( m_input.data() );
|
||||||
if( edit )
|
if( edit )
|
||||||
edit->setText( m_data.second.toString() );
|
edit->setText( m_data.second.toString() );
|
||||||
} else if ( selectedType() == "User Radio" )
|
}
|
||||||
|
else if ( selectedType() == "User Radio" )
|
||||||
{
|
{
|
||||||
QComboBox* combo = qobject_cast< QComboBox* >( m_input.data() );
|
QComboBox* combo = qobject_cast< QComboBox* >( m_input.data() );
|
||||||
if ( combo )
|
if ( combo )
|
||||||
@@ -629,17 +701,27 @@ Tomahawk::EchonestControl::updateWidgetsFromData()
|
|||||||
|
|
||||||
combo->setCurrentIndex( combo->findData( m_data.second ) );
|
combo->setCurrentIndex( combo->findData( m_data.second ) );
|
||||||
}
|
}
|
||||||
} else if( selectedType() == "Variety" || selectedType() == "Adventurousness" ) {
|
}
|
||||||
|
else if( selectedType() == "Variety" || selectedType() == "Adventurousness" )
|
||||||
|
{
|
||||||
LabeledSlider* s = qobject_cast<LabeledSlider*>( m_input.data() );
|
LabeledSlider* s = qobject_cast<LabeledSlider*>( m_input.data() );
|
||||||
if( s )
|
if( s )
|
||||||
s->slider()->setValue( m_data.second.toDouble() * 10000 );
|
s->slider()->setValue( m_data.second.toDouble() * 10000 );
|
||||||
} else if( selectedType() == "Tempo" || selectedType() == "Duration" || selectedType() == "Loudness" || selectedType() == "Latitude" || selectedType() == "Longitude" ) {
|
}
|
||||||
|
else if( selectedType() == "Tempo" || selectedType() == "Duration" || selectedType() == "Loudness" || selectedType() == "Latitude" || selectedType() == "Longitude" )
|
||||||
|
{
|
||||||
updateToComboAndSlider();
|
updateToComboAndSlider();
|
||||||
} else if( selectedType() == "Danceability" || selectedType() == "Energy" || selectedType() == "Artist Familiarity" || selectedType() == "Artist Hotttnesss" || selectedType() == "Song Hotttnesss" ) {
|
}
|
||||||
|
else if( selectedType() == "Danceability" || selectedType() == "Energy" || selectedType() == "Artist Familiarity" || selectedType() == "Artist Hotttnesss" || selectedType() == "Song Hotttnesss" )
|
||||||
|
{
|
||||||
updateToComboAndSlider( true );
|
updateToComboAndSlider( true );
|
||||||
} else if( selectedType() == "Mode" || selectedType() == "Key" || selectedType() == "Mood" || selectedType() == "Style" || selectedType() == "Genre" ) {
|
}
|
||||||
|
else if( selectedType() == "Mode" || selectedType() == "Key" || selectedType() == "Mood" || selectedType() == "Style" || selectedType() == "Genre" )
|
||||||
|
{
|
||||||
updateToLabelAndCombo();
|
updateToLabelAndCombo();
|
||||||
} else if( selectedType() == "Sorting" ) {
|
}
|
||||||
|
else if( selectedType() == "Sorting" )
|
||||||
|
{
|
||||||
QComboBox* match = qobject_cast<QComboBox*>( m_match.data() );
|
QComboBox* match = qobject_cast<QComboBox*>( m_match.data() );
|
||||||
QComboBox* input = qobject_cast< QComboBox* >( m_input.data() );
|
QComboBox* input = qobject_cast< QComboBox* >( m_input.data() );
|
||||||
if( match && input ) {
|
if( match && input ) {
|
||||||
@@ -648,9 +730,11 @@ Tomahawk::EchonestControl::updateWidgetsFromData()
|
|||||||
// HACK alert. if it's odd, subtract 1
|
// HACK alert. if it's odd, subtract 1
|
||||||
int val = ( m_data.second.toInt() - ( m_data.second.toInt() % 2 ) ) / 2;
|
int val = ( m_data.second.toInt() - ( m_data.second.toInt() % 2 ) ) / 2;
|
||||||
input->setCurrentIndex( val );
|
input->setCurrentIndex( val );
|
||||||
// qDebug() << "LOADING" << m_data.second.toInt() << "AS" << val;
|
//qDebug() << "LOADING" << m_data.second.toInt() << "AS" << val;
|
||||||
}
|
}
|
||||||
} else if( selectedType() == "Song Type" ) {
|
}
|
||||||
|
else if( selectedType() == "Song Type" )
|
||||||
|
{
|
||||||
QComboBox* match = qobject_cast<QComboBox*>( m_match.data() );
|
QComboBox* match = qobject_cast<QComboBox*>( m_match.data() );
|
||||||
QComboBox* combo = qobject_cast< QComboBox* >( m_input.data() );
|
QComboBox* combo = qobject_cast< QComboBox* >( m_input.data() );
|
||||||
if ( match && combo ) {
|
if ( match && combo ) {
|
||||||
@@ -680,9 +764,8 @@ void
|
|||||||
Tomahawk::EchonestControl::updateToLabelAndCombo()
|
Tomahawk::EchonestControl::updateToLabelAndCombo()
|
||||||
{
|
{
|
||||||
QComboBox* s = qobject_cast< QComboBox* >( m_input.data() );
|
QComboBox* s = qobject_cast< QComboBox* >( m_input.data() );
|
||||||
if( s ) {
|
if( s )
|
||||||
s->setCurrentIndex( s->findData( m_data.second ) );
|
s->setCurrentIndex( s->findData( m_data.second ) );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -945,12 +1028,18 @@ Tomahawk::EchonestControl::insertMoodsStylesAndGenres()
|
|||||||
{
|
{
|
||||||
QStringList src;
|
QStringList src;
|
||||||
if ( selectedType() == "Mood" )
|
if ( selectedType() == "Mood" )
|
||||||
|
{
|
||||||
src = EchonestGenerator::moods();
|
src = EchonestGenerator::moods();
|
||||||
|
}
|
||||||
else if ( selectedType() == "Style" )
|
else if ( selectedType() == "Style" )
|
||||||
|
{
|
||||||
src = EchonestGenerator::styles();
|
src = EchonestGenerator::styles();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
src = EchonestGenerator::genres();
|
src = EchonestGenerator::genres();
|
||||||
|
}
|
||||||
|
|
||||||
QComboBox* combo = qobject_cast< QComboBox* >( m_input.data() );
|
QComboBox* combo = qobject_cast< QComboBox* >( m_input.data() );
|
||||||
if( !combo )
|
if( !combo )
|
||||||
return false;
|
return false;
|
||||||
@@ -959,8 +1048,10 @@ Tomahawk::EchonestControl::insertMoodsStylesAndGenres()
|
|||||||
combo->addItem( item, item );
|
combo->addItem( item, item );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( src.isEmpty() && !combo->count() ) {
|
if( src.isEmpty() && !combo->count() )
|
||||||
if( s_stylePollCount <= 20 && !s_fetchingMoodsStylesAndGenres ) { // try for 20s to get the styles...
|
{
|
||||||
|
if( s_stylePollCount <= 20 && !s_fetchingMoodsStylesAndGenres )
|
||||||
|
{ // try for 20s to get the styles...
|
||||||
s_fetchingMoodsStylesAndGenres = true;
|
s_fetchingMoodsStylesAndGenres = true;
|
||||||
QTimer::singleShot( 1000, this, SLOT( checkForMoodsStylesOrGenresFetched() ) );
|
QTimer::singleShot( 1000, this, SLOT( checkForMoodsStylesOrGenresFetched() ) );
|
||||||
}
|
}
|
||||||
|
@@ -613,7 +613,7 @@ EchonestGenerator::sentenceSummary()
|
|||||||
void
|
void
|
||||||
EchonestGenerator::loadStylesMoodsAndGenres()
|
EchonestGenerator::loadStylesMoodsAndGenres()
|
||||||
{
|
{
|
||||||
if( !s_styles.isEmpty() || !s_moods.isEmpty() || !s_genres.isEmpty() ) //TODO: rly? if one of those is not empty we don't try to load the others?
|
if( !s_styles.isEmpty() && !s_moods.isEmpty() && !s_genres.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QVariant styles = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "styles" );
|
QVariant styles = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "styles" );
|
||||||
@@ -629,8 +629,7 @@ EchonestGenerator::loadStylesMoodsAndGenres()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVariant moods = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "moods" );
|
QVariant moods = TomahawkUtils::Cache::instance()->getData( "EchonesGenerator", "moods" );
|
||||||
if ( moods.isValid() && moods.canConvert< QStringList >() )
|
if ( moods.isValid() && moods.canConvert< QStringList >() ) {
|
||||||
{
|
|
||||||
s_moods = moods.toStringList();
|
s_moods = moods.toStringList();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -651,7 +650,6 @@ EchonestGenerator::loadStylesMoodsAndGenres()
|
|||||||
s_genresJob = Echonest::Artist::fetchGenres();
|
s_genresJob = Echonest::Artist::fetchGenres();
|
||||||
connect( s_genresJob, SIGNAL( finished() ), this, SLOT( genresReceived() ) );
|
connect( s_genresJob, SIGNAL( finished() ), this, SLOT( genresReceived() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -677,9 +675,12 @@ EchonestGenerator::moodsReceived()
|
|||||||
QNetworkReply* r = qobject_cast< QNetworkReply* >( sender() );
|
QNetworkReply* r = qobject_cast< QNetworkReply* >( sender() );
|
||||||
Q_ASSERT( r );
|
Q_ASSERT( r );
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
s_moods = Echonest::Artist::parseTermList( r ).toList();
|
s_moods = Echonest::Artist::parseTermList( r ).toList();
|
||||||
} catch( Echonest::ParseError& e ) {
|
}
|
||||||
|
catch( Echonest::ParseError& e )
|
||||||
|
{
|
||||||
qWarning() << "Echonest failed to parse moods list";
|
qWarning() << "Echonest failed to parse moods list";
|
||||||
}
|
}
|
||||||
s_moodsJob = 0;
|
s_moodsJob = 0;
|
||||||
@@ -702,9 +703,12 @@ EchonestGenerator::stylesReceived()
|
|||||||
QNetworkReply* r = qobject_cast< QNetworkReply* >( sender() );
|
QNetworkReply* r = qobject_cast< QNetworkReply* >( sender() );
|
||||||
Q_ASSERT( r );
|
Q_ASSERT( r );
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
s_styles = Echonest::Artist::parseTermList( r ).toList();
|
s_styles = Echonest::Artist::parseTermList( r ).toList();
|
||||||
} catch( Echonest::ParseError& e ) {
|
}
|
||||||
|
catch( Echonest::ParseError& e )
|
||||||
|
{
|
||||||
qWarning() << "Echonest failed to parse styles list";
|
qWarning() << "Echonest failed to parse styles list";
|
||||||
}
|
}
|
||||||
s_stylesJob = 0;
|
s_stylesJob = 0;
|
||||||
@@ -725,9 +729,12 @@ EchonestGenerator::genresReceived()
|
|||||||
QNetworkReply* r = qobject_cast< QNetworkReply* >( sender() );
|
QNetworkReply* r = qobject_cast< QNetworkReply* >( sender() );
|
||||||
Q_ASSERT( r );
|
Q_ASSERT( r );
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
s_genres = Echonest::Artist::parseGenreList( r ).toList();
|
s_genres = Echonest::Artist::parseGenreList( r ).toList();
|
||||||
} catch( Echonest::ParseError& e ) {
|
}
|
||||||
|
catch( Echonest::ParseError& e )
|
||||||
|
{
|
||||||
qWarning() << "Echonest failed to parse genres list";
|
qWarning() << "Echonest failed to parse genres list";
|
||||||
}
|
}
|
||||||
s_genresJob = 0;
|
s_genresJob = 0;
|
||||||
|
Reference in New Issue
Block a user