#ifndef STATUSWIDGET_H
#define STATUSWIDGET_H

#include <QWidget>
#include <QSettings>
#include <QTime>
#include <QMap>
#include <QPropertyAnimation>
#include <QGraphicsOpacityEffect>

#include "models/patchlist.h"

namespace Ui {
class StatusWidget;
}

class StatusWidget : public QWidget
{
    Q_OBJECT

public:
    explicit StatusWidget(PatchList *legacy_patches, QWidget *parent = 0);
    ~StatusWidget();

public slots:
    void updateFontsSizes();

protected:
    void resizeEvent(QResizeEvent *event) override;

private slots:
    void setToolTipToWeeklyCodeHelp();
    void setToolTipToWeeklyCodeComplete();
    void setToolTipToNewsHelp();
    void setToolTipToServersStatus();
    void resetToolTip();

    void fadeBetweenToolTips(QWidget* next_tooltip);

    void onPatchTotalOperationsStarted();
    void onPatchTotalOperationsFinished();

    void onPatchOperationStarted(Patch::Operation operation, Patch* patch);
    void onPatchOperationFinished(Patch::Operation operation, Patch* patch);

    void onPatchTotalProgressChanged(Patch::OperationProgress operation_progress);
    void onPatchProgressChanged(Patch::OperationProgress progress, Patch* patch);

private:
    void updateStatusBar(Patch::OperationProgress progress);

private:
    Ui::StatusWidget *ui;

    PatchList *legacy_patches_;

    bool all_patch_operations_finished_ = false;

    QMap<QString, QGraphicsOpacityEffect*> tooltip_effects;
    QMap<QString, QPropertyAnimation*> tooltip_animations;
    QMap<Patch*, Patch::Operation> patch_operations;
    QWidget* active_tooltip;

    QTime last_statusbar_update_time_;
};

#endif // STATUSWIDGET_H
