1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 00:09:47 +01:00

Merge branch 'master' into serventfixing

This commit is contained in:
Jeff Mitchell 2011-11-20 13:14:06 -05:00
commit 52df44c40c
22 changed files with 3619 additions and 19 deletions

View File

@ -108,7 +108,7 @@ macro_optional_find_package(LibAttica)
macro_log_feature(LIBATTICA_FOUND "libattica" "Provides support for automatic fetching and managing of resolvers from the tomahawk website" "https://projects.kde.org/projects/kdesupport/attica" FALSE "" "")
macro_optional_find_package(QuaZip)
macro_log_feature(QuaZip_FOUND "QuaZip" "Provides support for extracting downloaded resolvers autmatically. Will build internal copy instead." "http://quazip.sourceforge.net/" FALSE "" "")
macro_log_feature(QuaZip_FOUND "QuaZip" "Provides support for extracting downloaded resolvers automatically." "http://quazip.sourceforge.net/" FALSE "" "")
IF( NOT QuaZip_FOUND )
add_subdirectory( ${CMAKE_SOURCE_DIR}/src/libtomahawk/thirdparty/quazip )
@ -116,6 +116,7 @@ IF( NOT QuaZip_FOUND )
SET( QuaZip_LIBRARY quazip )
SET( QuaZip_LIBRARIES ${QuaZip_LIBRARY} )
SET( QuaZip_FOUND true )
macro_log_feature(QuaZip_FOUND "QuaZip" "Provides support for extracting downloaded resolvers automatically. Building internal copy" "http://quazip.sourceforge.net/" FALSE "" "")
# copy headers to build/quazip so we can use proper includes inside the code
FILE( COPY ${CMAKE_SOURCE_DIR}/src/libtomahawk/thirdparty/quazip/quazip/ DESTINATION ${CMAKE_BINARY_DIR}/libtomahawk/thirdparty/quazip )

3396
lang/tomahawk_sv.ts Normal file

File diff suppressed because it is too large Load Diff

View File

