-
Notifications
You must be signed in to change notification settings - Fork 0
/
GitChat.h
48 lines (41 loc) · 1.09 KB
/
GitChat.h
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
#ifndef MAINWINDOW_CHAT_H
#define MAINWINDOW_CHAT_H
#include <QMainWindow>
#include <QStandardItemModel>
#include <thread>
#include <atomic>
#include <queue>
using MessageType = std::queue<std::pair<QString, QString>>;
Q_DECLARE_METATYPE(MessageType);
QT_BEGIN_NAMESPACE
namespace Ui { class GitChat; }
QT_END_NAMESPACE
class Git;
class GitChat : public QMainWindow
{
Q_OBJECT
public:
GitChat(Git& git);
~GitChat();
private:
void AddIncomingMessage(const QString& author, const QString& message);
void AddOutgoingMessage(const QString& author, const QString& message);
public:
void StartGitListeningThread();
signals:
void SignalAddMessages(MessageType messages);
void SignalGitThreadError(const QString& message);
private slots:
void on_lineEdit_returnPressed();
void on_GitChat_destroyed();
private:
void GitThreadError(const QString& message);
void AddMessages(MessageType messages);
private:
Git& m_git;
std::thread m_gitThread;
std::atomic_bool m_running{false};
QStandardItemModel m_model;
Ui::GitChat *ui;
};
#endif // MAINWINDOW_CHAT_H