mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-19 07:22:32 +02:00
Merge pull request #121 from crabmanX/sourceButton
add source logo to now playing area
This commit is contained in:
commit
7bf019740c
Binary file not shown.
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 3.2 KiB |
BIN
data/images/resolver-default.png
Normal file
BIN
data/images/resolver-default.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 916 B |
@ -155,5 +155,6 @@
|
||||
<file>data/images/green-dot.png</file>
|
||||
<file>data/images/exfm.png</file>
|
||||
<file>data/images/soundcloud.png</file>
|
||||
<file>data/images/resolver-default.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QtGui/QDropEvent>
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QDesktopServices>
|
||||
|
||||
#include "audio/AudioEngine.h"
|
||||
#include "playlist/PlaylistView.h"
|
||||
@ -68,7 +69,6 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
ui->timeLeftLabel->setFont( font );
|
||||
|
||||
font.setPointSize( TomahawkUtils::defaultFontSize() - 2 );
|
||||
ui->ownerLabel->setFont( font );
|
||||
|
||||
ui->prevButton->setPixmap( RESPATH "images/back-rest.png" );
|
||||
ui->prevButton->setPixmap( RESPATH "images/back-pressed.png", QIcon::Off, QIcon::Active );
|
||||
@ -87,15 +87,12 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
ui->socialButton->setPixmap( RESPATH "images/share.png" );
|
||||
ui->loveButton->setPixmap( RESPATH "images/not-loved.png" );
|
||||
ui->loveButton->setCheckable( true );
|
||||
ui->ownerButton->setPixmap( RESPATH "images/resolver-default.png" );
|
||||
|
||||
ui->socialButton->setFixedSize( QSize( 20, 20 ) );
|
||||
ui->loveButton->setFixedSize( QSize( 20, 20 ) );
|
||||
ui->ownerButton->setFixedSize( QSize( 34, 34 ) );
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
ui->ownerLabel->setForegroundRole( QPalette::Text );
|
||||
#else
|
||||
ui->ownerLabel->setForegroundRole( QPalette::Dark );
|
||||
#endif
|
||||
ui->metaDataArea->setStyleSheet( "QWidget#metaDataArea {\nborder-width: 4px;\nborder-image: url(" RESPATH "images/now-playing-panel.png) 4 4 4 4 stretch stretch; }" );
|
||||
|
||||
ui->seekSlider->setEnabled( true );
|
||||
@ -128,6 +125,7 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
connect( ui->albumLabel, SIGNAL( clickedAlbum() ), SLOT( onAlbumClicked() ) );
|
||||
connect( ui->socialButton, SIGNAL( clicked() ), SLOT( onSocialButtonClicked() ) );
|
||||
connect( ui->loveButton, SIGNAL( clicked( bool ) ), SLOT( onLoveButtonClicked( bool ) ) );
|
||||
connect( ui->ownerButton, SIGNAL( clicked() ), SLOT( onOwnerButtonClicked() ) );
|
||||
|
||||
// <From AudioEngine>
|
||||
connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackLoading( Tomahawk::result_ptr ) ) );
|
||||
@ -239,7 +237,6 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
||||
|
||||
ui->artistTrackLabel->setResult( result );
|
||||
ui->albumLabel->setResult( result );
|
||||
ui->ownerLabel->setText( result->friendlySource() );
|
||||
|
||||
const QString duration = TomahawkUtils::timeToString( result.data()->duration() );
|
||||
ui->timeLabel->setFixedWidth( ui->timeLabel->fontMetrics().width( QString( duration.length(), QChar( '0' ) ) ) );
|
||||
@ -254,14 +251,22 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
||||
ui->loveButton->setVisible( true );
|
||||
ui->socialButton->setEnabled( true );
|
||||
ui->socialButton->setVisible( true );
|
||||
ui->ownerButton->setEnabled( true );
|
||||
ui->ownerButton->setVisible( true );
|
||||
|
||||
ui->timeLabel->setToolTip( tr( "Time Elapsed" ) );
|
||||
ui->timeLeftLabel->setToolTip( tr( "Time Remaining" ) );
|
||||
ui->ownerLabel->setToolTip( tr( "Music Source" ) );
|
||||
ui->shuffleButton->setToolTip( tr( "Shuffle" ) );
|
||||
ui->repeatButton->setToolTip( tr( "Repeat" ) );
|
||||
ui->socialButton->setToolTip( tr( "Share" ) );
|
||||
ui->loveButton->setToolTip( tr( "Love" ) );
|
||||
ui->ownerButton->setToolTip( QString( tr( "Playing from %1" ) ).arg( result->friendlySource() ) );
|
||||
QPixmap sourceIcon = result->sourceIcon().scaled( ui->ownerButton->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
ui->ownerButton->setPixmap( sourceIcon );
|
||||
if ( QUrl( result->purchaseUrl() ).isValid() || !result->collection().isNull() )
|
||||
ui->ownerButton->setCursor( Qt::PointingHandCursor );
|
||||
else
|
||||
ui->ownerButton->setCursor( Qt::ArrowCursor );
|
||||
|
||||
setCover();
|
||||
setSocialActions();
|
||||
@ -354,7 +359,6 @@ AudioControls::onPlaybackStopped()
|
||||
|
||||
ui->artistTrackLabel->setText( "" );
|
||||
ui->albumLabel->setText( "" );
|
||||
ui->ownerLabel->setText( "" );
|
||||
ui->timeLabel->setText( "" );
|
||||
ui->timeLeftLabel->setText( "" );
|
||||
ui->coverImage->setPixmap( QPixmap(), false );
|
||||
@ -362,20 +366,23 @@ AudioControls::onPlaybackStopped()
|
||||
m_sliderTimeLine.stop();
|
||||
m_sliderTimeLine.setCurrentTime( 0 );
|
||||
m_phononTickCheckTimer.stop();
|
||||
|
||||
ui->ownerButton->setPixmap( RESPATH "images/resolver-default.png" );
|
||||
|
||||
ui->stackedLayout->setCurrentWidget( ui->playPauseButton );
|
||||
ui->loveButton->setEnabled( false );
|
||||
ui->loveButton->setVisible( false );
|
||||
ui->socialButton->setEnabled( false );
|
||||
ui->socialButton->setVisible( false );
|
||||
ui->ownerButton->setEnabled( false );
|
||||
ui->ownerButton->setVisible( false );
|
||||
|
||||
ui->timeLabel->setToolTip( "" );
|
||||
ui->timeLeftLabel->setToolTip( "" );
|
||||
ui->ownerLabel->setToolTip( "" );
|
||||
ui->shuffleButton->setToolTip( "" );
|
||||
ui->repeatButton->setToolTip( "" );
|
||||
ui->socialButton->setToolTip( "" );
|
||||
ui->loveButton->setToolTip( "" );
|
||||
ui->ownerButton->setToolTip( "" );
|
||||
}
|
||||
|
||||
|
||||
@ -662,3 +669,16 @@ AudioControls::onLoveButtonClicked( bool checked )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::onOwnerButtonClicked()
|
||||
{
|
||||
if ( m_currentTrack->collection().isNull() )
|
||||
{
|
||||
QUrl url = QUrl( m_currentTrack->purchaseUrl() );
|
||||
if ( url.isValid() )
|
||||
QDesktopServices::openUrl( url );
|
||||
}
|
||||
else
|
||||
ViewManager::instance()->show( m_currentTrack->collection() );
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ private slots:
|
||||
void onTrackClicked();
|
||||
void onSocialButtonClicked();
|
||||
void onLoveButtonClicked( bool );
|
||||
void onOwnerButtonClicked();
|
||||
|
||||
void droppedTracks( QList<Tomahawk::query_ptr> );
|
||||
|
||||
|
@ -266,24 +266,6 @@
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="ownerLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>7</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Owner</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="socialLayout">
|
||||
<item>
|
||||
@ -348,6 +330,22 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ImageButton" name="ownerButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>resolver</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "database/DatabaseCommand_AllTracks.h"
|
||||
#include "database/DatabaseCommand_AddFiles.h"
|
||||
|
||||
#include "utils/TomahawkUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
@ -178,6 +179,7 @@ Result::toVariant() const
|
||||
m.insert( "album", album()->name() );
|
||||
m.insert( "track", track() );
|
||||
m.insert( "source", friendlySource() );
|
||||
m.insert( "sourceIcon", sourceIcon() );
|
||||
m.insert( "mimetype", mimetype() );
|
||||
m.insert( "size", size() );
|
||||
m.insert( "bitrate", bitrate() );
|
||||
@ -294,6 +296,25 @@ Result::friendlySource() const
|
||||
}
|
||||
|
||||
|
||||
QPixmap
|
||||
Result::sourceIcon() const
|
||||
{
|
||||
if ( collection().isNull() )
|
||||
{
|
||||
return m_sourceIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
QPixmap avatar = collection()->source()->avatar( Source::FancyStyle );
|
||||
if ( !avatar )
|
||||
{
|
||||
avatar = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::AvatarInFrame );
|
||||
}
|
||||
return avatar;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::Resolver*
|
||||
Result::resolvedBy() const
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define RESULT_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
@ -71,6 +72,8 @@ public:
|
||||
QString url() const { return m_url; }
|
||||
QString mimetype() const { return m_mimetype; }
|
||||
QString friendlySource() const;
|
||||
QPixmap sourceIcon() const;
|
||||
QString purchaseUrl() const { return m_purchaseUrl; }
|
||||
|
||||
unsigned int duration() const { return m_duration; }
|
||||
unsigned int bitrate() const { return m_bitrate; }
|
||||
@ -86,6 +89,8 @@ public:
|
||||
void setRID( RID id ) { m_rid = id; }
|
||||
void setCollection( const Tomahawk::collection_ptr& collection );
|
||||
void setFriendlySource( const QString& s ) { m_friendlySource = s; }
|
||||
void setSourceIcon( const QPixmap& i ) { m_sourceIcon = i; }
|
||||
void setPurchaseUrl( const QString& u ) { m_purchaseUrl = u; }
|
||||
void setArtist( const Tomahawk::artist_ptr& artist );
|
||||
void setAlbum( const Tomahawk::album_ptr& album );
|
||||
void setComposer( const Tomahawk::artist_ptr& composer );
|
||||
@ -135,8 +140,10 @@ private:
|
||||
Tomahawk::artist_ptr m_composer;
|
||||
QString m_track;
|
||||
QString m_url;
|
||||
QString m_purchaseUrl;
|
||||
QString m_mimetype;
|
||||
QString m_friendlySource;
|
||||
QPixmap m_sourceIcon;
|
||||
|
||||
unsigned int m_duration;
|
||||
unsigned int m_bitrate;
|
||||
|
@ -231,6 +231,10 @@ QtScriptResolver::QtScriptResolver( const QString& scriptPath )
|
||||
m_engine = new ScriptEngine( this );
|
||||
m_name = QFileInfo( filePath() ).baseName();
|
||||
|
||||
// set the icon, if we launch properly we'll get the icon the resolver reports
|
||||
m_icon.load( RESPATH "images/resolver-default.png" );
|
||||
|
||||
|
||||
if ( !QFile::exists( filePath() ) )
|
||||
{
|
||||
tLog() << Q_FUNC_INFO << "Failed loading JavaScript resolver:" << scriptPath;
|
||||
@ -322,13 +326,15 @@ QtScriptResolver::init()
|
||||
m_name = m.value( "name" ).toString();
|
||||
m_weight = m.value( "weight", 0 ).toUInt();
|
||||
m_timeout = m.value( "timeout", 25 ).toUInt() * 1000;
|
||||
QString iconPath = QFileInfo( filePath() ).path() + "/" + m.value( "icon" ).toString();
|
||||
int success = m_icon.load( iconPath );
|
||||
|
||||
// load config widget and apply settings
|
||||
loadUi();
|
||||
QVariantMap config = resolverUserConfig();
|
||||
fillDataInWidgets( config );
|
||||
|
||||
qDebug() << "JS" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout;
|
||||
qDebug() << "JS" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout << "icon" << iconPath << "icon found" << success;
|
||||
|
||||
m_ready = true;
|
||||
}
|
||||
@ -426,6 +432,8 @@ QtScriptResolver::parseResultVariantList( const QVariantList& reslist )
|
||||
rp->setSize( m.value( "size" ).toUInt() );
|
||||
rp->setRID( uuid() );
|
||||
rp->setFriendlySource( name() );
|
||||
rp->setSourceIcon( icon() );
|
||||
rp->setPurchaseUrl( m.value( "purchaseUrl" ).toString() );
|
||||
rp->setScore( m.value( "score" ).toFloat() );
|
||||
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
||||
|
||||
|
@ -130,6 +130,7 @@ public:
|
||||
static ExternalResolver* factory( const QString& scriptPath );
|
||||
|
||||
virtual QString name() const { return m_name; }
|
||||
virtual QPixmap icon() const { return m_icon; }
|
||||
virtual unsigned int weight() const { return m_weight; }
|
||||
virtual unsigned int timeout() const { return m_timeout; }
|
||||
|
||||
@ -168,6 +169,7 @@ private:
|
||||
ScriptEngine* m_engine;
|
||||
|
||||
QString m_name;
|
||||
QPixmap m_icon;
|
||||
unsigned int m_weight, m_timeout;
|
||||
|
||||
bool m_ready, m_stopped;
|
||||
|
@ -57,6 +57,9 @@ ScriptResolver::ScriptResolver( const QString& exe )
|
||||
|
||||
// set the name to the binary, if we launch properly we'll get the name the resolver reports
|
||||
m_name = QFileInfo( filePath() ).baseName();
|
||||
|
||||
// set the icon, if we launch properly we'll get the icon the resolver reports
|
||||
m_icon.load( RESPATH "images/resolver-default.png" );
|
||||
}
|
||||
|
||||
|
||||
@ -279,6 +282,8 @@ ScriptResolver::handleMsg( const QByteArray& msg )
|
||||
rp->setSize( m.value( "size" ).toUInt() );
|
||||
rp->setRID( uuid() );
|
||||
rp->setFriendlySource( m_name );
|
||||
rp->setSourceIcon( m_icon );
|
||||
rp->setPurchaseUrl( m.value( "purchaseUrl" ).toString() );
|
||||
rp->setYear( m.value( "year").toUInt() );
|
||||
rp->setDiscNumber( m.value( "discnumber" ).toUInt() );
|
||||
|
||||
@ -371,7 +376,10 @@ ScriptResolver::doSetup( const QVariantMap& m )
|
||||
m_name = m.value( "name" ).toString();
|
||||
m_weight = m.value( "weight", 0 ).toUInt();
|
||||
m_timeout = m.value( "timeout", 5 ).toUInt() * 1000;
|
||||
qDebug() << "SCRIPT" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout;
|
||||
QString iconPath = QFileInfo( filePath() ).path() + "/" + m.value( "icon" ).toString();
|
||||
int success = m_icon.load( iconPath );
|
||||
|
||||
qDebug() << "SCRIPT" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout << "icon" << iconPath << "icon found" << success;
|
||||
|
||||
m_ready = true;
|
||||
m_configSent = false;
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
static ExternalResolver* factory( const QString& exe );
|
||||
|
||||
virtual QString name() const { return m_name; }
|
||||
virtual QPixmap icon() const { return m_icon; }
|
||||
virtual unsigned int weight() const { return m_weight; }
|
||||
virtual unsigned int preference() const { return m_preference; }
|
||||
virtual unsigned int timeout() const { return m_timeout; }
|
||||
@ -82,6 +83,7 @@ private:
|
||||
|
||||
QProcess m_proc;
|
||||
QString m_name;
|
||||
QPixmap m_icon;
|
||||
unsigned int m_weight, m_preference, m_timeout, m_num_restarts;
|
||||
QWeakPointer< QWidget > m_configWidget;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user