Freeciv-3.2
Loading...
Searching...
No Matches
chatline.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifndef FC__CHATLINE_H
15#define FC__CHATLINE_H
16
17#ifdef HAVE_CONFIG_H
18#include <fc_config.h>
19#endif
20
21extern "C" {
22#include "chatline_g.h"
23}
24
25// Qt
26#include <QEvent>
27#include <QLineEdit>
28#include <QTextBrowser>
29
30// gui-qt
31#include "fonts.h"
32#include "listener.h"
33
34class chat_listener;
35class QCheckBox;
36class QMouseEvent;
37class QPushButton;
38
39QString apply_tags(QString str, const struct text_tag_list *tags,
41template<> std::set<chat_listener *> listener<chat_listener>::instances;
42
43/***************************************************************************
44 Listener for chat. See listener<> for information about how to use it
45***************************************************************************/
46class chat_listener : public listener<chat_listener>
47{
48 // History is shared among all instances...
50 // ...but each has its own position.
52
53 // Chat completion word list.
55
56public:
57 // Special value meaning "end of history".
58 static const int HISTORY_END = -1;
59
60 static void update_word_list();
61
62 explicit chat_listener();
63
64 virtual void chat_message_received(const QString &,
65 const struct text_tag_list *);
67
69
70 int position_in_history() { return position; }
74
76};
77
78/***************************************************************************
79 Chat input widget
80***************************************************************************/
81class chat_input : public QLineEdit, private chat_listener
82{
84
85private slots:
86 void send();
87
88public:
89 explicit chat_input(QWidget *parent = nullptr);
90
92
93 bool event(QEvent *event);
94};
95
96/***************************************************************************
97 Text browser with mouse double click signal
98***************************************************************************/
99class text_browser_dblclck : public QTextBrowser
100{
102public:
103 explicit text_browser_dblclck(QWidget *parent = NULL): QTextBrowser(parent) {}
104signals:
106protected:
110};
111
112/***************************************************************************
113 Class for chat widget
114***************************************************************************/
115class chatwdg : public QWidget, private chat_listener
116{
118public:
119 chatwdg(QWidget *parent);
120 void append(const QString &str);
122 void make_link(struct tile *ptile);
123 void update_widgets();
124 int default_size(int lines);
125 void scroll_to_bottom();
126 void update_font();
127private slots:
128 void state_changed(int state);
129 void rm_links();
130 void anchor_clicked(const QUrl &link);
131 void toggle_size();
132protected:
135 bool eventFilter(QObject *obj, QEvent *event);
136private:
138 const struct text_tag_list *tags);
139
141 QPushButton *remove_links;
143
144};
145
146class version_message_event : public QEvent
147{
149public:
150 explicit version_message_event(const QString &msg);
151 QString get_message() const { return message; }
152};
153
154#endif // FC__CHATLINE_H
#define str
Definition astring.c:76
virtual void chat_word_list_changed(const QStringList &cmplt_word_list)
Definition chatline.cpp:232
void send()
Definition chatline.cpp:223
QStringList current_word_list()
Definition chatline.h:75
static const int HISTORY_END
Definition chatline.h:58
QString forward_in_history()
Definition chatline.cpp:187
void send_chat_message(const QString &message)
Definition chatline.cpp:109
void reset_history_position()
Definition chatline.cpp:204
QString back_in_history()
Definition chatline.cpp:173
static QStringList history
Definition chatline.h:49
int position_in_history()
Definition chatline.h:70
virtual void chat_word_list_changed(const QStringList &cmplt_word_list)
Definition chatline.cpp:100
static void update_word_list()
Definition chatline.cpp:58
static QStringList word_list
Definition chatline.h:54
virtual void chat_message_received(const QString &, const struct text_tag_list *)
Definition chatline.cpp:92
bool eventFilter(QObject *obj, QEvent *event)
Definition chatline.cpp:463
chat_input * chat_line
Definition chatline.h:121
void paintEvent(QPaintEvent *event)
Definition chatline.cpp:451
void update_font()
Definition chatline.cpp:348
void anchor_clicked(const QUrl &link)
Definition chatline.cpp:366
int default_size(int lines)
Definition chatline.cpp:501
text_browser_dblclck * chat_output
Definition chatline.h:140
void make_link(struct tile *ptile)
Definition chatline.cpp:535
void chat_message_received(const QString &message, const struct text_tag_list *tags)
Definition chatline.cpp:419
void scroll_to_bottom()
Definition chatline.cpp:338
void paint(QPainter *painter, QPaintEvent *event)
Definition chatline.cpp:442
void update_widgets()
Definition chatline.cpp:486
QCheckBox * cb
Definition chatline.h:142
void rm_links()
Definition chatline.cpp:358
QPushButton * remove_links
Definition chatline.h:141
void state_changed(int state)
Definition chatline.cpp:312
void append(const QString &str)
Definition chatline.cpp:430
void toggle_size()
Definition chatline.cpp:324
text_browser_dblclck(QWidget *parent=NULL)
Definition chatline.h:103
void mouseDoubleClickEvent(QMouseEvent *event)
Definition chatline.h:107
QString get_message() const
Definition chatline.h:151
char * incite_cost
Definition comments.c:75
enum event_type event
Definition events.c:81
QString apply_tags(QString str, const struct text_tag_list *tags, QColor bg_color)
Definition chatline.cpp:555
char * lines
Definition packhand.c:131
struct player_slot * slots
Definition player.c:51
Definition tile.h:50