mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 03:10:12 +02:00
Support loading m3u playlists from 'Import Playlist' dialog.
This commit is contained in:
@@ -34,7 +34,7 @@ ENDIF( LIBLASTFM_FOUND )
|
|||||||
|
|
||||||
SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
||||||
dialogs/DiagnosticsDialog.cpp
|
dialogs/DiagnosticsDialog.cpp
|
||||||
dialogs/LoadXSPFDialog.cpp
|
dialogs/LoadPlaylistDialog.cpp
|
||||||
dialogs/SettingsDialog.cpp
|
dialogs/SettingsDialog.cpp
|
||||||
|
|
||||||
sourcetree/SourcesModel.cpp
|
sourcetree/SourcesModel.cpp
|
||||||
@@ -74,7 +74,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
|||||||
SET( tomahawkUI ${tomahawkUI}
|
SET( tomahawkUI ${tomahawkUI}
|
||||||
dialogs/DiagnosticsDialog.ui
|
dialogs/DiagnosticsDialog.ui
|
||||||
dialogs/HostDialog.ui
|
dialogs/HostDialog.ui
|
||||||
dialogs/LoadXSPFDialog.ui
|
dialogs/LoadPlaylistDialog.ui
|
||||||
dialogs/ProxyDialog.ui
|
dialogs/ProxyDialog.ui
|
||||||
dialogs/Settings_Accounts.ui
|
dialogs/Settings_Accounts.ui
|
||||||
dialogs/Settings_Advanced.ui
|
dialogs/Settings_Advanced.ui
|
||||||
|
@@ -48,6 +48,7 @@
|
|||||||
#include "utils/ProxyStyle.h"
|
#include "utils/ProxyStyle.h"
|
||||||
#include "utils/WidgetDragFilter.h"
|
#include "utils/WidgetDragFilter.h"
|
||||||
#include "utils/NetworkAccessManager.h"
|
#include "utils/NetworkAccessManager.h"
|
||||||
|
#include "utils/M3uLoader.h"
|
||||||
#include "widgets/AccountsToolButton.h"
|
#include "widgets/AccountsToolButton.h"
|
||||||
#include "widgets/AnimatedSplitter.h"
|
#include "widgets/AnimatedSplitter.h"
|
||||||
#include "widgets/ContainedMenuButton.h"
|
#include "widgets/ContainedMenuButton.h"
|
||||||
@@ -79,7 +80,7 @@
|
|||||||
#include "SourceList.h"
|
#include "SourceList.h"
|
||||||
#include "TomahawkTrayIcon.h"
|
#include "TomahawkTrayIcon.h"
|
||||||
#include "TomahawkApp.h"
|
#include "TomahawkApp.h"
|
||||||
#include "dialogs/LoadXSPFDialog.h"
|
#include "dialogs/LoadPlaylistDialog.h"
|
||||||
#include "utils/ImageRegistry.h"
|
#include "utils/ImageRegistry.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
@@ -1166,46 +1167,54 @@ TomahawkWindow::fullScreenExited()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkWindow::loadSpiff()
|
TomahawkWindow::loadPlaylist()
|
||||||
{
|
{
|
||||||
LoadXSPFDialog* diag = new LoadXSPFDialog( this, Qt::Sheet );
|
LoadPlaylistDialog* diag = new LoadPlaylistDialog( this, Qt::Sheet );
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
connect( diag, SIGNAL( finished( int ) ), this, SLOT( loadXspfFinished( int ) ) );
|
connect( diag, SIGNAL( finished( int ) ), this, SLOT( loadPlaylistFinished( int ) ) );
|
||||||
diag->show();
|
diag->show();
|
||||||
#else
|
#else
|
||||||
QPointer< LoadXSPFDialog > safe( diag );
|
QPointer< LoadPlaylistDialog > safe( diag );
|
||||||
|
|
||||||
int ret = diag->exec();
|
int ret = diag->exec();
|
||||||
if ( !safe.isNull() && ret == QDialog::Accepted )
|
if ( !safe.isNull() && ret == QDialog::Accepted )
|
||||||
{
|
{
|
||||||
QUrl url = QUrl::fromUserInput( safe.data()->xspfUrl() );
|
importPlaylist( safe->url(), safe->autoUpdate() );
|
||||||
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 );
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkWindow::loadXspfFinished( int ret )
|
TomahawkWindow::loadPlaylistFinished( int ret )
|
||||||
{
|
{
|
||||||
LoadXSPFDialog* d = qobject_cast< LoadXSPFDialog* >( sender() );
|
LoadPlaylistDialog* d = qobject_cast< LoadPlaylistDialog* >( sender() );
|
||||||
Q_ASSERT( d );
|
Q_ASSERT( d );
|
||||||
if ( ret == QDialog::Accepted )
|
if ( ret == QDialog::Accepted )
|
||||||
{
|
{
|
||||||
QUrl url = QUrl::fromUserInput( d->xspfUrl() );
|
importPlaylist( d->url(), d->autoUpdate() );
|
||||||
bool autoUpdate = 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 );
|
XSPFLoader* loader = new XSPFLoader( true, autoUpdate );
|
||||||
connect( loader, SIGNAL( error( XSPFLoader::XSPFErrorCode ) ), SLOT( onXSPFError( XSPFLoader::XSPFErrorCode ) ) );
|
connect( loader, SIGNAL( error( XSPFLoader::XSPFErrorCode ) ), SLOT( onXSPFError( XSPFLoader::XSPFErrorCode ) ) );
|
||||||
connect( loader, SIGNAL( ok( Tomahawk::playlist_ptr ) ), SLOT( onXSPFOk( Tomahawk::playlist_ptr ) ) );
|
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:
|
public slots:
|
||||||
void createStation();
|
void createStation();
|
||||||
void createPlaylist();
|
void createPlaylist();
|
||||||
void loadSpiff();
|
void loadPlaylist();
|
||||||
void showSettingsDialog();
|
void showSettingsDialog();
|
||||||
void showDiagnosticsDialog();
|
void showDiagnosticsDialog();
|
||||||
void legalInfo();
|
void legalInfo();
|
||||||
@@ -137,7 +137,7 @@ private slots:
|
|||||||
void onSearch( const QString& search );
|
void onSearch( const QString& search );
|
||||||
void onFilterEdited();
|
void onFilterEdited();
|
||||||
|
|
||||||
void loadXspfFinished( int );
|
void loadPlaylistFinished( int );
|
||||||
|
|
||||||
void minimize();
|
void minimize();
|
||||||
void maximize();
|
void maximize();
|
||||||
@@ -166,6 +166,8 @@ private:
|
|||||||
void setupShortcuts();
|
void setupShortcuts();
|
||||||
void setupUpdateCheck();
|
void setupUpdateCheck();
|
||||||
|
|
||||||
|
void importPlaylist( const QString& url, bool autoUpdate );
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
bool setupWindowsButtons();
|
bool setupWindowsButtons();
|
||||||
#if QT_VERSION < QT_VERSION_CHECK( 5, 2, 0 )
|
#if QT_VERSION < QT_VERSION_CHECK( 5, 2, 0 )
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.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
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "LoadXSPFDialog.h"
|
#include "LoadPlaylistDialog.h"
|
||||||
#include "ui_LoadXSPFDialog.h"
|
#include "ui_LoadPlaylistDialog.h"
|
||||||
|
|
||||||
#include "TomahawkSettings.h"
|
#include "TomahawkSettings.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
LoadXSPFDialog::LoadXSPFDialog( QWidget* parent, Qt::WindowFlags f )
|
LoadPlaylistDialog::LoadPlaylistDialog( QWidget* parent, Qt::WindowFlags f )
|
||||||
: QDialog( parent, f )
|
: QDialog( parent, f )
|
||||||
, m_ui( new Ui_LoadXSPF )
|
, m_ui( new Ui_LoadPlaylist )
|
||||||
{
|
{
|
||||||
m_ui->setupUi( this );
|
m_ui->setupUi( this );
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
m_ui->horizontalLayout->setContentsMargins( 0, 0, 0, 0 );
|
m_ui->horizontalLayout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
m_ui->horizontalLayout->setSpacing( 5 );
|
m_ui->horizontalLayout->setSpacing( 5 );
|
||||||
m_ui->verticalLayout->setContentsMargins( 0, 10, 0, 0 );
|
|
||||||
m_ui->verticalLayout->setSpacing( 0 );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
setMinimumSize( sizeHint() );
|
||||||
|
m_ui->autoUpdate->setEnabled( false );
|
||||||
|
|
||||||
connect( m_ui->navigateButton, SIGNAL( clicked( bool ) ), this, SLOT( getLocalFile() ) );
|
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
|
void
|
||||||
LoadXSPFDialog::getLocalFile()
|
LoadPlaylistDialog::getLocalFile()
|
||||||
{
|
{
|
||||||
const QString path = TomahawkSettings::instance()->importXspfPath();
|
const QString path = TomahawkSettings::instance()->importPlaylistPath();
|
||||||
QString url = QFileDialog::getOpenFileName( this, tr( "Load XSPF File" ), path, tr( "XSPF Files (*.xspf)" ) );
|
QString url = QFileDialog::getOpenFileName( this, tr( "Load Playlist" ), path, tr( "Playlists (*.xspf *.m3u)" ) );
|
||||||
|
|
||||||
if ( !url.isEmpty() )
|
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 );
|
m_ui->lineEdit->setText( url );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LoadPlaylistDialog::onUrlChanged()
|
||||||
|
{
|
||||||
|
m_ui->autoUpdate->setEnabled( m_ui->lineEdit->text().trimmed().startsWith( "http://" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
LoadXSPFDialog::xspfUrl() const
|
LoadPlaylistDialog::url() const
|
||||||
{
|
{
|
||||||
return m_ui->lineEdit->text();
|
return m_ui->lineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LoadXSPFDialog::autoUpdate() const
|
LoadPlaylistDialog::autoUpdate() const
|
||||||
{
|
{
|
||||||
return m_ui->autoUpdate->isChecked();
|
return m_ui->autoUpdate->isChecked();
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.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
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* 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/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LOADXSPFDIALOG_H
|
#ifndef LOADPLAYLISTDIALOG_H
|
||||||
#define LOADXSPFDIALOG_H
|
#define LOADPLAYLISTDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
class Ui_LoadXSPF;
|
class Ui_LoadPlaylist;
|
||||||
|
|
||||||
class LoadXSPFDialog : public QDialog
|
class LoadPlaylistDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit LoadXSPFDialog( QWidget* parent = 0, Qt::WindowFlags f = 0 );
|
explicit LoadPlaylistDialog( QWidget* parent = 0, Qt::WindowFlags f = 0 );
|
||||||
virtual ~LoadXSPFDialog();
|
virtual ~LoadPlaylistDialog();
|
||||||
|
|
||||||
QString xspfUrl() const;
|
QString url() const;
|
||||||
bool autoUpdate() const;
|
bool autoUpdate() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void getLocalFile();
|
void getLocalFile();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onUrlChanged();
|
||||||
|
|
||||||
private:
|
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"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>LoadXSPF</class>
|
<class>LoadPlaylist</class>
|
||||||
<widget class="QDialog" name="LoadXSPF">
|
<widget class="QDialog" name="LoadPlaylist">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>444</width>
|
<width>481</width>
|
||||||
<height>241</height>
|
<height>199</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Load XSPF</string>
|
<string>Load Playlist</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
@@ -19,6 +19,9 @@
|
|||||||
<property name="text">
|
<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>
|
<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>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@@ -75,6 +78,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>To import a playlist from Spotify, Rdio, Beats, etc. - simply drag the link into Tomahawk.</string>
|
<string>To import a playlist from Spotify, Rdio, Beats, etc. - simply drag the link into Tomahawk.</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@@ -97,7 +103,7 @@
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>LoadXSPF</receiver>
|
<receiver>LoadPlaylist</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
@@ -113,7 +119,7 @@
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>LoadXSPF</receiver>
|
<receiver>LoadPlaylist</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
Reference in New Issue
Block a user