X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Futils%2Ffreesound.cpp;h=00cb6ee4bb3eb1050887fecafb8333a8c2b01d87;hb=5d4746e4c3e8665de83e6d281dcd08a46cd22c31;hp=c74054fff62d5231d08f16eb3aef81ad3e8d7899;hpb=ef74a23b2fbb36d07eb877776a8c26c40a460cf8;p=kdenlive diff --git a/src/utils/freesound.cpp b/src/utils/freesound.cpp index c74054ff..00cb6ee4 100644 --- a/src/utils/freesound.cpp +++ b/src/utils/freesound.cpp @@ -30,7 +30,7 @@ #include #include "kdenlivesettings.h" #include -#include +#include #ifdef USE_QJSON #include @@ -47,19 +47,20 @@ FreeSound::FreeSound(QListWidget *listWidget, QObject *parent) : FreeSound::~FreeSound() { - if (m_previewProcess) delete m_previewProcess; + delete m_previewProcess; } -void FreeSound::slotStartSearch(const QString searchText, int page) +void FreeSound::slotStartSearch(const QString &searchText, int page) { m_listWidget->clear(); QString uri = "http://www.freesound.org/api/sounds/search/?q="; uri.append(searchText); - if (page > 1) uri.append("&p=" + QString::number(page)); + if (page > 1) + uri.append("&p=" + QString::number(page)); uri.append("&api_key=a1772c8236e945a4bee30a64058dabf8"); KJob* resolveJob = KIO::storedGet( KUrl(uri), KIO::NoReload, KIO::HideProgressInfo ); - connect( resolveJob, SIGNAL( result( KJob* ) ), this, SLOT( slotShowResults( KJob* ) ) ); + connect( resolveJob, SIGNAL(result(KJob*)), this, SLOT(slotShowResults(KJob*)) ); } @@ -142,7 +143,7 @@ OnlineItemInfo FreeSound::displayItemDetails(QListWidgetItem *item) QString extraInfoUrl = item->data(infoData).toString(); if (!extraInfoUrl.isEmpty()) { KJob* resolveJob = KIO::storedGet( KUrl(extraInfoUrl), KIO::NoReload, KIO::HideProgressInfo ); - connect( resolveJob, SIGNAL( result( KJob* ) ), this, SLOT( slotParseResults( KJob* ) ) ); + connect( resolveJob, SIGNAL(result(KJob*)), this, SLOT(slotParseResults(KJob*)) ); } emit gotThumb(item->data(imageRole).toString()); return info; @@ -155,7 +156,6 @@ void FreeSound::slotParseResults(KJob* job) KIO::StoredTransferJob* storedQueryJob = static_cast( job ); QJson::Parser parser; bool ok; - int ct = 0; QString html = QString("").arg(qApp->palette().alternateBase().color().name()); QVariant data = parser.parse(storedQueryJob->data(), &ok); @@ -166,37 +166,21 @@ void FreeSound::slotParseResults(KJob* job) html += ""; if (m_metaInfo.contains(i18n("Duration"))) { - ct++; - if (ct %2 == 0) { - html += ""; - } - else html += ""; + html += ""; html += ""; m_metaInfo.remove(i18n("Duration")); } if (infos.contains("samplerate")) { - ct++; - if (ct %2 == 0) { - html += ""; - } - else html += ""; + html += ""; html += ""; } if (infos.contains("channels")) { - ct++; - if (ct %2 == 0) { - html += ""; - } - else html += ""; + html += ""; html += ""; } if (infos.contains("filesize")) { - ct++; - if (ct %2 == 0) { - html += ""; - } - else html += ""; + html += ""; KIO::filesize_t fSize = infos.value("filesize").toDouble(); html += ""; } @@ -216,13 +200,15 @@ void FreeSound::slotParseResults(KJob* job) bool FreeSound::startItemPreview(QListWidgetItem *item) { - if (!item) return false; - QString url = item->data(previewRole).toString(); - if (url.isEmpty()) return false; + if (!item) + return false; + const QString url = item->data(previewRole).toString(); + if (url.isEmpty()) + return false; if (m_previewProcess && m_previewProcess->state() != QProcess::NotRunning) { m_previewProcess->close(); } - m_previewProcess->start("ffplay", QStringList() << url << "-nodisp"); + m_previewProcess->start(KdenliveSettings::ffplaypath(), QStringList() << url << "-nodisp"); return true; } @@ -236,13 +222,17 @@ void FreeSound::stopItemPreview(QListWidgetItem */*item*/) QString FreeSound::getExtension(QListWidgetItem *item) { - if (!item) return QString(); + if (!item) + return QString(); return QString("*.") + item->text().section('.', -1); } QString FreeSound::getDefaultDownloadName(QListWidgetItem *item) { - if (!item) return QString(); + if (!item) + return QString(); return item->text(); } + +#include "freesound.moc"
" + i18n("Duration") + "" + m_metaInfo.value(i18n("Duration")) + "
" + i18n("Samplerate") + "" + QString::number(infos.value("samplerate").toDouble()) + "
" + i18n("Channels") + "" + QString::number(infos.value("channels").toInt()) + "
" + i18n("File size") + "" + KIO::convertSize(fSize) + "