#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QButtonGroup>
#include <QStandardItem>
#include <QByteArray>
#include <QGSettings/QGSettings>
#include <knavigationbar.h>
#include <QDBusMessage>
#include <QDBusConnection>
#include <map>
#include <QMutex>
using namespace kdk;

const QByteArray TRANSPARENT_SCHEMAS = "org.ukui.control-center.personalise";

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "com.kylin.burner.manager")
signals:
    // log
    void info(QString); void warn(QString);
    void error(QString); void debug(QString);
    // busness
    void busness(int);
    // move
    void position(QPoint);
    // browse
    void browse(QString);
    // delete datas
    void delData(int);
public:
    MainWindow(QStringList args, QWidget *parent = nullptr);
    static MainWindow* Instance(QStringList args = QStringList(), QWidget *parent = nullptr);
    ~MainWindow();
protected:
    void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
    void moveEvent(QMoveEvent *event) Q_DECL_OVERRIDE;
    void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
    void changeEvent(QEvent *event) Q_DECL_OVERRIDE;
    void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
public slots:
    int slotsReShowMainWindow();
    bool isBusyDevice(QString device);
private slots:
    void slotsBurnData();
    void slotsBurnImage();
    void slotsCopyImage();
    void slotsAdjustBurnData(int idx);
    void slotsBusness(bool);
    void slotsInitCreateISO(void *);
    void slotsNoMediun(void *);
    void slotsRemoveCDROM(void *);
    void slotsBrowseOrSetting(bool);
    void slotsUpdateDisk(int, void *);
    void slotsCloseAll();
    void slotsChangeName(int);
    void slotsChangeBtnBusnessName();
    void uiModeChange(bool);
private:
    bool started();
    void uiAdjust();
    void initTransparent();
    void calculatorTime(int current);
private:
    QButtonGroup   *m_oGroup;
    QList<void *>   m_oCDROMS;
    QGSettings     *m_transparentSettings;
    double          m_transparentValue;
    QStandardItem  *m_burnDataItem;
    QStandardItem  *m_burnImageItem;
    QStandardItem  *m_copyImageItem;
    KNavigationBar *m_NavBar;
    QDBusMessage    msg;
    static MainWindow  *m_mainWindow;
    static QMutex   m_oMutex;
    bool 	    m_isTabletMode;
    int m_current_page = 0;
    QString m_window_id;
    std::map<int, qint64> m_mapStartTime = {
        {0, 0},
        {1, 0},
        {2, 0}
    };

private:
    Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
