File indexing completed on 2024-12-08 04:27:17

0001 /*
0002     SPDX-FileCopyrightText: 2022 Meltytech, LLC
0003     SPDX-FileCopyrightText: 2022 Julius Künzel <jk.kdedev@smartlab.uber.space>
0004 
0005     SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #pragma once
0009 
0010 #include <QLocalServer>
0011 #include <QLocalSocket>
0012 #include <QObject>
0013 #include <QPoint>
0014 #include <QSharedMemory>
0015 #include <mlt++/MltProducer.h>
0016 
0017 class ProjectClip;
0018 
0019 class GlaxnimateLauncher : public QObject
0020 {
0021     Q_OBJECT
0022 
0023     class ParentResources
0024     {
0025     public:
0026         std::shared_ptr<ProjectClip> m_binClip;
0027         int m_frameNum = -1;
0028         int m_clipId = -1;
0029     };
0030 
0031 public:
0032     static GlaxnimateLauncher &instance();
0033     bool checkInstalled();
0034     void openFile(const QString &url);
0035     void openClip(int clipId);
0036 
0037 private:
0038     std::unique_ptr<ParentResources> m_parent;
0039     std::unique_ptr<QDataStream> m_stream;
0040     std::unique_ptr<QLocalServer> m_server;
0041     std::unique_ptr<QSharedMemory> m_sharedMemory;
0042     bool m_isProtocolValid = false;
0043     QLocalSocket *m_socket;
0044 
0045     bool copyToShared(const QImage &image);
0046     void reset();
0047 
0048 private Q_SLOTS:
0049     void onConnect();
0050     void onReadyRead();
0051     void onSocketError(QLocalSocket::LocalSocketError socketError);
0052 };