gui: Begin IPCPreviewWorker
This commit is contained in:
		
							
								
								
									
										31
									
								
								gui/ipcpreviewworker.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								gui/ipcpreviewworker.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					#include <QtConcurrent>
 | 
				
			||||||
 | 
					#include "ipcpreviewworker.h"
 | 
				
			||||||
 | 
					#include "previewgeneratormapfunctor.h"
 | 
				
			||||||
 | 
					IPCPreviewWorker::IPCPreviewWorker()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void IPCPreviewWorker::start(RenderConfig config, const QVector<RenderTarget> &targets, QLocalSocket *peer)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						connect(&previewWorkerWatcher, &QFutureWatcher<QByteArray>::resultReadyAt, this,
 | 
				
			||||||
 | 
								[peer, this](int index)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									QDataStream stream{peer};
 | 
				
			||||||
 | 
									stream << previewWorkerWatcher.resultAt(index);
 | 
				
			||||||
 | 
									peer->flush();
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
						connect(&previewWorkerWatcher, &QFutureWatcher<QByteArray>::finished, this,
 | 
				
			||||||
 | 
								[peer]
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									/* TODO /
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									/*peer->waitForBytesWritten();
 | 
				
			||||||
 | 
									peer->disconnectFromServer();
 | 
				
			||||||
 | 
									peer->deleteLater();*/
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						auto mapFunctor = new PreviewGeneratorMapFunctor();
 | 
				
			||||||
 | 
						mapFunctor->setRenderConfig(config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						previewWorkerWatcher.setFuture(QtConcurrent::mapped(targets, *mapFunctor));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										20
									
								
								gui/ipcpreviewworker.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								gui/ipcpreviewworker.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
				
			|||||||
 | 
					#ifndef IPCPREVIEWWORKER_H
 | 
				
			||||||
 | 
					#define IPCPREVIEWWORKER_H
 | 
				
			||||||
 | 
					#include <QLocalSocket>
 | 
				
			||||||
 | 
					#include <QFutureWatcher>
 | 
				
			||||||
 | 
					#include "renderconfig.h"
 | 
				
			||||||
 | 
					#include "rendertarget.h"
 | 
				
			||||||
 | 
					#include "previewgenerator.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class IPCPreviewWorker : public QObject
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						Q_OBJECT
 | 
				
			||||||
 | 
					  private:
 | 
				
			||||||
 | 
						QFutureWatcher<QByteArray> previewWorkerWatcher;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  public:
 | 
				
			||||||
 | 
						IPCPreviewWorker();
 | 
				
			||||||
 | 
						void start(RenderConfig config, const QVector<RenderTarget> &targets, QLocalSocket *peer);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // IPCPREVIEWWORKER_H
 | 
				
			||||||
		Reference in New Issue
	
	Block a user