#include "pluginBase.h"
#include <QTranslator>
#include <QSettings>
#include <QCoreApplication>

#include <windows.h>
#include <WinBase.h>



namespace Plugins
{

PluginBase::PluginBase()
{
    _translator = new QTranslator;
}

PluginBase::~PluginBase()
{
    if (_translator != nullptr) delete _translator;
}

void PluginBase::setFileName(QString f)
{
    _libFileName = f;
}

QString PluginBase::getFileName()
{
    return _libFileName;
}

Plugins::PluginType PluginBase::getPluginType()
{
    return _pluginType;
}

void PluginBase::readINI(QSettings* settings)
{
    Q_UNUSED(settings)
}
void PluginBase::writeINI(QSettings*)
{

}

void PluginBase::setWinModule(HMODULE m)
{
    _winModule = m;
}

HMODULE PluginBase::getWinModule()
{
    return _winModule;
}


QString PluginBase::getDescribe()
{
    return _describe;
}

bool PluginBase::uninstall()
{
    QString path = qApp->applicationDirPath();
    QSettings settingwrite(path + "/RasterSetting.ini", QSettings::IniFormat);
    this->writeINI(&settingwrite);

    return false;
}

bool PluginBase::install()
{
    QString path = qApp->applicationDirPath();
    QSettings settingreader(path + "/RasterSetting.ini", QSettings::IniFormat);
    this->readINI(&settingreader);

    return false;
}

void PluginBase::reTranslate(QString lang)
{
    qDebug() << lang;
}

void PluginBase::exec(int commandType)
{
    Q_UNUSED(commandType)
}
  
void PluginBase::setType(PluginType t)
{
    _pluginType = t;
}

Plugins::PluginType PluginBase::getType()
{
    return _pluginType;
}


void PluginBase::writeToProjectFile(QDomDocument* doc, QDomElement* parent)
{
    Q_UNUSED(doc)
    Q_UNUSED(parent)
}

void PluginBase::readFromProjectFile(QDomElement* parentEle)
{
    Q_UNUSED(parentEle)
}

bool PluginBase::hasInfoToSave()
{
    return false;
}

}


