chat_moc.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * chat_moc.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include <QWidget>
  12. #include <QCompleter>
  13. namespace Ui {
  14. class Chat;
  15. }
  16. class Chat : public QWidget
  17. {
  18. Q_OBJECT
  19. enum ChatId
  20. {
  21. GLOBAL = 0,
  22. ROOM
  23. };
  24. QCompleter namesCompleter;
  25. QString username, session;
  26. ChatId chatId = GLOBAL;
  27. QVector<QTextDocument*> chatDocuments;
  28. private:
  29. void setChatId(ChatId);
  30. void sendMessage();
  31. public:
  32. explicit Chat(QWidget *parent = nullptr);
  33. ~Chat();
  34. void setUsername(const QString &);
  35. void setSession(const QString &);
  36. void setChannel(const QString &);
  37. void clearUsers();
  38. void addUser(const QString & user);
  39. void chatMessage(const QString & title, const QString & channel, QString body, bool isSystem = false);
  40. void chatMessage(const QString & title, QString body, bool isSystem = false);
  41. signals:
  42. void messageSent(QString);
  43. void channelSwitch(QString);
  44. public slots:
  45. void sysMessage(QString body);
  46. private slots:
  47. void on_messageEdit_returnPressed();
  48. void on_sendButton_clicked();
  49. void on_chatSwitch_clicked();
  50. private:
  51. Ui::Chat *ui;
  52. };