Freeciv-3.3: /fast/freeciv/nightly/main/client/gui-qt/chatline.cpp Source File

Freeciv-3.3

Loading...
Searching...
No Matches
chatline.cpp
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#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18// Qt
19#include <QApplication>
20#include <QCheckBox>
21#include <QCompleter>
22#include <QGridLayout>
23#include <QKeyEvent>
24#include <QPainter>
25#include <QScrollBar>
26#include <QStyleFactory>
27#include <QTextBlock>
28#include <QTextLayout>
29#include <QTextBrowser>
30
31// common
32#include "chat.h"
33
34// client
35#include "audio.h"
36#include "climap.h"
37#include "climisc.h" // For write_chatline_content()
38#include "connectdlg_common.h"
39#include "control.h"
40#include "game.h"
41
42// gui-qt
43#include "chatline.h"
44#include "colors.h"
45#include "fc_client.h"
46#include "gui_main.h"
47#include "qtg_cxxside.h"
48
49static bool is_plain_public_message(QString s);
50
51 FC_CPP_DECLARE_LISTENER(chat_listener)
52 QStringList chat_listener::history = QStringList();
53 QStringList chat_listener::word_list = QStringList();
54
55/***********************************************************************/
58 void chat_listener::update_word_list()
59{
60 QString str;
61
62 conn_list_iterate(game.est_connections, pconn) {
63 if (pconn->playing) {
64 word_list << pconn->playing->name;
65 word_list << pconn->playing->username;
66 } else {
67 word_list << pconn->username;
68 }
69 } conn_list_iterate_end;
70
71 players_iterate(pplayer) {
72 str = pplayer->name;
73 if (!word_list.contains(str)) {
74 word_list << str;
75 }
76 } players_iterate_end
77
78 invoke(&chat_listener::chat_word_list_changed, word_list);
79}
80
81/***********************************************************************/
84chat_listener::chat_listener() :
85 position(HISTORY_END)
86{}
87
88/***********************************************************************/
92 void chat_listener::chat_message_received(const QString &,
93 const struct text_tag_list *)
94{}
95
96/***********************************************************************/
100 void chat_listener::chat_word_list_changed(const QStringList &)
101{}
102
103/***********************************************************************/
109 void chat_listener::send_chat_message(const QString &message)
110{
111 int index;
112 QString splayer, s;
113
114 /* FIXME
115 * Key == PICK: used for picking nation, it was put here cause those
116 * Qt slots are a bit limited ...I'm unable to pass custom player pointer
117 * or idk how to do that
118 */
119 s = message;
120 index = message.indexOf("PICK:");
121
122 if (index != -1) {
123 s = s.remove("PICK:");
124 // Now should be playername left in string
125 players_iterate(pplayer) {
126 splayer = QString(pplayer->name);
127
128 if (!splayer.compare(s)) {
129 popup_races_dialog(pplayer);
130 }
131 } players_iterate_end;
132 return;
133 }
134
135 history << message;
136 reset_history_position();
137
138 // If client send commands to take ai, set /away to disable AI
139 if (message.startsWith("/take ")) {
140 s = s.remove("/take ");
141 players_iterate(pplayer) {
142 splayer = QString(pplayer->name);
143 splayer = "\"" + splayer + "\"";
144
145 if (!splayer.compare(s)) {
146 if (is_ai(pplayer)) {
147 send_chat(message.toUtf8());
148 send_chat("/away");
149 return;
150 }
151 }
152 } players_iterate_end;
153 }
154
155 // Option to send to allies by default
156 if (!message.isEmpty()) {
157 if (client_state() >= C_S_RUNNING && gui_options.gui_qt_allied_chat_only
158 && is_plain_public_message(message)) {
159 send_chat((QString(CHAT_ALLIES_PREFIX)
160 + " " + message).toUtf8());
161 } else {
162 send_chat(message.toUtf8());
163 }
164 }
165 // Empty messages aren't sent
166 // FIXME Inconsistent behavior: "." will send an empty message to allies
167}
168
169/***********************************************************************/
173 QString chat_listener::back_in_history()
174{
175 if (!history.empty() && position == HISTORY_END) {
176 position = history.size() - 1;
177 } else if (position > 0) {
178 position--;
179 }
180 return history.empty() ? "" : history.at(position);
181}
182
183/***********************************************************************/
187 QString chat_listener::forward_in_history()
188{
189 if (position == HISTORY_END) {
190 return "";
191 }
192 position++;
193 if (position >= history.size()) {
194 position = HISTORY_END;
195 return "";
196 } else {
197 return history.at(position);
198 }
199}
200
201/***********************************************************************/
204 void chat_listener::reset_history_position()
205{
206 position = HISTORY_END;
207}
208
209/***********************************************************************/
212chat_input::chat_input(QWidget *parent) :
213 QLineEdit(parent)
214{
215 connect(this, &QLineEdit::returnPressed, this, &chat_input::send);
216 chat_word_list_changed(current_word_list());
217 chat_listener::listen();
218}
219
220/***********************************************************************/
223 void chat_input::send()
224{
225 send_chat_message(text());
226 clear();
227}
228
229/***********************************************************************/
232 void chat_input::chat_word_list_changed(const QStringList &cmplt_word_list)
233{
234 QCompleter *cmplt = completer();
235
236 if (cmplt != nullptr) {
237 delete cmplt;
238 }
239
240 cmplt = new QCompleter(cmplt_word_list);
241 cmplt->setCaseSensitivity(Qt::CaseInsensitive);
242 cmplt->setCompletionMode(QCompleter::InlineCompletion);
243 setCompleter(cmplt);
244}
245
246/***********************************************************************/
249 bool chat_input::event(QEvent *event)
250{
251 if (event->type() == QEvent::KeyPress) {
252 QKeyEvent *keyEvent = static_cast< QKeyEvent *>(event);
253 switch (keyEvent->key()) {
254 case Qt::Key_Up:
255 setText(back_in_history());
256 return true;
257 case Qt::Key_Down:
258 setText(forward_in_history());
259 return true;
260 }
261 }
262 return QLineEdit::event(event);
263}
264
265/***********************************************************************/
268chatwdg::chatwdg(QWidget *parent)
269{
270 QGridLayout *gl;
271
272 setParent(parent);
273 cb = new QCheckBox("");
274 cb->setToolTip(_("Allies only"));
275 cb->setChecked(gui_options.gui_qt_allied_chat_only);
276 gl = new QGridLayout;
277 chat_line = new chat_input;
278 chat_output = new text_browser_dblclck(this);
279 chat_output->setFont(*fc_font::instance()->get_font(fonts::chatline));
280 remove_links = new QPushButton("");
281 remove_links->setIcon(style()->standardPixmap(QStyle::SP_DialogCancelButton));
282 remove_links->setToolTip(_("Clear links"));
283 gl->setVerticalSpacing(0);
284 gl->addWidget(chat_output,0 , 0, 1 ,3);
285 gl->addWidget(chat_line,1, 0);
286 gl->addWidget(cb,1,1);
287 gl->addWidget(remove_links,1,2);
288 gl->setContentsMargins(0, 0, 6, 0);
289 setLayout(gl);
290 chat_output->setReadOnly(true);
291 chat_line->installEventFilter(this);
292 chat_output->setVisible(true);
293 chat_output->setAcceptRichText(true);
294 chat_output->setOpenLinks(false);
295 chat_output->setReadOnly(true);
296 connect(chat_output, &QTextBrowser::anchorClicked,
297 this, &chatwdg::anchor_clicked);
298 connect(chat_output, &QTextBrowser::anchorClicked,
299 this, &chatwdg::anchor_clicked);
300 connect(chat_output, &text_browser_dblclck::dbl_clicked,
301 this, &chatwdg::toggle_size);
302 connect(remove_links, &QAbstractButton::clicked, this, &chatwdg::rm_links);
303 connect(cb, &QCheckBox::stateChanged, this, &chatwdg::state_changed);
304 setMouseTracking(true);
305
306 chat_listener::listen();
307}
308
309/***********************************************************************/
312 void chatwdg::state_changed(int state)
313{
314 if (state > 0) {
315 gui_options.gui_qt_allied_chat_only = true;
316 } else {
317 gui_options.gui_qt_allied_chat_only = false;
318 }
319}
320
321/***********************************************************************/
324 void chatwdg::toggle_size()
325{
326 if (gui()->infotab->chat_maximized) {
327 gui()->infotab->restore_chat();
328 return;
329 } else {
330 gui()->infotab->maximize_chat();
331 chat_line->setFocus();
332 }
333}
334
335/***********************************************************************/
338 void chatwdg::scroll_to_bottom()
339{
340 chat_output->verticalScrollBar()->setSliderPosition(
341 chat_output->verticalScrollBar()->maximum());
342}
343
344
345/***********************************************************************/
348 void chatwdg::update_font()
349{
350 QFont *qf;
351 qf = fc_font::instance()->get_font(fonts::chatline);
352 chat_output->setFont(*qf);
353}
354
355/***********************************************************************/
358 void chatwdg::rm_links()
359{
360 link_marks_clear_all();
361}
362
363/***********************************************************************/
366 void chatwdg::anchor_clicked(const QUrl &link)
367{
368 int n;
369 QStringList sl;
370 int id;
371 enum text_link_type type;
372 struct tile *ptile = nullptr;
373
374 sl = link.toString().split(",");
375 n = sl.at(0).toInt();
376 id = sl.at(1).toInt();
377
378 type = static_cast< text_link_type>(n);
379
380 switch (type) {
381 case TLT_CITY: {
382 struct city *pcity = game_city_by_number(id);
383
384 if (pcity) {
385 ptile = client_city_tile(pcity);
386 } else {
387 output_window_append(ftc_client, _("This city isn't known!"));
388 }
389 }
390 break;
391 case TLT_TILE:
392 ptile = index_to_tile(&(wld.map), id);
393
394 if (!ptile) {
395 output_window_append(ftc_client,
396 _("This tile doesn't exist in this game!"));
397 }
398 break;
399 case TLT_UNIT: {
400 struct unit *punit = game_unit_by_number(id);
401
402 if (punit) {
403 ptile = unit_tile(punit);
404 } else {
405 output_window_append(ftc_client, _("This unit isn't known!"));
406 }
407 }
408 break;
409 }
410 if (ptile != nullptr) {
411 center_tile_mapcanvas(ptile);
412 link_mark_restore(type, id);
413 }
414}
415
416/***********************************************************************/
419 void chatwdg::chat_message_received(const QString &message,
420 const struct text_tag_list *tags)
421{
422 QColor col = chat_output->palette().color(QPalette::Text);
423
424 append(apply_tags(message, tags, col));
425}
426
427/***********************************************************************/
430 void chatwdg::append(const QString &str)
431{
432 QTextCursor cursor;
433
434 chat_output->append(str);
435 chat_output->verticalScrollBar()->setSliderPosition(
436 chat_output->verticalScrollBar()->maximum());
437}
438
439/***********************************************************************/
442 void chatwdg::paint(QPainter *painter, QPaintEvent *event)
443{
444 painter->setBrush(QColor(0, 0, 0, 35));
445 painter->drawRect(0, 0, width(), height());
446}
447
448/***********************************************************************/
451 void chatwdg::paintEvent(QPaintEvent *event)
452{
453 QPainter painter;
454
455 painter.begin(this);
456 paint(&painter, event);
457 painter.end();
458}
459
460/***********************************************************************/
463 bool chatwdg::eventFilter(QObject *obj, QEvent *event)
464{
465 if (obj == chat_line) {
466 if (event->type() == QEvent::KeyPress) {
467 QKeyEvent *keyEvent = static_cast< QKeyEvent *>(event);
468
469 if (keyEvent->key() == Qt::Key_Escape) {
470 gui()->infotab->restore_chat();
471 gui()->mapview_wdg->setFocus();
472 return true;
473 }
474 }
475 if (event->type() == QEvent::ShortcutOverride) {
476 event->setAccepted(true);
477 }
478 }
479
480 return QObject::eventFilter(obj, event);
481}
482
483/***********************************************************************/
486 void chatwdg::update_widgets()
487{
488 if (is_server_running()) {
489 cb->hide();
490 remove_links->hide();
491 } else {
492 cb->show();
493 remove_links->show();
494 }
495}
496
497/***********************************************************************/
501 int chatwdg::default_size(int lines)
502{
503 int line_count = 0;
504 int line_height;
505 int size;
506 QTextBlock qtb;
507
508 qtb = chat_output->document()->firstBlock();
509 /* Count all lines in all text blocks layouts
510 * document()->lineCount returns number of lines without wordwrap */
511
512 while (qtb.isValid()) {
513 line_count = line_count + qtb.layout()->lineCount();
514 qtb = qtb.next();
515 }
516
517 if (line_count == 0) {
518 return 0;
519 }
520
521 line_height = (chat_output->document()->size().height()
522 - 2 * chat_output->document()->documentMargin())
523 / line_count;
524
525 size = lines * line_height
526 + chat_line->size().height() + chat_output->document()->documentMargin();
527 size = qMax(0, size);
528
529 return size;
530}
531
532/***********************************************************************/
535 void chatwdg::make_link(struct tile *ptile)
536{
537 struct unit *punit;
538 char buf[MAX_LEN_MSG];
539
540 punit = find_visible_unit(ptile);
541 if (tile_city(ptile)) {
542 sz_strlcpy(buf, city_link(tile_city(ptile)));
543 } else if (punit) {
544 sz_strlcpy(buf, unit_link(punit));
545 } else {
546 sz_strlcpy(buf, tile_link(ptile));
547 }
548 chat_line->insert(QString(buf));
549 chat_line->setFocus();
550}
551
552/***********************************************************************/
555 QString apply_tags(QString str, const struct text_tag_list *tags,
556 QColor bg_color)
557{
558 int start, stop, last_i;
559 QString str_col;
560 QString color;
561 QString final_string;
562 QByteArray qba;
563 QColor qc;
564 QMultiMap <int, QString> mm;
565 QByteArray str_bytes;
566
567 if (tags == nullptr) {
568 return str;
569 }
570 str_bytes = str.toUtf8();
571 qba = str_bytes.data();
572
573 text_tag_list_iterate(tags, ptag) {
574 if ((text_tag_stop_offset(ptag) == FT_OFFSET_UNSET)) {
575 stop = qba.length();
576 } else {
577 stop = text_tag_stop_offset(ptag);
578 }
579
580 if ((text_tag_start_offset(ptag) == FT_OFFSET_UNSET)) {
581 start = 0;
582 } else {
583 start = text_tag_start_offset(ptag);
584 }
585 switch (text_tag_type(ptag)) {
586 case TTT_BOLD:
587 mm.insert(stop, "</b>");
588 mm.insert(start, "<b>");
589 break;
590 case TTT_ITALIC:
591 mm.insert(stop, "</i>");
592 mm.insert(start, "<i>");
593 break;
594 case TTT_STRIKE:
595 mm.insert(stop, "</s>");
596 mm.insert(start, "<s>");
597 break;
598 case TTT_UNDERLINE:
599 mm.insert(stop, "</u>");
600 mm.insert(start, "<u>");
601 break;
602 case TTT_COLOR:
603 if (text_tag_color_foreground(ptag)) {
604 color = text_tag_color_foreground(ptag);
605 if (color == "#00008B") {
606 color = bg_color.name();
607 } else {
608#ifdef FC_QT6X_MODE
609 qc = QColor::fromString(color);
610#else // FC_QT6X_MODE
611 qc.setNamedColor(color);
612#endif // FC_QT6X_MODE
613 qc = qc.lighter(200);
614 color = qc.name();
615 }
616 str_col = QString("<span style=color:%1>").arg(color);
617 mm.insert(stop, "</span>");
618 mm.insert(start, str_col);
619 }
620 if (text_tag_color_background(ptag)) {
621 color = text_tag_color_background(ptag);
622 if (
623#ifdef FC_QT6X_MODE
624 QColor::isValidColorName(color)
625#else // FC_QT6X_MODE
626 QColor::isValidColor(color)
627#endif // FC_QT6X_MODE
628 ) {
629 str_col = QString("<span style= background-color:%1;>").arg(color);
630 mm.insert(stop, "</span>");
631 mm.insert(start, str_col);
632 }
633 }
634 break;
635 case TTT_LINK: {
636 struct color *pcolor = nullptr;
637
638 switch (text_tag_link_type(ptag)) {
639 case TLT_CITY:
640 pcolor = get_color(tileset, COLOR_MAPVIEW_CITY_LINK);
641 break;
642 case TLT_TILE:
643 pcolor = get_color(tileset, COLOR_MAPVIEW_TILE_LINK);
644 break;
645 case TLT_UNIT:
646 pcolor = get_color(tileset, COLOR_MAPVIEW_UNIT_LINK);
647 break;
648 }
649
650 if (pcolor == nullptr) {
651 break; // Not a valid link type case.
652 }
653 color = pcolor->qcolor.name(QColor::HexRgb);
654 str_col = QString("<font color=\"%1\">").arg(color);
655 mm.insert(stop, "</a></font>");
656
657 color = QString(str_col + "<a href=%1,%2>").
658 arg(QString::number(text_tag_link_type(ptag)),
659 QString::number(text_tag_link_id(ptag)));
660 mm.insert(start, color);
661 }
662 }
663 } text_tag_list_iterate_end;
664
665 // Insert html starting from last items
666 last_i = str.length();
667 QMultiMap<int, QString>::const_iterator i = mm.constEnd();
668 QMultiMap<int, QString>::const_iterator j = mm.constEnd();
669
670 while (i != mm.constBegin()) {
671 i--;
672 if (i.key() < last_i) {
673 final_string = final_string.prepend(QString(qba.mid(i.key(),
674 last_i - i.key()))
675 .toHtmlEscaped());
676 }
677 last_i = i.key();
678 j = i;
679 if (i != mm.constBegin()) {
680 j--;
681 }
682 if (j.key() == i.key() && i != j) {
683 final_string = final_string.prepend(j.value());
684 final_string = final_string.prepend(i.value());
685 i--;
686 } else {
687 final_string = final_string.prepend(i.value());
688 }
689 }
690
691 if (last_i == str.length()) {
692 return str;
693 }
694
695 return final_string;
696}
697
698/***********************************************************************/
702 static bool is_plain_public_message(QString s)
703{
704 QString s1, str;
705 int i;
706
707 str = s.trimmed();
708 if (str.at(0) == SERVER_COMMAND_PREFIX
709 || str.at(0) == CHAT_ALLIES_PREFIX
710 || str.at(0) == CHAT_DIRECT_PREFIX) {
711 return false;
712 }
713
714 // Search for private message
715 if (!str.contains(CHAT_DIRECT_PREFIX)) {
716 return true;
717 }
718 i = str.indexOf(CHAT_DIRECT_PREFIX);
719 str = str.left(i);
720
721 // Compare all players and connections looking for match
722 conn_list_iterate(game.all_connections, pconn) {
723 s1 = pconn->username;
724 if (s1.length() < i) {
725 continue;
726 }
727 if (!QString::compare(s1.left(i), str, Qt::CaseInsensitive)) {
728 return false;
729 }
730 } conn_list_iterate_end;
731 players_iterate(pplayer) {
732 s1 = pplayer->name;
733 if (s1.length() < i) {
734 continue;
735 }
736 if (!QString::compare(s1.left(i), str, Qt::CaseInsensitive)) {
737 return false;
738 }
739 } players_iterate_end;
740
741 return true;
742}
743
744/***********************************************************************/
748 void qtg_real_output_window_append(const char *astring,
749 const struct text_tag_list *tags,
750 int conn_id)
751{
752 QString str;
753 QString wakeup;
754 QApplication *qapp;
755
756 str = QString::fromUtf8(astring);
757 gui()->set_status_bar(str);
758
759 wakeup = gui_options.gui_qt_wakeup_text;
760
761 // Format wakeup string if needed
762 if (wakeup.contains("%1")) {
763 wakeup = wakeup.arg(client.conn.username);
764 }
765
766 qapp = current_app();
767
768 if (str.contains(client.conn.username)) {
769 qapp->alert(gui()->central_wdg);
770 }
771
772 // Play sound if we encountered wakeup string
773 if (str.contains(wakeup) && client_state() < C_S_RUNNING
774 && !wakeup.isEmpty()) {
775 qapp->alert(gui()->central_wdg);
776 audio_play_sound("e_player_wake", nullptr, nullptr);
777 }
778
779 chat_listener::update_word_list();
780 chat_listener::invoke(&chat_listener::chat_message_received,
781 str, tags);
782}
783
784/***********************************************************************/
788 void log_output_window(void)
789{
790 // PORTME
791 write_chatline_content(nullptr);
792}
793
794/***********************************************************************/
797 void clear_output_window(void)
798{
799 // PORTME
800#if 0
801 set_output_window_text(_("Cleared output window."));
802#endif
803}
804
805/***********************************************************************/
808version_message_event::version_message_event(const QString &msg) :
809 QEvent(QEvent::User),
810 message(msg)
811{}
812
813/***********************************************************************/
816 void qtg_version_message(const char *vertext)
817{
818 current_app()->postEvent(gui(), new version_message_event(vertext));
819}
str
#define str
Definition astring.c:76
n
#define n
Definition astring.c:77
audio_play_sound
void audio_play_sound(const char *const tag, const char *const alt_tag, const char *const alt_tag2)
Definition audio.c:528
audio.h
get_font
static QFont * get_font(enum client_font font)
Definition canvas.cpp:379
height
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
pcolor
struct canvas int int int int struct sprite *sprite struct canvas struct color * pcolor
Definition canvas_g.h:56
width
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
chat.h
CHAT_DIRECT_PREFIX
#define CHAT_DIRECT_PREFIX
Definition chat.h:31
CHAT_ALLIES_PREFIX
#define CHAT_ALLIES_PREFIX
Definition chat.h:30
SERVER_COMMAND_PREFIX
#define SERVER_COMMAND_PREFIX
Definition chat.h:28
log_output_window
void log_output_window(void)
Definition chatline.cpp:788
clear_output_window
void clear_output_window(void)
Definition chatline.cpp:797
apply_tags
QString apply_tags(QString str, const struct text_tag_list *tags, QColor bg_color)
Definition chatline.cpp:555
qtg_version_message
void qtg_version_message(const char *vertext)
Definition chatline.cpp:816
qtg_real_output_window_append
void qtg_real_output_window_append(const char *astring, const struct text_tag_list *tags, int conn_id)
Definition chatline.cpp:748
is_plain_public_message
static bool is_plain_public_message(QString s)
Definition chatline.cpp:702
send_chat
int send_chat(const char *message)
Definition chatline_common.c:46
output_window_append
void output_window_append(const struct ft_color color, const char *featured_text)
Definition chatline_common.c:104
write_chatline_content
void write_chatline_content(const char *txt)
Definition chatline_common.c:196
chat_input
Definition chatline.h:82
chat_input::event
bool event(QEvent *event)
Definition chatline.cpp:249
chat_input::chat_word_list_changed
virtual void chat_word_list_changed(const QStringList &cmplt_word_list)
Definition chatline.cpp:232
chat_input::send
void send()
Definition chatline.cpp:223
chat_input::chat_input
chat_input(QWidget *parent=nullptr)
Definition chatline.cpp:212
chat_listener
Definition chatline.h:47
chat_listener::current_word_list
QStringList current_word_list()
Definition chatline.h:75
chat_listener::HISTORY_END
static const int HISTORY_END
Definition chatline.h:58
chat_listener::forward_in_history
QString forward_in_history()
Definition chatline.cpp:187
chat_listener::send_chat_message
void send_chat_message(const QString &message)
Definition chatline.cpp:109
chat_listener::reset_history_position
void reset_history_position()
Definition chatline.cpp:204
chat_listener::back_in_history
QString back_in_history()
Definition chatline.cpp:173
chat_listener::history
static QStringList history
Definition chatline.h:49
chat_listener::chat_word_list_changed
virtual void chat_word_list_changed(const QStringList &cmplt_word_list)
Definition chatline.cpp:100
chat_listener::update_word_list
static void update_word_list()
Definition chatline.cpp:58
chat_listener::word_list
static QStringList word_list
Definition chatline.h:54
chat_listener::chat_listener
chat_listener()
Definition chatline.cpp:84
chat_listener::chat_message_received
virtual void chat_message_received(const QString &, const struct text_tag_list *)
Definition chatline.cpp:92
chat_listener::position
int position
Definition chatline.h:51
chatwdg::eventFilter
bool eventFilter(QObject *obj, QEvent *event)
Definition chatline.cpp:463
chatwdg::chat_line
chat_input * chat_line
Definition chatline.h:121
chatwdg::chatwdg
chatwdg(QWidget *parent)
Definition chatline.cpp:268
chatwdg::paintEvent
void paintEvent(QPaintEvent *event)
Definition chatline.cpp:451
chatwdg::update_font
void update_font()
Definition chatline.cpp:348
chatwdg::anchor_clicked
void anchor_clicked(const QUrl &link)
Definition chatline.cpp:366
chatwdg::default_size
int default_size(int lines)
Definition chatline.cpp:501
chatwdg::chat_output
text_browser_dblclck * chat_output
Definition chatline.h:140
chatwdg::make_link
void make_link(struct tile *ptile)
Definition chatline.cpp:535
chatwdg::chat_message_received
void chat_message_received(const QString &message, const struct text_tag_list *tags)
Definition chatline.cpp:419
chatwdg::scroll_to_bottom
void scroll_to_bottom()
Definition chatline.cpp:338
chatwdg::paint
void paint(QPainter *painter, QPaintEvent *event)
Definition chatline.cpp:442
chatwdg::update_widgets
void update_widgets()
Definition chatline.cpp:486
chatwdg::cb
QCheckBox * cb
Definition chatline.h:142
chatwdg::rm_links
void rm_links()
Definition chatline.cpp:358
chatwdg::remove_links
QPushButton * remove_links
Definition chatline.h:141
chatwdg::state_changed
void state_changed(int state)
Definition chatline.cpp:312
chatwdg::append
void append(const QString &str)
Definition chatline.cpp:430
chatwdg::toggle_size
void toggle_size()
Definition chatline.cpp:324
fc_font::instance
static fc_font * instance()
Definition fonts.cpp:41
fc_font::get_font
QFont * get_font(QString name)
Definition fonts.cpp:63
listener< chat_listener >::invoke
static void invoke(_member_fct_ function)
Definition listener.h:175
listener< chat_listener >::listen
void listen()
Definition listener.h:149
text_browser_dblclck
Definition chatline.h:100
text_browser_dblclck::dbl_clicked
void dbl_clicked()
version_message_event
Definition chatline.h:147
version_message_event::version_message_event
version_message_event(const QString &msg)
Definition chatline.cpp:808
client
struct civclient client
Definition client_main.c:153
client_state
enum client_states client_state(void)
Definition client_main.c:1034
C_S_RUNNING
@ C_S_RUNNING
Definition client_main.h:47
client_city_tile
struct tile * client_city_tile(const struct city *pcity)
Definition climap.c:87
climap.h
climisc.h
get_color
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
Definition colors_common.c:100
incite_cost
char * incite_cost
Definition comments.c:74
MAX_LEN_MSG
#define MAX_LEN_MSG
Definition conn_types.h:37
is_server_running
bool is_server_running(void)
Definition connectdlg_common.c:124
connectdlg_common.h
conn_list_iterate
#define conn_list_iterate(connlist, pconn)
Definition connection.h:108
conn_list_iterate_end
#define conn_list_iterate_end
Definition connection.h:110
find_visible_unit
struct unit * find_visible_unit(struct tile *ptile)
Definition control.c:804
control.h
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
id
int int id
Definition editgui_g.h:28
event
enum event_type event
Definition events.c:81
fc_client.h
_
#define _(String)
Definition fcintl.h:67
text_tag_link_type
enum text_link_type text_tag_link_type(const struct text_tag *ptag)
Definition featured_text.c:745
tile_link
const char * tile_link(const struct tile *ptile)
Definition featured_text.c:1110
text_tag_stop_offset
ft_offset_t text_tag_stop_offset(const struct text_tag *ptag)
Definition featured_text.c:708
text_tag_color_foreground
const char * text_tag_color_foreground(const struct text_tag *ptag)
Definition featured_text.c:717
ftc_client
const struct ft_color ftc_client
Definition featured_text.c:78
city_link
const char * city_link(const struct city *pcity)
Definition featured_text.c:1076
text_tag_link_id
int text_tag_link_id(const struct text_tag *ptag)
Definition featured_text.c:760
text_tag_start_offset
ft_offset_t text_tag_start_offset(const struct text_tag *ptag)
Definition featured_text.c:700
unit_link
const char * unit_link(const struct unit *punit)
Definition featured_text.c:1126
text_tag_color_background
const char * text_tag_color_background(const struct text_tag *ptag)
Definition featured_text.c:731
text_tag_list_iterate_end
#define text_tag_list_iterate_end
Definition featured_text.h:116
text_tag_list_iterate
#define text_tag_list_iterate(tags, ptag)
Definition featured_text.h:114
FT_OFFSET_UNSET
#define FT_OFFSET_UNSET
Definition featured_text.h:104
text_link_type
text_link_type
Definition featured_text.h:131
TLT_TILE
@ TLT_TILE
Definition featured_text.h:133
TLT_UNIT
@ TLT_UNIT
Definition featured_text.h:134
TLT_CITY
@ TLT_CITY
Definition featured_text.h:132
text_tag_type
text_tag_type
Definition featured_text.h:120
TTT_LINK
@ TTT_LINK
Definition featured_text.h:126
TTT_BOLD
@ TTT_BOLD
Definition featured_text.h:121
TTT_ITALIC
@ TTT_ITALIC
Definition featured_text.h:122
TTT_STRIKE
@ TTT_STRIKE
Definition featured_text.h:123
TTT_COLOR
@ TTT_COLOR
Definition featured_text.h:125
TTT_UNDERLINE
@ TTT_UNDERLINE
Definition featured_text.h:124
game
struct civ_game game
Definition game.c:61
wld
struct world wld
Definition game.c:62
game_unit_by_number
struct unit * game_unit_by_number(int id)
Definition game.c:115
game_city_by_number
struct city * game_city_by_number(int id)
Definition game.c:106
game.h
is_plain_public_message
static bool is_plain_public_message(const char *s)
Definition chatline.c:98
popup_races_dialog
void popup_races_dialog(struct player *pplayer)
Definition dialogs.c:1215
type
GType type
Definition repodlgs.c:1313
apply_tags
QString apply_tags(QString str, const struct text_tag_list *tags, QColor bg_color)
Definition chatline.cpp:555
set_output_window_text
#define set_output_window_text(_pstr_)
Definition chatline.h:31
chatline.h
colors.h
gui_main.h
qapp
static QApplication * qapp
Definition gui_main.cpp:68
current_app
QApplication * current_app()
Definition gui_main.cpp:226
FC_CPP_DECLARE_LISTENER
#define FC_CPP_DECLARE_LISTENER(_type_)
Definition listener.h:134
index_to_tile
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
Definition map.c:462
link_mark_restore
void link_mark_restore(enum text_link_type type, int id)
Definition mapview_common.c:3979
center_tile_mapcanvas
void center_tile_mapcanvas(const struct tile *ptile)
Definition mapview_common.c:1237
link_marks_clear_all
void link_marks_clear_all(void)
Definition mapview_common.c:3934
gui
static mpgui * gui
Definition mpgui_qt.cpp:52
fonts::chatline
const char *const chatline
Definition fonts.h:31
gui_options
struct client_options gui_options
Definition options.c:71
lines
char * lines
Definition packhand.c:131
players_iterate_end
#define players_iterate_end
Definition player.h:539
players_iterate
#define players_iterate(_pplayer)
Definition player.h:534
is_ai
#define is_ai(plr)
Definition player.h:232
qtg_cxxside.h
size
size_t size
Definition specvec.h:72
astring
Definition astring.h:36
city
Definition city.h:320
civ_game::est_connections
struct conn_list * est_connections
Definition game.h:97
civ_game::all_connections
struct conn_list * all_connections
Definition game.h:96
civclient::conn
struct connection conn
Definition client_main.h:96
client_options::gui_qt_allied_chat_only
bool gui_qt_allied_chat_only
Definition options.h:445
client_options::gui_qt_wakeup_text
char gui_qt_wakeup_text[512]
Definition options.h:457
color
Definition colors.h:21
connection::username
char username[MAX_LEN_NAME]
Definition connection.h:164
message
Definition messagewin_common.h:29
tile
Definition tile.h:50
tileset
Definition tilespec.c:482
unit
Definition unit.h:140
world::map
struct civ_map map
Definition world_object.h:38
sz_strlcpy
#define sz_strlcpy(dest, src)
Definition support.h:189
tile_city
struct city * tile_city(const struct tile *ptile)
Definition tile.c:83
unit_tile
#define unit_tile(_pu)
Definition unit.h:397