summaryrefslogtreecommitdiffstats
path: root/pica-client/chatwindow.h
blob: 1babd31adaeebb87dd2f41edb15d0528f704fd55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef CHATWINDOW_H
#define CHATWINDOW_H

#include <QWidget>
#include <QTextEdit>
#include <QList>

class TextSend : public QTextEdit
{
    Q_OBJECT
public:
    explicit TextSend(QWidget *parent);
signals:
    void send_pressed();
private:
    void keyPressEvent(QKeyEvent *e);

};

class ChatWindow : public QWidget
{
    Q_OBJECT
public:
    explicit ChatWindow(quint32 peer_id);

    quint32 getPeerId() { return peer_id_;};

signals:
    void msg_input(QString msg, ChatWindow *sender_window);
    void chatwindow_close(ChatWindow *sender_window);

public slots:
    void msg_from_peer(QString msg);
    void msg_delivered();
    void msg_informational(QString text);//юзер в оффлайне, набирает сообщение, и т.д. серым шрифтом, курсив


private:
    QTextEdit *chatw;
    TextSend *sendtextw;
    quint32 peer_id_;
    QList<int> undelivered_msgs;


    void put_message(QString msg, quint32 id, bool is_me);

    void closeEvent(QCloseEvent *e);

private slots:
    void send_message();
};

#endif // CHATWINDOW_H