Fix combobox behaviour for all cases (#947)

* make all option comboboxes work

* correct default page
This commit is contained in:
lambdcalculus 2024-03-29 17:56:20 -03:00 committed by GitHub
parent ad6552cdd5
commit 3e42588b51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 62 deletions

View File

@ -41,7 +41,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>394</width> <width>394</width>
<height>828</height> <height>858</height>
</rect> </rect>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
@ -157,43 +157,7 @@
</widget> </widget>
</item> </item>
<item row="18" column="1"> <item row="18" column="1">
<widget class="QComboBox" name="language_combobox"> <widget class="QComboBox" name="language_combobox"/>
<item>
<property name="text">
<string>en</string>
</property>
</item>
<item>
<property name="text">
<string>de</string>
</property>
</item>
<item>
<property name="text">
<string>es</string>
</property>
</item>
<item>
<property name="text">
<string>pt</string>
</property>
</item>
<item>
<property name="text">
<string>pl</string>
</property>
</item>
<item>
<property name="text">
<string>jp</string>
</property>
</item>
<item>
<property name="text">
<string>ru</string>
</property>
</item>
</widget>
</item> </item>
<item row="16" column="1"> <item row="16" column="1">
<widget class="QLineEdit" name="ms_textbox"/> <widget class="QLineEdit" name="ms_textbox"/>
@ -1012,26 +976,6 @@ Default: 0.</string>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<item>
<property name="text">
<string>h:mm:ss AP</string>
</property>
</item>
<item>
<property name="text">
<string>hh:mm:ss</string>
</property>
</item>
<item>
<property name="text">
<string>h:mm AP</string>
</property>
</item>
<item>
<property name="text">
<string>hh:mm</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="6" column="0">

View File

@ -35,7 +35,7 @@ void AOOptionsDialog::populateAudioDevices()
{ {
ui_audio_device_combobox->clear(); ui_audio_device_combobox->clear();
if (needsDefaultAudioDevice()) { if (needsDefaultAudioDevice()) {
ui_audio_device_combobox->addItem("default"); ui_audio_device_combobox->addItem("default", "default");
} }
BASS_DEVICEINFO info; BASS_DEVICEINFO info;
@ -116,7 +116,7 @@ void AOOptionsDialog::setWidgetData(QComboBox *widget, const QString &value)
template <> QString AOOptionsDialog::widgetData(QComboBox *widget) const template <> QString AOOptionsDialog::widgetData(QComboBox *widget) const
{ {
return widget->currentText(); return widget->currentData().toString();
} }
template <> template <>
@ -398,6 +398,15 @@ void AOOptionsDialog::setupUI()
&Options::setDiscordEnabled); &Options::setDiscordEnabled);
registerOption<QComboBox, QString>("language_combobox", &Options::language, registerOption<QComboBox, QString>("language_combobox", &Options::language,
&Options::setLanguage); &Options::setLanguage);
ui_language_combobox->addItem("English", "en");
ui_language_combobox->addItem("Deutsch", "de");
ui_language_combobox->addItem("Español", "es");
ui_language_combobox->addItem("Português", "pt");
ui_language_combobox->addItem("Polski", "pl");
ui_language_combobox->addItem("日本語", "jp");
ui_language_combobox->addItem("Русский", "ru");
registerOption<QComboBox, QString>("scaling_combobox", registerOption<QComboBox, QString>("scaling_combobox",
&Options::defaultScalingMode, &Options::defaultScalingMode,
&Options::setDefaultScalingMode); &Options::setDefaultScalingMode);
@ -605,6 +614,12 @@ 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("h:mm:ss AP");
ui_log_timestamp_format_combobox->addItem("hh:mm:ss");
ui_log_timestamp_format_combobox->addItem("h:mm AP");
ui_log_timestamp_format_combobox->addItem("hh:mm");
if (!Options::getInstance().logTimestampEnabled()) { if (!Options::getInstance().logTimestampEnabled()) {
ui_log_timestamp_format_combobox->setDisabled(true); ui_log_timestamp_format_combobox->setDisabled(true);
} }
@ -633,10 +648,14 @@ void AOOptionsDialog::setupUI()
void AOOptionsDialog::onTimestampFormatEdited() void AOOptionsDialog::onTimestampFormatEdited()
{ {
const QString format = ui_log_timestamp_format_combobox->currentText();
const int index = ui_log_timestamp_format_combobox->currentIndex();
ui_log_timestamp_format_combobox->setItemText(index, format);
ui_log_timestamp_format_combobox->setItemData(index, format);
ui_log_timestamp_format_lbl->setText( ui_log_timestamp_format_lbl->setText(
tr("Log timestamp format:\n") + tr("Log timestamp format:\n") +
QDateTime::currentDateTime().toString( QDateTime::currentDateTime().toString(format));
ui_log_timestamp_format_combobox->currentText()));
} }
void AOOptionsDialog::timestampCbChanged(int state) void AOOptionsDialog::timestampCbChanged(int state)