@ -238,6 +238,7 @@ set( libGuiHeaders
widgets/playlisttypeselectordlg.h
widgets/welcomewidget.h
widgets/whatshotwidget.h
widgets/whatshotwidget_p.h
widgets/RecentlyPlayedPlaylistsModel.h
widgets/RecentPlaylistsModel.h
widgets/OverlayButton.h

View File

@ -46,7 +46,7 @@ ActionCollection::initActions()
m_actionCollection[ "latchOff" ] = latchOff;
bool isPublic = TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening;
QAction *privacyToggle = new QAction( tr( QString( isPublic ? "&Listen Privately" : "&Listen Publicly" ).toAscii().constData() ), this );
QAction *privacyToggle = new QAction( ( isPublic ? tr( "&Listen Privately" ) : tr( "&Listen Publicly" ) ), this );
privacyToggle->setIcon( QIcon( RESPATH "images/private-listening.png" ) );
privacyToggle->setIconVisibleInMenu( isPublic );
m_actionCollection[ "togglePrivacy" ] = privacyToggle;

View File

@ -418,7 +418,7 @@ AudioEngine::togglePrivateListeningMode()
#ifndef TOMAHAWK_HEADLESS
QAction *privacyToggle = ActionCollection::instance()->getAction( "togglePrivacy" );
bool isPublic = TomahawkSettings::instance()->privateListeningMode() == TomahawkSettings::PublicListening;
privacyToggle->setText( tr( QString( isPublic ? "&Listen Privately" : "&Listen Publicly" ).toAscii().constData() ) );
privacyToggle->setText( ( isPublic ? tr( "&Listen Privately" ) : tr( "&Listen Publicly" ) ) );
privacyToggle->setIconVisibleInMenu( isPublic );
#endif
emit privacyModeChanged();

View File

@ -68,7 +68,8 @@ DropJob::mimeTypes()
<< "application/tomahawk.metadata.artist"
<< "application/tomahawk.metadata.album"
<< "application/tomahawk.mixed"
<< "text/plain";
<< "text/plain"
<< "text/uri-list";
return mimeTypes;
}
@ -77,6 +78,7 @@ bool
DropJob::acceptsMimeData( const QMimeData* data, DropJob::DropTypes acceptedType, DropJob::DropAction acceptedAction )
{
Q_UNUSED( acceptedAction );
if ( data->hasFormat( "application/tomahawk.query.list" )
|| data->hasFormat( "application/tomahawk.plentry.list" )
|| data->hasFormat( "application/tomahawk.result.list" )
@ -90,7 +92,9 @@ DropJob::acceptsMimeData( const QMimeData* data, DropJob::DropTypes acceptedType
// check plain text url types
if ( !data->hasFormat( "text/plain" ) )
return false;
if ( !data->hasFormat( "text/uri-list" ) )
return false;
const QString url = data->data( "text/plain" );
@ -99,6 +103,9 @@ DropJob::acceptsMimeData( const QMimeData* data, DropJob::DropTypes acceptedType
if( url.contains( "xspf" ) )
return true;
if( data->data( "text/uri-list" ).contains( "xspf" ) )
return true;
// Not the most elegant
if ( url.contains( "spotify" ) && url.contains( "playlist" ) && s_canParseSpotifyPlaylists )
return true;
@ -151,7 +158,7 @@ DropJob::isDropType( DropJob::DropType desired, const QMimeData* data )
const QString url = data->data( "text/plain" );
if ( desired == Playlist )
{
if( url.contains( "xspf" ) )
if( url.contains( "xspf" ) || data->data( "text/uri-list").contains( "xspf" ) )
return true;
// Not the most elegant
@ -222,10 +229,15 @@ DropJob::parseMimeData( const QMimeData *data )
results = tracksFromArtistMetaData( data );
else if ( data->hasFormat( "application/tomahawk.mixed" ) )
tracksFromMixedData( data );
else if ( data->hasFormat( "text/plain" ) )
else if ( data->hasFormat( "text/plain" ) && !data->data( "text/plain" ).isEmpty() )
{
const QString plainData = QString::fromUtf8( data->data( "text/plain" ) );
handleAllUrls( plainData );
}else if ( data->hasFormat( "text/uri-list" ) )
{
const QString plainData = QString::fromUtf8( data->data( "text/uri-list" ).trimmed() );
handleAllUrls( plainData );
}
m_resultList.append( results );
@ -411,7 +423,7 @@ void
DropJob::handleXspfs( const QString& fileUrls )
{
tDebug() << Q_FUNC_INFO << "Got xspf playlist!!" << fileUrls;
bool error = false;
QStringList urls = fileUrls.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
if ( dropAction() == Default )
@ -419,16 +431,37 @@ DropJob::handleXspfs( const QString& fileUrls )
foreach ( const QString& url, urls )
{
XSPFLoader* l;
QFile xspfFile( QUrl::fromUserInput( url ).toLocalFile() );
if ( xspfFile.exists() )
{
XSPFLoader* l = new XSPFLoader( true, this );
l = new XSPFLoader( dropAction() == Create, this );
tDebug( LOGINFO ) << "Loading local xspf " << xspfFile.fileName();
l->load( xspfFile );
}
else if( QUrl( url ).isValid() )
{
l = new XSPFLoader( dropAction() == Create, this );
tDebug( LOGINFO ) << "Loading remote xspf " << url;
l->load( QUrl( url ) );
}
else
tLog( LOGINFO ) << "Error Loading local xspf " << xspfFile.fileName();
{
error = true;
tLog() << "Failed to load or parse dropped XSPF";
}
if ( dropAction() == Append && !error )
{
qDebug() << Q_FUNC_INFO << "Trying to append xspf";
connect( l, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ), this, SLOT( onTracksAdded( QList< Tomahawk::query_ptr > ) ) );
}
}
}

View File

@ -81,6 +81,7 @@ JobStatusModel::data( const QModelIndex& index, int role ) const
{
case Qt::DecorationRole:
return item->icon();
case Qt::ToolTipRole:
case Qt::DisplayRole:
{
if ( m_collapseCount.contains( item->type() ) )

View File

@ -369,6 +369,9 @@ ArtistView::onMenuTriggered( int action )
bool
ArtistView::jumpToCurrentTrack()
{
if ( !m_proxyModel )
return false;
scrollTo( m_proxyModel->currentIndex(), QAbstractItemView::PositionAtCenter );
return true;
}

View File

@ -43,6 +43,15 @@ TreeProxyModel::TreeProxyModel( QObject* parent )
setSourceTreeModel( 0 );
}
QPersistentModelIndex
TreeProxyModel::currentIndex() const
{
if ( !m_model )
return QPersistentModelIndex();
return mapFromSource( m_model->currentItem() );
}
void
TreeProxyModel::setSourceModel( QAbstractItemModel* sourceModel )

View File

@ -39,7 +39,7 @@ public:
virtual void setSourceTreeModel( TreeModel* sourceModel );
virtual void setSourceModel( QAbstractItemModel* sourceModel );
virtual QPersistentModelIndex currentIndex() const { return mapFromSource( m_model->currentItem() ); }
virtual QPersistentModelIndex currentIndex() const;
virtual void setCurrentIndex( const QModelIndex& index ) { m_model->setCurrentItem( mapToSource( index ) ); }
virtual QList<Tomahawk::query_ptr> tracks() { Q_ASSERT( FALSE ); QList<Tomahawk::query_ptr> queries; return queries; }

View File

@ -67,6 +67,10 @@ public:
virtual void reset() {}
// Some playlist interfaces can wrap other interfaces. When checking for top-level
// equality (say, to compare the currently playing interface) this might be needed
virtual bool hasChildInterface( PlaylistInterface* ) { return false; }
QObject* object() const { return m_object; }
static void dontDelete( Tomahawk::PlaylistInterface* obj )

View File

@ -383,7 +383,7 @@ SipHandler::connectPlugin( bool startup, const QString &pluginId )
int result = QMessageBox::question(
//TomahawkApp::instance()->mainWindow(),
0, tr( "Legal Warning" ),
tr( "By pressing OK below, you agree that your use of Tomahawk will be in accordance with any applicable laws, including copyright and intellectual property laws, in effect in your country of residence, and indemnify the Tomahawk developers and project from liability should you choose to break those laws.\n\nFor more information, please see http://gettomahawk.com/legal" ),
tr( "By pressing I Agree below, you agree that your use of Tomahawk will be in accordance with any applicable laws, including copyright and intellectual property laws, in effect in your country of residence, and indemnify the Tomahawk developers and project from liability should you choose to break those laws.\n\nFor more information, please see http://gettomahawk.com/legal" ),
tr( "I Do Not Agree" ), tr( "I Agree" )
);
if ( result != 1 )

View File

@ -235,9 +235,16 @@ XSPFLoader::gotBody()
m_entries );
// 10 minute default---for now, no way to change it
connect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( playlistCreated() ) );
new Tomahawk::XspfUpdater( m_playlist, 6000000, m_autoUpdate, m_url.toString() );
deleteLater();
emit ok( m_playlist );
}
else{
if( !m_entries.isEmpty() )
emit tracks( m_entries );
}
emit ok( m_playlist );
deleteLater();
}

View File

@ -51,6 +51,8 @@ public:
signals:
void error( XSPFLoader::XSPFErrorCode error );
void ok( const Tomahawk::playlist_ptr& );
void track( const Tomahawk::query_ptr& track );
void tracks( const QList< Tomahawk::query_ptr > tracks );
public slots:
void load( const QUrl& url );

View File

@ -818,6 +818,8 @@ ViewManager::pageForInterface( Tomahawk::PlaylistInterface* interface ) const
ViewPage* page = m_pageHistory.at( i );
if ( page->playlistInterface() == interface )
return page;
if ( page->playlistInterface() && page->playlistInterface()->hasChildInterface( interface ) )
return page;
}
return 0;

