#ifndef LOGICMAIN_H
#define LOGICMAIN_H

#include <QObject>
#include <QMutex>
#include <QHash>
#include <QGSettings/QGSettings>
#include <QDBusMessage>
#include <QDBusConnection>

class LogicMain : public QObject
{
    Q_OBJECT
public:
    enum Busness
    {
        CreateISO = 0,
        BurnData,
        BurnUDFData,
        AddBurn,
        BurnImage,
        CopyData,
        GetISO

    };
public:
    static LogicMain *instance();
public:
    LogicMain(const LogicMain*)=delete;
    LogicMain *operator =(const LogicMain*)=delete;
public:
    void init(){}
    void destroy() { emit exit(); delete this; }
    void initISO();
    QString theme();
    QString icon();
private:
    explicit LogicMain(QObject *parent = nullptr);
    ~LogicMain();
private slots:
    void createCDROM(QString);
    void changeCDROM(QString);
    void removeCDROM(QString);
    void slotsEmptyMedium();
    void slotsAppendableMedium();
    void slotsFinishedMedium();
    void slotsMenuBurnSetting();
    void slotsSetBusness(int);
    void slotsDoBusness();
    void slotsDataSetting();
    void slotsDiskCheck();
    void slotsHelp();
private:
    static LogicMain     *m_oInstance;
    static QMutex         m_oMutex;
private:
    int                   m_iBusness;
    QString               m_oCurrentIcon;
    QGSettings           *m_oTheme;
    QHash<QString, void*> m_oCDROMS;
    QDBusMessage          msg;
signals:
    // log
    void info(QString); void warn(QString);
    void error(QString); void debug(QString);
    // logic
    void cdrom(void *);
    void createISO(void *);
    void createCopyImage(void *);
    void noMedium(void *);
    void emptyMedium(void *);
    void appendableMedium(void *);
    void finishedMedium(void *);
    void deleteCDROM(void *);
    // busness
    void createISO(); void burnData(); void addBurn();
    void burnImage(); void burnUDFData();
    void copyData(); void getISO();
    // menu
    void menu(void*);
    void burnDataSetting();
    void burnImageSetting();
    void burnCopySetting();
    // mainwindow position
    //void position(QPoint);
    // other
    void storagePath(QString);
    void iconChange(QIcon);
    void exit();
};

#define MAIN LogicMain::instance()

#endif // LOGICMAIN_H
