Skip to content

Commit

Permalink
Switch to radios
Browse files Browse the repository at this point in the history
  • Loading branch information
Emdek committed Apr 16, 2024
1 parent b382f3e commit 234856f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 19 deletions.
19 changes: 10 additions & 9 deletions src/modules/windows/preferences/AdvancedPreferencesPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ void AdvancedPreferencesPage::changeEvent(QEvent *event)
const QStringList navigationTitles({tr("Browsing"), tr("Notifications"), tr("Appearance"), {}, tr("Downloads"), tr("Programs"), {}, tr("History"), tr("Network"), tr("Scripting"), tr("Security"), tr("Updates"), {}, tr("Mouse")});

m_ui->retranslateUi(this);
m_ui->browsingDisplayModeComboBox->setItemText(0, tr("Compact"));
m_ui->browsingDisplayModeComboBox->setItemText(1, tr("Columns"));
m_ui->appearranceWidgetStyleComboBox->setItemText(0, tr("System Style"));
m_ui->notificationsPlaySoundFilePathWidget->setFilters({tr("WAV files (*.wav)")});
m_ui->appearranceStyleSheetFilePathWidget->setFilters({tr("Style sheets (*.css)")});
Expand Down Expand Up @@ -1014,14 +1012,17 @@ void AdvancedPreferencesPage::load()
m_ui->browsingSuggestBookmarksCheckBox->setChecked(SettingsManager::getOption(SettingsManager::AddressField_SuggestBookmarksOption).toBool());
m_ui->browsingSuggestHistoryCheckBox->setChecked(SettingsManager::getOption(SettingsManager::AddressField_SuggestHistoryOption).toBool());
m_ui->browsingSuggestLocalPathsCheckBox->setChecked(SettingsManager::getOption(SettingsManager::AddressField_SuggestLocalPathsOption).toBool());
m_ui->browsingCategoriesCheckBox->setChecked(SettingsManager::getOption(SettingsManager::AddressField_ShowCompletionCategoriesOption).toBool());

m_ui->browsingDisplayModeComboBox->addItem(tr("Compact"), QLatin1String("compact"));
m_ui->browsingDisplayModeComboBox->addItem(tr("Columns"), QLatin1String("columns"));

const int displayModeIndex(m_ui->browsingDisplayModeComboBox->findData(SettingsManager::getOption(SettingsManager::AddressField_CompletionDisplayModeOption).toString()));
if (SettingsManager::getOption(SettingsManager::AddressField_CompletionDisplayModeOption).toString() == QLatin1String("columns"))
{
m_ui->browsingDisplayModeColumnsRadioButton->setChecked(true);
}
else
{
m_ui->browsingDisplayModeCompactRadioButton->setChecked(true);
}

m_ui->browsingDisplayModeComboBox->setCurrentIndex((displayModeIndex < 0) ? 1 : displayModeIndex);
m_ui->browsingCategoriesCheckBox->setChecked(SettingsManager::getOption(SettingsManager::AddressField_ShowCompletionCategoriesOption).toBool());

m_ui->notificationsPlaySoundButton->setIcon(ThemesManager::createIcon(QLatin1String("media-playback-start")));
m_ui->notificationsPlaySoundFilePathWidget->setFilters({tr("WAV files (*.wav)")});
Expand Down Expand Up @@ -1344,8 +1345,8 @@ void AdvancedPreferencesPage::save()
SettingsManager::setOption(SettingsManager::AddressField_SuggestBookmarksOption, m_ui->browsingSuggestBookmarksCheckBox->isChecked());
SettingsManager::setOption(SettingsManager::AddressField_SuggestHistoryOption, m_ui->browsingSuggestHistoryCheckBox->isChecked());
SettingsManager::setOption(SettingsManager::AddressField_SuggestLocalPathsOption, m_ui->browsingSuggestLocalPathsCheckBox->isChecked());
SettingsManager::setOption(SettingsManager::AddressField_CompletionDisplayModeOption, (m_ui->browsingDisplayModeColumnsRadioButton->isChecked() ? QLatin1String("columns") : QLatin1String("compact")));
SettingsManager::setOption(SettingsManager::AddressField_ShowCompletionCategoriesOption, m_ui->browsingCategoriesCheckBox->isChecked());
SettingsManager::setOption(SettingsManager::AddressField_CompletionDisplayModeOption, m_ui->browsingDisplayModeComboBox->currentData(Qt::UserRole).toString());

QSettings notificationsSettings(SessionsManager::getWritableDataPath(QLatin1String("notifications.ini")), QSettings::IniFormat);
notificationsSettings.setIniCodec("UTF-8");
Expand Down
58 changes: 48 additions & 10 deletions src/modules/windows/preferences/AdvancedPreferencesPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,63 @@
<item>
<layout class="QVBoxLayout" name="browsingCompletionLayout">
<item>
<widget class="QCheckBox" name="browsingCategoriesCheckBox">
<widget class="QLabel" name="browsingDisplayModeLabel">
<property name="text">
<string>Show category headers</string>
<string>Display mode:</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="browsingDisplayModeLayout">
<item row="0" column="0">
<widget class="QLabel" name="browsingDisplayModeLabel">
<property name="text">
<string>Display mode:</string>
<layout class="QHBoxLayout" name="browsingDisplayModeHorizontalLayout">
<item>
<spacer name="browsingDisplayModeSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="browsingDisplayModeComboBox"/>
<item>
<layout class="QVBoxLayout" name="browsingDisplayModeVerticalLayout">
<item>
<widget class="QRadioButton" name="browsingDisplayModeCompactRadioButton">
<property name="text">
<string>Compact</string>
</property>
<attribute name="buttonGroup">
<string notr="true">browsingDisplayModeButtonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="browsingDisplayModeColumnsRadioButton">
<property name="text">
<string>Columns</string>
</property>
<attribute name="buttonGroup">
<string notr="true">browsingDisplayModeButtonGroup</string>
</attribute>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="browsingCategoriesCheckBox">
<property name="text">
<string>Show category headers</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -1356,6 +1393,7 @@
<resources/>
<connections/>
<buttongroups>
<buttongroup name="browsingDisplayModeButtonGroup"/>
<buttongroup name="mimeTypesButtonGroup"/>
</buttongroups>
</ui>

0 comments on commit 234856f

Please sign in to comment.