View File

@ -64,6 +64,12 @@ public:
virtual QList< Tomahawk::query_ptr > tracks() { return QList< Tomahawk::query_ptr >(); }
virtual int unfilteredTrackCount() const { return 0; }
virtual bool hasChildInterface( PlaylistInterface* other )
{
return ( m_w->ui->albums->playlistInterface() == other ) ||
( m_w->ui->relatedArtists->playlistInterface() == other ) ||
( m_w->ui->topHits->playlistInterface() == other );
}
public slots:
virtual void setRepeatMode( RepeatMode mode )
{

View File

@ -99,6 +99,19 @@ WelcomeWidget::~WelcomeWidget()
delete ui;
}
PlaylistInterface*
WelcomeWidget::playlistInterface() const
{
return ui->tracksView->playlistInterface();
}
bool
WelcomeWidget::jumpToCurrentTrack()
{
return ui->tracksView->jumpToCurrentTrack();
}
bool
WelcomeWidget::isBeingPlayed() const
{

View File

@ -84,7 +84,7 @@ public:
~WelcomeWidget();
virtual QWidget* widget() { return this; }
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
virtual Tomahawk::PlaylistInterface* playlistInterface() const;
virtual QString title() const { return tr( "Welcome to Tomahawk" ); }
virtual QString description() const { return QString(); }
@ -92,7 +92,7 @@ public:
virtual bool showStatsBar() const { return false; }
virtual bool showInfoBar() const { return false; }
virtual bool jumpToCurrentTrack() { return false; }
virtual bool jumpToCurrentTrack();
virtual bool isBeingPlayed() const;
protected:

View File

@ -18,6 +18,7 @@
*/
#include "whatshotwidget.h"
#include "whatshotwidget_p.h"
#include "ui_whatshotwidget.h"
#include <QtGui/QPainter>
@ -50,6 +51,7 @@ static QString s_whatsHotIdentifier = QString( "WhatsHotWidget" );
WhatsHotWidget::WhatsHotWidget( QWidget* parent )
: QWidget( parent )
, ui( new Ui::WhatsHotWidget )
, m_playlistInterface( 0 )
, m_sortedProxy( 0 )
{
ui->setupUi( this );
@ -90,6 +92,8 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent )
ui->artistsViewLeft->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->artistsViewLeft->header()->setVisible( false );
m_playlistInterface = new ChartsPlaylistInterface( this );
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
@ -102,9 +106,16 @@ WhatsHotWidget::WhatsHotWidget( QWidget* parent )
WhatsHotWidget::~WhatsHotWidget()
{
delete m_playlistInterface;
delete ui;
}
PlaylistInterface*
WhatsHotWidget::playlistInterface() const
{
return m_playlistInterface;
}
bool
WhatsHotWidget::isBeingPlayed() const

View File

@ -31,6 +31,7 @@
#include "dllmacro.h"
class ChartsPlaylistInterface;
class QSortFilterProxyModel;
class QStandardItemModel;
class QStandardItem;
@ -58,7 +59,7 @@ public:
~WhatsHotWidget();
virtual QWidget* widget() { return this; }
virtual Tomahawk::PlaylistInterface* playlistInterface() const { return 0; }
virtual Tomahawk::PlaylistInterface* playlistInterface() const;
virtual QString title() const { return tr( "Charts" ); }
virtual QString description() const { return QString(); }
@ -90,6 +91,7 @@ private:
QStandardItem* parseNode( QStandardItem* parentItem, const QString &label, const QVariant &data );
Ui::WhatsHotWidget *ui;
ChartsPlaylistInterface* m_playlistInterface;
QStandardItemModel* m_crumbModelLeft;
QSortFilterProxyModel* m_sortedProxy;
@ -101,6 +103,8 @@ private:
QString m_queueItemToShow;
QSet< QString > m_queuedFetches;
QTimer* m_timer;
friend class ChartsPlaylistInterface;
};
#endif // WHATSHOTWIDGET_H

