gui: IpcServer: Use IPCPreviewWorker
This commit is contained in:
parent
6439adffc6
commit
3e03fed1a2
11
gui/ipc.h
11
gui/ipc.h
@ -3,8 +3,13 @@
|
|||||||
|
|
||||||
enum IPCCommand
|
enum IPCCommand
|
||||||
{
|
{
|
||||||
DocOpen,
|
GeneratePreviews = 23,
|
||||||
FileOpen,
|
StopGeneratePreviews,
|
||||||
AddFile,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum IPCReply
|
||||||
|
{
|
||||||
|
FinishedGeneratePreviews,
|
||||||
|
};
|
||||||
|
|
||||||
#endif // IPC_H
|
#endif // IPC_H
|
||||||
|
@ -9,6 +9,9 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "databasefactory.h"
|
#include "databasefactory.h"
|
||||||
#include "../shared/logger.h"
|
#include "../shared/logger.h"
|
||||||
|
#include "renderconfig.h"
|
||||||
|
#include "rendertarget.h"
|
||||||
|
#include "ipcpreviewworker.h"
|
||||||
|
|
||||||
IpcServer::IpcServer()
|
IpcServer::IpcServer()
|
||||||
{
|
{
|
||||||
@ -23,22 +26,34 @@ bool IpcServer::startSpawner(QString socketPath)
|
|||||||
|
|
||||||
void IpcServer::spawnerNewConnection()
|
void IpcServer::spawnerNewConnection()
|
||||||
{
|
{
|
||||||
QScopedPointer<QLocalSocket> socket{this->spawningServer.nextPendingConnection()};
|
QLocalSocket *socket = this->spawningServer.nextPendingConnection();
|
||||||
if(!socket.isNull())
|
connect(socket, &QLocalSocket::disconnected, socket, &QLocalSocket::deleteLater);
|
||||||
|
if(socket != nullptr)
|
||||||
{
|
{
|
||||||
if(!socket->waitForReadyRead())
|
if(!socket->waitForReadyRead())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QDataStream stream(socket.get());
|
QDataStream stream(socket);
|
||||||
IPCCommand command;
|
IPCCommand command;
|
||||||
stream >> command;
|
stream >> command;
|
||||||
if(command == GeneratePreviews)
|
if(command == GeneratePreviews)
|
||||||
{
|
{
|
||||||
|
IPCPreviewWorker *worker = new IPCPreviewWorker();
|
||||||
RenderConfig renderConfig;
|
RenderConfig renderConfig;
|
||||||
QVector<RenderTarget> targets;
|
QVector<RenderTarget> targets;
|
||||||
stream >> renderConfig;
|
|
||||||
stream >> targets;
|
do
|
||||||
|
{
|
||||||
|
/* TODO: this is not entirely robust */
|
||||||
|
socket->waitForReadyRead(100);
|
||||||
|
stream.startTransaction();
|
||||||
|
stream >> renderConfig >> targets;
|
||||||
|
} while(!stream.commitTransaction() && socket->state() == QLocalSocket::ConnectedState);
|
||||||
|
|
||||||
|
stream << targets.count();
|
||||||
|
socket->flush();
|
||||||
|
worker->start(renderConfig, targets, socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user