mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
Don't rely on mood/style fetch being faster than dynamic control loading
This commit is contained in:
@@ -354,10 +354,6 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
QLabel* match = new QLabel( tr( "is" ) );
|
QLabel* match = new QLabel( tr( "is" ) );
|
||||||
|
|
||||||
QComboBox* combo = new QComboBox;
|
QComboBox* combo = new QComboBox;
|
||||||
QVector< QString > src = selectedType() == "Mood" ? EchonestGenerator::moods() : EchonestGenerator::styles();
|
|
||||||
foreach( const QString& item, src ) {
|
|
||||||
combo->addItem( item, item );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_matchString = match->text();
|
m_matchString = match->text();
|
||||||
m_matchData = match->text();
|
m_matchData = match->text();
|
||||||
@@ -370,6 +366,8 @@ Tomahawk::EchonestControl::updateWidgets()
|
|||||||
combo->hide();
|
combo->hide();
|
||||||
m_match = QWeakPointer< QWidget >( match );
|
m_match = QWeakPointer< QWidget >( match );
|
||||||
m_input = QWeakPointer< QWidget >( combo );
|
m_input = QWeakPointer< QWidget >( combo );
|
||||||
|
|
||||||
|
insertMoodsAndStyles();
|
||||||
} else {
|
} else {
|
||||||
m_match = QWeakPointer<QWidget>( new QWidget );
|
m_match = QWeakPointer<QWidget>( new QWidget );
|
||||||
m_input = QWeakPointer<QWidget>( new QWidget );
|
m_input = QWeakPointer<QWidget>( new QWidget );
|
||||||
@@ -697,3 +695,36 @@ Tomahawk::EchonestControl::calculateSummary()
|
|||||||
}
|
}
|
||||||
m_summary = summary;
|
m_summary = summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Tomahawk::EchonestControl::checkForMoodsOrStylesFetched()
|
||||||
|
{
|
||||||
|
if( selectedType() == "Mood" || selectedType() == "Style" ) {
|
||||||
|
QComboBox* cb = qobject_cast< QComboBox* >( m_input.data() );
|
||||||
|
if( cb && cb->count() == 0 ) { // got nothing, so lets populate
|
||||||
|
if( insertMoodsAndStyles() )
|
||||||
|
updateWidgetsFromData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Tomahawk::EchonestControl::insertMoodsAndStyles()
|
||||||
|
{
|
||||||
|
QVector< QString > src = selectedType() == "Mood" ? EchonestGenerator::moods() : EchonestGenerator::styles();
|
||||||
|
QComboBox* combo = qobject_cast< QComboBox* >( m_input.data() );
|
||||||
|
if( !combo )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
qDebug() << "Inserting moods and or styles, here's the list" << src;
|
||||||
|
foreach( const QString& item, src ) {
|
||||||
|
combo->addItem( item, item );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( src.isEmpty() ) {
|
||||||
|
QTimer::singleShot( 400, this, SLOT( checkForMoodsOrStylesFetched() ) );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@@ -50,6 +50,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setSelectedType ( const QString& type );
|
virtual void setSelectedType ( const QString& type );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateData();
|
void updateData();
|
||||||
void editingFinished();
|
void editingFinished();
|
||||||
@@ -58,7 +59,7 @@ private slots:
|
|||||||
void artistTextEdited( const QString& );
|
void artistTextEdited( const QString& );
|
||||||
void suggestFinished();
|
void suggestFinished();
|
||||||
|
|
||||||
|
void checkForMoodsOrStylesFetched();
|
||||||
private:
|
private:
|
||||||
void updateWidgets();
|
void updateWidgets();
|
||||||
void updateWidgetsFromData();
|
void updateWidgetsFromData();
|
||||||
@@ -67,6 +68,7 @@ private:
|
|||||||
void setupMinMaxWidgets( Echonest::DynamicPlaylist::PlaylistParam min, Echonest::DynamicPlaylist::PlaylistParam max, const QString& leftL, const QString& rightL, int maxRange );
|
void setupMinMaxWidgets( Echonest::DynamicPlaylist::PlaylistParam min, Echonest::DynamicPlaylist::PlaylistParam max, const QString& leftL, const QString& rightL, int maxRange );
|
||||||
void updateFromComboAndSlider( bool smooth = false );
|
void updateFromComboAndSlider( bool smooth = false );
|
||||||
void updateFromLabelAndCombo();
|
void updateFromLabelAndCombo();
|
||||||
|
bool insertMoodsAndStyles();
|
||||||
|
|
||||||
void updateToComboAndSlider( bool smooth = false );
|
void updateToComboAndSlider( bool smooth = false );
|
||||||
void updateToLabelAndCombo();
|
void updateToLabelAndCombo();
|
||||||
|
@@ -66,6 +66,7 @@ EchonestGenerator::EchonestGenerator ( QObject* parent )
|
|||||||
QNetworkReply* moods = Echonest::Artist::listTerms( "mood" );
|
QNetworkReply* moods = Echonest::Artist::listTerms( "mood" );
|
||||||
connect( moods, SIGNAL( finished() ), this, SLOT( moodsReceived() ) );
|
connect( moods, SIGNAL( finished() ), this, SLOT( moodsReceived() ) );
|
||||||
|
|
||||||
|
QTimer::singleShot( 20000, this, SLOT( get() ) );
|
||||||
// qDebug() << "ECHONEST:" << m_logo.size();
|
// qDebug() << "ECHONEST:" << m_logo.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user