mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
Add avatar support to controlconnection, source and sourcetreeview.
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include "database/databasecommand_collectionstats.h"
|
#include "database/databasecommand_collectionstats.h"
|
||||||
#include "dbsyncconnection.h"
|
#include "dbsyncconnection.h"
|
||||||
#include "sourcelist.h"
|
#include "sourcelist.h"
|
||||||
|
#include <sip/SipHandler.h>
|
||||||
|
|
||||||
#define TCP_TIMEOUT 600
|
#define TCP_TIMEOUT 600
|
||||||
|
|
||||||
@@ -120,6 +121,10 @@ ControlConnection::registerSource()
|
|||||||
Source* source = (Source*) sender();
|
Source* source = (Source*) sender();
|
||||||
Q_UNUSED( source )
|
Q_UNUSED( source )
|
||||||
Q_ASSERT( source == m_source.data() );
|
Q_ASSERT( source == m_source.data() );
|
||||||
|
|
||||||
|
qDebug() << Q_FUNC_INFO << "Setting avatar ... " << name() << !SipHandler::instance()->avatar( name() ).isNull();
|
||||||
|
source->setAvatar( SipHandler::instance()->avatar( name() ) );
|
||||||
|
|
||||||
// .. but we'll use the shared pointer we've already made:
|
// .. but we'll use the shared pointer we've already made:
|
||||||
|
|
||||||
m_registered = true;
|
m_registered = true;
|
||||||
|
@@ -44,6 +44,8 @@ public:
|
|||||||
|
|
||||||
DBSyncConnection* dbSyncConnection();
|
DBSyncConnection* dbSyncConnection();
|
||||||
|
|
||||||
|
Tomahawk::source_ptr source() const { return m_source; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setup();
|
virtual void setup();
|
||||||
|
|
||||||
|
@@ -58,6 +58,8 @@ signals:
|
|||||||
void peerOffline( const QString& );
|
void peerOffline( const QString& );
|
||||||
void msgReceived( const QString& from, const QString& msg );
|
void msgReceived( const QString& from, const QString& msg );
|
||||||
|
|
||||||
|
void avatarReceived ( const QString& from, const QPixmap& avatar);
|
||||||
|
|
||||||
void addMenu( QMenu* menu );
|
void addMenu( QMenu* menu );
|
||||||
void removeMenu( QMenu* menu );
|
void removeMenu( QMenu* menu );
|
||||||
};
|
};
|
||||||
|
@@ -107,6 +107,16 @@ Source::friendlyName() const
|
|||||||
return m_friendlyname;
|
return m_friendlyname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Source::setAvatar(const QPixmap& avatar)
|
||||||
|
{
|
||||||
|
m_avatar = avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QPixmap Source::avatar() const
|
||||||
|
{
|
||||||
|
return m_avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Source::addCollection( const collection_ptr& c )
|
Source::addCollection( const collection_ptr& c )
|
||||||
|
@@ -54,6 +54,8 @@ public:
|
|||||||
QString userName() const { return m_username; }
|
QString userName() const { return m_username; }
|
||||||
QString friendlyName() const;
|
QString friendlyName() const;
|
||||||
void setFriendlyName( const QString& fname ) { m_friendlyname = fname; }
|
void setFriendlyName( const QString& fname ) { m_friendlyname = fname; }
|
||||||
|
void setAvatar(const QPixmap &avatar);
|
||||||
|
const QPixmap avatar() const;
|
||||||
|
|
||||||
collection_ptr collection() const;
|
collection_ptr collection() const;
|
||||||
void addCollection( const Tomahawk::collection_ptr& c );
|
void addCollection( const Tomahawk::collection_ptr& c );
|
||||||
@@ -116,6 +118,8 @@ private:
|
|||||||
QString m_textStatus;
|
QString m_textStatus;
|
||||||
|
|
||||||
ControlConnection* m_cc;
|
ControlConnection* m_cc;
|
||||||
|
|
||||||
|
QPixmap m_avatar;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -537,17 +537,20 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
|
|
||||||
SourceTreeItem* sti = SourcesModel::indexToTreeItem( index );
|
SourceTreeItem* sti = SourcesModel::indexToTreeItem( index );
|
||||||
bool status = !( !sti || sti->source().isNull() || !sti->source()->isOnline() );
|
bool status = !( !sti || sti->source().isNull() || !sti->source()->isOnline() );
|
||||||
|
QPixmap avatar( RESPATH "images/user-avatar.png" );
|
||||||
QString tracks;
|
QString tracks;
|
||||||
int figWidth = 0;
|
int figWidth = 0;
|
||||||
|
|
||||||
if ( status )
|
if ( status && sti && !sti->source().isNull() )
|
||||||
{
|
{
|
||||||
tracks = QString::number( sti->source()->trackCount() );
|
tracks = QString::number( sti->source()->trackCount() );
|
||||||
figWidth = painter->fontMetrics().width( tracks );
|
figWidth = painter->fontMetrics().width( tracks );
|
||||||
|
if ( !sti->source()->avatar().isNull() )
|
||||||
|
avatar = sti->source()->avatar();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect iconRect = option.rect.adjusted( 4, 6, -option.rect.width() + option.rect.height() - 12 + 4, -6 );
|
QRect iconRect = option.rect.adjusted( 4, 6, -option.rect.width() + option.rect.height() - 12 + 4, -6 );
|
||||||
painter->drawPixmap( iconRect, QPixmap( RESPATH "images/user-avatar.png" ).scaledToHeight( iconRect.height(), Qt::SmoothTransformation ) );
|
painter->drawPixmap( iconRect, avatar.scaledToHeight( iconRect.height(), Qt::SmoothTransformation ) );
|
||||||
|
|
||||||
if ( ( option.state & QStyle::State_Selected ) == QStyle::State_Selected )
|
if ( ( option.state & QStyle::State_Selected ) == QStyle::State_Selected )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user