Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Fix online resources (freesound, archive.org and openclipart imports)

parent 58d1f915
......@@ -100,7 +100,7 @@ QUrl SamplePlugin::generatedClip(const QString &renderer, const QString &generat
if (generatorProcess.exitStatus() == QProcess::CrashExit) {
//qDebug() << "/// Generator failed: ";
QString error = QString::fromLocal8Bit(generatorProcess.readAllStandardError());
KMessageBox::sorry(QApplication::activeWindow(), i18n("Failed to generate clip:\n%1", error, i18n("Generator Failed")));
KMessageBox::sorry(QApplication::activeWindow(), i18n("Failed to generate clip:\n%1", error), i18n("Generator Failed"));
}
else {
result = view.path->url();
......@@ -108,7 +108,7 @@ QUrl SamplePlugin::generatedClip(const QString &renderer, const QString &generat
} else {
//qDebug() << "/// Generator failed: ";
QString error = QString::fromLocal8Bit(generatorProcess.readAllStandardError());
KMessageBox::sorry(QApplication::activeWindow(), i18n("Failed to generate clip:\n%1", error, i18n("Generator Failed")));
KMessageBox::sorry(QApplication::activeWindow(), i18n("Failed to generate clip:\n%1", error), i18n("Generator Failed"));
}
}
delete d;
......
......@@ -235,7 +235,8 @@ target_link_libraries(kdenlive
KF5::CoreAddons
KF5::KIOCore
KF5::KIOFileWidgets
KF5::KIOWidgets
KF5::KIOWidgets
KF5::KIONTLM
KF5::NotifyConfig
KF5::NewStuff
KF5::DBusAddons
......
......@@ -25,15 +25,14 @@
#include <QListWidget>
#include <QDomDocument>
#include <QApplication>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QDebug>
#include "kdenlivesettings.h"
#include <kio/job.h>
#include <kio/storedtransferjob.h>
#include <KLocalizedString>
#ifdef USE_QJSON
#include <qjson/parser.h>
#endif
#include <KMessageBox>
ArchiveOrg::ArchiveOrg(QListWidget *listWidget, QObject *parent) :
AbstractService(listWidget, parent),
......@@ -71,12 +70,15 @@ void ArchiveOrg::slotShowResults(KJob* job)
{
if (job->error() != 0 ) return;
m_listWidget->blockSignals(true);
#ifdef USE_QJSON
KIO::StoredTransferJob* storedQueryJob = static_cast<KIO::StoredTransferJob*>( job );
QJson::Parser parser;
bool ok;
////qDebug()<<"// GOT RESULT: "<<m_result;
QVariant data = parser.parse(storedQueryJob->data(), &ok);
QJsonParseError jsonError;
QJsonDocument doc = QJsonDocument::fromJson(storedQueryJob->data(), &jsonError);
if (jsonError.error != QJsonParseError::NoError) {
// There was an error parsing data
KMessageBox::sorry(m_listWidget, jsonError.errorString(), i18n("Error Loading Data"));
}
QVariant data = doc.toVariant();
QVariant sounds;
if (data.canConvert(QVariant::Map)) {
QMap <QString, QVariant> map = data.toMap();
......@@ -113,7 +115,6 @@ void ArchiveOrg::slotShowResults(KJob* job)
++i;
}
}
#endif
m_listWidget->blockSignals(false);
m_listWidget->setCurrentRow(0);
emit searchDone();
......
......@@ -24,15 +24,14 @@
#include <QPushButton>
#include <QListWidget>
#include <QApplication>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QDebug>
#include "kdenlivesettings.h"
#include <kio/job.h>
#include <kio/storedtransferjob.h>
#include <KLocalizedString>
#ifdef USE_QJSON
#include <qjson/parser.h>
#endif
#include <KMessageBox>
FreeSound::FreeSound(QListWidget *listWidget, QObject *parent) :
AbstractService(listWidget, parent),
......@@ -57,7 +56,8 @@ void FreeSound::slotStartSearch(const QString &searchText, int page)
uri.append("&p=" + QString::number(page));
uri.append("&api_key=a1772c8236e945a4bee30a64058dabf8");
KJob* resolveJob = KIO::storedGet( QUrl(uri), KIO::NoReload, KIO::HideProgressInfo );
KIO::StoredTransferJob* resolveJob = KIO::storedGet( QUrl(uri), KIO::NoReload, KIO::HideProgressInfo );
connect( resolveJob, SIGNAL(result(KJob*)), this, SLOT(slotShowResults(KJob*)) );
}
......@@ -66,12 +66,16 @@ void FreeSound::slotShowResults(KJob* job)
{
if (job->error() != 0 ) return;
m_listWidget->blockSignals(true);
#ifdef USE_QJSON
KIO::StoredTransferJob* storedQueryJob = static_cast<KIO::StoredTransferJob*>( job );
QJson::Parser parser;
bool ok;
////qDebug()<<"// GOT RESULT: "<<m_result;
QVariant data = parser.parse(storedQueryJob->data(), &ok);
QJsonParseError jsonError;
QJsonDocument doc = QJsonDocument::fromJson(storedQueryJob->data(), &jsonError);
if (jsonError.error != QJsonParseError::NoError) {
// There was an error parsing data
KMessageBox::sorry(m_listWidget, jsonError.errorString(), i18n("Error Loading Data"));
}
QVariant data = doc.toVariant();
QVariant sounds;
if (data.canConvert(QVariant::Map)) {
QMap <QString, QVariant> map = data.toMap();
......@@ -113,7 +117,6 @@ void FreeSound::slotShowResults(KJob* job)
++i;
}
}
#endif
m_listWidget->blockSignals(false);
m_listWidget->setCurrentRow(0);
emit searchDone();
......@@ -152,11 +155,14 @@ void FreeSound::slotParseResults(KJob* job)
{
#ifdef USE_QJSON
KIO::StoredTransferJob* storedQueryJob = static_cast<KIO::StoredTransferJob*>( job );
QJson::Parser parser;
bool ok;
QJsonParseError jsonError;
QJsonDocument doc = QJsonDocument::fromJson(storedQueryJob->data(), &jsonError);
if (jsonError.error != QJsonParseError::NoError) {
// There was an error parsing data
KMessageBox::sorry(m_listWidget, jsonError.errorString(), i18n("Error Loading Data"));
}
QVariant data = doc.toVariant();
QString html = QString("<style type=\"text/css\">tr.cellone {background-color: %1;}</style>").arg(qApp->palette().alternateBase().color().name());
QVariant data = parser.parse(storedQueryJob->data(), &ok);
if (data.canConvert(QVariant::Map)) {
QMap <QString, QVariant> infos = data.toMap();
//if (m_currentId != infos.value("id").toInt()) return;
......
......@@ -33,6 +33,7 @@
#include <QNetworkConfigurationManager>
#include <QDebug>
#include <QFontDatabase>
#include <QTemporaryFile>
#include <KSharedConfig>
#include <klocalizedstring.h>
......@@ -72,19 +73,22 @@ ResourceWidget::ResourceWidget(const QString & folder, QWidget * parent) :
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
#ifdef USE_QJSON
m_tmpThumbFile = new QTemporaryFile;
service_list->addItem(i18n("Freesound Audio Library"), FREESOUND);
service_list->addItem(i18n("Archive.org Video Library"), ARCHIVEORG);
#endif
service_list->addItem(i18n("Open Clip Art Graphic Library"), OPENCLIPART);
setWindowTitle(i18n("Search Online Resources"));
info_browser->setStyleSheet(QString("QTextBrowser { background-color: transparent;}"));
QPalette p = palette();
p.setBrush(QPalette::Base, p.window());
info_browser->setPalette(p);
connect(button_search, SIGNAL(clicked()), this, SLOT(slotStartSearch()));
connect(search_results, SIGNAL(currentRowChanged(int)), this, SLOT(slotUpdateCurrentSound()));
connect(button_preview, SIGNAL(clicked()), this, SLOT(slotPlaySound()));
connect(button_import, SIGNAL(clicked()), this, SLOT(slotSaveItem()));
connect(item_license, SIGNAL(leftClickedUrl(QString)), this, SLOT(slotOpenUrl(QString)));
connect(service_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChangeService()));
m_networkManager = new QNetworkConfigurationManager(this);
if (!m_networkManager->isOnline()) {
slotOnlineChanged(false);
}
......@@ -117,7 +121,7 @@ ResourceWidget::ResourceWidget(const QString & folder, QWidget * parent) :
ResourceWidget::~ResourceWidget()
{
delete m_currentService;
QFile::remove(m_tmpThumbFile);
delete m_tmpThumbFile;
saveConfig();
}
......@@ -149,10 +153,6 @@ void ResourceWidget::slotStartSearch(int page)
void ResourceWidget::slotUpdateCurrentSound()
{
if (QFile::exists(m_tmpThumbFile)) {
KIO::SimpleJob *job = KIO::file_delete(m_tmpThumbFile);
job->exec();
}
if (!m_autoPlay->isChecked())
m_currentService->stopItemPreview(NULL);
item_license->clear();
......@@ -197,10 +197,11 @@ void ResourceWidget::slotLoadThumb(const QString &url)
{
QUrl img(url);
if (img.isEmpty()) return;
if (QFile::exists(img.path())) {
KIO::FileCopyJob *copyjob = KIO::file_copy(img, QUrl(m_tmpThumbFile));
m_tmpThumbFile->close();
if (m_tmpThumbFile->open()) {
KIO::FileCopyJob *copyjob = KIO::file_copy(img, QUrl::fromLocalFile(m_tmpThumbFile->fileName()), -1, KIO::Overwrite);
if (copyjob->exec()) {
slotSetImage(m_tmpThumbFile);
slotSetImage(m_tmpThumbFile->fileName());
/*QPixmap pix(tmpFile);
int newHeight = pix.height() * item_image->width() / pix.width();
......
......@@ -34,6 +34,7 @@
class KPixmapSequenceOverlayPainter;
class QAction;
class QNetworkConfigurationManager;
class QTemporaryFile;
class ResourceWidget : public QDialog, public Ui::FreeSound_UI
{
......@@ -76,7 +77,7 @@ private:
OnlineItemInfo m_currentInfo;
KPixmapSequenceOverlayPainter *m_busyWidget;
QAction *m_autoPlay;
QString m_tmpThumbFile;
QTemporaryFile *m_tmpThumbFile;
QString m_title;
QString m_image;
QString m_desc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment