1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 17:43:59 +02:00

differentiate between synced and subscribed updaters, and show icon

This commit is contained in:
Leo Franchi
2012-07-24 21:12:34 -04:00
parent f4b1c5ba9f
commit c8bda2ccbe
7 changed files with 51 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -148,5 +148,6 @@
<file>data/images/jump-link.png</file> <file>data/images/jump-link.png</file>
<file>data/images/scrollbar-vertical-handle.png</file> <file>data/images/scrollbar-vertical-handle.png</file>
<file>data/images/scrollbar-horizontal-handle.png</file> <file>data/images/scrollbar-horizontal-handle.png</file>
<file>data/images/playlist-subscribed.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -35,6 +35,12 @@ namespace Tomahawk
/** /**
* PlaylistUpdaters are attached to playlists. They usually manipulate the playlist in some way * PlaylistUpdaters are attached to playlists. They usually manipulate the playlist in some way
* due to external input (spotify syncing) or timers (xspf updating) * due to external input (spotify syncing) or timers (xspf updating)
*
* Updaters have 2 modes of operation: syncing and subscribing. Syncing implies two-way sync, that is, this
* playlist is reproduced on some other service (e.g. spotify or rdio).
*
* Subscribing implies the playlist is being updated periodically with changes from some source, and the user
* is working with a copy: e.g. an xspf updater or a spotify subscribed playlist.
*/ */
class PlaylistUpdaterFactory; class PlaylistUpdaterFactory;
@@ -71,7 +77,8 @@ public:
static void registerUpdaterFactory( PlaylistUpdaterFactory* f ); static void registerUpdaterFactory( PlaylistUpdaterFactory* f );
virtual bool sync() const { return true; } virtual bool sync() const { return false; }
virtual bool subscribed() const { return false; }
signals: signals:
void changed(); void changed();

View File

@@ -48,6 +48,8 @@ public:
void setInterval( int intervalMsecs ) ; void setInterval( int intervalMsecs ) ;
int intervalMsecs() const { return m_timer->interval(); } int intervalMsecs() const { return m_timer->interval(); }
bool subscribed() const { return true; }
public slots: public slots:
void updateNow(); void updateNow();
void setAutoUpdate( bool autoUpdate ); void setAutoUpdate( bool autoUpdate );

View File

@@ -1,7 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2011, Leo Franchi <lfranchi@kde.org> * Copyright 2011-2012, Leo Franchi <lfranchi@kde.org>
* Copyright 2011, Michael Zanetti <mzanetti@kde.org> * Copyright 2011, Michael Zanetti <mzanetti@kde.org>
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org> * Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
* *
@@ -143,7 +143,7 @@ SourceDelegate::paintDecorations( QPainter* painter, const QStyleOptionViewItem&
iconW = ah->originalSize().height() - 4; iconW = ah->originalSize().height() - 4;
} }
} }
QRect iconRect = QRect( 4, option.rect.y() + 2, iconW, iconW ); QRect iconRect = QRect( 4, option.rect.y() + 2, iconW, iconW );
QPixmap speaker = option.state & QStyle::State_Selected ? m_nowPlayingSpeaker : m_nowPlayingSpeakerDark; QPixmap speaker = option.state & QStyle::State_Selected ? m_nowPlayingSpeaker : m_nowPlayingSpeakerDark;
speaker = speaker.scaledToHeight( iconW, Qt::SmoothTransformation ); speaker = speaker.scaledToHeight( iconW, Qt::SmoothTransformation );
@@ -549,6 +549,22 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
else else
QStyledItemDelegate::paint( painter, o, index ); QStyledItemDelegate::paint( painter, o, index );
} }
else if ( type == SourcesModel::StaticPlaylist )
{
QStyledItemDelegate::paint( painter, o, index );
PlaylistItem* plItem = qobject_cast< PlaylistItem* >( item );
if ( plItem->subscribed() && !plItem->subscribedIcon().isNull() )
{
const int padding = 2;
const int imgWidth = o.rect.height() - 2*padding;
const QPixmap icon = plItem->subscribedIcon().scaled( imgWidth, imgWidth, Qt::KeepAspectRatio, Qt::SmoothTransformation );
const QRect subRect( o.rect.right() - padding - imgWidth, o.rect.top() + padding, imgWidth, imgWidth );
painter->drawPixmap( subRect, icon );
}
}
else else
QStyledItemDelegate::paint( painter, o, index ); QStyledItemDelegate::paint( painter, o, index );
} }

View File

@@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org> * Copyright 2010-2012, Leo Franchi <lfranchi@kde.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -280,6 +280,7 @@ PlaylistItem::onUpdated()
if ( !newOverlay && !m_overlaidIcon.isNull() ) if ( !newOverlay && !m_overlaidIcon.isNull() )
m_overlaidIcon = QIcon(); m_overlaidIcon = QIcon();
emit updated(); emit updated();
} }
@@ -292,6 +293,19 @@ PlaylistItem::createOverlay()
if ( m_playlist->updaters().isEmpty() ) if ( m_playlist->updaters().isEmpty() )
return false; return false;
m_showSubscribed = false;
foreach ( PlaylistUpdaterInterface* updater, m_playlist->updaters() )
{
if ( updater->subscribed() )
{
m_showSubscribed = true;
break;
}
}
if ( m_showSubscribed && m_subscribedIcon.isNull() )
m_subscribedIcon = QPixmap( RESPATH "images/playlist-subscribed.png" );
QList< QPixmap > icons; QList< QPixmap > icons;
foreach ( PlaylistUpdaterInterface* updater, m_playlist->updaters() ) foreach ( PlaylistUpdaterInterface* updater, m_playlist->updaters() )
{ {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org> * Copyright 2010-2012, Leo Franchi <lfranchi@kde.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -42,6 +42,10 @@ public:
virtual SourceTreeItem* activateCurrent(); virtual SourceTreeItem* activateCurrent();
bool subscribed() const { return m_showSubscribed; }
QPixmap subscribedIcon() const { return m_subscribedIcon; }
QList< QAction* > subscribedActions() const;
public slots: public slots:
virtual void activate(); virtual void activate();
virtual void doubleClicked(); virtual void doubleClicked();
@@ -58,9 +62,10 @@ private slots:
private: private:
bool createOverlay(); bool createOverlay();
bool m_loaded; bool m_loaded, m_showSubscribed;
Tomahawk::playlist_ptr m_playlist; Tomahawk::playlist_ptr m_playlist;
QIcon m_icon, m_overlaidIcon; QIcon m_icon, m_overlaidIcon;
QPixmap m_subscribedIcon;
QList<Tomahawk::PlaylistUpdaterInterface*> m_overlaidUpdaters; QList<Tomahawk::PlaylistUpdaterInterface*> m_overlaidUpdaters;
}; };
Q_DECLARE_OPERATORS_FOR_FLAGS(PlaylistItem::DropTypes) Q_DECLARE_OPERATORS_FOR_FLAGS(PlaylistItem::DropTypes)