//
// Created by HW on 2023/07/26.
//

#ifndef OFFICEASSISTANT_NAVBAR_H
#define OFFICEASSISTANT_NAVBAR_H

#include <QWidget>
#include <QList>
#include <map>
#include "netio.h"
#include "MyButton.h"
#include <QColor>
#include <QPainter>
#include <QResizeEvent>
#include "buttonstruct.h"
#include <QtNetwork/QtNetwork>


QT_BEGIN_NAMESPACE
namespace Ui { class NavBar; }
QT_END_NAMESPACE

class NavBar : public QWidget {
Q_OBJECT

public:
    NavBar(ConfigResponse *configResponse,QWidget *parent = nullptr);

    ~NavBar() override;
protected:
    void paintEvent(QPaintEvent *event) override;

    void resizeEvent(QResizeEvent *event) override;


private:
    Ui::NavBar *ui;
	QColor qColor;
    QList<MyButton *> buttons;
	QList<ButtonStruct> buttonStructs;
	QByteArray *buffer;
    int width2;
    int height2;
	QNetworkAccessManager *manager;
	QNetworkReply *reply;
	QEventLoop eventLoop;
	QImage *logo;
	bool downloadSuccess=true;
	void getLogoFromInternet(ConfigResponse *configResponse);
	void getLogoFromLocal();
private slots:
	void storeToBuffer();
	void cancelDownload();
};


#endif //OFFICEASSISTANT_NAVBAR_H
