#ifndef STATUSWIDGET_H
#define STATUSWIDGET_H

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

#include "models/patchlist.h"

namespace Ui {
class StatusWidget;
}

class StatusWidget : public QWidget
{
    Q_OBJECT

public:
    // States. Higher state value means higher priority on visualisation
    enum ToolTipState : int {
        E_INFO = 8,
        E_ERROR = 4,
        E_PROCESS = 2,
        E_RANDOM = 1
    };

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

public slots:
    void updateFontsSizes();

    void setToolTipMessage(QString message, ToolTipState state);

    void unsetToolTipMessage(ToolTipState state);

protected:
    void resizeEvent(QResizeEvent *event) override;

private slots:
    void generateRandomTooltipMessage();

    void fadeBetweenToolTips(QString tooltip_id);

    void onPatchTotalOperationsStarted();

    void onPatchTotalOperationsFinished();

    void updatePatchProgressStatus(Patch::OperationProgress progress);

    void on_game_button_clicked();

    void on_check_for_updates_button_clicked();

private:
    void createTooltipMessageWidget(QString tooltip_id);

private:
    Ui::StatusWidget *ui;

    PatchList *legacy_patches_;

    bool all_patch_operations_finished_ = false;

    QMap<QString, QLabel*> tooltip_widgets_;
    QMap<QString, QGraphicsOpacityEffect*> tooltip_effects_;
    QMap<QString, QPropertyAnimation*> tooltip_animations_;
    QString current_tooltip_message_;

    QMap<Patch*, Patch::Operation> patch_operations;

    QTime last_statusbar_update_time_;

    ToolTipState tooltip_state_ = E_RANDOM;
    QMap<ToolTipState, QString> tooltip_messages_;

    QTimer random_tooltip_generator_timer_;
    QTimer process_completed_tooltip_hide_timer_;
};

#endif // STATUSWIDGET_H
