mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Added a WIP short style for our TrackViews.
This commit is contained in:
@@ -39,7 +39,7 @@ Database::Database( const QString& dbname, QObject* parent )
|
||||
{
|
||||
s_instance = this;
|
||||
|
||||
m_maxConcurrentThreads = qBound( DEFAULT_WORKER_THREADS, QThread::idealThreadCount() * 2, MAX_WORKER_THREADS );
|
||||
m_maxConcurrentThreads = qBound( DEFAULT_WORKER_THREADS, QThread::idealThreadCount(), MAX_WORKER_THREADS );
|
||||
qDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentThreads << "threads";
|
||||
|
||||
connect( m_impl, SIGNAL( indexReady() ), SIGNAL( indexReady() ) );
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <QSqlQuery>
|
||||
|
||||
#include "databaseimpl.h"
|
||||
#include "sourcelist.h"
|
||||
|
||||
|
||||
void
|
||||
@@ -36,7 +37,7 @@ DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi )
|
||||
}
|
||||
|
||||
QString sql = QString(
|
||||
"SELECT track, playtime, secs_played "
|
||||
"SELECT track, playtime, secs_played, source "
|
||||
"FROM playback_log "
|
||||
"%1 "
|
||||
"ORDER BY playtime DESC "
|
||||
@@ -63,6 +64,16 @@ DatabaseCommand_PlaybackHistory::exec( DatabaseImpl* dbi )
|
||||
if ( query_track.next() )
|
||||
{
|
||||
Tomahawk::query_ptr q = Tomahawk::Query::get( query_track.value( 1 ).toString(), query_track.value( 0 ).toString(), QString(), uuid() );
|
||||
|
||||
if ( query.value( 3 ).toUInt() == 0 )
|
||||
{
|
||||
q->setPlayedBy( SourceList::instance()->getLocal() );
|
||||
}
|
||||
else
|
||||
{
|
||||
q->setPlayedBy( SourceList::instance()->get( query.value( 3 ).toUInt() ) );
|
||||
}
|
||||
|
||||
ql << q;
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,9 @@
|
||||
|
||||
#include "query.h"
|
||||
#include "result.h"
|
||||
#include "artist.h"
|
||||
#include "source.h"
|
||||
#include "sourcelist.h"
|
||||
|
||||
#include "trackmodelitem.h"
|
||||
#include "trackproxymodel.h"
|
||||
@@ -37,7 +40,6 @@
|
||||
|
||||
PlaylistItemDelegate::PlaylistItemDelegate( TrackView* parent, TrackProxyModel* proxy )
|
||||
: QStyledItemDelegate( (QObject*)parent )
|
||||
, m_style( Detailed )
|
||||
, m_view( parent )
|
||||
, m_model( proxy )
|
||||
{
|
||||
@@ -45,13 +47,6 @@ PlaylistItemDelegate::PlaylistItemDelegate( TrackView* parent, TrackProxyModel*
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistItemDelegate::setStyle( PlaylistItemDelegate::PlaylistItemStyle style )
|
||||
{
|
||||
m_style = style;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistItemDelegate::updateRowSize( const QModelIndex& index )
|
||||
{
|
||||
@@ -63,6 +58,14 @@ QSize
|
||||
PlaylistItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
{
|
||||
QSize size = QStyledItemDelegate::sizeHint( option, index );
|
||||
|
||||
if ( index.isValid() )
|
||||
{
|
||||
int style = index.data( TrackModel::StyleRole ).toInt();
|
||||
if ( style == TrackModel::Short )
|
||||
size.setHeight( 48 );
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -77,16 +80,50 @@ PlaylistItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem&
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistItemDelegate::prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index ) const
|
||||
{
|
||||
initStyleOption( option, index );
|
||||
|
||||
TrackModelItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
|
||||
if ( item->isPlaying() )
|
||||
{
|
||||
option->palette.setColor( QPalette::Highlight, option->palette.color( QPalette::Mid ) );
|
||||
option->state |= QStyle::State_Selected;
|
||||
}
|
||||
|
||||
if ( item->isPlaying() || index.column() == TrackModel::Score )
|
||||
option->text.clear();
|
||||
|
||||
if ( option->state & QStyle::State_Selected )
|
||||
{
|
||||
option->palette.setColor( QPalette::Text, option->palette.color( QPalette::HighlightedText ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
float opacity = 0.0;
|
||||
if ( item->query()->results().count() )
|
||||
opacity = item->query()->results().first()->score();
|
||||
|
||||
opacity = qMax( (float)0.3, opacity );
|
||||
QColor textColor = TomahawkUtils::alphaBlend( option->palette.color( QPalette::Foreground ), option->palette.color( QPalette::Background ), opacity );
|
||||
|
||||
option->palette.setColor( QPalette::Text, textColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
{
|
||||
switch ( m_style )
|
||||
int style = index.data( TrackModel::StyleRole ).toInt();
|
||||
switch ( style )
|
||||
{
|
||||
case Detailed:
|
||||
case TrackModel::Detailed:
|
||||
paintDetailed( painter, option, index );
|
||||
break;
|
||||
|
||||
case Short:
|
||||
case TrackModel::Short:
|
||||
paintShort( painter, option, index );
|
||||
break;
|
||||
}
|
||||
@@ -96,7 +133,85 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
|
||||
void
|
||||
PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
{
|
||||
TrackModelItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
|
||||
Q_ASSERT( item );
|
||||
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
prepareStyleOption( &opt, index );
|
||||
opt.text.clear();
|
||||
|
||||
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
|
||||
|
||||
if ( m_view->header()->visualIndex( index.column() ) > 0 )
|
||||
return;
|
||||
|
||||
QPixmap pixmap;
|
||||
QString artist, track, upperText, lowerText;
|
||||
if ( item->query()->results().count() )
|
||||
{
|
||||
artist = item->query()->results().first()->artist()->name();
|
||||
track = item->query()->results().first()->track();
|
||||
}
|
||||
else
|
||||
{
|
||||
artist = item->query()->artist();
|
||||
track = item->query()->track();
|
||||
}
|
||||
|
||||
if ( item->query()->playedBy().isNull() )
|
||||
{
|
||||
upperText = artist;
|
||||
lowerText = track;
|
||||
}
|
||||
else
|
||||
{
|
||||
upperText = QString( "%1 - %2" ).arg( artist ).arg( track );
|
||||
|
||||
if ( item->query()->playedBy() == SourceList::instance()->getLocal() )
|
||||
lowerText = QString( "played by you" );
|
||||
else
|
||||
lowerText = QString( "played by %1" ).arg( item->query()->playedBy()->friendlyName() );
|
||||
|
||||
pixmap = item->query()->playedBy()->avatar();
|
||||
}
|
||||
|
||||
if ( pixmap.isNull() )
|
||||
pixmap = QPixmap( RESPATH "images/no-album-art-placeholder.png" );
|
||||
|
||||
painter->save();
|
||||
{
|
||||
QRect r = opt.rect.adjusted( 3, 6, 0, -6 );
|
||||
|
||||
// Paint Now Playing Speaker Icon
|
||||
if ( item->isPlaying() )
|
||||
{
|
||||
r.adjust( 0, 0, 0, 0 );
|
||||
QRect npr = r.adjusted( 3, r.height() / 2 - m_nowPlayingIcon.height() / 2, 18 - r.width(), -r.height() + m_nowPlayingIcon.height() / 2 );
|
||||
painter->drawPixmap( npr, m_nowPlayingIcon );
|
||||
r.adjust( 22, 0, 0, 0 );
|
||||
}
|
||||
|
||||
painter->setPen( opt.palette.text().color() );
|
||||
|
||||
QRect ir = r.adjusted( 4, 0, -option.rect.width() + option.rect.height() - 8 + r.left(), 0 );
|
||||
painter->drawPixmap( ir, pixmap );
|
||||
//painter->drawPixmap( ir, item->cover );
|
||||
|
||||
QFont boldFont = opt.font;
|
||||
boldFont.setBold( true );
|
||||
|
||||
r.adjust( ir.width() + 12, 0, 0, 0 );
|
||||
QTextOption to( Qt::AlignTop );
|
||||
QString text = painter->fontMetrics().elidedText( upperText, Qt::ElideRight, r.width() - 3 );
|
||||
painter->setFont( boldFont );
|
||||
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, to );
|
||||
|
||||
to.setAlignment( Qt::AlignBottom );
|
||||
text = painter->fontMetrics().elidedText( lowerText, Qt::ElideRight, r.width() - 3 );
|
||||
painter->setFont( opt.font );
|
||||
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, to );
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
||||
@@ -104,30 +219,10 @@ void
|
||||
PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
{
|
||||
TrackModelItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
|
||||
if ( !item || item->query().isNull() )
|
||||
return;
|
||||
|
||||
float opacity = 0.0;
|
||||
if ( item->query()->results().count() )
|
||||
opacity = item->query()->results().first()->score();
|
||||
|
||||
opacity = qMax( (float)0.3, opacity );
|
||||
QColor textColor = TomahawkUtils::alphaBlend( option.palette.color( QPalette::Foreground ), option.palette.color( QPalette::Background ), opacity );
|
||||
Q_ASSERT( item );
|
||||
|
||||
QStyleOptionViewItemV4 opt = option;
|
||||
initStyleOption( &opt, index );
|
||||
|
||||
if ( item->isPlaying() )
|
||||
{
|
||||
opt.palette.setColor( QPalette::Highlight, opt.palette.color( QPalette::Mid ) );
|
||||
opt.state |= QStyle::State_Selected;
|
||||
}
|
||||
if ( item->isPlaying() || index.column() == TrackModel::Score )
|
||||
opt.text.clear();
|
||||
if ( opt.state & QStyle::State_Selected )
|
||||
opt.palette.setColor( QPalette::Text, opt.palette.color( QPalette::HighlightedText ) );
|
||||
else
|
||||
opt.palette.setColor( QPalette::Text, textColor );
|
||||
prepareStyleOption( &opt, index );
|
||||
|
||||
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
|
||||
|
||||
@@ -139,7 +234,7 @@ PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewIt
|
||||
else
|
||||
painter->setPen( opt.palette.highlight().color() );
|
||||
|
||||
QRect r = opt.rect.adjusted( 3, 3, -6, -5 );
|
||||
QRect r = opt.rect.adjusted( 3, 3, -6, -4 );
|
||||
painter->drawRect( r );
|
||||
|
||||
QRect fillR = r;
|
||||
@@ -172,16 +267,6 @@ PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewIt
|
||||
QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, r.width() - 3 );
|
||||
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, to );
|
||||
}
|
||||
|
||||
// Paint Now Playing Frame
|
||||
/* {
|
||||
QRect r = QRect( 3, opt.rect.y() + 1, m_view->viewport()->width() - 6, opt.rect.height() - 2 );
|
||||
painter->setPen( opt.palette.highlight().color() );
|
||||
QPen pen = painter->pen();
|
||||
pen.setWidth( 1.0 );
|
||||
painter->setPen( pen );
|
||||
painter->drawRoundedRect( r, 3.0, 3.0 );
|
||||
}*/
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
@@ -21,6 +21,8 @@
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
#include "trackmodel.h"
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class TrackProxyModel;
|
||||
@@ -31,12 +33,8 @@ class DLLEXPORT PlaylistItemDelegate : public QStyledItemDelegate
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum PlaylistItemStyle
|
||||
{ Detailed = 0, Short = 1 };
|
||||
|
||||
PlaylistItemDelegate( TrackView* parent = 0, TrackProxyModel* proxy = 0 );
|
||||
|
||||
void setStyle( PlaylistItemDelegate::PlaylistItemStyle style );
|
||||
void updateRowSize( const QModelIndex& index );
|
||||
|
||||
public slots:
|
||||
@@ -48,13 +46,14 @@ protected:
|
||||
QWidget* createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||
|
||||
private:
|
||||
void prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index ) const;
|
||||
|
||||
void paintDetailed( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||
void paintShort( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||
|
||||
unsigned int m_removalProgress;
|
||||
QPixmap m_nowPlayingIcon;
|
||||
|
||||
PlaylistItemStyle m_style;
|
||||
TrackView* m_view;
|
||||
TrackProxyModel* m_model;
|
||||
};
|
||||
|
@@ -72,7 +72,7 @@ PlaylistView::setPlaylistModel( PlaylistModel* model )
|
||||
setGuid( QString( "playlistview/%1" ).arg( m_model->playlist()->guid() ) );
|
||||
else
|
||||
{
|
||||
setGuid( "playlistview" );
|
||||
setGuid( QString( "playlistview/%1" ).arg( m_model->columnCount() ) );
|
||||
}
|
||||
|
||||
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||
|
@@ -87,7 +87,7 @@ TrackHeader::checkState()
|
||||
else
|
||||
{
|
||||
QList< double > m_columnWeights;
|
||||
m_columnWeights << 0.20 << 0.20 << 0.18 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.12; // << 0.05;
|
||||
m_columnWeights << 0.20 << 0.20 << 0.18 << 0.05 << 0.05 << 0.05 << 0.05 << 0.05 << 0.10; // << 0.05;
|
||||
|
||||
for ( int i = 0; i < count() - 1; i++ )
|
||||
{
|
||||
|
@@ -35,6 +35,7 @@ TrackModel::TrackModel( QObject* parent )
|
||||
: QAbstractItemModel( parent )
|
||||
, m_rootItem( new TrackModelItem( 0, this ) )
|
||||
, m_readOnly( true )
|
||||
, m_style( Detailed )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@@ -82,7 +83,18 @@ int
|
||||
TrackModel::columnCount( const QModelIndex& parent ) const
|
||||
{
|
||||
Q_UNUSED( parent );
|
||||
return 10;
|
||||
|
||||
switch ( m_style )
|
||||
{
|
||||
case Short:
|
||||
return 1;
|
||||
break;
|
||||
|
||||
case Detailed:
|
||||
default:
|
||||
return 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +135,11 @@ TrackModel::data( const QModelIndex& index, int role ) const
|
||||
return QSize( 0, 18 );
|
||||
}
|
||||
|
||||
if ( role == StyleRole )
|
||||
{
|
||||
return m_style;
|
||||
}
|
||||
|
||||
if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
|
||||
return QVariant();
|
||||
|
||||
@@ -373,3 +390,10 @@ TrackModel::ensureResolved()
|
||||
Pipeline::instance()->resolve( query );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackModel::setStyle( TrackModel::TrackItemStyle style )
|
||||
{
|
||||
m_style = style;
|
||||
}
|
||||
|
@@ -33,6 +33,12 @@ class DLLEXPORT TrackModel : public QAbstractItemModel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum TrackItemStyle
|
||||
{ Detailed = 0, Short = 1 };
|
||||
|
||||
enum TrackModelRole
|
||||
{ StyleRole = Qt::UserRole + 1 };
|
||||
|
||||
enum Columns {
|
||||
Artist = 0,
|
||||
Track = 1,
|
||||
@@ -49,6 +55,9 @@ public:
|
||||
explicit TrackModel( QObject* parent = 0 );
|
||||
virtual ~TrackModel();
|
||||
|
||||
TrackModel::TrackItemStyle style() const { return m_style; }
|
||||
void setStyle( TrackModel::TrackItemStyle style );
|
||||
|
||||
virtual QModelIndex index( int row, int column, const QModelIndex& parent ) const;
|
||||
virtual QModelIndex parent( const QModelIndex& child ) const;
|
||||
|
||||
@@ -116,6 +125,8 @@ private:
|
||||
|
||||
QString m_title;
|
||||
QString m_description;
|
||||
|
||||
TrackItemStyle m_style;
|
||||
};
|
||||
|
||||
#endif // TRACKMODEL_H
|
||||
|
@@ -140,6 +140,9 @@ TrackView::setTrackModel( TrackModel* model )
|
||||
connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) );
|
||||
|
||||
setAcceptDrops( true );
|
||||
|
||||
if ( model->style() == TrackModel::Short )
|
||||
setHeaderHidden( true );
|
||||
}
|
||||
|
||||
|
||||
@@ -179,6 +182,7 @@ TrackView::onItemResized( const QModelIndex& index )
|
||||
m_delegate->updateRowSize( index );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackView::playItem()
|
||||
{
|
||||
|
@@ -38,7 +38,7 @@ class DLLEXPORT TrackView : public QTreeView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TrackView( QWidget* parent = 0 );
|
||||
explicit TrackView( QWidget* parent = 0 );
|
||||
~TrackView();
|
||||
|
||||
virtual QString guid() const { return m_guid; }
|
||||
|
@@ -100,20 +100,15 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
painter->setPen( opt.palette.color( QPalette::Text ) );
|
||||
|
||||
QRect r = option.rect.adjusted( 4, 4, -option.rect.width() + option.rect.height() - 4, -4 );
|
||||
// painter->drawPixmap( option.rect.adjusted( 4, 4, -4, -38 ), QPixmap( RESPATH "images/cover-shadow.png" ) );
|
||||
// painter->drawPixmap( r, QPixmap( RESPATH "images/cover-shadow.png" ) );
|
||||
painter->drawPixmap( r, item->cover );
|
||||
|
||||
QTextOption to;
|
||||
to.setAlignment( Qt::AlignVCenter );
|
||||
QFont font = opt.font;
|
||||
QFont boldFont = opt.font;
|
||||
boldFont.setBold( true );
|
||||
|
||||
r = option.rect.adjusted( option.rect.height(), 6, -4, -option.rect.height() + 22 );
|
||||
text = painter->fontMetrics().elidedText( text, Qt::ElideRight, r.width() );
|
||||
painter->drawText( r, text, to );
|
||||
|
||||
// painter->setFont( boldFont );
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
@@ -91,6 +91,7 @@ SourceList::setSources( const QList<Tomahawk::source_ptr>& sources )
|
||||
}
|
||||
|
||||
qDebug() << Q_FUNC_INFO << "- Total sources now:" << m_sources.size();
|
||||
emit ready();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -76,6 +76,7 @@ TomahawkSettings::~TomahawkSettings()
|
||||
s_instance = 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::doInitialSetup()
|
||||
{
|
||||
@@ -236,18 +237,21 @@ TomahawkSettings::setWatchForChanges( bool watch )
|
||||
setValue( "scanner/watchforchanges", watch );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setAcceptedLegalWarning( bool accept )
|
||||
{
|
||||
setValue( "acceptedLegalWarning", accept );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TomahawkSettings::acceptedLegalWarning() const
|
||||
{
|
||||
return value( "acceptedLegalWarning", false ).toBool();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TomahawkSettings::httpEnabled() const
|
||||
{
|
||||
@@ -429,18 +433,21 @@ TomahawkSettings::setPlaylistColumnSizes( const QString& playlistid, const QByte
|
||||
setValue( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ), state );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TomahawkSettings::shuffleState( const QString& playlistid ) const
|
||||
{
|
||||
return value( QString( "ui/playlist/%1/shuffleState" ).arg( playlistid )).toBool();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setShuffleState( const QString& playlistid, bool state)
|
||||
{
|
||||
setValue( QString( "ui/playlist/%1/shuffleState" ).arg( playlistid ), state );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::removePlaylistSettings( const QString& playlistid )
|
||||
{
|
||||
@@ -448,27 +455,30 @@ TomahawkSettings::removePlaylistSettings( const QString& playlistid )
|
||||
remove( QString( "ui/playlist/%1/repeatMode" ).arg( playlistid ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setRepeatMode( const QString& playlistid, PlaylistInterface::RepeatMode mode )
|
||||
TomahawkSettings::setRepeatMode( const QString& playlistid, Tomahawk::PlaylistInterface::RepeatMode mode )
|
||||
{
|
||||
setValue( QString( "ui/playlist/%1/repeatMode" ).arg( playlistid ), (int)mode );
|
||||
}
|
||||
|
||||
PlaylistInterface::RepeatMode
|
||||
|
||||
Tomahawk::PlaylistInterface::RepeatMode
|
||||
TomahawkSettings::repeatMode( const QString& playlistid )
|
||||
{
|
||||
return (PlaylistInterface::RepeatMode)value( QString( "ui/playlist/%1/repeatMode" ).arg( playlistid )).toInt();
|
||||
}
|
||||
|
||||
|
||||
QList<Tomahawk::playlist_ptr>
|
||||
TomahawkSettings::recentlyPlayedPlaylists() const
|
||||
{
|
||||
QStringList playlist_guids = value( "playlists/recentlyPlayed" ).toStringList();
|
||||
|
||||
QList<Tomahawk::playlist_ptr> playlists;
|
||||
QList<playlist_ptr> playlists;
|
||||
foreach( const QString& guid, playlist_guids )
|
||||
{
|
||||
Tomahawk::playlist_ptr pl = Tomahawk::Playlist::load( guid );
|
||||
playlist_ptr pl = Playlist::load( guid );
|
||||
if ( !pl.isNull() )
|
||||
playlists << pl;
|
||||
}
|
||||
@@ -476,6 +486,7 @@ TomahawkSettings::recentlyPlayedPlaylists() const
|
||||
return playlists;
|
||||
}
|
||||
|
||||
|
||||
QStringList
|
||||
TomahawkSettings::recentlyPlayedPlaylistGuids( unsigned int amount ) const
|
||||
{
|
||||
@@ -501,42 +512,49 @@ TomahawkSettings::appendRecentlyPlayedPlaylist( const Tomahawk::playlist_ptr& pl
|
||||
emit recentlyPlayedPlaylistAdded( playlist );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
TomahawkSettings::bookmarkPlaylist() const
|
||||
{
|
||||
return value( "playlists/bookmark", QString() ).toString();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setBookmarkPlaylist( const QString& guid )
|
||||
{
|
||||
setValue( "playlists/bookmark", guid );
|
||||
}
|
||||
|
||||
|
||||
QStringList
|
||||
TomahawkSettings::sipPlugins() const
|
||||
{
|
||||
return value( "sip/allplugins", QStringList() ).toStringList();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setSipPlugins( const QStringList& plugins )
|
||||
{
|
||||
setValue( "sip/allplugins", plugins );
|
||||
}
|
||||
|
||||
|
||||
QStringList
|
||||
TomahawkSettings::enabledSipPlugins() const
|
||||
{
|
||||
return value( "sip/enabledplugins", QStringList() ).toStringList();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setEnabledSipPlugins( const QStringList& list )
|
||||
{
|
||||
setValue( "sip/enabledplugins", list );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::enableSipPlugin( const QString& pluginId )
|
||||
{
|
||||
@@ -545,6 +563,7 @@ TomahawkSettings::enableSipPlugin( const QString& pluginId )
|
||||
setEnabledSipPlugins( list );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::disableSipPlugin( const QString& pluginId )
|
||||
{
|
||||
@@ -553,6 +572,7 @@ TomahawkSettings::disableSipPlugin( const QString& pluginId )
|
||||
setEnabledSipPlugins( list );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::addSipPlugin( const QString& pluginId, bool enable )
|
||||
{
|
||||
@@ -564,6 +584,7 @@ TomahawkSettings::addSipPlugin( const QString& pluginId, bool enable )
|
||||
enableSipPlugin( pluginId );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::removeSipPlugin( const QString& pluginId )
|
||||
{
|
||||
@@ -589,40 +610,47 @@ TomahawkSettings::setExternalAddressMode( ExternalAddressMode externalAddressMod
|
||||
setValue( "network/external-address-mode", externalAddressMode );
|
||||
}
|
||||
|
||||
|
||||
bool TomahawkSettings::preferStaticHostPort() const
|
||||
{
|
||||
return value( "network/prefer-static-host-and-port" ).toBool();
|
||||
}
|
||||
|
||||
|
||||
void TomahawkSettings::setPreferStaticHostPort( bool prefer )
|
||||
{
|
||||
setValue( "network/prefer-static-host-and-port", prefer );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
TomahawkSettings::externalHostname() const
|
||||
{
|
||||
return value( "network/external-hostname" ).toString();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setExternalHostname(const QString& externalHostname)
|
||||
{
|
||||
setValue( "network/external-hostname", externalHostname );
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TomahawkSettings::defaultPort() const
|
||||
{
|
||||
return 50210;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TomahawkSettings::externalPort() const
|
||||
{
|
||||
return value( "network/external-port", 50210 ).toInt();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setExternalPort(int externalPort)
|
||||
{
|
||||
@@ -674,6 +702,7 @@ TomahawkSettings::setLastFmUsername( const QString& username )
|
||||
setValue( "lastfm/username", username );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TomahawkSettings::scrobblingEnabled() const
|
||||
{
|
||||
@@ -743,18 +772,21 @@ TomahawkSettings::setXmppBotPort( const int port )
|
||||
setValue( "xmppBot/port", port );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::addScriptResolver(const QString& resolver)
|
||||
{
|
||||
setValue( "script/resolvers", allScriptResolvers() << resolver );
|
||||
}
|
||||
|
||||
|
||||
QStringList
|
||||
TomahawkSettings::allScriptResolvers() const
|
||||
{
|
||||
return value( "script/resolvers" ).toStringList();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setAllScriptResolvers( const QStringList& resolver )
|
||||
{
|
||||
@@ -768,12 +800,14 @@ TomahawkSettings::enabledScriptResolvers() const
|
||||
return value( "script/loadedresolvers" ).toStringList();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setEnabledScriptResolvers( const QStringList& resolvers )
|
||||
{
|
||||
setValue( "script/loadedresolvers", resolvers );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TomahawkSettings::nowPlayingEnabled() const
|
||||
{
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@@ -47,15 +47,15 @@ namespace Tomahawk
|
||||
typedef QSharedPointer<Source> source_ptr;
|
||||
typedef QSharedPointer<Artist> artist_ptr;
|
||||
typedef QSharedPointer<Album> album_ptr;
|
||||
|
||||
|
||||
typedef QSharedPointer<DynamicControl> dyncontrol_ptr;
|
||||
typedef QSharedPointer<GeneratorInterface> geninterface_ptr;
|
||||
|
||||
|
||||
// let's keep these typesafe, they are different kinds of GUID:
|
||||
typedef QString QID; //query id
|
||||
typedef QString RID; //result id
|
||||
|
||||
|
||||
|
||||
|
||||
enum GeneratorMode {
|
||||
OnDemand = 0,
|
||||
Static
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@@ -41,23 +41,17 @@ SourceInfoWidget::SourceInfoWidget( const Tomahawk::source_ptr& source, QWidget*
|
||||
ui->historyView->overlay()->setEnabled( false );
|
||||
|
||||
m_recentCollectionModel = new CollectionFlatModel( ui->recentCollectionView );
|
||||
m_recentCollectionModel->setStyle( TrackModel::Short );
|
||||
ui->recentCollectionView->setTrackModel( m_recentCollectionModel );
|
||||
m_recentCollectionModel->addFilteredCollection( source->collection(), 250, DatabaseCommand_AllTracks::ModificationTime );
|
||||
|
||||
m_historyModel = new PlaylistModel( ui->historyView );
|
||||
m_historyModel->setStyle( TrackModel::Short );
|
||||
ui->historyView->setPlaylistModel( m_historyModel );
|
||||
m_historyModel->loadHistory( source );
|
||||
|
||||
connect( source.data(), SIGNAL( playbackFinished( Tomahawk::query_ptr ) ), SLOT( onPlaybackFinished( Tomahawk::query_ptr ) ) );
|
||||
|
||||
ui->recentCollectionView->setColumnHidden( TrackModel::Bitrate, true );
|
||||
ui->recentCollectionView->setColumnHidden( TrackModel::Origin, true );
|
||||
ui->recentCollectionView->setColumnHidden( TrackModel::Filesize, true );
|
||||
|
||||
ui->historyView->setColumnHidden( TrackModel::Bitrate, true );
|
||||
ui->historyView->setColumnHidden( TrackModel::Origin, true );
|
||||
ui->historyView->setColumnHidden( TrackModel::Filesize, true );
|
||||
|
||||
m_recentAlbumModel = new AlbumModel( ui->recentAlbumView );
|
||||
ui->recentAlbumView->setAlbumModel( m_recentAlbumModel );
|
||||
m_recentAlbumModel->addFilteredCollection( source->collection(), 20, DatabaseCommand_AllAlbums::ModificationTime );
|
||||
|
@@ -50,19 +50,19 @@ WelcomeWidget::WelcomeWidget( QWidget* parent )
|
||||
ui->playlistWidget->setItemDelegate( new PlaylistDelegate() );
|
||||
ui->playlistWidget->setModel( model );
|
||||
ui->playlistWidget->overlay()->resize( 380, 86 );
|
||||
ui->tracksView->overlay()->setEnabled( false );
|
||||
|
||||
connect( model, SIGNAL( emptinessChanged( bool) ), this, SLOT( updatePlaylists() ) );
|
||||
|
||||
m_tracksModel = new PlaylistModel( ui->tracksView );
|
||||
m_tracksModel->setStyle( TrackModel::Short );
|
||||
ui->tracksView->overlay()->setEnabled( false );
|
||||
ui->tracksView->setPlaylistModel( m_tracksModel );
|
||||
m_tracksModel->loadHistory( Tomahawk::source_ptr(), HISTORY_TRACK_ITEMS );
|
||||
|
||||
m_timer = new QTimer( this );
|
||||
connect( m_timer, SIGNAL( timeout() ), SLOT( checkQueries() ) );
|
||||
|
||||
connect( SourceList::instance(), SIGNAL( ready() ), SLOT( updateRecentTracks() ) );
|
||||
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( onSourceAdded( Tomahawk::source_ptr ) ) );
|
||||
|
||||
connect( ui->playlistWidget, SIGNAL( activated( QModelIndex ) ), SLOT( onPlaylistActivated( QModelIndex ) ) );
|
||||
connect( AudioEngine::instance() ,SIGNAL( playlistChanged( Tomahawk::PlaylistInterface* ) ), this, SLOT( updatePlaylists() ), Qt::QueuedConnection );
|
||||
}
|
||||
@@ -74,6 +74,13 @@ WelcomeWidget::~WelcomeWidget()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WelcomeWidget::updateRecentTracks()
|
||||
{
|
||||
m_tracksModel->loadHistory( Tomahawk::source_ptr(), HISTORY_TRACK_ITEMS );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WelcomeWidget::updatePlaylists()
|
||||
{
|
||||
@@ -100,6 +107,7 @@ WelcomeWidget::updatePlaylists()
|
||||
ui->playlistWidget->overlay()->hide();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WelcomeWidget::onSourceAdded( const Tomahawk::source_ptr& source )
|
||||
{
|
||||
|
@@ -96,6 +96,7 @@ signals:
|
||||
void destroyed( QWidget* widget );
|
||||
|
||||
public slots:
|
||||
void updateRecentTracks();
|
||||
void updatePlaylists();
|
||||
|
||||
private slots:
|
||||
|
Reference in New Issue
Block a user