mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-21 05:11:44 +02:00
Merge remote branch 'origin/master' into dynamic
This commit is contained in:
@@ -23,7 +23,7 @@ PortFwdThread::~PortFwdThread()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "waiting for event loop to finish...";
|
||||
quit();
|
||||
wait( 2500 );
|
||||
wait( 10000 );
|
||||
|
||||
delete m_portfwd;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ PortFwdThread::work()
|
||||
m_portfwd->remove( tryport );
|
||||
}
|
||||
|
||||
for( int r = 0; r < 5; ++r )
|
||||
for( int r = 0; r < 3; ++r )
|
||||
{
|
||||
qDebug() << "Trying to setup portfwd on" << tryport;
|
||||
if( m_portfwd->add( tryport, m_port ) )
|
||||
|
@@ -13,6 +13,7 @@ using namespace Tomahawk;
|
||||
CollectionView::CollectionView( QWidget* parent )
|
||||
: TrackView( parent )
|
||||
{
|
||||
setGuid( "collectionview" );
|
||||
setProxyModel( new CollectionProxyModel( this ) );
|
||||
|
||||
setSortingEnabled( true );
|
||||
|
@@ -2,22 +2,26 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QAbstractItemView>
|
||||
|
||||
#include "query.h"
|
||||
#include "result.h"
|
||||
|
||||
#include "playlist/plitem.h"
|
||||
#include "playlist/trackproxymodel.h"
|
||||
#include "playlist/trackview.h"
|
||||
#include "playlist/trackheader.h"
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
|
||||
#define PLAYING_ICON QString( RESPATH "images/now-playing-speaker.png" )
|
||||
|
||||
|
||||
PlaylistItemDelegate::PlaylistItemDelegate( QAbstractItemView* parent, TrackProxyModel* proxy )
|
||||
PlaylistItemDelegate::PlaylistItemDelegate( TrackView* parent, TrackProxyModel* proxy )
|
||||
: QStyledItemDelegate( (QObject*)parent )
|
||||
, m_view( parent )
|
||||
, m_model( proxy )
|
||||
{
|
||||
m_nowPlayingIcon = QPixmap( PLAYING_ICON );
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +41,7 @@ PlaylistItemDelegate::sizeHint( const QStyleOptionViewItem& option, const QModel
|
||||
|
||||
|
||||
QWidget*
|
||||
PlaylistItemDelegate::createEditor ( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
PlaylistItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -48,9 +52,7 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
|
||||
{
|
||||
PlItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) );
|
||||
if ( !item || item->query().isNull() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( item->query()->results().count() )
|
||||
painter->setOpacity( item->query()->results().at( 0 )->score() );
|
||||
@@ -63,18 +65,21 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
|
||||
painter->setRenderHint( QPainter::Antialiasing );
|
||||
|
||||
{
|
||||
QRect r = option.rect.adjusted( 3, 0, 0, -3 );
|
||||
if ( index.column() == 0 )
|
||||
QRect r = option.rect.adjusted( 3, 0, 0, 0 );
|
||||
if ( m_view->header()->visualIndex( index.column() ) == 0 )
|
||||
{
|
||||
painter->drawPixmap( r.adjusted( 3, 3, 18 - r.width(), 0 ), QPixmap( index.data( Qt::DecorationRole ).toString() ) );
|
||||
r = r.adjusted( 22, 0, 0, 0 );
|
||||
r.adjust( 0, 0, 0, -3 );
|
||||
painter->drawPixmap( r.adjusted( 3, 3, 18 - r.width(), 0 ), m_nowPlayingIcon );
|
||||
r.adjust( 22, 0, 0, 3 );
|
||||
}
|
||||
|
||||
QTextOption to( Qt::AlignVCenter );
|
||||
|
||||
painter->setPen( option.palette.text().color() );
|
||||
painter->drawText( r.adjusted( 0, 2, 0, 0 ), index.data().toString() );
|
||||
painter->drawText( r.adjusted( 0, 1, 0, 0 ), index.data().toString(), to );
|
||||
}
|
||||
|
||||
if ( index.column() == index.model()->columnCount() - 1 )
|
||||
if ( m_view->header()->visualIndex( index.column() ) == m_view->header()->visibleSectionCount() - 1 )
|
||||
{
|
||||
QRect r = QRect( 3, option.rect.y() + 1, m_view->viewport()->width() - 6, option.rect.height() - 2 );
|
||||
painter->setPen( option.palette.highlight().color() );
|
||||
|
@@ -6,13 +6,14 @@
|
||||
#include "dllmacro.h"
|
||||
|
||||
class TrackProxyModel;
|
||||
class TrackView;
|
||||
|
||||
class DLLEXPORT PlaylistItemDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PlaylistItemDelegate( QAbstractItemView* parent = 0, TrackProxyModel* proxy = 0 );
|
||||
PlaylistItemDelegate( TrackView* parent = 0, TrackProxyModel* proxy = 0 );
|
||||
|
||||
void updateRowSize( const QModelIndex& index );
|
||||
|
||||
@@ -27,7 +28,9 @@ protected:
|
||||
|
||||
private:
|
||||
unsigned int m_removalProgress;
|
||||
QAbstractItemView* m_view;
|
||||
QPixmap m_nowPlayingIcon;
|
||||
|
||||
TrackView* m_view;
|
||||
TrackProxyModel* m_model;
|
||||
};
|
||||
|
||||
|
@@ -31,6 +31,8 @@ public:
|
||||
|
||||
virtual bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent );
|
||||
|
||||
Tomahawk::playlist_ptr playlist() const { return m_playlist; }
|
||||
|
||||
void loadPlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||
void loadHistory( const Tomahawk::source_ptr& source, unsigned int amount = 100 );
|
||||
|
||||
|
@@ -4,6 +4,7 @@
|
||||
#include <QKeyEvent>
|
||||
#include <QPainter>
|
||||
|
||||
#include "playlist/playlistmodel.h"
|
||||
#include "playlist/playlistproxymodel.h"
|
||||
#include "widgets/overlaywidget.h"
|
||||
|
||||
@@ -13,6 +14,7 @@ using namespace Tomahawk;
|
||||
PlaylistView::PlaylistView( QWidget* parent )
|
||||
: TrackView( parent )
|
||||
{
|
||||
setGuid( "playlistview" );
|
||||
setProxyModel( new PlaylistProxyModel( this ) );
|
||||
|
||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
@@ -27,8 +29,13 @@ PlaylistView::~PlaylistView()
|
||||
|
||||
|
||||
void
|
||||
PlaylistView::setModel( TrackModel* model )
|
||||
PlaylistView::setModel( PlaylistModel* model )
|
||||
{
|
||||
if ( !model->playlist().isNull() )
|
||||
setGuid( QString( "playlistview/%1" ).arg( model->playlist()->guid() ) );
|
||||
|
||||
m_model = model;
|
||||
|
||||
TrackView::setModel( model );
|
||||
setColumnHidden( 5, true ); // Hide age column per default
|
||||
|
||||
|
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class PlaylistModel;
|
||||
|
||||
class DLLEXPORT PlaylistView : public TrackView
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -15,7 +17,8 @@ public:
|
||||
explicit PlaylistView( QWidget* parent = 0 );
|
||||
~PlaylistView();
|
||||
|
||||
virtual void setModel( TrackModel* model );
|
||||
PlaylistModel* playlistModel() const { return m_model; }
|
||||
virtual void setModel( PlaylistModel* model );
|
||||
|
||||
protected:
|
||||
void keyPressEvent( QKeyEvent* event );
|
||||
@@ -30,6 +33,8 @@ private slots:
|
||||
private:
|
||||
void setupMenus();
|
||||
|
||||
PlaylistModel* m_model;
|
||||
|
||||
QMenu m_itemMenu;
|
||||
|
||||
QAction* m_playItemAction;
|
||||
|
@@ -18,15 +18,15 @@ TrackHeader::TrackHeader( TrackView* parent )
|
||||
, m_hiddenPct( 0.0 )
|
||||
, m_init( false )
|
||||
{
|
||||
setStretchLastSection( false );
|
||||
setStretchLastSection( true );
|
||||
setResizeMode( QHeaderView::Interactive );
|
||||
setMinimumSectionSize( 60 );
|
||||
setDefaultAlignment( Qt::AlignLeft );
|
||||
setMovable( true );
|
||||
// setCascadingSectionResizes( true );
|
||||
|
||||
m_menu->addAction( tr( "Resize columns to fit window" ), this, SLOT( onToggleResizeColumns() ) );
|
||||
m_menu->addSeparator();
|
||||
// m_menu->addAction( tr( "Resize columns to fit window" ), this, SLOT( onToggleResizeColumns() ) );
|
||||
// m_menu->addSeparator();
|
||||
|
||||
connect( this, SIGNAL( sectionResized( int, int, int ) ), SLOT( onSectionResized( int, int, int ) ) );
|
||||
connect( m_sigmap, SIGNAL( mapped( int ) ), SLOT( toggleVisibility( int ) ) );
|
||||
@@ -39,6 +39,13 @@ TrackHeader::~TrackHeader()
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TrackHeader::visibleSectionCount() const
|
||||
{
|
||||
return count() - hiddenSectionCount();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackHeader::onSectionResized( int logicalidx, int oldSize, int newSize )
|
||||
{
|
||||
@@ -83,7 +90,7 @@ TrackHeader::onResized()
|
||||
void
|
||||
TrackHeader::restoreColumnsState()
|
||||
{
|
||||
QList<QVariant> list = TomahawkSettings::instance()->playlistColumnSizes();
|
||||
QList<QVariant> list = TomahawkSettings::instance()->playlistColumnSizes( m_parent->guid() );
|
||||
|
||||
if ( list.count() != count() ) // FIXME: const
|
||||
{
|
||||
@@ -105,7 +112,7 @@ TrackHeader::saveColumnsState()
|
||||
foreach( double w, m_columnWeights )
|
||||
wlist << QVariant( w );
|
||||
|
||||
TomahawkSettings::instance()->setPlaylistColumnSizes( wlist );
|
||||
TomahawkSettings::instance()->setPlaylistColumnSizes( m_parent->guid(), wlist );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -16,6 +16,8 @@ public:
|
||||
explicit TrackHeader( TrackView* parent = 0 );
|
||||
~TrackHeader();
|
||||
|
||||
int visibleSectionCount() const;
|
||||
|
||||
public slots:
|
||||
void onResized();
|
||||
void toggleVisibility( int index );
|
||||
|
@@ -95,9 +95,6 @@ TrackModel::data( const QModelIndex& index, int role ) const
|
||||
|
||||
if ( role == Qt::DecorationRole )
|
||||
{
|
||||
if ( index.column() == 0 && entry->isPlaying() )
|
||||
return QString( RESPATH "images/now-playing-speaker.png" );
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
@@ -57,7 +57,7 @@ TrackView::~TrackView()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
delete m_overlay;
|
||||
delete m_header;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -22,16 +22,18 @@ public:
|
||||
explicit TrackView( QWidget* parent = 0 );
|
||||
~TrackView();
|
||||
|
||||
virtual QString guid() const { return m_guid; }
|
||||
virtual void setGuid( const QString& guid ) { m_guid = guid; }
|
||||
|
||||
virtual void setModel( TrackModel* model );
|
||||
void setProxyModel( TrackProxyModel* model );
|
||||
|
||||
TrackModel* model() const { return m_model; }
|
||||
virtual TrackModel* model() const { return m_model; }
|
||||
TrackProxyModel* proxyModel() const { return m_proxyModel; }
|
||||
PlaylistItemDelegate* delegate() const { return m_delegate; }
|
||||
TrackHeader* header() const { return m_header; }
|
||||
OverlayWidget* overlay() const { return m_overlay; }
|
||||
|
||||
virtual void setModel( TrackModel* model );
|
||||
|
||||
QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
|
||||
void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; }
|
||||
|
||||
@@ -59,6 +61,7 @@ private slots:
|
||||
void onFilterChanged( const QString& filter );
|
||||
|
||||
private:
|
||||
QString m_guid;
|
||||
TrackModel* m_model;
|
||||
TrackProxyModel* m_proxyModel;
|
||||
PlaylistItemDelegate* m_delegate;
|
||||
|
@@ -185,16 +185,16 @@ TomahawkSettings::setMainWindowState( const QByteArray& state )
|
||||
|
||||
|
||||
QList<QVariant>
|
||||
TomahawkSettings::playlistColumnSizes() const
|
||||
TomahawkSettings::playlistColumnSizes( const QString& playlistid ) const
|
||||
{
|
||||
return value( "ui/playlist/columnSize" ).toList();
|
||||
return value( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ) ).toList();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkSettings::setPlaylistColumnSizes( const QList<QVariant>& cols )
|
||||
TomahawkSettings::setPlaylistColumnSizes( const QString& playlistid, const QList<QVariant>& cols )
|
||||
{
|
||||
setValue( "ui/playlist/columnSize", cols );
|
||||
setValue( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ), cols );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -32,8 +32,8 @@ public:
|
||||
void setMainWindowState( const QByteArray& state );
|
||||
|
||||
/// Playlist stuff
|
||||
QList<QVariant> playlistColumnSizes() const;
|
||||
void setPlaylistColumnSizes( const QList<QVariant>& cols );
|
||||
QList<QVariant> playlistColumnSizes( const QString& playlistid ) const;
|
||||
void setPlaylistColumnSizes( const QString& playlistid, const QList<QVariant>& cols );
|
||||
|
||||
QList<Tomahawk::playlist_ptr> recentlyPlayedPlaylists() const;
|
||||
void appendRecentlyPlayedPlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||
|
@@ -399,7 +399,7 @@ TomahawkApp::setupSIP()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
if( !arguments().contains( "--nojabber" ) )
|
||||
if( !arguments().contains( "--nosip" ) )
|
||||
{
|
||||
m_xmppBot = new XMPPBot( this );
|
||||
|
||||
|
Reference in New Issue
Block a user