diff --git a/include/aoconfig.h b/include/aoconfig.h index 0fbb287f3..46fce7240 100644 --- a/include/aoconfig.h +++ b/include/aoconfig.h @@ -40,6 +40,7 @@ class AOConfig : public QObject bool is_manual_timeofday_selection_enabled() const; bool always_pre_enabled() const; int chat_tick_interval() const; + bool emote_preview_enabled() const; int log_max_lines() const; bool log_display_timestamp_enabled() const; bool log_display_self_highlight_enabled() const; @@ -89,6 +90,7 @@ public slots: void set_manual_timeofday_selection_enabled(bool p_enabled); void set_always_pre(bool p_enabled); void set_chat_tick_interval(int p_number); + void set_emote_preview(bool p_enabled); void set_log_max_lines(int p_number); void set_log_display_timestamp(bool p_enabled); void set_log_display_self_highlight(bool p_enabled); @@ -138,6 +140,7 @@ public slots: void character_ini_changed(QString base_character); void always_pre_changed(bool); void chat_tick_interval_changed(int); + void emote_preview_changed(bool); // log void log_max_lines_changed(int); diff --git a/include/aoconfigpanel.h b/include/aoconfigpanel.h index cc0915f93..6615ad1ab 100644 --- a/include/aoconfigpanel.h +++ b/include/aoconfigpanel.h @@ -92,6 +92,8 @@ private slots: QLineEdit *ui_showname = nullptr; QCheckBox *ui_always_pre = nullptr; QSpinBox *ui_chat_tick_interval = nullptr; + QCheckBox *ui_emote_preview = nullptr; + // IC Chatlog QSpinBox *ui_log_max_lines = nullptr; QCheckBox *ui_log_display_timestamp = nullptr; diff --git a/include/courtroom.h b/include/courtroom.h index 40477b343..4f59788df 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -585,6 +585,7 @@ private slots: void on_emote_clicked(int id); void show_emote_tooltip(int id, QPoint global_pos); void hide_emote_tooltip(int id); + void on_emote_preview_toggled(bool); void on_emote_left_clicked(); void on_emote_right_clicked(); diff --git a/res/ui/config_panel.ui b/res/ui/config_panel.ui index ad5b580c9..cd03f5eaf 100644 --- a/res/ui/config_panel.ui +++ b/res/ui/config_panel.ui @@ -409,7 +409,7 @@ - + Qt::Vertical @@ -422,6 +422,20 @@ + + + + + + + + + + + Emote preview: + + + diff --git a/src/aoconfig.cpp b/src/aoconfig.cpp index f2ba4e692..2fb58a8af 100644 --- a/src/aoconfig.cpp +++ b/src/aoconfig.cpp @@ -64,6 +64,7 @@ private slots: QMap ini_map; bool always_pre; int chat_tick_interval; + bool emote_preview; int log_max_lines; bool log_display_timestamp; bool log_display_self_highlight; @@ -132,6 +133,7 @@ void AOConfigPrivate::read_file() manual_timeofday_selection = cfg.value("manual_timeofday", false).toBool(); always_pre = cfg.value("always_pre", true).toBool(); chat_tick_interval = cfg.value("chat_tick_interval", 60).toInt(); + emote_preview = cfg.value("emote_preview", true).toBool(); log_max_lines = cfg.value("chatlog_limit", 100).toInt(); log_is_topdown = cfg.value("chatlog_scrolldown", true).toBool(); log_display_timestamp = cfg.value("chatlog_display_timestamp", true).toBool(); @@ -203,6 +205,7 @@ void AOConfigPrivate::save_file() cfg.setValue("manual_timeofday", manual_timeofday_selection); cfg.setValue("always_pre", always_pre); cfg.setValue("chat_tick_interval", chat_tick_interval); + cfg.setValue("emote_preview", emote_preview); cfg.setValue("chatlog_limit", log_max_lines); cfg.setValue("chatlog_display_timestamp", log_display_timestamp); cfg.setValue("chatlog_display_self_highlight", log_display_self_highlight); @@ -438,6 +441,11 @@ int AOConfig::chat_tick_interval() const return d->chat_tick_interval; } +bool AOConfig::emote_preview_enabled() const +{ + return d->emote_preview; +} + int AOConfig::log_max_lines() const { return d->log_max_lines; @@ -712,6 +720,14 @@ void AOConfig::set_chat_tick_interval(int p_number) d->invoke_signal("chat_tick_interval_changed", Q_ARG(int, p_number)); } +void AOConfig::set_emote_preview(bool p_enabled) +{ + if (d->emote_preview == p_enabled) + return; + d->emote_preview = p_enabled; + d->invoke_signal("emote_preview_changed", Q_ARG(bool, p_enabled)); +} + void AOConfig::set_log_max_lines(int p_number) { if (d->log_max_lines == p_number) diff --git a/src/aoconfigpanel.cpp b/src/aoconfigpanel.cpp index e3fc78a5b..6d65e067f 100644 --- a/src/aoconfigpanel.cpp +++ b/src/aoconfigpanel.cpp @@ -60,6 +60,7 @@ AOConfigPanel::AOConfigPanel(AOApplication *p_ao_app, QWidget *p_parent) ui_showname = AO_GUI_WIDGET(QLineEdit, "showname"); ui_always_pre = AO_GUI_WIDGET(QCheckBox, "always_pre"); ui_chat_tick_interval = AO_GUI_WIDGET(QSpinBox, "chat_tick_interval"); + ui_emote_preview = AO_GUI_WIDGET(QCheckBox, "emote_preview"); // IC Chatlog ui_log_max_lines = AO_GUI_WIDGET(QSpinBox, "log_length"); @@ -124,6 +125,7 @@ AOConfigPanel::AOConfigPanel(AOApplication *p_ao_app, QWidget *p_parent) SLOT(on_showname_placeholder_changed(QString))); connect(m_config, SIGNAL(always_pre_changed(bool)), ui_always_pre, SLOT(setChecked(bool))); connect(m_config, SIGNAL(chat_tick_interval_changed(int)), ui_chat_tick_interval, SLOT(setValue(int))); + connect(m_config, SIGNAL(emote_preview_changed(bool)), ui_emote_preview, SLOT(setChecked(bool))); // log connect(m_config, SIGNAL(log_max_lines_changed(int)), ui_log_max_lines, SLOT(setValue(int))); @@ -187,6 +189,7 @@ AOConfigPanel::AOConfigPanel(AOApplication *p_ao_app, QWidget *p_parent) connect(ui_showname, SIGNAL(editingFinished()), this, SLOT(showname_editing_finished())); connect(ui_always_pre, SIGNAL(toggled(bool)), m_config, SLOT(set_always_pre(bool))); connect(ui_chat_tick_interval, SIGNAL(valueChanged(int)), m_config, SLOT(set_chat_tick_interval(int))); + connect(ui_emote_preview, SIGNAL(toggled(bool)), m_config, SLOT(set_emote_preview(bool))); // out, log connect(ui_log_max_lines, SIGNAL(valueChanged(int)), m_config, SLOT(set_log_max_lines(int))); @@ -234,6 +237,7 @@ AOConfigPanel::AOConfigPanel(AOApplication *p_ao_app, QWidget *p_parent) on_showname_placeholder_changed(m_config->showname_placeholder()); ui_always_pre->setChecked(m_config->always_pre_enabled()); ui_chat_tick_interval->setValue(m_config->chat_tick_interval()); + ui_emote_preview->setChecked(m_config->emote_preview_enabled()); // log ui_log_max_lines->setValue(m_config->log_max_lines()); diff --git a/src/aoemotebutton.cpp b/src/aoemotebutton.cpp index 72773383a..2d21c99c5 100644 --- a/src/aoemotebutton.cpp +++ b/src/aoemotebutton.cpp @@ -87,7 +87,7 @@ bool AOEmoteButton::event(QEvent *event) Q_EMIT tooltip_requested(m_index, dynamic_cast(event)->globalPos()); break; - case QEvent::HoverLeave: + case QEvent::Leave: Q_EMIT mouse_left(m_index); break; diff --git a/src/courtroom_widgets.cpp b/src/courtroom_widgets.cpp index 0ec297941..aaeb7aba1 100644 --- a/src/courtroom_widgets.cpp +++ b/src/courtroom_widgets.cpp @@ -258,6 +258,7 @@ void Courtroom::connect_widgets() connect(m_flash_timer, SIGNAL(timeout()), this, SLOT(realization_done())); + connect(ao_config, SIGNAL(emote_preview_changed(bool)), this, SLOT(on_emote_preview_toggled(bool))); connect(ui_emote_left, SIGNAL(clicked()), this, SLOT(on_emote_left_clicked())); connect(ui_emote_right, SIGNAL(clicked()), this, SLOT(on_emote_right_clicked())); diff --git a/src/emotes.cpp b/src/emotes.cpp index 20dd3113c..cda532841 100644 --- a/src/emotes.cpp +++ b/src/emotes.cpp @@ -202,6 +202,9 @@ void Courtroom::on_emote_clicked(int p_id) void Courtroom::show_emote_tooltip(int p_id, QPoint p_global_pos) { + if (!ao_config->emote_preview_enabled()) + return; + if (m_emote_preview_id != -1 || m_emote_preview_id == p_id) return; m_emote_preview_id = p_id; @@ -242,6 +245,12 @@ void Courtroom::hide_emote_tooltip(int p_id) ui_emote_preview_character->stop(); } +void Courtroom::on_emote_preview_toggled(bool p_enabled) +{ + if (!p_enabled) + hide_emote_tooltip(m_emote_preview_id); +} + void Courtroom::on_emote_left_clicked() { --m_current_emote_page;