43 lines
1004 B
C++
43 lines
1004 B
C++
|
|
#ifndef PLUGINIMPORTER_H
|
||
|
|
#define PLUGINIMPORTER_H
|
||
|
|
|
||
|
|
#include <QObject>
|
||
|
|
#include <QString>
|
||
|
|
|
||
|
|
class ExtensionHost;
|
||
|
|
|
||
|
|
class PluginImporter : public QObject
|
||
|
|
{
|
||
|
|
Q_OBJECT
|
||
|
|
public:
|
||
|
|
explicit PluginImporter(ExtensionHost *extHost, QObject *parent = nullptr);
|
||
|
|
|
||
|
|
enum ImportResult {
|
||
|
|
Success = 0,
|
||
|
|
InvalidPlugin,
|
||
|
|
FileNotFound,
|
||
|
|
CopyFailed,
|
||
|
|
AlreadyExists,
|
||
|
|
LoadFailed
|
||
|
|
};
|
||
|
|
|
||
|
|
ImportResult importFromDirectory(const QString &dirPath);
|
||
|
|
ImportResult importFromZip(const QString &zipPath);
|
||
|
|
QString lastError() const { return m_lastError; }
|
||
|
|
|
||
|
|
signals:
|
||
|
|
void importProgress(const QString &step, int percent);
|
||
|
|
void importCompleted(const QString &pluginName, bool success);
|
||
|
|
void importError(const QString &error);
|
||
|
|
|
||
|
|
private:
|
||
|
|
ImportResult copyPluginFiles(const QString &sourceDir, const QString &targetDir);
|
||
|
|
bool validatePlugin(const QString &dirPath);
|
||
|
|
|
||
|
|
ExtensionHost *m_extHost;
|
||
|
|
QString m_lastError;
|
||
|
|
QString m_pluginsDir;
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif
|