19#include <QApplication>
26#include <QStyleFactory>
29#include <QTextBrowser>
93 const struct text_tag_list *)
120 index =
message.indexOf(
"PICK:");
123 s = s.remove(
"PICK:");
126 splayer = QString(pplayer->name);
128 if (!splayer.compare(s)) {
141 if (
message.startsWith(
"/take ")) {
142 s = s.remove(
"/take ");
144 splayer = QString(pplayer->name);
145 splayer =
"\"" + splayer +
"\"";
147 if (!splayer.compare(s)) {
148 if (
is_ai(pplayer)) {
238 QCompleter *cmplt = completer();
240 if (cmplt !=
nullptr) {
244 cmplt =
new QCompleter(cmplt_word_list);
245 cmplt->setCaseSensitivity(Qt::CaseInsensitive);
246 cmplt->setCompletionMode(QCompleter::InlineCompletion);
255 if (
event->type() == QEvent::KeyPress) {
256 QKeyEvent *keyEvent =
static_cast<QKeyEvent *
>(
event);
257 switch (keyEvent->key()) {
266 return QLineEdit::event(
event);
277 cb =
new QCheckBox(
"");
278 cb->setToolTip(
_(
"Allies only"));
280 gl =
new QGridLayout;
285 remove_links->setIcon(style()->standardPixmap(QStyle::SP_DialogCancelButton));
287 gl->setVerticalSpacing(0);
290 gl->addWidget(
cb,1,1);
292 gl->setContentsMargins(0, 0, 6, 0);
308 setMouseTracking(
true);
330 if (
gui()->infotab->chat_maximized) {
331 gui()->infotab->restore_chat();
334 gui()->infotab->maximize_chat();
344 chat_output->verticalScrollBar()->setSliderPosition(
376 struct tile *ptile =
nullptr;
378 sl = link.toString().split(
",");
379 n = sl.at(0).toInt();
380 id = sl.at(1).toInt();
400 _(
"This tile doesn't exist in this game!"));
414 if (ptile !=
nullptr) {
424 const struct text_tag_list *tags)
426 QColor col =
chat_output->palette().color(QPalette::Text);
438 chat_output->verticalScrollBar()->setSliderPosition(
447 painter->setBrush(QColor(0, 0, 0, 35));
469 if (
event->type() == QEvent::KeyPress) {
470 QKeyEvent *keyEvent =
static_cast<QKeyEvent *
>(
event);
471 if (keyEvent->key() == Qt::Key_Escape) {
472 gui()->infotab->restore_chat();
473 gui()->mapview_wdg->setFocus();
477 if (
event->type() == QEvent::ShortcutOverride) {
478 event->setAccepted(
true);
482 return QObject::eventFilter(obj,
event);
514 while (qtb.isValid()) {
515 line_count = line_count + qtb.layout()->lineCount();
519 if (line_count == 0) {
523 line_height = (
chat_output->document()->size().height()
560 int start, stop, last_i;
563 QString final_string;
566 QMultiMap <int, QString> mm;
567 QByteArray str_bytes;
569 if (tags ==
nullptr) {
572 str_bytes =
str.toUtf8();
573 qba = str_bytes.data();
589 mm.insert(stop,
"</b>");
590 mm.insert(start,
"<b>");
593 mm.insert(stop,
"</i>");
594 mm.insert(start,
"<i>");
597 mm.insert(stop,
"</s>");
598 mm.insert(start,
"<s>");
601 mm.insert(stop,
"</u>");
602 mm.insert(start,
"<u>");
607 if (
color ==
"#00008B") {
608 color = bg_color.name();
610 qc.setNamedColor(
color);
611 qc = qc.lighter(200);
614 str_col = QString(
"<span style=color:%1>").arg(
color);
615 mm.insert(stop,
"</span>");
616 mm.insert(start, str_col);
620 if (QColor::isValidColor(
color)) {
621 str_col = QString(
"<span style= background-color:%1;>").arg(
color);
622 mm.insert(stop,
"</span>");
623 mm.insert(start, str_col);
646 str_col = QString(
"<font color=\"%1\">").arg(
color);
647 mm.insert(stop,
"</a></font>");
649 color = QString(str_col +
"<a href=%1,%2>").
652 mm.insert(start,
color);
658 last_i =
str.length();
659 QMultiMap<int, QString>::const_iterator i = mm.constEnd();
660 QMultiMap<int, QString>::const_iterator j = mm.constEnd();
662 while (i != mm.constBegin()) {
664 if (i.key() < last_i) {
665 final_string = final_string.prepend(QString(qba.mid(i.key(),
671 if (i != mm.constBegin()) {
674 if (j.key() == i.key() && i != j) {
675 final_string = final_string.prepend(j.value());
676 final_string = final_string.prepend(i.value());
679 final_string = final_string.prepend(i.value());
683 if (last_i ==
str.length()) {
715 s1 = pconn->username;
716 if (s1.length() < i) {
719 if (!QString::compare(s1.left(i),
str, Qt::CaseInsensitive)) {
725 if (s1.length() < i) {
728 if (!QString::compare(s1.left(i),
str, Qt::CaseInsensitive)) {
741 const struct text_tag_list *tags,
749 gui()->set_status_bar(
str);
754 if (wakeup.contains(
"%1")) {
761 qapp->alert(
gui()->central_wdg);
766 && !wakeup.isEmpty()) {
767 qapp->alert(
gui()->central_wdg);
801 QEvent(QEvent::User),
void audio_play_sound(const char *const tag, const char *const alt_tag)
static QFont * get_font(enum client_font font)
struct canvas int int struct sprite int int int int height
struct canvas int int struct sprite bool int int fog_y struct canvas struct sprite struct color * pcolor
struct canvas int int struct sprite int int int width
#define CHAT_DIRECT_PREFIX
#define CHAT_ALLIES_PREFIX
#define SERVER_COMMAND_PREFIX
void log_output_window(void)
void clear_output_window(void)
QString apply_tags(QString str, const struct text_tag_list *tags, QColor bg_color)
void qtg_version_message(const char *vertext)
void qtg_real_output_window_append(const char *astring, const struct text_tag_list *tags, int conn_id)
static bool is_plain_public_message(QString s)
int send_chat(const char *message)
void output_window_append(const struct ft_color color, const char *featured_text)
void write_chatline_content(const char *txt)
QStringList current_word_list()
static const int HISTORY_END
QString forward_in_history()
void send_chat_message(const QString &message)
void reset_history_position()
QString back_in_history()
static QStringList history
virtual void chat_word_list_changed(const QStringList &cmplt_word_list)
static void update_word_list()
static QStringList word_list
virtual void chat_message_received(const QString &, const struct text_tag_list *)
bool eventFilter(QObject *obj, QEvent *event)
void paintEvent(QPaintEvent *event)
void anchor_clicked(const QUrl &link)
int default_size(int lines)
text_browser_dblclck * chat_output
void make_link(struct tile *ptile)
void chat_message_received(const QString &message, const struct text_tag_list *tags)
void paint(QPainter *painter, QPaintEvent *event)
QPushButton * remove_links
void state_changed(int state)
void append(const QString &str)
static fc_font * instance()
QFont * get_font(QString name)
static void invoke(_member_fct_ function)
version_message_event(const QString &msg)
enum client_states client_state(void)
struct tile * client_city_tile(const struct city *pcity)
struct color * get_color(const struct tileset *t, enum color_std stdcolor)
bool is_server_running(void)
#define conn_list_iterate(connlist, pconn)
#define conn_list_iterate_end
struct unit * find_visible_unit(struct tile *ptile)
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
enum text_link_type text_tag_link_type(const struct text_tag *ptag)
const char * tile_link(const struct tile *ptile)
ft_offset_t text_tag_stop_offset(const struct text_tag *ptag)
const char * text_tag_color_foreground(const struct text_tag *ptag)
const struct ft_color ftc_client
const char * city_link(const struct city *pcity)
int text_tag_link_id(const struct text_tag *ptag)
ft_offset_t text_tag_start_offset(const struct text_tag *ptag)
const char * unit_link(const struct unit *punit)
const char * text_tag_color_background(const struct text_tag *ptag)
#define text_tag_list_iterate_end
#define text_tag_list_iterate(tags, ptag)
struct unit * game_unit_by_number(int id)
struct city * game_city_by_number(int id)
static bool is_plain_public_message(const char *s)
void popup_races_dialog(struct player *pplayer)
QString apply_tags(QString str, const struct text_tag_list *tags, QColor bg_color)
#define set_output_window_text(_pstr_)
static QApplication * qapp
QApplication * current_app()
#define FC_CPP_DECLARE_LISTENER(_type_)
struct tile * index_to_tile(const struct civ_map *imap, int mindex)
void link_mark_restore(enum text_link_type type, int id)
void center_tile_mapcanvas(const struct tile *ptile)
void link_marks_clear_all(void)
const char *const chatline
struct client_options gui_options
#define players_iterate_end
#define players_iterate(_pplayer)
struct conn_list * est_connections
struct conn_list * all_connections
bool gui_qt_allied_chat_only
char gui_qt_wakeup_text[512]
char username[MAX_LEN_NAME]
#define sz_strlcpy(dest, src)
struct city * tile_city(const struct tile *ptile)