1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 08:34:34 +02:00

Improve the steering widget, now it is clear when a steer is being applied

This commit is contained in:
Leo Franchi
2011-02-08 17:38:31 -05:00
parent 03281b58f9
commit b465eaf5ad
4 changed files with 41 additions and 17 deletions

View File

@@ -196,9 +196,7 @@ EchonestGenerator::dynamicFetched()
Q_ASSERT( qobject_cast< QNetworkReply* >( sender() ) );
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
m_steeredSinceLastTrack = false;
m_steerData.first = Echonest::DynamicPlaylist::Steer;
m_steerData.second = QString();
resetSteering();
if( !m_steerer.isNull() )
m_steerer.data()->resetSteering( true );
@@ -230,6 +228,14 @@ EchonestGenerator::steerField( const QString& field )
m_steerData.second = field;
}
void
EchonestGenerator::resetSteering()
{
m_steeredSinceLastTrack = false;
m_steerData.first = Echonest::DynamicPlaylist::Steer;
m_steerData.second = QString();
}
bool
EchonestGenerator::onlyThisArtistType( Echonest::DynamicPlaylist::ArtistTypeEnum type ) const throw( std::runtime_error )
@@ -293,6 +299,7 @@ EchonestGenerator::steeringWidget()
connect( m_steerer.data(), SIGNAL( steerField( QString ) ), this, SLOT( steerField( QString ) ) );
connect( m_steerer.data(), SIGNAL( steerDescription( QString ) ), this, SLOT( steerDescription( QString ) ) );
connect( m_steerer.data(), SIGNAL( reset() ), this, SLOT( resetSteering() ) );
}
return m_steerer.data();

View File

@@ -63,6 +63,7 @@ private slots:
// steering controls
void steerField( const QString& field );
void steerDescription( const QString& desc );
void resetSteering();
private:
Echonest::DynamicPlaylist::PlaylistParams getParams() const throw( std::runtime_error );

View File

@@ -61,11 +61,14 @@ EchonestSteerer::EchonestSteerer( QWidget* parent )
m_layout->addLayout( m_textL, 1 );
m_amplifier = new QComboBox( this );
m_amplifier->addItem( tr( "Much less" ), "^.5" );
m_amplifier->addItem( tr( "Less" ), "^.75" );
m_amplifier->addItem( tr( "More" ), "^1.25" );
m_amplifier->addItem( tr( "Much more" ), "^1.5" );
m_amplifier->addItem( tr( "Much more" ), "^1.5" );
m_amplifier->addItem( tr( "Much less" ), "^.1" );
m_amplifier->addItem( tr( "Less" ), "^.5" );
m_amplifier->addItem( tr( "A bit less" ), "^.75" );
m_amplifier->addItem( tr( "Keep at current", "" ) );
m_amplifier->addItem( tr( "A bit more" ), "^1.25" );
m_amplifier->addItem( tr( "More" ), "^1.5" );
m_amplifier->addItem( tr( "Much more" ), "^2" );
m_amplifier->setCurrentIndex( 3 );
m_field = new QComboBox( this );
m_field->addItem( tr( "Tempo" ), "tempo");
m_field->addItem( tr( "Loudness" ), "loudness");
@@ -85,12 +88,14 @@ EchonestSteerer::EchonestSteerer( QWidget* parent )
m_description->setPlaceholderText( tr( "Enter a description" ) );
m_description->hide();
connect( m_description, SIGNAL( textChanged( QString ) ), this, SLOT( changed() ) );
m_reset = initButton( this );
m_reset->setIcon( QIcon( RESPATH "images/view-refresh.png" ) );
m_reset->setToolTip( tr( "Reset all steering commands" ) );
m_layout->addWidget( m_reset );
connect( m_reset, SIGNAL( clicked( bool )), this, SLOT(resetSteering(bool)));
connect( m_reset, SIGNAL( clicked( bool ) ), this, SLOT( resetSteering( bool ) ) );
setLayout( m_layout );
setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
@@ -130,10 +135,18 @@ EchonestSteerer::paintEvent( QPaintEvent* )
void
EchonestSteerer::changed()
{
if( m_field->itemData( m_field->currentIndex() ).toString() != "desc" ) {
bool keep = false;
if( m_amplifier->itemData( m_amplifier->currentIndex() ).toString().isEmpty() ) { // Keep Current
keep = true;
QString steer = m_field->itemData( m_field->currentIndex() ).toString() + m_amplifier->itemData( m_amplifier->currentIndex() ).toString();
emit steerField( steer );
emit reset();
}
if( m_field->itemData( m_field->currentIndex() ).toString() != "desc" ) {
if( !keep ) {
QString steer = m_field->itemData( m_field->currentIndex() ).toString() + m_amplifier->itemData( m_amplifier->currentIndex() ).toString();
emit steerField( steer );
}
// if description was shown, animate to shrink
if( m_layout->indexOf( m_description ) > 0 ) {
@@ -151,7 +164,7 @@ EchonestSteerer::changed()
qDebug() << "COLLAPSING FROM" << start << "TO" << end;
}
} else { // description, so put in the description field
if( !m_description->text().isEmpty() ) {
if( !m_description->text().isEmpty() && !keep ) {
QString steer = m_description->text() + m_amplifier->itemData( m_amplifier->currentIndex() ).toString();
emit steerDescription( steer );
}
@@ -186,11 +199,13 @@ EchonestSteerer::resizeFrame( int width )
void
EchonestSteerer::resetSteering( bool automatic )
{
m_field->setCurrentIndex( 0 );
m_amplifier->setCurrentIndex( 0 );
m_amplifier->setCurrentIndex( 3 );
if( !automatic )
changed();
if( !automatic ) {
m_description->clear();
m_field->setCurrentIndex( 0 );
emit reset();
}
}

View File

@@ -45,6 +45,7 @@ public slots:
signals:
void steerField( const QString& field );
void steerDescription( const QString& desc );
void reset();
void resized();
private slots: