mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-23 06:02:53 +02:00
Add icon to steering overlay and fix steering
This commit is contained in:
@@ -197,6 +197,13 @@ EchonestGenerator::dynamicFetched()
|
|||||||
Q_ASSERT( qobject_cast< QNetworkReply* >( sender() ) );
|
Q_ASSERT( qobject_cast< QNetworkReply* >( sender() ) );
|
||||||
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
|
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
|
||||||
|
|
||||||
|
m_steeredSinceLastTrack = false;
|
||||||
|
m_steerData.first = Echonest::DynamicPlaylist::Steer;
|
||||||
|
m_steerData.second = QString();
|
||||||
|
|
||||||
|
if( m_steerer )
|
||||||
|
m_steerer->resetSteering( true );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Echonest::Song song = m_dynPlaylist->parseNextSong( reply );
|
Echonest::Song song = m_dynPlaylist->parseNextSong( reply );
|
||||||
@@ -282,9 +289,13 @@ EchonestGenerator::queryFromSong(const Echonest::Song& song)
|
|||||||
QWidget*
|
QWidget*
|
||||||
EchonestGenerator::steeringWidget()
|
EchonestGenerator::steeringWidget()
|
||||||
{
|
{
|
||||||
if( !m_steerer )
|
if( !m_steerer ) {
|
||||||
m_steerer = new EchonestSteerer();
|
m_steerer = new EchonestSteerer();
|
||||||
|
|
||||||
|
connect( m_steerer, SIGNAL( steerField( QString ) ), this, SLOT( steerField( QString ) ) );
|
||||||
|
connect( m_steerer, SIGNAL( steerDescription( QString ) ), this, SLOT( steerDescription( QString ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
return m_steerer;
|
return m_steerer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,6 +15,9 @@
|
|||||||
****************************************************************************************/
|
****************************************************************************************/
|
||||||
|
|
||||||
#include "dynamic/echonest/EchonestSteerer.h"
|
#include "dynamic/echonest/EchonestSteerer.h"
|
||||||
|
|
||||||
|
#include "utils/tomahawkutils.h"
|
||||||
|
|
||||||
#include <QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
@@ -22,6 +25,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <Playlist.h>
|
#include <Playlist.h>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -30,16 +34,18 @@ using namespace Tomahawk;
|
|||||||
EchonestSteerer::EchonestSteerer( QWidget* parent )
|
EchonestSteerer::EchonestSteerer( QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, m_layout( new QHBoxLayout )
|
, m_layout( new QHBoxLayout )
|
||||||
, m_steerTop( 0 )
|
|
||||||
, m_steerBottom( 0 )
|
|
||||||
, m_amplifier( 0 )
|
, m_amplifier( 0 )
|
||||||
, m_field( 0 )
|
, m_field( 0 )
|
||||||
, m_description( 0 )
|
, m_description( 0 )
|
||||||
, m_textL( new QVBoxLayout )
|
, m_textL( new QVBoxLayout )
|
||||||
|
, m_steerTop( 0 )
|
||||||
|
, m_steerBottom( 0 )
|
||||||
|
, m_reset( 0 )
|
||||||
, m_expanding( true )
|
, m_expanding( true )
|
||||||
|
|
||||||
{
|
{
|
||||||
m_layout->setContentsMargins( 8, 8, 8, 8 );
|
m_layout->setContentsMargins( 8, 8, 8, 8 );
|
||||||
|
|
||||||
m_textL->setSpacing( 0 );
|
m_textL->setSpacing( 0 );
|
||||||
m_steerTop = new QLabel( tr( "Steer this station:" ), this );
|
m_steerTop = new QLabel( tr( "Steer this station:" ), this );
|
||||||
QFont f = m_steerTop->font();
|
QFont f = m_steerTop->font();
|
||||||
@@ -79,6 +85,13 @@ EchonestSteerer::EchonestSteerer( QWidget* parent )
|
|||||||
m_description->setPlaceholderText( tr( "Enter a description" ) );
|
m_description->setPlaceholderText( tr( "Enter a description" ) );
|
||||||
m_description->hide();
|
m_description->hide();
|
||||||
|
|
||||||
|
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)));
|
||||||
|
|
||||||
setLayout( m_layout );
|
setLayout( m_layout );
|
||||||
setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||||
|
|
||||||
@@ -88,7 +101,6 @@ EchonestSteerer::EchonestSteerer( QWidget* parent )
|
|||||||
m_resizeAnim.setUpdateInterval( 8 );
|
m_resizeAnim.setUpdateInterval( 8 );
|
||||||
|
|
||||||
connect( &m_resizeAnim, SIGNAL( frameChanged( int ) ), this, SLOT( resizeFrame( int ) ) );
|
connect( &m_resizeAnim, SIGNAL( frameChanged( int ) ), this, SLOT( resizeFrame( int ) ) );
|
||||||
connect( &m_resizeAnim, SIGNAL( finished() ), this, SLOT( resizeFinished() ) );
|
|
||||||
|
|
||||||
resize( sizeHint() );
|
resize( sizeHint() );
|
||||||
}
|
}
|
||||||
@@ -119,6 +131,7 @@ void
|
|||||||
EchonestSteerer::changed()
|
EchonestSteerer::changed()
|
||||||
{
|
{
|
||||||
if( m_field->itemData( m_field->currentIndex() ).toString() != "desc" ) {
|
if( m_field->itemData( m_field->currentIndex() ).toString() != "desc" ) {
|
||||||
|
|
||||||
QString steer = m_field->itemData( m_field->currentIndex() ).toString() + m_amplifier->itemData( m_amplifier->currentIndex() ).toString();
|
QString steer = m_field->itemData( m_field->currentIndex() ).toString() + m_amplifier->itemData( m_amplifier->currentIndex() ).toString();
|
||||||
emit steerField( steer );
|
emit steerField( steer );
|
||||||
|
|
||||||
@@ -138,8 +151,14 @@ EchonestSteerer::changed()
|
|||||||
qDebug() << "COLLAPSING FROM" << start << "TO" << end;
|
qDebug() << "COLLAPSING FROM" << start << "TO" << end;
|
||||||
}
|
}
|
||||||
} else { // description, so put in the description field
|
} else { // description, so put in the description field
|
||||||
|
if( !m_description->text().isEmpty() ) {
|
||||||
|
QString steer = m_description->text() + m_amplifier->itemData( m_amplifier->currentIndex() ).toString();
|
||||||
|
emit steerDescription( steer );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !m_layout->indexOf( m_description ) > 0 ) {
|
||||||
// animate to expand
|
// animate to expand
|
||||||
m_layout->addWidget( m_description, 1 );
|
m_layout->insertWidget( m_layout->count() - 1, m_description, 1 );
|
||||||
m_layout->setStretchFactor( m_textL, 0 );
|
m_layout->setStretchFactor( m_textL, 0 );
|
||||||
m_description->show();
|
m_description->show();
|
||||||
|
|
||||||
@@ -152,6 +171,7 @@ EchonestSteerer::changed()
|
|||||||
qDebug() << "EXPANDING FROM" << start << "TO" << end;
|
qDebug() << "EXPANDING FROM" << start << "TO" << end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EchonestSteerer::resizeFrame( int width )
|
EchonestSteerer::resizeFrame( int width )
|
||||||
@@ -164,9 +184,24 @@ EchonestSteerer::resizeFrame( int width )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EchonestSteerer::resizeFinished()
|
EchonestSteerer::resetSteering( bool automatic )
|
||||||
{
|
{
|
||||||
// resize( m_layout->sizeHint() );
|
m_field->setCurrentIndex( 0 );
|
||||||
// update();
|
m_amplifier->setCurrentIndex( 0 );
|
||||||
|
|
||||||
|
if( !automatic )
|
||||||
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QToolButton*
|
||||||
|
EchonestSteerer::initButton( QWidget* parent )
|
||||||
|
{
|
||||||
|
QToolButton* btn = new QToolButton( parent );
|
||||||
|
btn->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||||
|
btn->setIconSize( QSize( 14, 14 ) );
|
||||||
|
btn->setToolButtonStyle( Qt::ToolButtonIconOnly );
|
||||||
|
btn->setAutoRaise( true );
|
||||||
|
btn->setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
return btn;
|
||||||
|
}
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QTimeLine>
|
#include <QTimeLine>
|
||||||
|
|
||||||
|
class QToolButton;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
@@ -32,11 +33,15 @@ namespace Tomahawk
|
|||||||
class EchonestSteerer : public QWidget
|
class EchonestSteerer : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EchonestSteerer( QWidget* parent = 0 );
|
EchonestSteerer( QWidget* parent = 0 );
|
||||||
|
|
||||||
virtual void paintEvent(QPaintEvent* );
|
virtual void paintEvent(QPaintEvent* );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void resetSteering( bool automatic = false );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void steerField( const QString& field );
|
void steerField( const QString& field );
|
||||||
void steerDescription( const QString& desc );
|
void steerDescription( const QString& desc );
|
||||||
@@ -46,19 +51,24 @@ private slots:
|
|||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
void resizeFrame( int );
|
void resizeFrame( int );
|
||||||
void resizeFinished();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QToolButton* initButton( QWidget* parent );
|
||||||
|
|
||||||
QHBoxLayout* m_layout;
|
QHBoxLayout* m_layout;
|
||||||
QLabel* m_steerTop;
|
|
||||||
QLabel* m_steerBottom;
|
|
||||||
|
|
||||||
QComboBox* m_amplifier;
|
QComboBox* m_amplifier;
|
||||||
QComboBox* m_field;
|
QComboBox* m_field;
|
||||||
|
|
||||||
QLineEdit* m_description;
|
QLineEdit* m_description;
|
||||||
|
|
||||||
|
// text on the left
|
||||||
QVBoxLayout* m_textL;
|
QVBoxLayout* m_textL;
|
||||||
|
QLabel* m_steerTop;
|
||||||
|
QLabel* m_steerBottom;
|
||||||
|
|
||||||
|
// icons on the right
|
||||||
|
QToolButton* m_reset;
|
||||||
|
|
||||||
// animations
|
// animations
|
||||||
QTimeLine m_resizeAnim;
|
QTimeLine m_resizeAnim;
|
||||||
|
Reference in New Issue
Block a user