View File

@ -0,0 +1,107 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2011, Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WHATSHOTWIDGET_P_H
#define WHATSHOTWIDGET_P_H
#include "whatshotwidget.h"
#include "playlistinterface.h"
#include "ui_whatshotwidget.h"
#include "treeproxymodel.h"
#include "playlistview.h"
#include "result.h"
#include <QObject>
class ChartsPlaylistInterface : public QObject, public Tomahawk::PlaylistInterface
{
Q_OBJECT
public:
explicit ChartsPlaylistInterface( WhatsHotWidget* w )
: PlaylistInterface( this )
, m_w( w )
{
connect( m_w->ui->tracksViewLeft->proxyModel(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
SLOT( anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
connect( m_w->ui->artistsViewLeft->proxyModel(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
SLOT( anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
connect( m_w->ui->tracksViewLeft->proxyModel(), SIGNAL( shuffleModeChanged( bool ) ),
SLOT( anyShuffleChanged( bool ) ) );
connect( m_w->ui->artistsViewLeft->proxyModel(), SIGNAL( shuffleModeChanged( bool ) ),
SLOT( anyShuffleChanged( bool ) ) );
}
virtual ~ChartsPlaylistInterface() {}
// Any one is fine, we keep them all synched
virtual RepeatMode repeatMode() const { return m_w->ui->tracksViewLeft->proxyModel()->repeatMode(); }
virtual bool shuffled() const { return m_w->ui->tracksViewLeft->proxyModel()->shuffled(); }
// Do nothing
virtual Tomahawk::result_ptr currentItem() const { return Tomahawk::result_ptr(); }
virtual Tomahawk::result_ptr siblingItem( int ) { return Tomahawk::result_ptr(); }
virtual int trackCount() const { return 0; }
virtual QList< Tomahawk::query_ptr > tracks() { return QList< Tomahawk::query_ptr >(); }
virtual int unfilteredTrackCount() const { return 0; }
virtual bool hasChildInterface( PlaylistInterface* other )
{
return m_w->ui->tracksViewLeft->playlistInterface() == other ||
m_w->ui->artistsViewLeft->playlistInterface() == other;
}
public slots:
virtual void setRepeatMode( RepeatMode mode )
{
m_w->ui->tracksViewLeft->proxyModel()->setRepeatMode( mode );
m_w->ui->artistsViewLeft->proxyModel()->setRepeatMode( mode );
}
virtual void setShuffled( bool enabled )
{
m_w->ui->tracksViewLeft->proxyModel()->setShuffled( enabled );
m_w->ui->artistsViewLeft->proxyModel()->setShuffled( enabled );
}
signals:
void repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode );
void shuffleModeChanged( bool enabled );
void trackCountChanged( unsigned int tracks );
void sourceTrackCountChanged( unsigned int tracks );
void nextTrackReady();
private slots:
void anyRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode mode )
{
emit repeatModeChanged( mode );
}
void anyShuffleChanged( bool enabled )
{
emit shuffleModeChanged( enabled );
}
private:
WhatsHotWidget* m_w;
};
#endif

View File

@ -144,8 +144,8 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
type == SourcesModel::Station ||
type == SourcesModel::TemporaryPage ||
type == SourcesModel::GenericPage );
if ( playable && item->isBeingPlayed() )
const bool playing = ( AudioEngine::instance()->isPlaying() || AudioEngine::instance()->isPaused() );
if ( playable && playing && item->isBeingPlayed() )
{
const int iconW = o3.rect.height() - 4;
QRect iconRect = QRect( option.rect.x() - iconW - 4, option.rect.y() + 2, iconW, iconW );