mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-14 18:14:50 +02:00
differentiate between synced and subscribed updaters, and show icon
This commit is contained in:
BIN
data/images/playlist-subscribed.png
Executable file
BIN
data/images/playlist-subscribed.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@@ -148,5 +148,6 @@
|
||||
<file>data/images/jump-link.png</file>
|
||||
<file>data/images/scrollbar-vertical-handle.png</file>
|
||||
<file>data/images/scrollbar-horizontal-handle.png</file>
|
||||
<file>data/images/playlist-subscribed.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@@ -35,6 +35,12 @@ namespace Tomahawk
|
||||
/**
|
||||
* PlaylistUpdaters are attached to playlists. They usually manipulate the playlist in some way
|
||||
* 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;
|
||||
@@ -71,7 +77,8 @@ public:
|
||||
|
||||
static void registerUpdaterFactory( PlaylistUpdaterFactory* f );
|
||||
|
||||
virtual bool sync() const { return true; }
|
||||
virtual bool sync() const { return false; }
|
||||
virtual bool subscribed() const { return false; }
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
@@ -48,6 +48,8 @@ public:
|
||||
void setInterval( int intervalMsecs ) ;
|
||||
int intervalMsecs() const { return m_timer->interval(); }
|
||||
|
||||
bool subscribed() const { return true; }
|
||||
|
||||
public slots:
|
||||
void updateNow();
|
||||
void setAutoUpdate( bool autoUpdate );
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/* === This file is part of Tomahawk Player - <http://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 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||
*
|
||||
@@ -143,7 +143,7 @@ SourceDelegate::paintDecorations( QPainter* painter, const QStyleOptionViewItem&
|
||||
iconW = ah->originalSize().height() - 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QRect iconRect = QRect( 4, option.rect.y() + 2, iconW, iconW );
|
||||
QPixmap speaker = option.state & QStyle::State_Selected ? m_nowPlayingSpeaker : m_nowPlayingSpeakerDark;
|
||||
speaker = speaker.scaledToHeight( iconW, Qt::SmoothTransformation );
|
||||
@@ -549,6 +549,22 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
||||
else
|
||||
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
|
||||
QStyledItemDelegate::paint( painter, o, index );
|
||||
}
|
||||
|
@@ -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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -280,6 +280,7 @@ PlaylistItem::onUpdated()
|
||||
if ( !newOverlay && !m_overlaidIcon.isNull() )
|
||||
m_overlaidIcon = QIcon();
|
||||
|
||||
|
||||
emit updated();
|
||||
}
|
||||
|
||||
@@ -292,6 +293,19 @@ PlaylistItem::createOverlay()
|
||||
if ( m_playlist->updaters().isEmpty() )
|
||||
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;
|
||||
foreach ( PlaylistUpdaterInterface* updater, m_playlist->updaters() )
|
||||
{
|
||||
|
@@ -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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -42,6 +42,10 @@ public:
|
||||
|
||||
virtual SourceTreeItem* activateCurrent();
|
||||
|
||||
bool subscribed() const { return m_showSubscribed; }
|
||||
QPixmap subscribedIcon() const { return m_subscribedIcon; }
|
||||
QList< QAction* > subscribedActions() const;
|
||||
|
||||
public slots:
|
||||
virtual void activate();
|
||||
virtual void doubleClicked();
|
||||
@@ -58,9 +62,10 @@ private slots:
|
||||
private:
|
||||
bool createOverlay();
|
||||
|
||||
bool m_loaded;
|
||||
bool m_loaded, m_showSubscribed;
|
||||
Tomahawk::playlist_ptr m_playlist;
|
||||
QIcon m_icon, m_overlaidIcon;
|
||||
QPixmap m_subscribedIcon;
|
||||
QList<Tomahawk::PlaylistUpdaterInterface*> m_overlaidUpdaters;
|
||||
};
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(PlaylistItem::DropTypes)
|
||||
|
Reference in New Issue
Block a user