#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QDebug>
#include <QHBoxLayout>

#include <Widgets/commonbuttongroupwidget.h>
#include <Widgets/updatenotifywidget.h>
#include <Widgets/entrywidget.h>

#include <Data/Datas.h>
#include <UI/resourcemanager.h>
#include "mywinheader.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE


class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow(){};

    void initialize(ResourceManager *resourceManager);
    void addWidgetToChangeGroup(CommonButtonGroupWidget *commonWidgetGroup);
    void addWidgetToInteractiveGroup(EntryWidget *entryWidget);
    void setLoadSettings(ServerSettings *serverSettings);
    void setLoginSuccessState();
    void setLoginFailedState();
    void setClientVersionName(const QString &versionName);

    void loadToServer();
    void undoCurrentChanges();
    void disableUnsaveButton(bool flag);
    void showMainFrame(bool flag);
    void loadCompleteState();
    void setInlineDebug(QString value);
    bool getIsAutoStart();
    void setNeedUpdateState(const QString &notifyText);
    void setLastVersionState();
    void showConnectionEmpty();
    void showOfflineButton(bool flag);
    void setStartOfflineButton(bool isAvailable);
    void setStartState();
    void serverBlocked();

    QHBoxLayout *getDisplayLayout() const;
public slots:
    void slotShowUpdateInfo();
    void slotConnectionState(bool flag);
    void slotServerDisconnect();
    void slotCommonWidgetState();
    void setServerVersion(StreamingVersionData *version);

    void updateInitInformation(QString fullSize, QString currentSize);
signals:
    void sigShowSettings(bool isActive);
    void sigChangeLanguage(const QString& arg1);
    void sigShowUpdateInfo();
    void sigExit();
    void sigTryLogin();
    void sigStartOffline();

private slots:
    void on_settingsButton_clicked();
    void on_languageComboBox_activated(const QString &arg1);
    void on_exitButton_clicked();
    void on_offlineStartButton_clicked();
    void on_unsafeChangingButton_clicked();
    void slotDisableNotify();

private:
    Ui::MainWindow *ui;
    ResourceManager *resourceManager;
    EntryWidget *entryWidget;

    QTimer *timer;
    QPixmap background;
    QRect bottomRightPosition;
    QRect offlinePosition;
    void bindClient();
    void bindConnection();
    void setUpUi();

    void paintEvent(QPaintEvent *event);
protected:
    virtual void keyPressEvent(QKeyEvent *event);
};
#endif // MAINWINDOW_H
