mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-21 00:12:06 +02:00
Support loading m3u playlists from 'Import Playlist' dialog.
This commit is contained in:
parent
1a6927a6ad
commit
d2d44f41cb
@ -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
|
||||
|
@ -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"
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 )
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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">
|
||||
|
Loading…
x
Reference in New Issue
Block a user