#ifndef MODALDIALOG_H
#define MODALDIALOG_H

#include <QDialog>
#include <QMutex>
#include <QPoint>

namespace Ui {
class ModalDialog;
}

class ModalDialog : public QDialog
{
    Q_OBJECT
public:
    enum Pages
    {
        Progress = 0,
        Tip,
        BusnessSetting,
        DataSetting,
        DiskCheck
    };

public:
    static ModalDialog *instance();
public:
    ModalDialog(const ModalDialog*)=delete;
    ModalDialog *operator =(const ModalDialog*)=delete;
public:
    void init(){}
    bool isWayland() { return m_bIsWayland; }
public slots:
    QWidget *showPage(int);
    QWidget *getPageByIndex(int index);
    void cancelEnable(bool);
    void updatePosition(QPoint);
    void show();
    void wexec();
    bool canBeClose() { return m_bCanClose; }

    void slotChangeUIFontSize(int fontSize);

protected:
    void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
    void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;

private:
    explicit ModalDialog(QWidget *parent = nullptr);
    ~ModalDialog();

private slots:
    void slotsTitle(QString);
    void slotsClose();

private:
    static ModalDialog *m_oInstance;
    static QMutex       m_oMutex;

private:
    bool                m_bCanClose;
    bool                m_bIsWayland;
    bool                m_isprogress;
    QPoint              m_oMainPos;
    QPushButton         *m_oCancelBtn;
    QPushButton         *m_oEnsureBtn;

private:
    Ui::ModalDialog    *ui;
Q_SIGNALS:
    void cancel();
};

#define MODAL ModalDialog::instance()
#define PROGRESS MODAL->showPage(ModalDialog::Progress)
#define BUSNESSSETTING MODAL->getPageByIndex(ModalDialog::BusnessSetting)

#endif // MODALDIALOG_H
