mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +02:00
TWK-434: Added drag indicators for artist and album
This commit is contained in:
@@ -227,7 +227,7 @@ AlbumView::startDrag( Qt::DropActions supportedActions )
|
|||||||
|
|
||||||
QDrag* drag = new QDrag( this );
|
QDrag* drag = new QDrag( this );
|
||||||
drag->setMimeData( data );
|
drag->setMimeData( data );
|
||||||
const QPixmap p = TomahawkUtils::createDragPixmap( indexes.count() );
|
const QPixmap p = TomahawkUtils::createDragPixmap( TomahawkUtils::MediaTypeAlbum, indexes.count() );
|
||||||
drag->setPixmap( p );
|
drag->setPixmap( p );
|
||||||
drag->setHotSpot( QPoint( -20, -20 ) );
|
drag->setHotSpot( QPoint( -20, -20 ) );
|
||||||
|
|
||||||
|
@@ -215,7 +215,15 @@ ArtistView::startDrag( Qt::DropActions supportedActions )
|
|||||||
|
|
||||||
QDrag* drag = new QDrag( this );
|
QDrag* drag = new QDrag( this );
|
||||||
drag->setMimeData( data );
|
drag->setMimeData( data );
|
||||||
const QPixmap p = TomahawkUtils::createDragPixmap( indexes.count() );
|
|
||||||
|
QPixmap p;
|
||||||
|
if ( data->hasFormat( "application/tomahawk.metadata.artist" ) )
|
||||||
|
p = TomahawkUtils::createDragPixmap( TomahawkUtils::MediaTypeArtist, indexes.count() );
|
||||||
|
else if ( data->hasFormat( "application/tomahawk.metadata.album" ) )
|
||||||
|
p = TomahawkUtils::createDragPixmap( TomahawkUtils::MediaTypeAlbum, indexes.count() );
|
||||||
|
else
|
||||||
|
p = TomahawkUtils::createDragPixmap( TomahawkUtils::MediaTypeTrack, indexes.count() );
|
||||||
|
|
||||||
drag->setPixmap( p );
|
drag->setPixmap( p );
|
||||||
drag->setHotSpot( QPoint( -20, -20 ) );
|
drag->setHotSpot( QPoint( -20, -20 ) );
|
||||||
|
|
||||||
|
@@ -378,7 +378,7 @@ TrackView::startDrag( Qt::DropActions supportedActions )
|
|||||||
|
|
||||||
QDrag* drag = new QDrag( this );
|
QDrag* drag = new QDrag( this );
|
||||||
drag->setMimeData( data );
|
drag->setMimeData( data );
|
||||||
const QPixmap p = TomahawkUtils::createDragPixmap( indexes.count() );
|
const QPixmap p = TomahawkUtils::createDragPixmap( TomahawkUtils::MediaTypeTrack, indexes.count() );
|
||||||
drag->setPixmap( p );
|
drag->setPixmap( p );
|
||||||
drag->setHotSpot( QPoint( -20, -20 ) );
|
drag->setHotSpot( QPoint( -20, -20 ) );
|
||||||
|
|
||||||
|
@@ -349,6 +349,7 @@ TreeModel::mimeData( const QModelIndexList &indexes ) const
|
|||||||
|
|
||||||
// lets try with album only
|
// lets try with album only
|
||||||
fail = false;
|
fail = false;
|
||||||
|
resultData.clear();
|
||||||
foreach ( const QModelIndex& i, indexes)
|
foreach ( const QModelIndex& i, indexes)
|
||||||
{
|
{
|
||||||
if ( i.column() > 0 || indexes.contains( i.parent() ) )
|
if ( i.column() > 0 || indexes.contains( i.parent() ) )
|
||||||
@@ -380,6 +381,7 @@ TreeModel::mimeData( const QModelIndexList &indexes ) const
|
|||||||
|
|
||||||
// lets try with tracks only
|
// lets try with tracks only
|
||||||
fail = false;
|
fail = false;
|
||||||
|
resultData.clear();
|
||||||
foreach ( const QModelIndex& i, indexes)
|
foreach ( const QModelIndex& i, indexes)
|
||||||
{
|
{
|
||||||
if ( i.column() > 0 || indexes.contains( i.parent() ) )
|
if ( i.column() > 0 || indexes.contains( i.parent() ) )
|
||||||
@@ -408,6 +410,7 @@ TreeModel::mimeData( const QModelIndexList &indexes ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ok... we have to use mixed
|
// Ok... we have to use mixed
|
||||||
|
resultData.clear();
|
||||||
foreach ( const QModelIndex& i, indexes )
|
foreach ( const QModelIndex& i, indexes )
|
||||||
{
|
{
|
||||||
if ( i.column() > 0 || indexes.contains( i.parent() ) )
|
if ( i.column() > 0 || indexes.contains( i.parent() ) )
|
||||||
|
@@ -568,7 +568,7 @@ QueryLabel::startDrag()
|
|||||||
mimeData->setData( "application/tomahawk.query.list", queryData );
|
mimeData->setData( "application/tomahawk.query.list", queryData );
|
||||||
QDrag *drag = new QDrag( this );
|
QDrag *drag = new QDrag( this );
|
||||||
drag->setMimeData( mimeData );
|
drag->setMimeData( mimeData );
|
||||||
drag->setPixmap( TomahawkUtils::createDragPixmap() );
|
drag->setPixmap( TomahawkUtils::createDragPixmap( TomahawkUtils::MediaTypeTrack ) );
|
||||||
|
|
||||||
// QPoint hotSpot = event->pos() - child->pos();
|
// QPoint hotSpot = event->pos() - child->pos();
|
||||||
// drag->setHotSpot( hotSpot );
|
// drag->setHotSpot( hotSpot );
|
||||||
|
@@ -307,7 +307,7 @@ alphaBlend( const QColor& colorFrom, const QColor& colorTo, float opacity )
|
|||||||
|
|
||||||
|
|
||||||
QPixmap
|
QPixmap
|
||||||
createDragPixmap( int itemCount )
|
createDragPixmap( MediaType type, int itemCount )
|
||||||
{
|
{
|
||||||
// If more than one item is dragged, align the items inside a
|
// If more than one item is dragged, align the items inside a
|
||||||
// rectangular grid. The maximum grid size is limited to 5 x 5 items.
|
// rectangular grid. The maximum grid size is limited to 5 x 5 items.
|
||||||
@@ -344,11 +344,26 @@ createDragPixmap( int itemCount )
|
|||||||
|
|
||||||
QPainter painter( &dragPixmap );
|
QPainter painter( &dragPixmap );
|
||||||
painter.setRenderHint( QPainter::Antialiasing );
|
painter.setRenderHint( QPainter::Antialiasing );
|
||||||
|
|
||||||
|
QPixmap pixmap;
|
||||||
|
switch ( type )
|
||||||
|
{
|
||||||
|
case MediaTypeArtist:
|
||||||
|
pixmap = QPixmap( ":/data/images/artist-icon.png" ).scaledToWidth( size, Qt::SmoothTransformation );
|
||||||
|
break;
|
||||||
|
case MediaTypeAlbum:
|
||||||
|
pixmap = QPixmap( ":/data/images/album-icon.png" ).scaledToWidth( size, Qt::SmoothTransformation );
|
||||||
|
break;
|
||||||
|
case MediaTypeTrack:
|
||||||
|
pixmap = QPixmap( QString( ":/data/images/track-icon-%2x%2.png" ).arg( size ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
for( int i = 0; i < itemCount; ++i )
|
for( int i = 0; i < itemCount; ++i )
|
||||||
{
|
{
|
||||||
const QPixmap pixmap = QPixmap( QString( ":/data/images/track-icon-%2x%2.png" ).arg( size ) );
|
|
||||||
painter.drawPixmap( x, y, pixmap );
|
painter.drawPixmap( x, y, pixmap );
|
||||||
|
|
||||||
x += size + 1;
|
x += size + 1;
|
||||||
|
@@ -40,6 +40,13 @@ class QNetworkAccessManager;
|
|||||||
|
|
||||||
namespace TomahawkUtils
|
namespace TomahawkUtils
|
||||||
{
|
{
|
||||||
|
enum MediaType
|
||||||
|
{
|
||||||
|
MediaTypeArtist,
|
||||||
|
MediaTypeAlbum,
|
||||||
|
MediaTypeTrack
|
||||||
|
};
|
||||||
|
|
||||||
class DLLEXPORT NetworkProxyFactory : public QNetworkProxyFactory
|
class DLLEXPORT NetworkProxyFactory : public QNetworkProxyFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -74,7 +81,7 @@ namespace TomahawkUtils
|
|||||||
DLLEXPORT QString extensionToMimetype( const QString& extension );
|
DLLEXPORT QString extensionToMimetype( const QString& extension );
|
||||||
|
|
||||||
DLLEXPORT QColor alphaBlend( const QColor& colorFrom, const QColor& colorTo, float opacity );
|
DLLEXPORT QColor alphaBlend( const QColor& colorFrom, const QColor& colorTo, float opacity );
|
||||||
DLLEXPORT QPixmap createDragPixmap( int itemCount = 1 );
|
DLLEXPORT QPixmap createDragPixmap( MediaType type, int itemCount = 1 );
|
||||||
|
|
||||||
DLLEXPORT void drawBackgroundAndNumbers( QPainter* p, const QString& text, const QRect& rect );
|
DLLEXPORT void drawBackgroundAndNumbers( QPainter* p, const QString& text, const QRect& rect );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user