File indexing completed on 2024-09-01 03:52:59
0001 /* 0002 SPDX-FileCopyrightText: 2007 Paolo Capriotti <p.capriotti@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef CHATWIDGET_H 0008 #define CHATWIDGET_H 0009 0010 #include <QList> 0011 #include <QWidget> 0012 0013 class QTextEdit; 0014 class QLineEdit; 0015 class QEvent; 0016 class Entity; 0017 0018 class ChatWidget : public QWidget 0019 { 0020 Q_OBJECT 0021 QTextEdit* m_chat; 0022 QLineEdit* m_input; 0023 0024 int m_current; 0025 QList<QString> m_history; 0026 QString m_nick; 0027 0028 void setHistoryText(int index); 0029 public: 0030 explicit ChatWidget(QWidget* parent = nullptr); 0031 0032 QSize sizeHint() const override; 0033 void bindTo(Entity* entity); 0034 0035 void setNick(const QString& nick); 0036 void display(const QString& nick, const QString& message); 0037 void display(const QString& message); 0038 protected: 0039 bool eventFilter(QObject*, QEvent* e) override; 0040 void resizeEvent(QResizeEvent*) override; 0041 Q_SIGNALS: 0042 void message(const QString& text); 0043 private Q_SLOTS: 0044 void sendLine(); 0045 }; 0046 0047 #endif // CHATWIDGET_H