Show rendering progress in the correct Kdenlive instance:

http://www.kdenlive.org/mantis/view.php?id=1265

svn path=/trunk/kdenlive/; revision=5936
parent e171db6f
......@@ -32,6 +32,7 @@ int main(int argc, char **argv)
QStringList args = app.arguments();
QStringList preargs;
QString locale;
int pid = 0;
int in = -1;
int out = -1;
if (args.count() >= 7) {
......@@ -48,6 +49,11 @@ int main(int argc, char **argv)
usekuiserver = true;
args.removeFirst();
}
if (QString(args.at(0)).startsWith("-pid:")) {
pid = QString(args.at(0)).section(':', 1).toInt();
args.removeFirst();
}
if (QString(args.at(0)).startsWith("-locale:")) {
locale = QString(args.at(0)).section(':', 1);
args.removeFirst();
......@@ -90,14 +96,14 @@ int main(int argc, char **argv)
}
qDebug() << "//STARTING RENDERING: " << erase << "," << usekuiserver << "," << render << "," << profile << "," << rendermodule << "," << player << "," << src << "," << dest << "," << preargs << "," << args << "," << in << "," << out ;
RenderJob *job = new RenderJob(doerase, usekuiserver, render, profile, rendermodule, player, src, dest, preargs, args, in, out);
RenderJob *job = new RenderJob(doerase, usekuiserver, pid, render, profile, rendermodule, player, src, dest, preargs, args, in, out);
if (!locale.isEmpty()) job->setLocale(locale);
job->start();
if (dualpass) {
if (vprelist.size()>1)
args.replaceInStrings(QRegExp("^vpre=.*"),QString("vpre=").append(vprelist.at(1)));
args.replace(args.indexOf("pass=1"), "pass=2");
RenderJob *dualjob = new RenderJob(erase, usekuiserver, render, profile, rendermodule, player, src, dest, preargs, args, in, out);
RenderJob *dualjob = new RenderJob(erase, usekuiserver, pid, render, profile, rendermodule, player, src, dest, preargs, args, in, out);
QObject::connect(job, SIGNAL(renderingFinished()), dualjob, SLOT(start()));
}
app.exec();
......
......@@ -38,14 +38,14 @@ public:
}
};
static QDBusConnection connection(QLatin1String(""));
RenderJob::RenderJob(bool erase, bool usekuiserver, const QString& renderer, const QString& profile, const QString& rendermodule, const QString& player, const QString& scenelist, const QString& dest, const QStringList& preargs, const QStringList& args, int in, int out) :
RenderJob::RenderJob(bool erase, bool usekuiserver, int pid, const QString& renderer, const QString& profile, const QString& rendermodule, const QString& player, const QString& scenelist, const QString& dest, const QStringList& preargs, const QStringList& args, int in, int out) :
QObject(),
m_jobUiserver(NULL),
m_kdenliveinterface(NULL),
m_usekuiserver(usekuiserver),
m_enablelog(false)
m_enablelog(false),
m_pid(pid)
{
m_scenelist = scenelist;
m_dest = dest;
......@@ -233,16 +233,24 @@ void RenderJob::start()
if (interface->isServiceRegistered("org.kde.JobViewServer")) {
QDBusInterface kuiserver("org.kde.JobViewServer", "/JobViewServer", "org.kde.JobViewServer");
QDBusReply<QDBusObjectPath> objectPath = kuiserver.call("requestView", "kdenlive", "kdenlive", 0x0001);
QDBusReply<QDBusObjectPath> objectPath = kuiserver.call("requestView", "Kdenlive", "kdenlive", 0x0001);
QString reply = ((QDBusObjectPath) objectPath).path();
m_jobUiserver = new QDBusInterface("org.kde.JobViewServer", reply, "org.kde.JobView");
if (m_jobUiserver) {
// Use of the KDE JobViewServer is an ugly hack, it is not reliable
QString dbusView = "org.kde.JobViewV2";
m_jobUiserver = new QDBusInterface("org.kde.JobViewServer", reply, dbusView);
if (!m_jobUiserver || !m_jobUiserver->isValid()) {
dbusView = "org.kde.JobView";
m_jobUiserver = new QDBusInterface("org.kde.JobViewServer", reply, dbusView);
}
if (m_jobUiserver && m_jobUiserver->isValid()) {
m_startTime = QTime::currentTime();
if (!m_args.contains("pass=2"))
m_jobUiserver->call("setPercent", (uint) 0);
m_jobUiserver->call("setInfoMessage", tr("Rendering %1").arg(QFileInfo(m_dest).fileName()));
//m_jobUiserver->call("setDescriptionField", (uint) 0, tr("Rendering to"), m_dest);
QDBusConnection::sessionBus().connect("org.kde.JobViewServer", reply, "org.kde.JobView", "cancelRequested", this, SLOT(slotAbort()));
//m_jobUiserver->call("setInfoMessage", tr("Rendering %1").arg(QFileInfo(m_dest).fileName()));
m_jobUiserver->call("setDescriptionField", (uint) 0, tr("Rendering"), m_dest);
QDBusConnection::sessionBus().connect("org.kde.JobViewServer", reply, dbusView, "cancelRequested", this, SLOT(slotAbort()));
}
}
}
......@@ -269,12 +277,17 @@ void RenderJob::initKdenliveDbusInterface()
QString kdenliveId;
QDBusConnection connection = QDBusConnection::sessionBus();
QDBusConnectionInterface* ibus = connection.interface();
const QStringList services = ibus->registeredServiceNames();
foreach(const QString & service, services) {
if (!service.startsWith("org.kde.kdenlive"))
continue;
kdenliveId = service;
break;
kdenliveId = QString("org.kde.kdenlive-%1").arg(m_pid);
if (!ibus->isServiceRegistered(kdenliveId))
{
kdenliveId.clear();
const QStringList services = ibus->registeredServiceNames();
foreach(const QString & service, services) {
if (!service.startsWith("org.kde.kdenlive"))
continue;
kdenliveId = service;
break;
}
}
m_dbusargs.clear();
if (kdenliveId.isEmpty()) return;
......
......@@ -34,7 +34,7 @@ class RenderJob : public QObject
Q_OBJECT
public:
RenderJob(bool erase, bool usekuiserver, const QString& renderer, const QString& profile, const QString& rendermodule, const QString& player, const QString& scenelist, const QString& dest, const QStringList& preargs, const QStringList& args, int in = -1, int out = -1);
RenderJob(bool erase, bool usekuiserver, int pid, const QString& renderer, const QString& profile, const QString& rendermodule, const QString& player, const QString& scenelist, const QString& dest, const QStringList& preargs, const QStringList& args, int in = -1, int out = -1);
~RenderJob();
void setLocale(const QString &locale);
......@@ -70,6 +70,8 @@ private:
QTemporaryFile m_logfile;
/** @brief Used to write to the log file. */
QTextStream m_logstream;
/** @brief The process id of the Kdenlive instance, used to get the dbus service. */
int m_pid;
signals:
void renderingFinished();
......
......@@ -773,6 +773,9 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
if (!scriptExport) render_process_args << "-erase";
if (KdenliveSettings::usekuiserver()) render_process_args << "-kuiserver";
// get process id
render_process_args << QString("-pid:%1").arg(QCoreApplication::applicationPid());
// Set locale for render process if required
if (QLocale().decimalPoint() != QLocale::system().decimalPoint()) {
render_process_args << QString("-locale:%1").arg(QLocale().name());
......
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