#ifndef MAIN_WIN_PROPERTY_WIDGET_H
#define MAIN_WIN_PROPERTY_WIDGET_H

#include <QObject>
#include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QTableView>
#include <QStandardItemModel>

#include "ukui_printer.h"
#include "my_line_edit.h"
#include "custom_label.h"
#include "custom_push_button.h"

class PropertyManagerModel;
namespace Ui {
class MainWinPropertyWidget;
}

class MainWinPropertyWidget : public QWidget
{
    Q_OBJECT
public:
    explicit MainWinPropertyWidget(QWidget *main ,QWidget *parent = nullptr);
    void updateText(const UkuiUsbPrinter&);
    void setQSSFontSize(QFont curFont);

signals:
    void ppdDialogShowRequest();
    void sendOutCurrentPinterInfo(const UkuiUsbPrinter&);
    void sendOutCurrentPinterName(const QString&);
    void currentPinterInfoPrintTest(const UkuiUsbPrinter&);
    void updateWholeMainWin(QString);
protected:
    void paintEvent(QPaintEvent *) override;

private slots:
    void onEditPrinterNameBtnPressed();
    bool isPrinterNameLegalCheck();
    void modifyCurrentPrinterName();
    void restoreWin();
private:
    Ui::MainWinPropertyWidget *m_ui;
    void setUI();
    void setFont(QFont ft, QLabel *label);
    void updateWin(QString newPrinterName);
    QPushButton *m_logoIcon;

    CustomLabel *m_printerShowName;
    QString     m_currentPrinterNameText;
    MyLineEdit  *m_printerShowNameEdit;
    QPushButton *m_printerShowNameEditIcon;

    QPushButton *m_showPropertyBtn;
    QPushButton *m_showJobListBtn;
    QPushButton *m_printTestPageBtn;
    QTableView  *m_properytView;
    PropertyManagerModel *m_propertyManagerModel;

    bool m_isPpdDialogShownFlag;

    UkuiUsbPrinter m_currentPrinter;

    QWidget *m_mainWinPtr;

    friend class MainWindow;
};

class PropertyManagerModel : public QStandardItemModel
{
    Q_OBJECT
public:

    explicit PropertyManagerModel(QStandardItemModel *parent = nullptr);
    void setPrinterModel(const QString &str);
    void setPrinterStatus(const QString &str);
    void setPrinterLocation(const QString &str);
    void setPrinterDriver(const QString &str);
    ~PropertyManagerModel();
};


#endif // MAINWINPROPERTYWIDGET_H
