#ifndef SERVERSTATUSWIDGET_H
#define SERVERSTATUSWIDGET_H

#include <QWidget>
#include <QTimer>
#include <QByteArray>
#include "models/downloader.h"

namespace Ui {
class ServerStatusWidget;
}

class ServerStatusWidget : public QWidget
{
    Q_OBJECT

public:
    explicit ServerStatusWidget(QWidget *parent = 0);
    ~ServerStatusWidget();

public slots:
    void updateFontsSizes();

signals:
    void showServersTooltip(QString tooltip);
    void showNoTooltip();

protected:
    void resizeEvent(QResizeEvent *event) override;
    virtual void leaveEvent(QEvent * event) override;
    virtual void enterEvent(QEvent * event) override;

public slots:
    void updateStatus();
    void updateTechWorksMessage();

private:
    QString server_status_tooltip_ = "Информация о состоянии серверов загружается...";
    QTimer update_timer;

    Downloader status_downloader;
    QByteArray status_data;

    Downloader tech_work_message_downloader;
    QByteArray tech_work_message_data;

    const QString open_color = "color: rgb(0, 170, 0);";
    const QString closed_color = "color: rgb(255, 0, 0);";

private:
    const QStringList servers_list = {"Anor",
                                      "Arkenstone",
                                      "Belegaer",
                                      "Brandywine",
                                      "Bullroarer",
                                      "Crickhollow",
                                      "Evernight",
                                      "Gladden",
                                      "Gwaihir",
                                      "Ithil",
                                      "Landroval",
                                      "Laurelin",
                                      "Sirannon"};

    Ui::ServerStatusWidget *ui;
    bool servers_disabled;

};

#endif // SERVERSTATUSWIDGET_H
