mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
some work
This commit is contained in:
@@ -144,6 +144,40 @@ GlobalActionManager::shortenLink( const QUrl& url, const QVariant& callbackObj )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
GlobalActionManager::getShortLink( const playlist_ptr& pl )
|
||||||
|
{
|
||||||
|
QVariantMap m;
|
||||||
|
m[ "title" ] = playlist->title();
|
||||||
|
QVariantList tracks;
|
||||||
|
foreach( const plentry_ptr& pl, playlist->entries() )
|
||||||
|
{
|
||||||
|
if ( pl->query().isNull() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QVariantMap track;
|
||||||
|
track[ "title" ] = pl->query()->track();
|
||||||
|
track[ "artist" ] = pl->query()->artist();
|
||||||
|
track[ "album" ] = pl->query()->album();
|
||||||
|
|
||||||
|
tracks << track;
|
||||||
|
}
|
||||||
|
m[ "tracks" ] = tracks;
|
||||||
|
|
||||||
|
QJson::Parser p;
|
||||||
|
QByteArray msg = p.parse( m );
|
||||||
|
qDebug() << "POSTING DATA:" << msg;
|
||||||
|
|
||||||
|
const QUrl url( QString( "%1/playlist").arg( hostname() ) );
|
||||||
|
QNetworkRequest req( url );
|
||||||
|
req.setHeader( QNetworkRequest::ContentTypeHeader, QLatin1String( "application/x-www-form-urlencoded" ) );
|
||||||
|
QNetworkReply *reply = TomahawkUtils::nam()->get( request );
|
||||||
|
if ( callbackObj.isValid() )
|
||||||
|
reply->setProperty( "callbackobj", callbackObj );
|
||||||
|
connect( reply, SIGNAL( finished() ), SLOT( shortenLinkRequestFinished() ) );
|
||||||
|
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), SLOT( shortenLinkRequestError( QNetworkReply::NetworkError ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
GlobalActionManager::copyPlaylistToClipboard( const dynplaylist_ptr& playlist )
|
GlobalActionManager::copyPlaylistToClipboard( const dynplaylist_ptr& playlist )
|
||||||
{
|
{
|
||||||
@@ -1157,7 +1191,7 @@ GlobalActionManager::waitingForResolved( bool /* success */ )
|
|||||||
QString
|
QString
|
||||||
GlobalActionManager::hostname() const
|
GlobalActionManager::hostname() const
|
||||||
{
|
{
|
||||||
return QString( "http://toma.hk" );
|
return QString( "http://stage.toma.hk" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -57,6 +57,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void shortenLink( const QUrl& url, const QVariant &callbackObj = QVariant() );
|
void shortenLink( const QUrl& url, const QVariant &callbackObj = QVariant() );
|
||||||
|
void getShortLink( const playlist_ptr& playlist );
|
||||||
|
|
||||||
bool parseTomahawkLink( const QString& link );
|
bool parseTomahawkLink( const QString& link );
|
||||||
void waitingForResolved( bool );
|
void waitingForResolved( bool );
|
||||||
|
@@ -226,8 +226,8 @@ SourceTreeView::setupMenus()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( type == SourcesModel::StaticPlaylist )
|
// if ( type == SourcesModel::StaticPlaylist )
|
||||||
copyPlaylistAction->setText( tr( "&Export Playlist" ) );
|
// copyPlaylistAction->setText( tr( "&Export Playlist" ) );
|
||||||
|
|
||||||
connect( loadPlaylistAction, SIGNAL( triggered() ), SLOT( loadPlaylist() ) );
|
connect( loadPlaylistAction, SIGNAL( triggered() ), SLOT( loadPlaylist() ) );
|
||||||
connect( renamePlaylistAction, SIGNAL( triggered() ), SLOT( renamePlaylist() ) );
|
connect( renamePlaylistAction, SIGNAL( triggered() ), SLOT( renamePlaylist() ) );
|
||||||
@@ -357,18 +357,21 @@ SourceTreeView::copyPlaylistLink()
|
|||||||
}
|
}
|
||||||
else if ( type == SourcesModel::StaticPlaylist )
|
else if ( type == SourcesModel::StaticPlaylist )
|
||||||
{
|
{
|
||||||
|
|
||||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
|
PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
|
||||||
playlist_ptr playlist = item->playlist();
|
playlist_ptr playlist = item->playlist();
|
||||||
|
|
||||||
QString suggestedFilename = TomahawkSettings::instance()->playlistDefaultPath() + "/" + playlist->title();
|
GlobalActionManager::instance()->getShortLink( playlist );
|
||||||
QString filename = QFileDialog::getSaveFileName( TomahawkUtils::tomahawkWindow(), tr( "Save XSPF" ),
|
|
||||||
suggestedFilename, tr( "Playlists (*.xspf)" ) );
|
// QString suggestedFilename = TomahawkSettings::instance()->playlistDefaultPath() + "/" + playlist->title();
|
||||||
if ( !filename.isEmpty() )
|
// QString filename = QFileDialog::getSaveFileName( TomahawkUtils::tomahawkWindow(), tr( "Save XSPF" ),
|
||||||
{
|
// suggestedFilename, tr( "Playlists (*.xspf)" ) );
|
||||||
QFileInfo playlistAbsoluteFilePath = filename;
|
// if ( !filename.isEmpty() )
|
||||||
TomahawkSettings::instance()->setPlaylistDefaultPath( playlistAbsoluteFilePath.absolutePath() );
|
// {
|
||||||
GlobalActionManager::instance()->savePlaylistToFile( playlist, filename );
|
// QFileInfo playlistAbsoluteFilePath = filename;
|
||||||
}
|
// TomahawkSettings::instance()->setPlaylistDefaultPath( playlistAbsoluteFilePath.absolutePath() );
|
||||||
|
// GlobalActionManager::instance()->savePlaylistToFile( playlist, filename );
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user