Allow the toggling of custom shownames.

Don't forget to enable it in a theme.
This commit is contained in:
Cerapter 2018-07-28 23:56:37 +02:00
parent 5283bc68d2
commit 0561ae7fd6
4 changed files with 29 additions and 8 deletions

View File

@ -140,6 +140,9 @@ public:
// Returns the username the user may have set in config.ini. // Returns the username the user may have set in config.ini.
QString get_default_username(); QString get_default_username();
// Returns whether the user would like to have custom shownames on by default.
bool get_showname_enabled_by_default();
//Returns the list of words in callwords.ini //Returns the list of words in callwords.ini
QStringList get_call_words(); QStringList get_call_words();

View File

@ -169,6 +169,11 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_guard->setText("Guard"); ui_guard->setText("Guard");
ui_guard->hide(); ui_guard->hide();
ui_showname_enable = new QCheckBox(this);
ui_showname_enable->setChecked(ao_app->get_showname_enabled_by_default());
ui_showname_enable->setText("Custom shownames");
ui_showname_enable;
ui_custom_objection = new AOButton(this, ao_app); ui_custom_objection = new AOButton(this, ao_app);
ui_realization = new AOButton(this, ao_app); ui_realization = new AOButton(this, ao_app);
ui_mute = new AOButton(this, ao_app); ui_mute = new AOButton(this, ao_app);
@ -278,6 +283,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
connect(ui_flip, SIGNAL(clicked()), this, SLOT(on_flip_clicked())); connect(ui_flip, SIGNAL(clicked()), this, SLOT(on_flip_clicked()));
connect(ui_guard, SIGNAL(clicked()), this, SLOT(on_guard_clicked())); connect(ui_guard, SIGNAL(clicked()), this, SLOT(on_guard_clicked()));
connect(ui_showname_enable, SIGNAL(clicked()), this, SLOT(on_showname_enable_clicked()));
connect(ui_evidence_button, SIGNAL(clicked()), this, SLOT(on_evidence_button_clicked())); connect(ui_evidence_button, SIGNAL(clicked()), this, SLOT(on_evidence_button_clicked()));
set_widgets(); set_widgets();
@ -489,6 +496,8 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_guard, "guard"); set_size_and_pos(ui_guard, "guard");
set_size_and_pos(ui_showname_enable, "showname_enable");
set_size_and_pos(ui_custom_objection, "custom_objection"); set_size_and_pos(ui_custom_objection, "custom_objection");
ui_custom_objection->set_image("custom.png"); ui_custom_objection->set_image("custom.png");
@ -985,7 +994,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
return; return;
QString f_showname; QString f_showname;
if (m_chatmessage[SHOWNAME].isEmpty()) if (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())
{ {
f_showname = ao_app->get_showname(char_list.at(f_char_id).name); f_showname = ao_app->get_showname(char_list.at(f_char_id).name);
} }
@ -1077,7 +1086,7 @@ void Courtroom::handle_chatmessage_2()
ui_vp_speedlines->stop(); ui_vp_speedlines->stop();
ui_vp_player_char->stop(); ui_vp_player_char->stop();
if (m_chatmessage[SHOWNAME].isEmpty()) if (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())
{ {
QString real_name = char_list.at(m_chatmessage[CHAR_ID].toInt()).name; QString real_name = char_list.at(m_chatmessage[CHAR_ID].toInt()).name;
@ -2497,6 +2506,11 @@ void Courtroom::on_guard_clicked()
ui_ic_chat_message->setFocus(); ui_ic_chat_message->setFocus();
} }
void Courtroom::on_showname_enable_clicked()
{
ui_ic_chat_message->setFocus();
}
void Courtroom::on_evidence_button_clicked() void Courtroom::on_evidence_button_clicked()
{ {
if (ui_evidence->isHidden()) if (ui_evidence->isHidden())

View File

@ -351,6 +351,8 @@ private:
QCheckBox *ui_flip; QCheckBox *ui_flip;
QCheckBox *ui_guard; QCheckBox *ui_guard;
QCheckBox *ui_showname_enable;
AOButton *ui_custom_objection; AOButton *ui_custom_objection;
AOButton *ui_realization; AOButton *ui_realization;
AOButton *ui_mute; AOButton *ui_mute;
@ -500,6 +502,8 @@ private slots:
void on_flip_clicked(); void on_flip_clicked();
void on_guard_clicked(); void on_guard_clicked();
void on_showname_enable_clicked();
void on_evidence_button_clicked(); void on_evidence_button_clicked();
void on_evidence_delete_clicked(); void on_evidence_delete_clicked();

View File

@ -102,13 +102,13 @@ int AOApplication::get_max_log_size()
bool AOApplication::get_log_goes_downwards() bool AOApplication::get_log_goes_downwards()
{ {
QString f_result = read_config("log_goes_downwards"); QString f_result = read_config("log_goes_downwards");
return f_result.startsWith("true");
}
if (f_result == "true") bool AOApplication::get_showname_enabled_by_default()
return true; {
else if (f_result == "false") QString f_result = read_config("show_custom_shownames");
return false; return f_result.startsWith("true");
else
return true;
} }
QString AOApplication::get_default_username() QString AOApplication::get_default_username()