mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-25 02:09:48 +01:00
some work
This commit is contained in:
parent
ab84f6837a
commit
15595b741e
@ -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
|
||||
GlobalActionManager::copyPlaylistToClipboard( const dynplaylist_ptr& playlist )
|
||||
{
|
||||
@ -1157,7 +1191,7 @@ GlobalActionManager::waitingForResolved( bool /* success */ )
|
||||
QString
|
||||
GlobalActionManager::hostname() const
|
||||
{
|
||||
return QString( "http://toma.hk" );
|
||||
return QString( "http://stage.toma.hk" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,6 +57,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void shortenLink( const QUrl& url, const QVariant &callbackObj = QVariant() );
|
||||
void getShortLink( const playlist_ptr& playlist );
|
||||
|
||||
bool parseTomahawkLink( const QString& link );
|
||||
void waitingForResolved( bool );
|
||||
|
@ -226,8 +226,8 @@ SourceTreeView::setupMenus()
|
||||
}
|
||||
|
||||
|
||||
if ( type == SourcesModel::StaticPlaylist )
|
||||
copyPlaylistAction->setText( tr( "&Export Playlist" ) );
|
||||
// if ( type == SourcesModel::StaticPlaylist )
|
||||
// copyPlaylistAction->setText( tr( "&Export Playlist" ) );
|
||||
|
||||
connect( loadPlaylistAction, SIGNAL( triggered() ), SLOT( loadPlaylist() ) );
|
||||
connect( renamePlaylistAction, SIGNAL( triggered() ), SLOT( renamePlaylist() ) );
|
||||
@ -357,18 +357,21 @@ SourceTreeView::copyPlaylistLink()
|
||||
}
|
||||
else if ( type == SourcesModel::StaticPlaylist )
|
||||
{
|
||||
|
||||
PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
|
||||
playlist_ptr playlist = item->playlist();
|
||||
|
||||
QString suggestedFilename = TomahawkSettings::instance()->playlistDefaultPath() + "/" + playlist->title();
|
||||
QString filename = QFileDialog::getSaveFileName( TomahawkUtils::tomahawkWindow(), tr( "Save XSPF" ),
|
||||
suggestedFilename, tr( "Playlists (*.xspf)" ) );
|
||||
if ( !filename.isEmpty() )
|
||||
{
|
||||
QFileInfo playlistAbsoluteFilePath = filename;
|
||||
TomahawkSettings::instance()->setPlaylistDefaultPath( playlistAbsoluteFilePath.absolutePath() );
|
||||
GlobalActionManager::instance()->savePlaylistToFile( playlist, filename );
|
||||
}
|
||||
GlobalActionManager::instance()->getShortLink( playlist );
|
||||
|
||||
// QString suggestedFilename = TomahawkSettings::instance()->playlistDefaultPath() + "/" + playlist->title();
|
||||
// QString filename = QFileDialog::getSaveFileName( TomahawkUtils::tomahawkWindow(), tr( "Save XSPF" ),
|
||||
// suggestedFilename, tr( "Playlists (*.xspf)" ) );
|
||||
// if ( !filename.isEmpty() )
|
||||
// {
|
||||
// QFileInfo playlistAbsoluteFilePath = filename;
|
||||
// TomahawkSettings::instance()->setPlaylistDefaultPath( playlistAbsoluteFilePath.absolutePath() );
|
||||
// GlobalActionManager::instance()->savePlaylistToFile( playlist, filename );
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user