#ifndef PROCESSBASIC_H
#define PROCESSBASIC_H

#include <QObject>
#include <QProcess>
#include <QIcon>
#include <QTimer>

class ProcessBasic : public QObject
{
    Q_OBJECT
    enum ProcessStep
    {
        Prepare = 0,
        Config,
        Working,
        Worked
    };

Q_SIGNALS:
    // progress
    void title(QString);
    void setRange(int, int);
    void setValue(int, QIcon icon = QIcon(), QString str = QString());
    void addValue(int, QIcon icon = QIcon(), QString str = QString());
    void cancel(bool);

    // tip
    void success(QString);
    void fail(QString);
    void eject();
    void umountfail(QString);
public:
    ProcessBasic(QObject *parent = nullptr);
    ~ProcessBasic();
public:
    virtual void exec();
protected:
    virtual bool prepare();
    virtual bool config();
    virtual bool working();
    virtual bool worked();
protected slots:
    virtual void slotsCancel();
    virtual void slotsStart() = 0;
    virtual void slotsOutput() = 0;
    virtual void slotsError() = 0;
    virtual void slotsFinished(int,QProcess::ExitStatus) = 0;
    virtual void slotsExit();
private:
    void connection();
protected:
    unsigned int    m_u32Icon;
    bool            m_bCancel;
    bool            m_umountError;
    QString         m_umountErrorStr;
    bool            m_oKeep;
    QProcess       *m_oProcess;
    QString         m_oProcessName;
    QString         m_oDeviceBlock;
    QString         m_oSrcDeviceBlock; /* 刻录镜像功能 */
    QString         m_oDesDeviceBlock; /* 刻录镜像功能 */
    QStringList     m_oArguments;
    QIcon           m_oIcon;
    QString         m_lastErrorMsg;
};

#endif // PROCESSBASIC_H
