#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QScrollArea>
#include <QLineEdit>

#include "ukui_printer.h"
#include "add_printer_window.h"
#include "title_bar.h"
#include "menumodule.h"

#include "quad_btns_title_bar.h"
#include "right_widget.h"
#include "left_widget.h"
#include "select_ppd_dialog.h"
#include "property_window.h"
#include "job_manager_window.h"
#include "deb_install_window.h"

#define g_printerManger UkuiPrinterManager::getInstance()
class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    static MainWindow *getInstance();
protected:
    void keyPressEvent(QKeyEvent *event);
    bool eventFilter(QObject* watched, QEvent* event);
signals:
    void updateMainWin();
    void modifyPPD(QString);
    void addPrinterToListSector(const UkuiUsbPrinter &printer);
    void updateListSector(const QList<UkuiUsbPrinter> &printersVector,const UkuiUsbPrinter& currentPrinter);
    void addDeviceBtnClicked();
    void updateRightWidget(const UkuiUsbPrinter&);
    void addNewPrinter(const UkuiUsbPrinter&);
    void clearRightWidget();
    void showPPDSelectDialog();
    void getCurFontSize();
public:
    bool mainWindowIsHidden(){
        return this->isHidden();
    }
public slots:
    void updateRightWidgetByCheckBtn(const UkuiUsbPrinter&);
    void updateMainWindowByAdd(QString);
    void updateByChangePPD(QString);
    void setQSSFontSize(QFont currentFont);
private slots:
    void topWindow();
    void onBtnClicked();
    void ppdDialogShow();
    void propertyDialogShow(const UkuiUsbPrinter&);
    void jobListDialogShow(const QString&);
    void printTestPage(const UkuiUsbPrinter&printer);

    void updateMainWindowByDel(QString);

    void modifyPrinterPPD(QString);
    void updateCurrentSelectedPrinter(const UkuiUsbPrinter&printer);

    void updateImmediately();
    void updateByRename(QString printerName);
    void recvDeviceIn(DeviceInformation&);

private:
    ~MainWindow();
    explicit MainWindow(QWidget *parent = nullptr);
    MainWindow(MainWindow const&);
    MainWindow& operator=(MainWindow const&);

    DaemonIpcDbus *m_dbus;
    AddPrinterWindow *m_AddWindow;

    QWidget     *m_centerWidget;
    LeftWidget  *m_leftWidget;
    RightWidget *m_rightWidget;

    QHBoxLayout *m_HLayoutWholeWin;

    PropertyWindow *m_propertyDialog = nullptr;
    JobManagerWindow *m_jobListDialog = nullptr;

    UkuiUsbPrinter m_currentSelectedPrinter;

    void initModule();
    void initQSS();
    void initConnect();

    QList<UkuiUsbPrinter> m_allPrintersVector;

    QTimer *m_timer;

    DebInstallWindow* m_pDebInstallWindow = nullptr;

    QFont m_curFont;
    double m_curFontPointSize;

    //=======================test接口=========================



};

#endif // MAINWINDOW_H
