Freeciv-3.3
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 = nullptr): 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(Qt::CheckState state);
129 void state_changed_depr(int state);
130 void rm_links();
131 void anchor_clicked(const QUrl &link);
132 void toggle_size();
133protected:
136 bool eventFilter(QObject *obj, QEvent *event);
137private:
139 const struct text_tag_list *tags);
140
142 QPushButton *remove_links;
144
145};
146
147class version_message_event : public QEvent
148{
150public:
151 explicit version_message_event(const QString &msg);
152 QString get_message() const { return message; }
153};
154
155#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:480
chat_input * chat_line
Definition chatline.h:121
void paintEvent(QPaintEvent *event)
Definition chatline.cpp:468
void update_font()
Definition chatline.cpp:365
void anchor_clicked(const QUrl &link)
Definition chatline.cpp:383
int default_size(int lines)
Definition chatline.cpp:518
text_browser_dblclck * chat_output
Definition chatline.h:141
void make_link(struct tile *ptile)
Definition chatline.cpp:552
void chat_message_received(const QString &message, const struct text_tag_list *tags)
Definition chatline.cpp:436
void scroll_to_bottom()
Definition chatline.cpp:355
void state_changed(Qt::CheckState state)
Definition chatline.cpp:316
void paint(QPainter *painter, QPaintEvent *event)
Definition chatline.cpp:459
void update_widgets()
Definition chatline.cpp:503
void state_changed_depr(int state)
Definition chatline.cpp:329
QCheckBox * cb
Definition chatline.h:143
void rm_links()
Definition chatline.cpp:375
QPushButton * remove_links
Definition chatline.h:142
void append(const QString &str)
Definition chatline.cpp:447
void toggle_size()
Definition chatline.cpp:341
void mouseDoubleClickEvent(QMouseEvent *event)
Definition chatline.h:107
text_browser_dblclck(QWidget *parent=nullptr)
Definition chatline.h:103
QString get_message() const
Definition chatline.h:152
char * incite_cost
Definition comments.c:76
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:572
char * lines
Definition packhand.c:131
struct player_slot * slots
Definition player.c:51
Definition tile.h:50