#ifndef MESSANGERWIDGET_H
#define MESSANGERWIDGET_H

#include <QWidget>
#include <QTranslator>
#include <user.h>
#include "Datas.h"
#include "tabdialogmessenger.h"


namespace Ui {
class MessangerWidget;
}

class MessangerWidget : public QWidget
{
    Q_OBJECT

public:
    enum ETypeMsg{fromClient, toClient};

public:
    explicit MessangerWidget(QWidget *parent = nullptr);
    ~MessangerWidget();

public:
    void initUserRemote(User user);
    void reinitMessangerWidget(User user);
    void initGUIclientId(QString id_GUIclient);
    int getIDuserRemote();

    void showSendedMessage(ClientMessage clientMessage);
    void showReceivedMessage(ClientMessage clientMessage);

private:
    void addTabDialogMessenger(User user);
    void updateLoggedIn(bool loggedIn);

private slots:
    void on_btnSend_clicked();

signals:
    //сигнал о готовности нового сообщения на отправку клиенту
    void signal_sendMessage(ClientMessage clientMessage);

private:
    virtual void keyPressEvent(QKeyEvent *event) override;

protected:
    void changeEvent(QEvent * event) override;

private:    
    TabDialogMessenger* tabDialogMessenger;
    User userRemote;
    QString currGUIclientId;   //id этого клиента

    QTranslator qtLanguageTranslator;

private:
    Ui::MessangerWidget *ui;
};

#endif // MESSANGERWIDGET_H
