diff options
Diffstat (limited to 'src/aooptionsdialog.cpp')
| -rw-r--r-- | src/aooptionsdialog.cpp | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 5f3dbf0..1b9342c 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -29,12 +29,12 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) QDialogButtonBox::Save | QDialogButtonBox::RestoreDefaults); - QObject::connect(ui_settings_buttons, SIGNAL(accepted()), this, - SLOT(save_pressed())); - QObject::connect(ui_settings_buttons, SIGNAL(rejected()), this, - SLOT(discard_pressed())); - QObject::connect(ui_settings_buttons, SIGNAL(clicked(QAbstractButton*)), this, - SLOT(button_clicked(QAbstractButton*))); + connect(ui_settings_buttons, &QDialogButtonBox::accepted, this, + &AOOptionsDialog::save_pressed); + connect(ui_settings_buttons, &QDialogButtonBox::rejected, this, + &AOOptionsDialog::discard_pressed); + connect(ui_settings_buttons, &QDialogButtonBox::clicked, this, + &AOOptionsDialog::button_clicked); // We'll stop updates so that the window won't flicker while it's being made. setUpdatesEnabled(false); @@ -90,8 +90,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) } } - QObject::connect(ui_theme_combobox, SIGNAL(currentIndexChanged(int)), this, - SLOT(theme_changed(int))); + connect(ui_theme_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + &AOOptionsDialog::theme_changed); ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_theme_combobox); row += 1; @@ -124,8 +124,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_theme_reload_button->setToolTip( tr("Refresh the theme and update all of the ui elements to match.")); ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_theme_reload_button); - QObject::connect(ui_theme_reload_button, SIGNAL(clicked()), this, - SLOT(on_reload_theme_clicked())); + connect(ui_theme_reload_button, &QPushButton::clicked, this, + &AOOptionsDialog::on_reload_theme_clicked); row += 1; ui_animated_theme_lbl = new QLabel(ui_form_layout_widget); @@ -216,9 +216,34 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_log_timestamp_cb = new QCheckBox(ui_form_layout_widget); + connect(ui_log_timestamp_cb, &QCheckBox::stateChanged, this, &AOOptionsDialog::timestamp_cb_changed); + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_timestamp_cb); row += 1; + ui_log_timestamp_format_lbl = new QLabel(ui_form_layout_widget); + ui_log_timestamp_format_lbl->setText(tr("Log timestamp format:\n") + QDateTime::currentDateTime().toString(ao_app->get_log_timestamp_format())); + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_log_timestamp_format_lbl); + + ui_log_timestamp_format_combobox = new QComboBox(ui_form_layout_widget); + ui_log_timestamp_format_combobox->setEditable(true); + + QString l_current_format = ao_app->get_log_timestamp_format(); + + ui_log_timestamp_format_combobox->setCurrentText(l_current_format); + ui_log_timestamp_format_combobox->addItem("h:mm:ss AP"); // 2:13:09 PM + ui_log_timestamp_format_combobox->addItem("hh:mm:ss"); // 14:13:09 + ui_log_timestamp_format_combobox->addItem("h:mm AP"); // 2:13 PM + ui_log_timestamp_format_combobox->addItem("hh:mm"); // 14:13 + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_timestamp_format_combobox); + + connect(ui_log_timestamp_format_combobox, &QComboBox::currentTextChanged, this, &AOOptionsDialog::on_timestamp_format_edited); + + if(!ao_app->get_log_timestamp()) + ui_log_timestamp_format_combobox->setDisabled(true); + + row += 1; ui_log_ic_actions_lbl = new QLabel(ui_form_layout_widget); ui_log_ic_actions_lbl->setText(tr("Log IC actions:")); ui_log_ic_actions_lbl->setToolTip( @@ -230,7 +255,6 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_ic_actions_cb); - row += 1; ui_stay_time_lbl = new QLabel(ui_form_layout_widget); ui_stay_time_lbl->setText(tr("Text Stay Time:")); @@ -1072,6 +1096,7 @@ void AOOptionsDialog::update_values() { ui_downwards_cb->setChecked(ao_app->get_log_goes_downwards()); ui_log_newline_cb->setChecked(ao_app->get_log_newline()); ui_log_timestamp_cb->setChecked(ao_app->get_log_timestamp()); + ui_log_timestamp_format_combobox->setCurrentText(ao_app->get_log_timestamp_format()); ui_log_ic_actions_cb->setChecked(ao_app->get_log_ic_actions()); ui_desync_logs_cb->setChecked(ao_app->is_desyncrhonized_logs_enabled()); ui_instant_objection_cb->setChecked(ao_app->is_instant_objection_enabled()); @@ -1133,6 +1158,7 @@ void AOOptionsDialog::save_pressed() configini->setValue("log_newline", ui_log_newline_cb->isChecked()); configini->setValue("log_margin", ui_log_margin_spinbox->value()); configini->setValue("log_timestamp", ui_log_timestamp_cb->isChecked()); + configini->setValue("log_timestamp_format", ui_log_timestamp_format_combobox->currentText()); configini->setValue("log_ic_actions", ui_log_ic_actions_cb->isChecked()); configini->setValue("desync_logs", ui_desync_logs_cb->isChecked()); configini->setValue("stay_time", ui_stay_time_spinbox->value()); @@ -1260,6 +1286,10 @@ void AOOptionsDialog::theme_changed(int i) { } +void AOOptionsDialog::on_timestamp_format_edited() { ui_log_timestamp_format_lbl->setText(tr("Log timestamp format:\n") + QDateTime::currentDateTime().toString(ui_log_timestamp_format_combobox->currentText())); } + +void AOOptionsDialog::timestamp_cb_changed(int state) { ui_log_timestamp_format_combobox->setDisabled(state == 0); } + #if (defined(_WIN32) || defined(_WIN64)) bool AOOptionsDialog::needs_default_audiodev() { return true; } #elif (defined(LINUX) || defined(__linux__)) |
