Commit b520e187 authored by Vincent Pinon's avatar Vincent Pinon
Browse files

invert option switch, fix Dbus ON mode, abort job in OFF

parent 72777c5d
......@@ -24,7 +24,7 @@ option(RELEASE_BUILD "Remove Git revision from program version" ON)
option(BUILD_TESTING "Build tests" ON)
option(CRASH_AUTO_TEST "Auto-generate testcases upon some crashes (uses RTTR library, needed for fuzzing)" OFF)
option(BUILD_FUZZING "Build fuzzing target" OFF)
option(USE_DBUS "Build with DBus IPC" ON)
option(NODBUS "Build without DBus IPC" OFF)
# Minimum versions of main dependencies.
set(MLT_MIN_MAJOR_VERSION 7)
......@@ -54,8 +54,8 @@ find_package(KF5 REQUIRED COMPONENTS Archive Bookmarks CoreAddons Config ConfigW
# Qt
set(QT_MIN_VERSION 5.11.0)
find_package(Qt5 REQUIRED COMPONENTS Core DBus Widgets Svg Quick QuickControls2 Concurrent QuickWidgets Multimedia NetworkAuth)
if(USE_DBUS)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Svg Quick QuickControls2 Concurrent QuickWidgets Multimedia NetworkAuth)
if(NOT NODBUS)
find_package(KF5 REQUIRED COMPONENTS DBusAddons)
find_package(Qt5 REQUIRED COMPONENTS DBus)
endif()
......
set(QT_DONT_USE_QTGUI 1)
if(USE_DBUS)
if(NOT NODBUS)
set(QT_USE_QTDBUS 1)
endif()
include_directories(
......@@ -16,14 +16,14 @@ set(kdenlive_render_SRCS
add_executable(kdenlive_render ${kdenlive_render_SRCS})
ecm_mark_nongui_executable(kdenlive_render)
target_link_libraries(kdenlive_render Qt5::Core Qt5::Widgets Qt5::DBus Qt5::Xml
target_link_libraries(kdenlive_render Qt5::Core Qt5::Widgets Qt5::Xml
${MLT_LIBRARIES}
${MLTPP_LIBRARIES})
if(USE_DBUS)
target_link_libraries(kdenlive_render Qt5::DBus)
target_compile_definitions(kdenlive_render PRIVATE USE_DBUS)
else()
if(NODBUS)
target_compile_definitions(kdenlive_render PRIVATE NODBUS)
target_link_libraries(kdenlive_render Qt5::Network)
else()
target_link_libraries(kdenlive_render Qt5::DBus)
endif()
install(TARGETS kdenlive_render DESTINATION ${BIN_INSTALL_DIR})
......@@ -22,7 +22,7 @@
#include <QFile>
#include <QStringList>
#include <QThread>
#ifdef USE_DBUS
#ifndef NODBUS
#include <QtDBus>
#else
#include <QJsonObject>
......@@ -47,7 +47,7 @@ RenderJob::RenderJob(const QString &render, const QString &scenelist, const QStr
, m_progress(0)
, m_prog(std::move(render))
, m_player()
#ifdef USE_DBUS
#ifndef NODBUS
, m_jobUiserver(nullptr)
, m_kdenliveinterface(nullptr)
#else
......@@ -87,7 +87,7 @@ RenderJob::RenderJob(const QString &render, const QString &scenelist, const QStr
RenderJob::~RenderJob()
{
#ifdef USE_DBUS
#ifndef NODBUS
delete m_jobUiserver;
delete m_kdenliveinterface;
#else
......@@ -108,7 +108,7 @@ void RenderJob::slotAbort(const QString &url)
}
void RenderJob::sendFinish(int status, QString error) {
#ifdef USE_DBUS
#ifndef NODBUS
if (m_kdenliveinterface) {
m_kdenliveinterface->callWithArgumentList(QDBus::NoBlock, QStringLiteral("setRenderingFinished"), {m_dest, status, error});
}
......@@ -119,23 +119,19 @@ void RenderJob::sendFinish(int status, QString error) {
m_jobUiserver->call(QStringLiteral("terminate"), QString());
}
#else
if (m_kdenlivesocket) {
QJsonObject method, args;
args["url"] = m_dest;
args["status"] = status;
args["error"] = error;
method["setRenderingFinished"] = args;
m_kdenlivesocket->write(QJsonDocument(method).toJson());
m_kdenlivesocket->flush();
}
QJsonObject method, args;
args["url"] = m_dest;
args["status"] = status;
args["error"] = error;
method["setRenderingFinished"] = args;
m_kdenlivesocket->write(QJsonDocument(method).toJson());
m_kdenlivesocket->flush();
#endif
}
void RenderJob::slotAbort()
{
qWarning() << "Job aborted by user...";
m_renderProcess->kill();
sendFinish(-3, QString());
if (m_erase) {
QFile(m_scenelist).remove();
......@@ -144,7 +140,9 @@ void RenderJob::slotAbort()
m_logstream << "Job aborted by user" << "\n";
m_logstream.flush();
m_logfile.close();
//qApp->quit();
#ifndef NODBUS
qApp->quit();
#endif
}
void RenderJob::receivedStderr()
......@@ -165,13 +163,13 @@ void RenderJob::receivedStderr()
} else if (m_args.contains(QStringLiteral("pass=2"))) {
m_progress = 50 + m_progress / 2;
}
#ifdef USE_DBUS
qint64 elapsedTime = m_startTime.secsTo(QDateTime::currentDateTime());
if (elapsedTime == m_seconds) {
return;
}
int speed = (frame - m_frame) / (elapsedTime - m_seconds);
m_seconds = elapsedTime;
#ifndef NODBUS
if ((m_kdenliveinterface != nullptr) && m_kdenliveinterface->isValid()) {
m_kdenliveinterface->callWithArgumentList(QDBus::NoBlock, QStringLiteral("setRenderingProgress"), {m_dest, m_progress, frame});
}
......@@ -187,30 +185,28 @@ void RenderJob::receivedStderr()
est.append(when.toString(QStringLiteral("hh:mm:ss")));
m_jobUiserver->call(QStringLiteral("setPercent"), uint(m_progress));
m_jobUiserver->call(QStringLiteral("setDescriptionField"), 0, QString(), est);
m_jobUiserver->call(QStringLiteral("setProcessedAmount"), qulonglong(frame - m_framein), tr("frames"));
m_jobUiserver->call(QStringLiteral("setSpeed"), qulonglong(speed));
m_jobUiserver->call(QStringLiteral("setDescriptionField"), 0, QString(), est);
}
m_logstream << QStringLiteral("%1\t%2\t%3\n").arg(m_seconds).arg(m_frame).arg(m_progress);
#else
if (m_kdenlivesocket) {
QJsonObject method, args;
args["url"] = m_dest;
args["progress"] = m_progress;
args["frame"] = frame;
method["setRenderingProgress"] = args;
m_kdenlivesocket->write(QJsonDocument(method).toJson());
m_kdenlivesocket->flush();
}
QJsonObject method, args;
args["url"] = m_dest;
args["progress"] = m_progress;
args["frame"] = frame;
method["setRenderingProgress"] = args;
m_kdenlivesocket->write(QJsonDocument(method).toJson());
m_kdenlivesocket->flush();
#endif
m_frame = frame;
m_logstream << QStringLiteral("%1\t%2\t%3\n").arg(m_seconds).arg(m_frame).arg(m_progress);
}
}
void RenderJob::start()
{
m_startTime = QDateTime::currentDateTime();
#ifdef USE_DBUS
#ifndef NODBUS
QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface();
if ((interface != nullptr) && m_usekuiserver) {
if (!interface->isServiceRegistered(QStringLiteral("org.kde.JobViewServer"))) {
......@@ -279,13 +275,12 @@ void RenderJob::start()
m_logstream.flush();
}
#ifdef USE_DBUS
#ifndef NODBUS
void RenderJob::initKdenliveDbusInterface()
{
QString kdenliveId;
QString kdenliveId = QStringLiteral("org.kde.kdenlive-%1").arg(m_pid);
QDBusConnection connection = QDBusConnection::sessionBus();
QDBusConnectionInterface *ibus = connection.interface();
kdenliveId = QStringLiteral("org.kde.kdenlive-%1").arg(m_pid);
if (!ibus->isServiceRegistered(kdenliveId)) {
kdenliveId.clear();
const QStringList services = ibus->registeredServiceNames();
......
......@@ -20,10 +20,10 @@
#ifndef RENDERJOB_H
#define RENDERJOB_H
#ifdef USE_DBUS
#include <QDBusInterface>
#else
#ifdef NODBUS
#include <QLocalSocket>
#else
#include <QDBusInterface>
#endif
#include <QObject>
#include <QProcess>
......@@ -56,11 +56,11 @@ private:
int m_progress;
QString m_prog;
QString m_player;
#ifdef USE_DBUS
#ifdef NODBUS
QLocalSocket* m_kdenlivesocket;
#else
QDBusInterface *m_jobUiserver;
QDBusInterface *m_kdenliveinterface;
#else
QLocalSocket* m_kdenlivesocket;
#endif
bool m_usekuiserver;
/** @brief Used to create a temporary file for logging. */
......@@ -80,10 +80,10 @@ private:
QStringList m_args;
/** @brief Used to write to the log file. */
QTextStream m_logstream;
#ifdef USE_DBUS
void initKdenliveDbusInterface();
#else
#ifdef NODBUS
void fromServer();
#else
void initKdenliveDbusInterface();
#endif
void sendFinish(int status, QString error);
void sendProgress();
......
......@@ -77,7 +77,7 @@ list(APPEND kdenlive_SRCS ${top_SRCS})
kconfig_add_kcfg_files(kdenlive_SRCS kdenlivesettings.kcfgc)
install(FILES kdenlivesettings.kcfg DESTINATION ${KCFG_INSTALL_DIR})
ecm_qt_declare_logging_category(kdenlive_SRCS HEADER kdenlive_debug.h IDENTIFIER KDENLIVE_LOG CATEGORY_NAME org.kde.multimedia.kdenlive)
if(USE_DBUS)
if(NOT NODBUS)
qt5_add_dbus_adaptor(kdenlive_SRCS org.kdenlive.MainWindow.xml mainwindow.h MainWindow)
else()
add_subdirectory(render)
......@@ -150,7 +150,7 @@ target_link_libraries(kdenliveLib
${CMAKE_DL_LIBS}
${CMAKE_THREAD_LIBS_INIT}
kiss_fft)
if(USE_DBUS)
if(NOT NODBUS)
target_link_libraries(kdenliveLib KF5::DBusAddons)
endif()
if(BUILD_COVERAGE)
......@@ -210,8 +210,9 @@ if(HAVE_LINUX_INPUT_H)
target_link_libraries(kdenliveLib media_ctrl)
endif()
if (USE_DBUS)
target_compile_definitions(kdenliveLib PRIVATE -DUSE_DBUS)
if(NODBUS)
target_compile_definitions(kdenliveLib PRIVATE -DNODBUS)
target_compile_definitions(kdenlive PRIVATE -DNODBUS)
endif()
if (BUILD_QCH)
......
......@@ -43,7 +43,7 @@
#include "definitions.h"
#include "kdenlive_debug.h"
#ifdef USE_DBUS
#ifndef NODBUS
#include <KDBusService>
#endif
#include <KIconTheme>
......@@ -160,9 +160,9 @@ int main(int argc, char *argv[])
qputenv("XDG_CURRENT_DESKTOP","KDE");
#endif
#ifdef USE_DBUS
#ifndef NODBUS
// Init DBus services
KDBusService programDBusService();
KDBusService programDBusService;
#endif
bool forceBreeze = grp.readEntry("force_breeze", QVariant(false)).toBool();
if (forceBreeze) {
......
......@@ -46,10 +46,10 @@
#include "layoutmanagement.h"
#include "library/librarywidget.h"
#include "audiomixer/mixermanager.hpp"
#ifdef USE_DBUS
#include "mainwindowadaptor.h"
#else
#ifdef NODBUS
#include "render/renderserver.h"
#else
#include "mainwindowadaptor.h"
#endif
#include "mltconnection.h"
#include "mltcontroller/clipcontroller.h"
......@@ -214,8 +214,9 @@ void MainWindow::init(const QString &mltPath)
}
connect(stylesGroup, &QActionGroup::triggered, this, &MainWindow::slotChangeStyle);
// QIcon::setThemeSearchPaths(QStringList() <<QStringLiteral(":/icons/"));
#ifdef USE_DBUS
#ifdef NODBUS
new RenderServer(this);
#else
new RenderingAdaptor(this);
#endif
QString defaultProfile = KdenliveSettings::default_profile();
......@@ -841,9 +842,6 @@ void MainWindow::init(const QString &mltPath)
}
});
// m_messageLabel->setMessage(QStringLiteral("This is a beta version. Always backup your data"), MltError);
#ifndef USE_DBUS
new RenderServer(this);
#endif
}
void MainWindow::slotThemeChanged(const QString &name)
......@@ -2292,7 +2290,7 @@ void MainWindow::scriptRender(const QString &url)
m_renderWidget->slotPrepareExport(true, url);
}
#ifdef USE_DBUS
#ifndef NODBUS
void MainWindow::exitApp()
{
QApplication::exit(0);
......@@ -3832,7 +3830,7 @@ void MainWindow::slotShutdown()
{
pCore->currentDoc()->setModified(false);
// Call shutdown
#ifdef USE_DBUS
#ifndef NODBUS
QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface();
if ((interface != nullptr) && interface->isServiceRegistered(QStringLiteral("org.kde.ksmserver"))) {
QDBusInterface smserver(QStringLiteral("org.kde.ksmserver"), QStringLiteral("/KSMServer"), QStringLiteral("org.kde.KSMServerInterface"));
......
......@@ -21,7 +21,7 @@
#define MAINWINDOW_H
#include <QComboBox>
#ifdef USE_DBUS
#ifndef NODBUS
#include <QDBusAbstractAdaptor>
#endif
#include <QDockWidget>
......@@ -302,7 +302,7 @@ public slots:
Q_SCRIPTABLE void addTimelineClip(const QString &url);
Q_SCRIPTABLE void addEffect(const QString &effectId);
Q_SCRIPTABLE void scriptRender(const QString &url);
#ifdef USE_DBUS
#ifndef NODBUS
Q_NOREPLY void exitApp();
#endif
......
......@@ -21,6 +21,7 @@ RenderServer::RenderServer(QObject *parent)
} else {
pCore->displayMessage(i18n("Can't open communication with render job %1").arg(servername), ErrorMessage);
}
connect(pCore->window(), &MainWindow::abortRenderJob, this, &RenderServer::abortJob);
}
RenderServer::~RenderServer() {}
......@@ -58,7 +59,7 @@ void RenderServer::jobSent() {
}
}
void RenderServer::abortJob(QString job) {
void RenderServer::abortJob(const QString &job) {
if (m_jobSocket.contains(job)) {
m_jobSocket[job]->write("abort");
m_jobSocket[job]->flush();
......
......@@ -20,7 +20,7 @@ public:
~RenderServer() override;
public slots:
void abortJob(QString job);
void abortJob(const QString &job);
private slots:
void jobConnected();
......
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