Skip to content

Commit 75da07d

Browse files
authored
Merge pull request #545 from MangosArentLiterature/default-shownames
Add default shownames
2 parents 1d80972 + 99d083d commit 75da07d

5 files changed

Lines changed: 28 additions & 0 deletions

File tree

include/aoapplication.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ class AOApplication : public QApplication {
278278
// Returns whether the user would like to have custom shownames on by default.
279279
bool get_showname_enabled_by_default();
280280

281+
//Returns the showname the user may have set in config.ini.
282+
QString get_default_showname();
283+
281284
// Returns the list of words in callwords.ini
282285
QStringList get_call_words();
283286

include/aooptionsdialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class AOOptionsDialog : public QDialog {
7878
QLabel *ui_username_lbl;
7979
QLabel *ui_showname_lbl;
8080
QCheckBox *ui_showname_cb;
81+
QLabel *ui_default_showname_lbl;
82+
QLineEdit *ui_default_showname_textbox;
8183
QFrame *ui_net_divider;
8284
QLabel *ui_ms_lbl;
8385
QLineEdit *ui_ms_textbox;

src/aooptionsdialog.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,20 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
325325

326326
ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_showname_cb);
327327

328+
row +=1;
329+
ui_default_showname_lbl = new QLabel(ui_form_layout_widget);
330+
ui_default_showname_lbl->setText(tr("Default showname:"));
331+
ui_default_showname_lbl->setToolTip(
332+
tr("Your showname will be automatically set to this value "
333+
"when you join a server."));
334+
335+
ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_default_showname_lbl);
336+
337+
ui_default_showname_textbox = new QLineEdit(ui_form_layout_widget);
338+
ui_default_showname_textbox->setMaxLength(30);
339+
340+
ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_default_showname_textbox);
341+
328342
row += 1;
329343
ui_net_divider = new QFrame(ui_form_layout_widget);
330344
ui_net_divider->setFrameShape(QFrame::HLine);
@@ -961,6 +975,7 @@ void AOOptionsDialog::update_values() {
961975
ui_sfx_volume_spinbox->setValue(ao_app->get_default_sfx());
962976
ui_blips_volume_spinbox->setValue(ao_app->get_default_blip());
963977
ui_bliprate_spinbox->setValue(ao_app->read_blip_rate());
978+
ui_default_showname_textbox->setText(ao_app->get_default_showname());
964979
}
965980

966981
void AOOptionsDialog::save_pressed()
@@ -987,6 +1002,7 @@ void AOOptionsDialog::save_pressed()
9871002
configini->setValue("chat_ratelimit", ui_chat_ratelimit_spinbox->value());
9881003
configini->setValue("default_username", ui_username_textbox->text());
9891004
configini->setValue("show_custom_shownames", ui_showname_cb->isChecked());
1005+
configini->setValue("default_showname", ui_default_showname_textbox->text());
9901006
configini->setValue("master", ui_ms_textbox->text());
9911007
configini->setValue("discord", ui_discord_cb->isChecked());
9921008
configini->setValue("language", ui_language_combobox->currentText().left(2));

src/courtroom.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
161161
ui_ic_chat_name = new QLineEdit(this);
162162
ui_ic_chat_name->setFrame(false);
163163
ui_ic_chat_name->setPlaceholderText(tr("Showname"));
164+
ui_ic_chat_name->setText(p_ao_app->get_default_showname());
164165
ui_ic_chat_name->setObjectName("ui_ic_chat_name");
165166

166167
ui_ic_chat_message = new AOLineEdit(this);

src/text_file_functions.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ QString AOApplication::get_default_username()
112112
return result;
113113
}
114114

115+
QString AOApplication::get_default_showname()
116+
{
117+
QString result = configini->value("default_showname", "").value<QString>();
118+
return result;
119+
}
120+
115121
QString AOApplication::get_audio_output_device()
116122
{
117123
QString result =

0 commit comments

Comments
 (0)