#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 onPatchOperationsStarted();
    void onPatchOperationsFinished();
    void onDownloadTotalStatusChanged(Downloader::Status status);
    void onInstallTotalStatusChanged(Patch::InstallationStatus status);
    
    void onPatchOperationStarted(QString operation_name, Patch* patch);
    void onPatchOperationFinished(QString operation_name, Patch* patch, bool result);
    void onPatchDownloadStatusChanged(Patch* patch, Downloader::Status status);
    void onPatchInstallStatusChanged(Patch* patch, Patch::InstallationStatus status);

private:
    void updateStatusBar();

private:
    Downloader::Status last_download_status_;
    Patch::InstallationStatus last_install_status_;
    
    Ui::StatusWidget *ui;

    PatchList *legacy_patches_;

    QMap<QString, QGraphicsOpacityEffect*> tooltip_effects;
    QMap<QString, QPropertyAnimation*> tooltip_animations;
    QWidget* active_tooltip;

    QTime last_progress_update_time;
};

#endif // STATUSWIDGET_H
