#ifndef MENUFACTORY_H
#define MENUFACTORY_H

#include <QObject>
#include <QMutex>
#include <QAction>
#include <QMenu>

class MenuFactory : public QObject
{
    Q_OBJECT
public:
    static MenuFactory *instance();
public:
    MenuFactory(const MenuFactory*)=delete;
    MenuFactory *operator =(const MenuFactory*)=delete;
public:
    void init(){}
    void destroy(){ if (m_oInstance) delete this; }
public:
    QMenu *getMenu(int);
private:
    explicit MenuFactory(QObject *parent = nullptr);
    ~MenuFactory();
private slots:
    void newCDROM(void *);
    void checkEject(bool);
    void newEarse(void *);
    void removeEarse(void *);
    void takeCDROM(void *);
    void showabout();
private:
    static MenuFactory *m_oInstance;
    static QMutex       m_oMutex;
private:
    QMenu              *m_oSubEject;
    QMenu              *m_oSubErase;
    QAction            *m_oActionSetting;
    QAction            *m_oActionDataSetting;
    QAction            *m_oActionFileFilter;
    QAction            *m_oActionFileFilterView;
    QAction            *m_oActionDiskCheck;
    QAction            *m_oActionBurnerSetting;
    QAction            *m_oActionEject;
    QAction            *m_oActionEarse;
    QAction            *m_oActionVersion;
    QAction            *m_oActionAbout;
    QAction            *m_oActionHelp;
    QAction            *m_oActionExit;
    QAction            *m_oSeparator;
    QList<QAction *>    m_oCommonActions;
    QList<QMenu *>      m_oMenus;
    QList<void *>       m_oEjects;
    QList<QAction *>    m_oEjectActions;
    QList<void *>       m_oErases;
    QList<QAction *>    m_oEraseActions;
signals:
    // log
    void info(QString); void warn(QString);
    void error(QString); void debug(QString);
    // set burn setting
    void setSetting(bool);
    // set view filter file.
    void setViewFilterFile(bool);
    // menu
    void setting(bool);
    void dataSetting(bool);
    void fileFilter(bool);
    void viewFilterFile(bool);
    void diskCheck(bool);
    void burnSetting(bool);
    void eject(bool);
    void eject(QString);
    void earse(bool);
    void earse(QString);
    void version(bool);
    void about(bool);
    void help(bool);
};
#define MENU MenuFactory::instance()
#define GETMENU(bus) MENU->getMenu(bus)
#endif // MENUFACTORY_H
