#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMutex>
#include <QButtonGroup>
#include <QStandardItem>
#include <QByteArray>
#include <QGSettings/QGSettings>
#include <knavigationbar.h>
#include <QDBusMessage>
#include <QDBusConnection>
#include <QPushButton>
#include <map>
#include <windowmanager/windowmanager.h>
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")
Q_SIGNALS:
    // 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();
    bool currentDataRomIsUDF();
    int getCountDevice(){ return m_oCDROMS.size();}
    QString getDeviceByIndex(int index);
    WindowId getWinId() { return m_lastestWindowId; }
protected:
    bool eventFilter(QObject *watched, QEvent *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;
    void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;

public slots:
    int slotsReShowMainWindow(QStringList args);
    bool isBusyDevice(QString device);
    void slotChangeUIFontSize(int fontSize);

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);
    void slotsCloseApp();
    void slotsChangeCurrentIndex(int);
private:
    bool started();
    void uiAdjust();
    void initTransparent();
    void calculatorTime(int current);
    void resetText(QPushButton* item);
    void setAccessibleName();

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;
    bool m_isWayland;
    int m_current_page = 0;
    WindowId m_lastestWindowId;
    WindowId m_mainWindowId;

    std::map<int, qint64> m_mapStartTime = {
        {0, 0},
        {1, 0},
        {2, 0}
    };

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