#ifndef WEDITPROGRAM_H
#define WEDITPROGRAM_H

#include <QDebug>
#include <LoQClass/loqmainwindow.h>
#include <LoQClass/loqwindowtitlebar.h>
#include <LoUIClass/loemptydialog.h>
#include <QToolBar>
#include <QAction>
#include <QIcon>
#include <QFile>
#include <QListWidget>
#include <QJsonDocument>
#include <QThread>
#include <wProgramManager/wEditProgram/wmaintoolbar.h>
#include <wProgramManager/wEditProgram/wpagelist.h>
#include <wProgramManager/wEditProgram/wdrawingboard.h>
#include <wProgramManager/wEditProgram/wattrview.h>
#include <QUdpSocket>
#include <QNetworkInterface>
#include <QProcess>
namespace Ui {
class wEditProgram;
}

class wEditProgram : public LoQMainWindow
{
    Q_OBJECT

public:
    explicit wEditProgram(QString &name, int &w, int &h, QString &remarks, const QString strProgramPath,const QString pRoot, QWidget *parent = nullptr);
    ~wEditProgram();
//    void closeEvent(QCloseEvent *event);
    void readSettings();
    void writeSettings();
signals:
    void sProgramChanged();
    void sProgramSaveAs(QString name, QSize size, QString remarks);
    void sigProgPlayerQuit();
public slots:
    void onSave();
    void onSaveAs();
    void onSetting();
    void onSend();
    void onPreview(int iState);
    void onEditHead(QString name, QSize size, QString remarks);
    void onReNameProgram(QString strName);
    void StopPreview();
private:
    Ui::wEditProgram *ui;
    QString m_strProgramItemPath;
    QString m_strSavePath;
    LoQWindowTitleBar *m_title_bar = nullptr;
    wMainToolBar  *m_tool_bar      = nullptr;
    wPageList     *m_page_list     = nullptr;
    wDrawingBoard *m_drawing_board = nullptr;
    wAttrView     *m_attr_view     = nullptr;
    //主区域横向布局（幻灯片页列表，编辑窗，属性窗）
    QHBoxLayout *m_playout_main_area = nullptr;
//    //垂直布局（标题栏，主工具栏，主区域）
    QVBoxLayout *m_pLayout = nullptr;
    bool IsChangedProgram();
    void Save();

private:
    QString   &m_name;
    int       &m_width;
    int       &m_height;
    QString   &m_remarks;
    int m_iNeedSaveFlag=0;
    int m_flagPreviewing=0;
    void UdpSendJson(QJsonObject json);
    QProcess *m_po=nullptr;
protected:
    virtual void closeEvent(QCloseEvent *event);
};

#endif // WEDITPROGRAM_H
