#include "processopenfile.h"

ProcessOpenFile::ProcessOpenFile(QString path, QObject *parent) :
    ProcessBasic(parent)
{
    m_oArguments << path;
}

void ProcessOpenFile::setFile(QString path)
{
    m_oArguments.clear();
    m_oArguments << path;
}

void ProcessOpenFile::exec()
{
    prepare();
    m_oProcess->setArguments(m_oArguments);
    m_oProcess->start();
    connect(m_oProcess, SIGNAL(started()), this, SLOT(slotsStart()));
    connect(m_oProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(slotsOutput()));
    connect(m_oProcess, SIGNAL(readyReadStandardError()), this, SLOT(slotsError()));
    connect(m_oProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotsFinished(int,QProcess::ExitStatus)));
}

bool ProcessOpenFile::prepare()
{
    m_oProcess->setProgram("xdg-open");
    return true;
}

void ProcessOpenFile::slotsError()
{
}

void ProcessOpenFile::slotsFinished(int errCode, QProcess::ExitStatus status)
{
}

ProcessOpenFile::~ProcessOpenFile()
{}
