MCPcopy Create free account
hub / github.com/KDE/kdenlive / processDownload

Method processDownload

src/pythoninterfaces/dialogs/modeldownloadwidget.cpp:51–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void ModelDownloadWidget::processDownload()
52{
53 m_args.prepend(m_scriptPath);
54 QProcess scriptJob;
55
56 connect(this, &ModelDownloadWidget::abortScript, &scriptJob, &QProcess::kill, Qt::DirectConnection);
57 scriptJob.setProcessChannelMode(QProcess::MergedChannels);
58 QMetaObject::Connection readConnection = connect(&scriptJob, &QProcess::readyReadStandardOutput, this, [this, &scriptJob]() {
59 if (scriptJob.state() == QProcess::NotRunning) {
60 return;
61 }
62 const QString processData = QString::fromUtf8(scriptJob.readAllStandardOutput());
63 Q_EMIT installFeedback(processData);
64 if (processData.contains(QLatin1Char('%'))) {
65 bool ok;
66 int progress = processData.section(QLatin1Char('%'), 0, 0).section(QLatin1Char(' '), -1).simplified().toInt(&ok);
67 if (ok && progress != m_downloadProgress) {
68 if (m_downloadProgress == -1) {
69 QMetaObject::invokeMethod(m_pb, "setRange", Q_ARG(int, 0), Q_ARG(int, 100));
70 }
71 // Display download progress
72 m_downloadProgress = progress;
73 QMetaObject::invokeMethod(m_pb, "setValue", Q_ARG(int, m_downloadProgress));
74 }
75 }
76 });
77 scriptJob.start(m_engine->venvPythonExecs().python, m_args);
78 // Don't timeout
79 scriptJob.waitForFinished(-1);
80 // Disconnect read
81 QObject::disconnect(readConnection);
82 QMetaObject::invokeMethod(m_pb, "setVisible", Q_ARG(bool, false));
83 if (scriptJob.exitStatus() != QProcess::NormalExit || scriptJob.exitCode() != 0) {
84 const QString errorMessage = scriptJob.readAllStandardOutput();
85 Q_EMIT installFeedback(i18n("Error downloading model:\n %1\n%2", m_scriptPath, errorMessage));
86 Q_EMIT jobDone(false);
87 return;
88 }
89 QMetaObject::invokeMethod(this, "jobSuccess");
90 Q_EMIT jobDone(true);
91}
92
93void ModelDownloadWidget::jobSuccess()
94{

Callers

nothing calls this directly

Calls 3

containsMethod · 0.45
startMethod · 0.45
venvPythonExecsMethod · 0.45

Tested by

no test coverage detected