#ifndef MESSANGERWIDGET_H
#define MESSANGERWIDGET_H

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

class MyTextEdit : public QTextEdit
{
    Q_OBJECT

public:
    MyTextEdit(){};

signals:
    void signal_pressEnter();

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

namespace Ui {
class MessangerWidget;
}

class MessangerWidget : public QWidget
{
    Q_OBJECT

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

public:
    void initUserRemote(User user);
    void reinitMessangerWidget(User user);
    void initUserLocalGUI(User user);
    int getIDuserRemote();

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

private:
    void addTabDialogMessenger(User user);
    void updateHeader(User user);

private slots:
    void on_btnSend_clicked();

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

protected:
    void changeEvent(QEvent * event) override;

private:    
    OneDialogMessenger* oneDialogMessenger;
    User userLocalGUI;
    User userRemote;

    QTranslator qtLanguageTranslator;

private:
    Ui::MessangerWidget *ui;

    MyTextEdit* myTextEdit;
};

#endif // MESSANGERWIDGET_H
