Skip to content

Commit

Permalink
Add anti-aliasing to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaulat committed Oct 10, 2023
1 parent 3a754c0 commit c5a5668
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
9 changes: 6 additions & 3 deletions scwx-qt/source/scwx/qt/map/map_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,12 @@ public slots:
MapWidget::MapWidget(const QMapLibreGL::Settings& settings) :
p(std::make_unique<MapWidgetImpl>(this, settings))
{
QSurfaceFormat surfaceFormat = QSurfaceFormat::defaultFormat();
surfaceFormat.setSamples(4);
setFormat(surfaceFormat);
if (settings::GeneralSettings::Instance().anti_aliasing_enabled().GetValue())
{
QSurfaceFormat surfaceFormat = QSurfaceFormat::defaultFormat();
surfaceFormat.setSamples(4);
setFormat(surfaceFormat);
}

setFocusPolicy(Qt::StrongFocus);

Expand Down
13 changes: 11 additions & 2 deletions scwx-qt/source/scwx/qt/settings/general_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class GeneralSettings::Impl
boost::to_lower(defaultDefaultAlertActionValue);
boost::to_lower(defaultMapProviderValue);

antiAliasingEnabled_.SetDefault(true);
debugEnabled_.SetDefault(false);
defaultAlertAction_.SetDefault(defaultDefaultAlertActionValue);
defaultRadarSite_.SetDefault("KLSX");
Expand Down Expand Up @@ -104,6 +105,7 @@ class GeneralSettings::Impl

~Impl() {}

SettingsVariable<bool> antiAliasingEnabled_ {"anti_aliasing_enabled"};
SettingsVariable<bool> debugEnabled_ {"debug_enabled"};
SettingsVariable<std::string> defaultAlertAction_ {"default_alert_action"};
SettingsVariable<std::string> defaultRadarSite_ {"default_radar_site"};
Expand All @@ -122,7 +124,8 @@ class GeneralSettings::Impl
GeneralSettings::GeneralSettings() :
SettingsCategory("general"), p(std::make_unique<Impl>())
{
RegisterVariables({&p->debugEnabled_,
RegisterVariables({&p->antiAliasingEnabled_,
&p->debugEnabled_,
&p->defaultAlertAction_,
&p->defaultRadarSite_,
&p->fontSizes_,
Expand All @@ -143,6 +146,11 @@ GeneralSettings::GeneralSettings(GeneralSettings&&) noexcept = default;
GeneralSettings&
GeneralSettings::operator=(GeneralSettings&&) noexcept = default;

SettingsVariable<bool>& GeneralSettings::anti_aliasing_enabled() const
{
return p->antiAliasingEnabled_;
}

SettingsVariable<bool>& GeneralSettings::debug_enabled() const
{
return p->debugEnabled_;
Expand Down Expand Up @@ -229,7 +237,8 @@ GeneralSettings& GeneralSettings::Instance()

bool operator==(const GeneralSettings& lhs, const GeneralSettings& rhs)
{
return (lhs.p->debugEnabled_ == rhs.p->debugEnabled_ &&
return (lhs.p->antiAliasingEnabled_ == rhs.p->antiAliasingEnabled_ &&
lhs.p->debugEnabled_ == rhs.p->debugEnabled_ &&
lhs.p->defaultAlertAction_ == rhs.p->defaultAlertAction_ &&
lhs.p->defaultRadarSite_ == rhs.p->defaultRadarSite_ &&
lhs.p->fontSizes_ == rhs.p->fontSizes_ &&
Expand Down
1 change: 1 addition & 0 deletions scwx-qt/source/scwx/qt/settings/general_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class GeneralSettings : public SettingsCategory
GeneralSettings(GeneralSettings&&) noexcept;
GeneralSettings& operator=(GeneralSettings&&) noexcept;

SettingsVariable<bool>& anti_aliasing_enabled() const;
SettingsVariable<bool>& debug_enabled() const;
SettingsVariable<std::string>& default_alert_action() const;
SettingsVariable<std::string>& default_radar_site() const;
Expand Down
6 changes: 6 additions & 0 deletions scwx-qt/source/scwx/qt/ui/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class SettingsDialogImpl
&mapboxApiKey_,
&mapTilerApiKey_,
&defaultAlertAction_,
&antiAliasingEnabled_,
&updateNotificationsEnabled_,
&debugEnabled_,
&hoverTextWrap_,
Expand Down Expand Up @@ -176,6 +177,7 @@ class SettingsDialogImpl
settings::SettingsInterface<std::string> mapboxApiKey_ {};
settings::SettingsInterface<std::string> mapTilerApiKey_ {};
settings::SettingsInterface<std::string> defaultAlertAction_ {};
settings::SettingsInterface<bool> antiAliasingEnabled_ {};
settings::SettingsInterface<bool> updateNotificationsEnabled_ {};
settings::SettingsInterface<bool> debugEnabled_ {};

Expand Down Expand Up @@ -511,6 +513,10 @@ void SettingsDialogImpl::SetupGeneralTab()
defaultAlertAction_.SetEditWidget(self_->ui->defaultAlertActionComboBox);
defaultAlertAction_.SetResetButton(self_->ui->resetDefaultAlertActionButton);

antiAliasingEnabled_.SetSettingsVariable(
generalSettings.anti_aliasing_enabled());
antiAliasingEnabled_.SetEditWidget(self_->ui->antiAliasingEnabledCheckBox);

updateNotificationsEnabled_.SetSettingsVariable(
generalSettings.update_notifications_enabled());
updateNotificationsEnabled_.SetEditWidget(
Expand Down
7 changes: 7 additions & 0 deletions scwx-qt/source/scwx/qt/ui/settings_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="antiAliasingEnabledCheckBox">
<property name="text">
<string>Anti-Aliasing Enabled</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableUpdateNotificationsCheckBox">
<property name="text">
Expand Down

0 comments on commit c5a5668

Please sign in to comment.