1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-17 22:38:33 +01:00

change the dynamic header a bit, still not final or anything, but more bearable

add logo to generators
This commit is contained in:
Leo Franchi 2011-01-11 21:51:20 -05:00
parent 6adae0c1d9
commit d3c48a5342
8 changed files with 44 additions and 17 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -65,6 +65,7 @@
<file>./data/images/volume-icon-muted.png</file>
<file>./data/images/volume-slider-bkg.png</file>
<file>./data/images/volume-slider-level.png</file>
<file>./data/images/echonest_logo.png</file>
<file>./data/topbar-radiobuttons.css</file>
<file>./data/icons/tomahawk-icon-16x16.png</file>
<file>./data/icons/tomahawk-icon-32x32.png</file>

View File

@ -45,22 +45,29 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
, m_model()
{
m_headerLayout = new QHBoxLayout;
m_headerText = new QLabel( "Dynamic Playlist Type:", this );
m_headerText = new QLabel( tr( "Type:" ), this );
m_headerLayout->addWidget( m_headerText );
m_modeCombo = new QComboBox( this );
m_modeCombo->addItem( "On Demand", 0 );
m_modeCombo->addItem( "Static", 1 );
m_modeCombo->addItem( tr( "On Demand" ), OnDemand );
m_modeCombo->addItem( tr( "Static" ), Static );
m_headerLayout->addWidget( m_modeCombo );
m_generatorCombo = new QComboBox( this );
foreach( const QString& type, GeneratorFactory::types() )
m_generatorCombo->addItem( type );
m_headerLayout->addWidget( m_generatorCombo );
m_generateButton = new QPushButton( tr( "Generate" ), this );
connect( m_generateButton, SIGNAL( clicked( bool ) ), this, SLOT( generateOrStart() ) );
m_headerLayout->addWidget( m_generateButton );
m_headerLayout->addSpacing( 1 );
m_headerLayout->addStretch( 1 );
m_generateButton = new QPushButton( "Generate", this );
m_generateButton->hide();
connect( m_generateButton, SIGNAL( clicked( bool ) ), this, SLOT( generate() ) );
m_logo = new QLabel( this );
if( !playlist->generator()->logo().isNull() ) {
QPixmap p = playlist->generator()->logo().scaledToHeight( m_headerText->height(), Qt::SmoothTransformation );
qDebug() << "Trying to scale to:" << QSize( m_headerText->height(), m_headerText->height() ) << playlist->generator()->logo().size() << p.size();
m_logo->setPixmap( p );
}
m_headerLayout->addWidget(m_logo);
m_layout->addLayout( m_headerLayout );
@ -77,6 +84,7 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
m_splitter->addWidget( m_controls );
m_splitter->addWidget( m_view );
m_splitter->setGreedyWidget( 1 );
m_splitter->setHandleWidth( 0 );
m_splitter->show( 0, false );
@ -107,11 +115,9 @@ void DynamicWidget::loadDynamicPlaylist(const Tomahawk::dynplaylist_ptr& playlis
m_modeCombo->setCurrentIndex( static_cast<int>( playlist->mode() ) );
if( playlist->mode() == Static ) {
m_generateButton->show();
m_headerLayout->addWidget( m_generateButton );
m_generateButton->setText( tr( "Generate" ) );
} else {
m_generateButton->hide();
m_headerLayout->removeWidget(m_generateButton);
m_generateButton->setText( tr( "Play" ) );
}
connect( m_playlist->generator().data(), SIGNAL( generated( QList<Tomahawk::query_ptr> ) ), this, SLOT( tracksGenerated( QList<Tomahawk::query_ptr> ) ) );
connect( m_playlist.data(), SIGNAL( dynamicRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ), this, SLOT( onRevisionLoaded( Tomahawk::DynamicPlaylistRevision ) ) );
@ -133,10 +139,13 @@ DynamicWidget::playlistInterface() const
}
void
DynamicWidget::generate()
DynamicWidget::generateOrStart()
{
// get the items from the generator, and put them in the playlist
m_playlist->generator()->generate( 15 );
if( m_playlist->mode() == Static )
{
// get the items from the generator, and put them in the playlist
m_playlist->generator()->generate( 15 );
}
}
void

View File

@ -56,7 +56,7 @@ public slots:
void onRevisionLoaded( const Tomahawk::DynamicPlaylistRevision& rev );
private slots:
void generate();
void generateOrStart();
void tracksGenerated( const QList< Tomahawk::query_ptr>& queries );
void controlsChanged();

View File

@ -42,6 +42,12 @@ Tomahawk::GeneratorInterface::controls()
return m_controls;
}
QPixmap
Tomahawk::GeneratorInterface::logo()
{
return QPixmap();
}
void
Tomahawk::GeneratorInterface::addControl( const Tomahawk::dyncontrol_ptr& control )
{

View File

@ -54,6 +54,8 @@ public:
/// you ask it to create
virtual dyncontrol_ptr createControl( const QString& type = QString() );
/// A logo to display for this generator, if it has one
virtual QPixmap logo();
/**
* Generate tracks from the controls in this playlist. If the current mode is
* OnDemand, then \p number is not taken into account. If this generator is in static

View File

@ -17,6 +17,7 @@
#include "dynamic/echonest/EchonestGenerator.h"
#include "dynamic/echonest/EchonestControl.h"
#include "query.h"
#include "tomahawk/tomahawkapp.h"
using namespace Tomahawk;
@ -50,7 +51,8 @@ EchonestGenerator::EchonestGenerator ( QObject* parent )
{
m_type = "echonest";
m_mode = OnDemand;
m_logo.load( RESPATH "/images/echonest_logo.png" );
qDebug() << "ECHONEST:" << m_logo.size();
}
EchonestGenerator::~EchonestGenerator()
@ -65,6 +67,12 @@ EchonestGenerator::createControl( const QString& type )
return m_controls.last();
}
QPixmap EchonestGenerator::logo()
{
return m_logo;
}
void
EchonestGenerator::generate ( int number )
{

View File

@ -44,7 +44,7 @@ public:
virtual ~EchonestGenerator();
virtual dyncontrol_ptr createControl( const QString& type = QString() );
virtual QPixmap logo();
virtual void generate ( int number = -1 );
private slots:
@ -52,6 +52,7 @@ private slots:
private:
Echonest::DynamicPlaylist::ArtistTypeEnum determineRadioType() const;
QPixmap m_logo;
};
};