Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added cursor icon always on option to general settings #311

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scwx-qt/source/scwx/qt/map/map_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,11 +1020,14 @@ void MapWidget::UpdateMouseCoordinate(const common::Coordinate& coordinate)
{
if (p->context_->mouse_coordinate() != coordinate)
{
auto& generalSettings = settings::GeneralSettings::Instance();

p->context_->set_mouse_coordinate(coordinate);

auto keyboardModifiers = QGuiApplication::keyboardModifiers();

if (keyboardModifiers != Qt::KeyboardModifier::NoModifier ||
if (generalSettings.cursor_icon_always_on().GetValue() ||
keyboardModifiers != Qt::KeyboardModifier::NoModifier ||
keyboardModifiers != p->lastKeyboardModifiers_)
{
QMetaObject::invokeMethod(
Expand Down
10 changes: 6 additions & 4 deletions scwx-qt/source/scwx/qt/map/overlay_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,13 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
p->activeBoxInner_->SetBorder(1.0f * pixelRatio, {255, 255, 255, 255});
}

auto& generalSettings = settings::GeneralSettings::Instance();

// Cursor Icon
bool cursorIconVisible = QGuiApplication::keyboardModifiers() &
Qt::KeyboardModifier::ControlModifier;
bool cursorIconVisible =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'cursorIconVisible' of type 'bool' can be declared 'const' [misc-const-correctness]

Suggested change
bool cursorIconVisible =
bool const cursorIconVisible =

generalSettings.cursor_icon_always_on().GetValue() ||
(QGuiApplication::keyboardModifiers() &
Qt::KeyboardModifier::ControlModifier);
p->geoIcons_->SetIconVisible(p->cursorIcon_, cursorIconVisible);
if (cursorIconVisible)
{
Expand Down Expand Up @@ -434,8 +438,6 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
ImGui::End();
}

auto& generalSettings = settings::GeneralSettings::Instance();

// Map Center Icon
if (params.width != p->lastWidth_ || params.height != p->lastHeight_)
{
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 @@ -77,6 +77,7 @@ class GeneralSettings::Impl
trackLocation_.SetDefault(false);
updateNotificationsEnabled_.SetDefault(true);
warningsProvider_.SetDefault(defaultWarningsProviderValue);
cursorIconAlwaysOn_.SetDefault(false);

fontSizes_.SetElementMinimum(1);
fontSizes_.SetElementMaximum(72);
Expand Down Expand Up @@ -166,6 +167,7 @@ class GeneralSettings::Impl
SettingsVariable<bool> trackLocation_ {"track_location"};
SettingsVariable<bool> updateNotificationsEnabled_ {"update_notifications"};
SettingsVariable<std::string> warningsProvider_ {"warnings_provider"};
SettingsVariable<bool> cursorIconAlwaysOn_ {"cursor_icon_always_on"};
};

GeneralSettings::GeneralSettings() :
Expand Down Expand Up @@ -198,7 +200,8 @@ GeneralSettings::GeneralSettings() :
&p->themeFile_,
&p->trackLocation_,
&p->updateNotificationsEnabled_,
&p->warningsProvider_});
&p->warningsProvider_,
&p->cursorIconAlwaysOn_});
SetDefaults();
}
GeneralSettings::~GeneralSettings() = default;
Expand Down Expand Up @@ -348,6 +351,11 @@ SettingsVariable<std::string>& GeneralSettings::warnings_provider() const
return p->warningsProvider_;
}

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

bool GeneralSettings::Shutdown()
{
bool dataChanged = false;
Expand Down Expand Up @@ -397,7 +405,8 @@ bool operator==(const GeneralSettings& lhs, const GeneralSettings& rhs)
lhs.p->trackLocation_ == rhs.p->trackLocation_ &&
lhs.p->updateNotificationsEnabled_ ==
rhs.p->updateNotificationsEnabled_ &&
lhs.p->warningsProvider_ == rhs.p->warningsProvider_);
lhs.p->warningsProvider_ == rhs.p->warningsProvider_ &&
lhs.p->cursorIconAlwaysOn_ == rhs.p->cursorIconAlwaysOn_);
}

} // namespace settings
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 @@ -53,6 +53,7 @@ class GeneralSettings : public SettingsCategory
SettingsVariable<bool>& track_location() const;
SettingsVariable<bool>& update_notifications_enabled() const;
SettingsVariable<std::string>& warnings_provider() const;
SettingsVariable<bool>& cursor_icon_always_on() const;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: function 'cursor_icon_always_on' should be marked [[nodiscard]] [modernize-use-nodiscard]

Suggested change
SettingsVariable<bool>& cursor_icon_always_on() const;
[[nodiscard]] SettingsVariable<bool>& cursor_icon_always_on() const;


static GeneralSettings& Instance();

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 @@ -137,6 +137,7 @@ class SettingsDialogImpl
&showMapCenter_,
&showMapLogo_,
&updateNotificationsEnabled_,
&cursorIconAlwaysOn_,
&debugEnabled_,
&alertAudioSoundFile_,
&alertAudioLocationMethod_,
Expand Down Expand Up @@ -251,6 +252,7 @@ class SettingsDialogImpl
settings::SettingsInterface<bool> showMapCenter_ {};
settings::SettingsInterface<bool> showMapLogo_ {};
settings::SettingsInterface<bool> updateNotificationsEnabled_ {};
settings::SettingsInterface<bool> cursorIconAlwaysOn_ {};
settings::SettingsInterface<bool> debugEnabled_ {};

std::unordered_map<std::string, settings::SettingsInterface<std::string>>
Expand Down Expand Up @@ -762,6 +764,10 @@ void SettingsDialogImpl::SetupGeneralTab()
updateNotificationsEnabled_.SetEditWidget(
self_->ui->enableUpdateNotificationsCheckBox);

cursorIconAlwaysOn_.SetSettingsVariable(
generalSettings.cursor_icon_always_on());
cursorIconAlwaysOn_.SetEditWidget(self_->ui->cursorIconAlwaysOnCheckBox);

debugEnabled_.SetSettingsVariable(generalSettings.debug_enabled());
debugEnabled_.SetEditWidget(self_->ui->debugEnabledCheckBox);
}
Expand Down
17 changes: 15 additions & 2 deletions scwx-qt/source/scwx/qt/ui/settings_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-133</y>
<y>-246</y>
<width>511</width>
<height>676</height>
<height>703</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down Expand Up @@ -590,6 +590,19 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cursorIconAlwaysOnCheckBox">
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Multi-Pane Cursor Marker Always On</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="debugEnabledCheckBox">
<property name="text">
Expand Down
Loading