1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-22 13:43:11 +02:00
This commit is contained in:
hansschmucker
2014-11-13 15:58:19 +01:00
64 changed files with 4996 additions and 257 deletions

View File

@@ -108,7 +108,7 @@ ActionCollection::initActions()
connect( m_actionCollection[ "nextTrack" ], SIGNAL( triggered() ), ae, SLOT( next() ), Qt::UniqueConnection );
// main menu actions
m_actionCollection[ "loadXSPF" ] = new QAction( tr( "Import Playlist..." ), this );
m_actionCollection[ "importPlaylist" ] = new QAction( tr( "Import Playlist..." ), this );
m_actionCollection[ "updateCollection" ] = new QAction( tr( "U&pdate Collection" ), this );
m_actionCollection[ "rescanCollection" ] = new QAction( tr( "Fully &Rescan Collection" ), this );
m_actionCollection[ "showOfflineSources" ] = new QAction( tr( "Show Offline Friends" ), this );
@@ -163,7 +163,7 @@ ActionCollection::createMenuBar( QWidget *parent )
controlsMenu->addAction( m_actionCollection[ "togglePrivacy" ] );
controlsMenu->addAction( m_actionCollection[ "showOfflineSources" ] );
controlsMenu->addSeparator();
controlsMenu->addAction( m_actionCollection[ "loadXSPF" ] );
controlsMenu->addAction( m_actionCollection[ "importPlaylist" ] );
controlsMenu->addAction( m_actionCollection[ "updateCollection" ] );
controlsMenu->addAction( m_actionCollection[ "rescanCollection" ] );
controlsMenu->addSeparator();
@@ -226,7 +226,7 @@ ActionCollection::createMenuBar( QWidget *parent )
QMenu*
ActionCollection::createCompactMenu( QWidget *parent )
ActionCollection::createCompactMenu( QWidget* parent )
{
QMenu* compactMenu = new QMenu( tr( "Main Menu" ), parent );
compactMenu->setFont( TomahawkUtils::systemFont() );
@@ -238,7 +238,7 @@ ActionCollection::createCompactMenu( QWidget *parent )
compactMenu->addAction( m_actionCollection[ "togglePrivacy" ] );
compactMenu->addAction( m_actionCollection[ "showOfflineSources" ] );
compactMenu->addSeparator();
compactMenu->addAction( m_actionCollection[ "loadXSPF" ] );
compactMenu->addAction( m_actionCollection[ "importPlaylist" ] );
compactMenu->addAction( m_actionCollection[ "updateCollection" ] );
compactMenu->addAction( m_actionCollection[ "rescanCollection" ] );
compactMenu->addSeparator();

View File

@@ -39,7 +39,7 @@ public:
static ActionCollection* instance();
ActionCollection( QObject *parent );
ActionCollection( QObject* parent );
~ActionCollection();
void initActions();
@@ -47,7 +47,7 @@ public:
/**
* This method returns a main menu bar, suitable for Windows, Mac and X11.
*/
QMenuBar *createMenuBar( QWidget *parent );
QMenuBar* createMenuBar( QWidget* parent );
/**
* Returns a QMenu with all the entries that would normally be in the main menu,
@@ -55,7 +55,7 @@ public:
* and fairly little sense on Unity and other X11 desktop configurations which pull
* out the menu bar from the window.
*/
QMenu *createCompactMenu( QWidget *parent );
QMenu* createCompactMenu( QWidget* parent );
QAction* getAction( const QString& name );
QList< QAction* > getAction( ActionDestination category );

View File

@@ -1545,19 +1545,19 @@ TomahawkSettings::updateIndex()
QString
TomahawkSettings::importXspfPath() const
TomahawkSettings::importPlaylistPath() const
{
if ( contains( "importXspfPath" ) )
return value( "importXspfPath" ).toString();
if ( contains( "importPlaylistPath" ) )
return value( "importPlaylistPath" ).toString();
else
return QDir::homePath();
}
void
TomahawkSettings::setImportXspfPath( const QString& path )
TomahawkSettings::setImportPlaylistPath( const QString& path )
{
setValue( "importXspfPath", path );
setValue( "importPlaylistPath", path );
}

View File

@@ -216,8 +216,8 @@ public:
PrivateListeningMode privateListeningMode() const;
void setPrivateListeningMode( PrivateListeningMode mode );
void setImportXspfPath( const QString& path );
QString importXspfPath() const;
void setImportPlaylistPath( const QString& path );
QString importPlaylistPath() const;
Tomahawk::SerializedUpdaters playlistUpdaters() const;
void setPlaylistUpdaters( const Tomahawk::SerializedUpdaters& updaters );

View File

@@ -173,6 +173,21 @@ AudioOutput::setCurrentSource( QIODevice* stream )
}
int readCallback ( void* data, const char* cookie, int64_t* dts, int64_t* pts, unsigned* flags, size_t* bufferSize, void** buffer )
{
MediaStream* mediaStream = static_cast< MediaStream * >( data );
return mediaStream->readCallback( cookie, dts, pts, flags, bufferSize, buffer );
}
int
readDoneCallback ( void *data, const char *cookie, size_t bufferSize, void *buffer )
{
MediaStream* mediaStream = static_cast< MediaStream * >( data );
return mediaStream->readDoneCallback( cookie, bufferSize, buffer );
}
void
AudioOutput::setCurrentSource( MediaStream* stream )
{
@@ -248,9 +263,9 @@ AudioOutput::setCurrentSource( MediaStream* stream )
libvlc_media_add_option_flag(m_vlcMedia, "imem-cat=4", libvlc_media_option_trusted);
const char* imemData = QString( "imem-data=%1" ).arg( (uintptr_t)stream ).toLatin1().constData();
libvlc_media_add_option_flag(m_vlcMedia, imemData, libvlc_media_option_trusted);
const char* imemGet = QString( "imem-get=%1" ).arg( (uintptr_t)&MediaStream::readCallback ).toLatin1().constData();
const char* imemGet = QString( "imem-get=%1" ).arg( (uintptr_t)&readCallback ).toLatin1().constData();
libvlc_media_add_option_flag(m_vlcMedia, imemGet, libvlc_media_option_trusted);
const char* imemRelease = QString( "imem-release=%1" ).arg( (uintptr_t)&MediaStream::readDoneCallback ).toLatin1().constData();
const char* imemRelease = QString( "imem-release=%1" ).arg( (uintptr_t)&readDoneCallback ).toLatin1().constData();
libvlc_media_add_option_flag(m_vlcMedia, imemRelease, libvlc_media_option_trusted);
const char* imemSeek = QString( "imem-seek=%1" ).arg( (uintptr_t)&MediaStream::seekCallback ).toLatin1().constData();
libvlc_media_add_option_flag(m_vlcMedia, imemSeek, libvlc_media_option_trusted);

View File

@@ -98,38 +98,43 @@ MediaStream::bufferingFinished()
int
MediaStream::readCallback ( void* data, const char* cookie, int64_t* dts, int64_t* pts, unsigned* flags, size_t* bufferSize, void** buffer )
MediaStream::readCallback ( const char* cookie, int64_t* dts, int64_t* pts, unsigned* flags, size_t* bufferSize, void** buffer )
{
Q_UNUSED(cookie);
Q_UNUSED(dts);
Q_UNUSED(pts);
Q_UNUSED(flags);
MediaStream* that = static_cast < MediaStream * > ( data );
qint64 bufsize = 0;
*bufferSize = 0;
if ( that->m_eos == true ) {
if ( m_eos == true )
{
return -1;
}
if ( that->m_type == Stream ) {
bufsize = that->needData(buffer);
if ( m_type == Stream )
{
bufsize = needData( buffer );
}
else if ( that->m_type == IODevice ) {
bufsize = that->m_ioDevice->read( that->m_buffer, BLOCK_SIZE );
*buffer = that->m_buffer;
else if ( m_type == IODevice )
{
bufsize = m_ioDevice->read( m_buffer, BLOCK_SIZE );
*buffer = m_buffer;
}
if ( bufsize > 0 ) {
that->m_started = true;
if ( bufsize > 0 )
{
m_started = true;
}
if ( that->m_type == IODevice && bufsize == 0 && that->m_started && that->m_bufferingFinished == true ) {
that->m_eos = true;
if ( m_type == IODevice && bufsize == 0 && m_started && m_bufferingFinished == true )
{
m_eos = true;
return -1;
}
if ( bufsize < 0 ) {
that->m_eos = true;
if ( bufsize < 0 )
{
m_eos = true;
return -1;
}
@@ -139,14 +144,12 @@ MediaStream::readCallback ( void* data, const char* cookie, int64_t* dts, int64_
int
MediaStream::readDoneCallback ( void *data, const char *cookie, size_t bufferSize, void *buffer )
MediaStream::readDoneCallback ( const char *cookie, size_t bufferSize, void *buffer )
{
Q_UNUSED(cookie);
Q_UNUSED(bufferSize);
MediaStream* that = static_cast < MediaStream * > ( data );
if ( ( that->m_type == Stream ) && buffer != 0 && bufferSize > 0 ) {
if ( ( m_type == Stream ) && buffer != nullptr && bufferSize > 0 ) {
delete static_cast< char* >( buffer );
}

View File

@@ -54,8 +54,8 @@ public:
virtual void seekStream( qint64 offset ) { (void)offset; }
virtual qint64 needData ( void** buffer ) { (void)buffer; return 0; }
static int readCallback ( void* data, const char* cookie, int64_t* dts, int64_t* pts, unsigned* flags, size_t* bufferSize, void** buffer );
static int readDoneCallback ( void *data, const char *cookie, size_t bufferSize, void *buffer );
int readCallback( const char* cookie, int64_t* dts, int64_t* pts, unsigned* flags, size_t* bufferSize, void** buffer );
int readDoneCallback ( const char *cookie, size_t bufferSize, void *buffer );
static int seekCallback ( void *data, const uint64_t pos );
public slots:

View File

@@ -74,15 +74,13 @@ QNR_IODeviceStream::QNR_IODeviceStream( const QSharedPointer<QNetworkReply>& rep
QNR_IODeviceStream::~QNR_IODeviceStream()
{
tDebug() << Q_FUNC_INFO;
}
void
QNR_IODeviceStream::seekStream( qint64 offset )
{
tDebug() << Q_FUNC_INFO;
QMutexLocker locker( &m_mutex );
m_pos = offset;
}
@@ -90,6 +88,7 @@ QNR_IODeviceStream::seekStream( qint64 offset )
qint64
QNR_IODeviceStream::needData ( void** buffer )
{
QMutexLocker locker( &m_mutex );
QByteArray data = m_data.mid( m_pos, BLOCK_SIZE );
m_pos += data.size();
if ( ( data.size() == 0 ) && m_networkReply->atEnd() && m_networkReply->isFinished() )
@@ -101,13 +100,13 @@ QNR_IODeviceStream::needData ( void** buffer )
*buffer = new char[data.size()];
memcpy(*buffer, data.data(), data.size());
// tDebug() << Q_FUNC_INFO << " Returning buffer with size " << data.size();
return data.size();
}
void
QNR_IODeviceStream::readyRead()
{
QMutexLocker locker( &m_mutex );
m_data += m_networkReply->readAll();
}

View File

@@ -26,6 +26,7 @@
#include "DllMacro.h"
#include <QByteArray>
#include <QMutex>
#include <QNetworkReply>
#include <QSharedPointer>
@@ -52,6 +53,7 @@ private slots:
void readyRead();
private:
QMutex m_mutex;
QByteArray m_data;
QSharedPointer<QNetworkReply> m_networkReply;
QTimer* m_timer;

View File

@@ -384,15 +384,8 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T
const unsigned int albumpos2 = t2->albumpos();
const unsigned int discnumber1 = t1->discnumber();
const unsigned int discnumber2 = t2->discnumber();
qint64 id1 = 0, id2 = 0;
// This makes it a stable sorter and prevents items from randomly jumping about.
// FIXME: This always true.
if ( id1 == id2 )
{
id1 = (qint64)&q1;
id2 = (qint64)&q2;
}
const qint64 id1 = (qint64)&q1;
const qint64 id2 = (qint64)&q2;
if ( column == PlayableModel::Artist ) // sort by artist
{
@@ -566,6 +559,18 @@ PlayableProxyModel::lessThan( int column, const Tomahawk::query_ptr& q1, const T
}
bool
PlayableProxyModel::lessThan( const Tomahawk::album_ptr& album1, const Tomahawk::album_ptr& album2 ) const
{
if ( album1->artist() == album2->artist() )
{
return QString::localeAwareCompare( album1->sortname(), album2->sortname() ) < 0;
}
return QString::localeAwareCompare( album1->artist()->sortname(), album2->artist()->sortname() ) < 0;
}
bool
PlayableProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right ) const
{
@@ -581,6 +586,10 @@ PlayableProxyModel::lessThan( const QModelIndex& left, const QModelIndex& right
{
return lessThan( left.column(), p1->query(), p2->query() );
}
if ( p1->album() && p2->album() )
{
return lessThan( p1->album(), p2->album() );
}
return QString::localeAwareCompare( sourceModel()->data( left ).toString(), sourceModel()->data( right ).toString() ) < 0;
}

View File

@@ -135,7 +135,9 @@ private:
bool nameFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent ) const;
bool dupeFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const;
bool visibilityFilterAcceptsRow( int sourceRow, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const;
bool lessThan( int column, const Tomahawk::query_ptr& left, const Tomahawk::query_ptr& right ) const;
bool lessThan( const Tomahawk::album_ptr& album1, const Tomahawk::album_ptr& album2 ) const;
QPointer<PlayableModel> m_model;

View File

@@ -172,6 +172,7 @@ RecentlyPlayedModel::onPlaybackFinished( const Tomahawk::track_ptr& track, const
void
RecentlyPlayedModel::onTracksLoaded( QList<Tomahawk::track_ptr> tracks, QList<Tomahawk::PlaybackLog> logs )
{
finishLoading();
for ( int i = 0; i < tracks.count(); i++ )
{
onPlaybackFinished( tracks.at( i ), logs.at( i ) );

View File

@@ -216,8 +216,7 @@ TreeModel::addTracks( const album_ptr& album, const QModelIndex& parent, bool au
connect( album.data(), SIGNAL( tracksAdded( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ),
SLOT( onTracksFound( QList<Tomahawk::query_ptr>, Tomahawk::ModelMode, Tomahawk::collection_ptr ) ) );
if ( !album->tracks( m_mode, m_collection ).isEmpty() )
onTracksAdded( album->tracks( m_mode, m_collection ), parent );
onTracksAdded( album->tracks( m_mode, m_collection ), parent );
}
@@ -305,6 +304,8 @@ TreeModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const QModel
QPair< int, int > crows;
int c = rowCount( parent );
removeRows( 0, c, parent );
crows.first = c;
crows.second = c + tracks.count() - 1;

View File

@@ -111,7 +111,7 @@ M3uLoader::parseLine( const QString& line, const QFile& file )
{
QFileInfo tmpFile( QUrl::fromUserInput( QString( line.simplified() ) ).toLocalFile() );
if( tmpFile.exists() )
if ( tmpFile.exists() )
{
getTags( tmpFile );
}
@@ -190,6 +190,7 @@ M3uLoader::parseM3u( const QString& fileLink )
}
else
emit tracks( m_tracks );
m_tracks.clear();
}

View File

@@ -47,6 +47,7 @@ public:
public slots:
void parse();
private slots:
void playlistCreated();
@@ -57,7 +58,7 @@ signals:
private:
void parseM3u( const QString& track );
void getTags( const QFileInfo& info );
void parseLine(const QString& line , const QFile &file);
void parseLine(const QString& line , const QFile& file);
QList< query_ptr > m_tracks;
QString m_title, m_info, m_creator;
bool m_single;

View File

@@ -295,6 +295,7 @@ tomahawkWindow()
void
bringToFront()
{
#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 )
#if defined(Q_WS_X11)
{
qDebug() << Q_FUNC_INFO;
@@ -348,6 +349,20 @@ bringToFront()
}
}
#endif
#endif
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
{
qDebug() << Q_FUNC_INFO;
QWidget* widget = tomahawkWindow();
if ( !widget )
return;
widget->show();
widget->activateWindow();
widget->raise();
}
#endif
}
#endif

View File

@@ -71,7 +71,6 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti
m_albumView->setItemWidth( TomahawkUtils::DpiScaler::scaledX( this, 170 ) );
m_albumView->delegate()->setWordWrapping( true );
m_albumView->proxyModel()->sort( -1 );
m_albumView->setEmptyTip( tr( "Sorry, there are no albums in this collection!" ) );
TomahawkStyle::stylePageFrame( m_albumView );
@@ -186,6 +185,7 @@ CollectionViewPage::setAlbumModel( PlayableModel* model )
m_albumModel = model;
m_albumView->setPlayableModel( model );
m_albumView->proxyModel()->sort( PlayableModel::Artist, Qt::AscendingOrder );
if ( oldModel )
{

View File

@@ -34,7 +34,7 @@ ENDIF( LIBLASTFM_FOUND )
SET( tomahawkSourcesGui ${tomahawkSourcesGui}
dialogs/DiagnosticsDialog.cpp
dialogs/LoadXSPFDialog.cpp
dialogs/LoadPlaylistDialog.cpp
dialogs/SettingsDialog.cpp
sourcetree/SourcesModel.cpp
@@ -74,7 +74,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
SET( tomahawkUI ${tomahawkUI}
dialogs/DiagnosticsDialog.ui
dialogs/HostDialog.ui
dialogs/LoadXSPFDialog.ui
dialogs/LoadPlaylistDialog.ui
dialogs/ProxyDialog.ui
dialogs/Settings_Accounts.ui
dialogs/Settings_Advanced.ui

View File

@@ -48,6 +48,7 @@
#include "utils/ProxyStyle.h"
#include "utils/WidgetDragFilter.h"
#include "utils/NetworkAccessManager.h"
#include "utils/M3uLoader.h"
#include "widgets/AccountsToolButton.h"
#include "widgets/AnimatedSplitter.h"
#include "widgets/ContainedMenuButton.h"
@@ -79,7 +80,7 @@
#include "SourceList.h"
#include "TomahawkTrayIcon.h"
#include "TomahawkApp.h"
#include "dialogs/LoadXSPFDialog.h"
#include "dialogs/LoadPlaylistDialog.h"
#include "utils/ImageRegistry.h"
#include "utils/Logger.h"
@@ -679,7 +680,7 @@ TomahawkWindow::setupSignals()
connect( ac->getAction( "openLogfile" ), SIGNAL( triggered() ), SLOT( openLogfile() ) );
connect( ac->getAction( "updateCollection" ), SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
connect( ac->getAction( "rescanCollection" ), SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
connect( ac->getAction( "loadXSPF" ), SIGNAL( triggered() ), SLOT( loadSpiff() ) );
connect( ac->getAction( "importPlaylist" ), SIGNAL( triggered() ), SLOT( loadPlaylist() ) );
connect( ac->getAction( "whatsnew_0_8" ), SIGNAL( triggered() ), SLOT( showWhatsNew_0_8() ) );
connect( ac->getAction( "aboutTomahawk" ), SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
connect( ac->getAction( "quit" ), SIGNAL( triggered() ), qApp, SLOT( quit() ) );
@@ -1166,46 +1167,54 @@ TomahawkWindow::fullScreenExited()
void
TomahawkWindow::loadSpiff()
TomahawkWindow::loadPlaylist()
{
LoadXSPFDialog* diag = new LoadXSPFDialog( this, Qt::Sheet );
LoadPlaylistDialog* diag = new LoadPlaylistDialog( this, Qt::Sheet );
#ifdef Q_OS_MAC
connect( diag, SIGNAL( finished( int ) ), this, SLOT( loadXspfFinished( int ) ) );
connect( diag, SIGNAL( finished( int ) ), this, SLOT( loadPlaylistFinished( int ) ) );
diag->show();
#else
QPointer< LoadXSPFDialog > safe( diag );
QPointer< LoadPlaylistDialog > safe( diag );
int ret = diag->exec();
if ( !safe.isNull() && ret == QDialog::Accepted )
{
QUrl url = QUrl::fromUserInput( safe.data()->xspfUrl() );
bool autoUpdate = safe.data()->autoUpdate();
XSPFLoader* loader = new XSPFLoader( true, autoUpdate );
connect( loader, SIGNAL( error( XSPFLoader::XSPFErrorCode ) ), SLOT( onXSPFError( XSPFLoader::XSPFErrorCode ) ) );
connect( loader, SIGNAL( ok( Tomahawk::playlist_ptr ) ), SLOT( onXSPFOk( Tomahawk::playlist_ptr ) ) );
loader->load( url );
importPlaylist( safe->url(), safe->autoUpdate() );
}
#endif
}
void
TomahawkWindow::loadXspfFinished( int ret )
TomahawkWindow::loadPlaylistFinished( int ret )
{
LoadXSPFDialog* d = qobject_cast< LoadXSPFDialog* >( sender() );
LoadPlaylistDialog* d = qobject_cast< LoadPlaylistDialog* >( sender() );
Q_ASSERT( d );
if ( ret == QDialog::Accepted )
{
QUrl url = QUrl::fromUserInput( d->xspfUrl() );
bool autoUpdate = d->autoUpdate();
importPlaylist( d->url(), d->autoUpdate() );
}
d->deleteLater();
}
void
TomahawkWindow::importPlaylist( const QString& url, bool autoUpdate )
{
const QUrl u = QUrl::fromUserInput( url );
if ( u.toString().toLower().endsWith( ".m3u" ) )
{
M3uLoader* loader = new M3uLoader( u.toString(), true );
loader->parse();
}
else
{
XSPFLoader* loader = new XSPFLoader( true, autoUpdate );
connect( loader, SIGNAL( error( XSPFLoader::XSPFErrorCode ) ), SLOT( onXSPFError( XSPFLoader::XSPFErrorCode ) ) );
connect( loader, SIGNAL( ok( Tomahawk::playlist_ptr ) ), SLOT( onXSPFOk( Tomahawk::playlist_ptr ) ) );
loader->load( url );
loader->load( u );
}
d->deleteLater();
}

View File

@@ -99,7 +99,7 @@ protected:
public slots:
void createStation();
void createPlaylist();
void loadSpiff();
void loadPlaylist();
void showSettingsDialog();
void showDiagnosticsDialog();
void legalInfo();
@@ -137,7 +137,7 @@ private slots:
void onSearch( const QString& search );
void onFilterEdited();
void loadXspfFinished( int );
void loadPlaylistFinished( int );
void minimize();
void maximize();
@@ -166,6 +166,8 @@ private:
void setupShortcuts();
void setupUpdateCheck();
void importPlaylist( const QString& url, bool autoUpdate );
#ifdef Q_OS_WIN
bool setupWindowsButtons();
#if QT_VERSION < QT_VERSION_CHECK( 5, 2, 0 )

View File

@@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2014, Christian Muehlhaeuser <muesli@tomahawk-player.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
@@ -16,53 +17,70 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "LoadXSPFDialog.h"
#include "ui_LoadXSPFDialog.h"
#include "LoadPlaylistDialog.h"
#include "ui_LoadPlaylistDialog.h"
#include "TomahawkSettings.h"
#include "Source.h"
#include <QFileDialog>
LoadXSPFDialog::LoadXSPFDialog( QWidget* parent, Qt::WindowFlags f )
LoadPlaylistDialog::LoadPlaylistDialog( QWidget* parent, Qt::WindowFlags f )
: QDialog( parent, f )
, m_ui( new Ui_LoadXSPF )
, m_ui( new Ui_LoadPlaylist )
{
m_ui->setupUi( this );
#ifdef Q_OS_MAC
m_ui->horizontalLayout->setContentsMargins( 0, 0, 0, 0 );
m_ui->horizontalLayout->setSpacing( 5 );
m_ui->verticalLayout->setContentsMargins( 0, 10, 0, 0 );
m_ui->verticalLayout->setSpacing( 0 );
#endif
setMinimumSize( sizeHint() );
m_ui->autoUpdate->setEnabled( false );
connect( m_ui->navigateButton, SIGNAL( clicked( bool ) ), this, SLOT( getLocalFile() ) );
connect( m_ui->lineEdit, SIGNAL( textChanged( QString ) ), this, SLOT( onUrlChanged() ) );
}
LoadXSPFDialog::~LoadXSPFDialog()
LoadPlaylistDialog::~LoadPlaylistDialog()
{
}
void
LoadXSPFDialog::getLocalFile()
LoadPlaylistDialog::getLocalFile()
{
const QString path = TomahawkSettings::instance()->importXspfPath();
QString url = QFileDialog::getOpenFileName( this, tr( "Load XSPF File" ), path, tr( "XSPF Files (*.xspf)" ) );
const QString path = TomahawkSettings::instance()->importPlaylistPath();
QString url = QFileDialog::getOpenFileName( this, tr( "Load Playlist" ), path, tr( "Playlists (*.xspf *.m3u)" ) );
if ( !url.isEmpty() )
TomahawkSettings::instance()->setImportXspfPath( QFileInfo( url ).absoluteDir().absolutePath() );
{
const QFileInfo fi( url );
TomahawkSettings::instance()->setImportPlaylistPath( fi.absoluteDir().absolutePath() );
}
m_ui->lineEdit->setText( url );
}
void
LoadPlaylistDialog::onUrlChanged()
{
m_ui->autoUpdate->setEnabled( m_ui->lineEdit->text().trimmed().startsWith( "http://" ) );
}
QString
LoadXSPFDialog::xspfUrl() const
LoadPlaylistDialog::url() const
{
return m_ui->lineEdit->text();
}
bool
LoadXSPFDialog::autoUpdate() const
LoadPlaylistDialog::autoUpdate() const
{
return m_ui->autoUpdate->isChecked();
}

View File

@@ -1,6 +1,7 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
* Copyright 2014, Christian Muehlhaeuser <muesli@tomahawk-player.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
@@ -16,28 +17,31 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LOADXSPFDIALOG_H
#define LOADXSPFDIALOG_H
#ifndef LOADPLAYLISTDIALOG_H
#define LOADPLAYLISTDIALOG_H
#include <QDialog>
class Ui_LoadXSPF;
class Ui_LoadPlaylist;
class LoadXSPFDialog : public QDialog
class LoadPlaylistDialog : public QDialog
{
Q_OBJECT
public:
explicit LoadXSPFDialog( QWidget* parent = 0, Qt::WindowFlags f = 0 );
virtual ~LoadXSPFDialog();
explicit LoadPlaylistDialog( QWidget* parent = 0, Qt::WindowFlags f = 0 );
virtual ~LoadPlaylistDialog();
QString xspfUrl() const;
QString url() const;
bool autoUpdate() const;
public slots:
void getLocalFile();
private slots:
void onUrlChanged();
private:
Ui_LoadXSPF* m_ui;
Ui_LoadPlaylist* m_ui;
};
#endif // LOADXSPFDIALOG_H
#endif // LOADPLAYLISTDIALOG_H

View File

@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LoadXSPF</class>
<widget class="QDialog" name="LoadXSPF">
<class>LoadPlaylist</class>
<widget class="QDialog" name="LoadPlaylist">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>444</width>
<height>241</height>
<width>481</width>
<height>199</height>
</rect>
</property>
<property name="windowTitle">
<string>Load XSPF</string>
<string>Load Playlist</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@@ -19,6 +19,9 @@
<property name="text">
<string>Enter the URL of the hosted playlist (e.g. .xspf format) or click the button to select a local M3U of XSPF playlist to import.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
@@ -75,6 +78,9 @@
<property name="text">
<string>To import a playlist from Spotify, Rdio, Beats, etc. - simply drag the link into Tomahawk.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
@@ -97,7 +103,7 @@
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>LoadXSPF</receiver>
<receiver>LoadPlaylist</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
@@ -113,7 +119,7 @@
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>LoadXSPF</receiver>
<receiver>LoadPlaylist</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">