Skip to content

Commit

Permalink
Merge pull request #220 from Chrezm/nonum/emote_preview_toggle
Browse files Browse the repository at this point in the history
Add emote preview toggle
  • Loading branch information
Chrezm authored Sep 25, 2021
2 parents b87cfd3 + bbc01f1 commit 8fef49f
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/aoconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions include/aoconfigpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions include/courtroom.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 15 additions & 1 deletion res/ui/config_panel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
</property>
</widget>
</item>
<item row="8" column="1">
<item row="10" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -422,6 +422,20 @@
</property>
</spacer>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="emote_preview">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="emote_preview_label">
<property name="text">
<string>Emote preview:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_8">
Expand Down
16 changes: 16 additions & 0 deletions src/aoconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private slots:
QMap<QString, QString> 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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/aoconfigpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)));
Expand Down Expand Up @@ -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)));
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/aoemotebutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bool AOEmoteButton::event(QEvent *event)
Q_EMIT tooltip_requested(m_index, dynamic_cast<QHelpEvent *>(event)->globalPos());
break;

case QEvent::HoverLeave:
case QEvent::Leave:
Q_EMIT mouse_left(m_index);
break;

Expand Down
1 change: 1 addition & 0 deletions src/courtroom_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand Down
9 changes: 9 additions & 0 deletions src/emotes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8fef49f

Please sign in to comment.