Fix combobox options not persisting (#949)

* fix combobox options not persisting

* remove accidental newline

* convert combobox data to string
This commit is contained in:
lambdcalculus 2024-05-09 00:38:09 -03:00 committed by GitHub
parent ad93dd8238
commit d680a6afdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -105,7 +105,7 @@ template <>
void AOOptionsDialog::setWidgetData(QComboBox *widget, const QString &value) void AOOptionsDialog::setWidgetData(QComboBox *widget, const QString &value)
{ {
for (auto i = 0; i < widget->count(); i++) { for (auto i = 0; i < widget->count(); i++) {
if (widget->itemText(i) == value) { if (widget->itemData(i).toString() == value) {
widget->setCurrentIndex(i); widget->setCurrentIndex(i);
return; return;
} }
@ -614,11 +614,11 @@ void AOOptionsDialog::setupUI()
ui_log_timestamp_format_combobox->setCurrentText(l_current_format); ui_log_timestamp_format_combobox->setCurrentText(l_current_format);
ui_log_timestamp_format_combobox->addItem(l_current_format); ui_log_timestamp_format_combobox->addItem(l_current_format, l_current_format);
ui_log_timestamp_format_combobox->addItem("h:mm:ss AP"); ui_log_timestamp_format_combobox->addItem("h:mm:ss AP", "h:mm:ss AP");
ui_log_timestamp_format_combobox->addItem("hh:mm:ss"); ui_log_timestamp_format_combobox->addItem("hh:mm:ss", "hh:mm:ss");
ui_log_timestamp_format_combobox->addItem("h:mm AP"); ui_log_timestamp_format_combobox->addItem("h:mm AP", "h:mm AP");
ui_log_timestamp_format_combobox->addItem("hh:mm"); ui_log_timestamp_format_combobox->addItem("hh:mm", "hh:mm");
if (!Options::getInstance().logTimestampEnabled()) { if (!Options::getInstance().logTimestampEnabled()) {
ui_log_timestamp_format_combobox->setDisabled(true); ui_log_timestamp_format_combobox->setDisabled(true);