API Documentation
Loading...
Searching...
No Matches
ChatDialog.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVR
28File: ChatDialog
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#ifdef NDEVR_SUPPORTS_SOCKET_IO
34#include <QMainWindow>
35#include <QListWidget>
36#include <QPlainTextEdit>
37#include <QTimer>
38#include <sio_client.h>
39#include "UsernameDialog.h>
40namespace Ui {
41class ChatDialogUI;
42}
43
44using namespace sio;
45namespace NDEVR
46{
47 class ChatDialog : public QWidget
48 {
49 Q_OBJECT
50
51 public:
52 explicit ChatDialog(QWidget *parent = 0);
53 ~ChatDialog();
54
55 public Q_SLOTS:
56 void SendBtnClicked();
57 void TypingChanged();
58 void OnMessageReturn();
59 protected:
60 void showEvent(QShowEvent* event);
61
62 Q_SIGNALS:
63 void RequestAddListItem(QListWidgetItem *item);
64 void RequestRemoveListItem(QListWidgetItem *item);
65 void RequestToggleInputs(bool loginOrNot);
66 private Q_SLOTS:
67 void AddListItem(QListWidgetItem *item);
68 void RemoveListItem(QListWidgetItem *item);
69 void ToggleInputs(bool loginOrNot);
70 void TypingStop();
71 void NicknameAccept();
72 void NicknameCancelled();
73 private:
74 void OnNewMessage(std::string const& name, message::ptr const& data, bool hasAck, message::list &ack_resp);
75 void OnUserJoined(std::string const& name, message::ptr const& data, bool hasAck, message::list &ack_resp);
76 void OnUserLeft(std::string const& name, message::ptr const& data, bool hasAck, message::list &ack_resp);
77 void OnTyping(std::string const& name, message::ptr const& data, bool hasAck, message::list &ack_resp);
78 void OnStopTyping(std::string const& name, message::ptr const& data, bool hasAck, message::list &ack_resp);
79 void OnLogin(std::string const& name, message::ptr const& data, bool hasAck, message::list &ack_resp);
80 void OnConnected(std::string const& nsp);
81 void OnClosed(client::close_reason const& reason);
82 void OnFailed();
83 void ShowLoginDialog();
84
85 Ui::ChatDialogUI *ui;
86
87 std::unique_ptr<client> _io;
88
89 std::unique_ptr<UsernameDialog> m_dialog;
90
91 QString m_name;
92
93 std::unique_ptr<QTimer> m_timer;
94
95 QListWidgetItem *m_typingItem;
96 };
97
98}
99#endif
100
Definition ACIColor.h:37
Definition FontEditor.h:6