#include <QMainWindow>

#include <vector>
#include <QTimer>
#include <fstream>
#include <filesystem>

#include "uihelper.h"
#include "WidgetLogin.h"
#include "WidgetPage.h"

class Menu : public QObject
{
    Q_OBJECT
public:
    std::string curMenuId_;
    std::vector<std::shared_ptr<QPushButton>> vecBtn_;
    QPushButton* activeBtn_ = NULL;
    std::function<void(std::string id)> cb_ = nullptr;

    void init(QWidget* parent, int x, int y, std::vector<std::string>& vecMenuId, std::function<void(std::string id)> cb);
    void onMenuBtnClicked();
};


class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    MainWindow();
    void initMenu();

    void initWebView();

    void resizeEvent(QResizeEvent* event);

public slots:
    void slotLoginSuccess();
    void onMenuClicked(std::string menuId);
    void onTimeout();

public:
    QLabel labBkg_;
    QLabel labBkgHead_;
    QLabel labTitle_;
    QLabel labTime_;

    WidgetLogin wLogin_;

    QTimer timer_;

    std::shared_ptr<WidgetPage> wPage_ = nullptr;

    std::shared_ptr<Menu> menu_ = nullptr;

    //std::shared_ptr<QWebEngineView> webView_;
};