Commit ba9ea12d authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix compilation with KF5 < 5.71

parent a391cdff
Pipeline #50098 canceled with stage
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "mlt++/MltTractor.h" #include "mlt++/MltTractor.h"
#include "mlt++/MltConsumer.h" #include "mlt++/MltConsumer.h"
#include <kio_version.h>
#include <QFontDatabase> #include <QFontDatabase>
#include <QDir> #include <QDir>
#include <QProcess> #include <QProcess>
...@@ -38,7 +39,9 @@ ...@@ -38,7 +39,9 @@
#include <KZip> #include <KZip>
#include <KTar> #include <KTar>
#include <KIO/FileCopyJob> #include <KIO/FileCopyJob>
#if KIO_VERSION > QT_VERSION_CHECK(5, 70, 0)
#include <KIO/OpenUrlJob> #include <KIO/OpenUrlJob>
#endif
#include <KIO/JobUiDelegate> #include <KIO/JobUiDelegate>
#include <KArchiveDirectory> #include <KArchiveDirectory>
#include <KMessageWidget> #include <KMessageWidget>
...@@ -61,11 +64,13 @@ SpeechDialog::SpeechDialog(const std::shared_ptr<TimelineItemModel> &timeline, Q ...@@ -61,11 +64,13 @@ SpeechDialog::SpeechDialog(const std::shared_ptr<TimelineItemModel> &timeline, Q
}); });
connect(dict_info, &KMessageWidget::linkActivated, [&](const QString &contents) { connect(dict_info, &KMessageWidget::linkActivated, [&](const QString &contents) {
qDebug()<<"=== LINK CLICKED: "<<contents; qDebug()<<"=== LINK CLICKED: "<<contents;
#if KIO_VERSION > QT_VERSION_CHECK(5, 70, 0)
auto *job = new KIO::OpenUrlJob(QUrl(contents)); auto *job = new KIO::OpenUrlJob(QUrl(contents));
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
// methods like setRunExecutables, setSuggestedFilename, setEnableExternalBrowser, setFollowRedirections // methods like setRunExecutables, setSuggestedFilename, setEnableExternalBrowser, setFollowRedirections
// exist in both classes // exist in both classes
job->start(); job->start();
#endif
}); });
//TODO: check for the python scripts vosk and srt //TODO: check for the python scripts vosk and srt
...@@ -76,7 +81,10 @@ void SpeechDialog::slotProcessSpeech(const std::shared_ptr<TimelineItemModel> &t ...@@ -76,7 +81,10 @@ void SpeechDialog::slotProcessSpeech(const std::shared_ptr<TimelineItemModel> &t
{ {
QString pyExec = QStandardPaths::findExecutable(QStringLiteral("python3")); QString pyExec = QStandardPaths::findExecutable(QStringLiteral("python3"));
if (pyExec.isEmpty()) { if (pyExec.isEmpty()) {
//TODO speech_info->setMessageType(KMessageWidget::Warning);
speech_info->setText(i18n("Cannot find python3, please install it on your system."));
speech_info->animatedShow();
return;
} }
speech_info->setMessageType(KMessageWidget::Information); speech_info->setMessageType(KMessageWidget::Information);
speech_info->setText(i18n("Starting audio export")); speech_info->setText(i18n("Starting audio export"));
...@@ -85,9 +93,9 @@ void SpeechDialog::slotProcessSpeech(const std::shared_ptr<TimelineItemModel> &t ...@@ -85,9 +93,9 @@ void SpeechDialog::slotProcessSpeech(const std::shared_ptr<TimelineItemModel> &t
QString sceneList; QString sceneList;
QString speech; QString speech;
QString audio; QString audio;
QTemporaryFile tmpPlaylist(QDir::tempPath() + QStringLiteral("/XXXXXX.mlt")); QTemporaryFile tmpPlaylist(QDir::temp().absoluteFilePath(QStringLiteral("XXXXXX.mlt")));
QTemporaryFile tmpSpeech(QDir::tempPath() + QStringLiteral("/XXXXXX.srt")); QTemporaryFile tmpSpeech(QDir::temp().absoluteFilePath(QStringLiteral("XXXXXX.srt")));
QTemporaryFile tmpAudio(QDir::tempPath() + QStringLiteral("/XXXXXX.wav")); QTemporaryFile tmpAudio(QDir::temp().absoluteFilePath(QStringLiteral("XXXXXX.wav")));
if (tmpPlaylist.open()) { if (tmpPlaylist.open()) {
sceneList = tmpPlaylist.fileName(); sceneList = tmpPlaylist.fileName();
} }
...@@ -126,6 +134,12 @@ void SpeechDialog::slotProcessSpeech(const std::shared_ptr<TimelineItemModel> &t ...@@ -126,6 +134,12 @@ void SpeechDialog::slotProcessSpeech(const std::shared_ptr<TimelineItemModel> &t
qDebug()<<"=== STARTING RENDER D"; qDebug()<<"=== STARTING RENDER D";
QString language = language_box->currentText(); QString language = language_box->currentText();
QString speechScript = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("scripts/speech.py")); QString speechScript = QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("scripts/speech.py"));
if (speechScript.isEmpty()) {
speech_info->setMessageType(KMessageWidget::Warning);
speech_info->setText(i18n("The speech script was not found, check your install."));
speech_info->animatedShow();
return;
}
qDebug()<<"=== RUNNING SPEECH ANALYSIS: "<<speechScript; qDebug()<<"=== RUNNING SPEECH ANALYSIS: "<<speechScript;
QProcess speechJob; QProcess speechJob;
......
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