#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTimer>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

#include "worker.h"

class MainWindow : public QMainWindow {
    Q_OBJECT

protected:
    void customEvent(QEvent *event) override;

public:
    MainWindow(Worker *worker, QWidget *parent = nullptr);
    ~MainWindow();

    static const int START_PROGRESS_LOOP = -1;
    static const int STOP_PROGRESS_LOOP = -2;

    int progressValue() const { return m_progressValue; }

public slots:
    void onAppendText(QString, QString suffix = "");
    void onReplaceLast(QString, QString suffix = "");
    void onShowErrorMessage(QString, QString);
    void onStopStartTimer();
    void onRestartExitTimer();
    void onEnableExit();
    void onDisableExit();

private slots:
    void onQuit();

private:
    void scrollDownTextEdit();

    Ui::MainWindow *ui;
    Worker *m_worker;
    int m_width;
    QTimer *m_startTimer;
    QTimer *m_exitTimer;
    bool m_progressRunning;
    int m_progressValue;
};
#endif // MAINWINDOW_H
