#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QWidget>
#include <QTimer>
#include "fancywindow.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWidget; }
QT_END_NAMESPACE

class SidePanel;
class CameraPanel;
class LoginWidget;
class LogWidget;

class QHBoxLayout;
class QFrame;
class QMenu;
class QAction;
class QPushButton;
class QToolButton;
class QSplitter;
class QStackedWidget;

class ChartPanel;
class CStackedWidget;
class CameraParam;
class LoginInfo;
class AdditionalWidget;
class PopupMenu;
class LoginWidget;
class SetupWaitProgressBar;
class FuncButtonWidget;
class CTextEdit;
class TreeWidget;
class FuncWidget1;
class FuncWidget2;

class MainWidget : public QWidget
{
    Q_OBJECT

public:
    MainWidget(QWidget *parent = nullptr);
    ~MainWidget();

    Ui::MainWidget *ui;
};

class MainWindow : public FancyWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void setCameraInitPanel();

protected:
    void closeEvent(QCloseEvent*) override;

private:
    /**
    * @brief 初始化UI
    **/
    void initUI();

    /**
    * @brief 创建信号和槽
    **/
    void createConnections();

    void createDockWidget();

    void closeOtherWidget();

    QWidget* widgetFromIndex(int index);
private slots:
    void clickedTreeWidget(const QString& txt);

    void refeshWindow();

private:
    MainWidget* mMainWidget;

    // 样式表
    QAction* mStyleAction;
    QMenu* mStyleMenu;
    QAction* mDarkBlueAction;
    QAction* mDarkGreenAction;
    QAction* mDarkYellowGreenAction;
    QAction* mLightBlueAction;
    QAction* mLightGreenAction;

    // 标题上的窗口
    AdditionalWidget* mAdditionalWidget;

    QPushButton* mMiddleButton;

    SidePanel* mSidePanel;

    // 登录信息展示
    LoginInfo *mLoginInfo;

    PopupMenu* mPopupMenu;

    LogWidget* mLogWidget;

    LoginWidget* mLoginWidget;

    SetupWaitProgressBar* mProgressBar;

    FuncWidget1* mFuncWidget1;
    FuncWidget2* mFuncWidget2;

    QTimer mTimer;
    int mRefreshIndex;
    int mRefreshSum;
};

#endif // WIDGET_H
