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

Add slider to change radar tag font size #226

Merged
merged 2 commits into from
Nov 19, 2023
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
12 changes: 11 additions & 1 deletion src/blackgui/components/radarcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using namespace BlackGui::Views;
namespace BlackGui::Components
{
CRadarComponent::CRadarComponent(QWidget *parent) : QFrame(parent),
ui(new Ui::CRadarComponent)
ui(new Ui::CRadarComponent), m_tagFont(QApplication::font())
{
ui->setupUi(this);

Expand All @@ -39,13 +39,16 @@ namespace BlackGui::Components
}

ui->cb_RadarRange->setCurrentText(QString::number(m_rangeNM) % u" nm");
ui->sb_FontSize->setRange(1, 100);
ui->sb_FontSize->setValue(QApplication::font().pointSize());

connect(ui->gv_RadarView, &CRadarView::radarViewResized, this, &CRadarComponent::fitInView);
connect(ui->gv_RadarView, &CRadarView::zoomEvent, this, &CRadarComponent::changeRangeInSteps);
connect(&m_updateTimer, &QTimer::timeout, this, &CRadarComponent::refreshTargets);
connect(&m_headingTimer, &QTimer::timeout, this, &CRadarComponent::rotateView);

connect(ui->cb_RadarRange, qOverload<int>(&QComboBox::currentIndexChanged), this, &CRadarComponent::changeRangeFromUserSelection);
connect(ui->sb_FontSize, qOverload<int>(&QSpinBox::valueChanged), this, &CRadarComponent::updateFont);
connect(ui->cb_Callsign, &QCheckBox::toggled, this, &CRadarComponent::refreshTargets);
connect(ui->cb_Heading, &QCheckBox::toggled, this, &CRadarComponent::refreshTargets);
connect(ui->cb_Altitude, &QCheckBox::toggled, this, &CRadarComponent::refreshTargets);
Expand Down Expand Up @@ -175,6 +178,7 @@ namespace BlackGui::Components
}

tag->setPlainText(tagText);
tag->setFont(m_tagFont);
tag->setPos(position);
tag->setDefaultTextColor(Qt::green);
tag->setFlags(QGraphicsItem::ItemIgnoresTransformations);
Expand Down Expand Up @@ -259,6 +263,12 @@ namespace BlackGui::Components
}
}

void CRadarComponent::updateFont(int pointSize)
{
m_tagFont.setPointSize(pointSize);
this->refreshTargets();
}

void CRadarComponent::onInfoAreaTabBarChanged(int index)
{
Q_UNUSED(index)
Expand Down
3 changes: 3 additions & 0 deletions src/blackgui/components/radarcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace BlackGui::Components
void fitInView();
void changeRangeInSteps(bool zoomIn);
void changeRangeFromUserSelection(int index);
void updateFont(int pointSize);

static QPointF polarPoint(double distance, double angleRadians);

Expand All @@ -74,6 +75,8 @@ namespace BlackGui::Components
QTimer m_updateTimer;
QTimer m_headingTimer;

QFont m_tagFont;

BlackCore::CActionBind m_actionZoomIn { BlackMisc::Input::radarZoomInHotkeyAction(), BlackMisc::Input::radarZoomInHotkeyIcon(), this, &CRadarComponent::rangeZoomIn };
BlackCore::CActionBind m_actionZoomOut { BlackMisc::Input::radarZoomOutHotkeyAction(), BlackMisc::Input::radarZoomOutHotkeyIcon(), this, &CRadarComponent::rangeZoomOut };
void rangeZoomIn(bool keydown)
Expand Down
48 changes: 31 additions & 17 deletions src/blackgui/components/radarcomponent.ui
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@
<property name="bottomMargin">
<number>2</number>
</property>
<item row="1" column="0">
<widget class="QCheckBox" name="cb_LockNorth">
<item row="0" column="4">
<widget class="QSpinBox" name="sb_FontSize"/>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cb_Callsign">
<property name="text">
<string>Lock North</string>
<string>Callsign</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
Expand All @@ -61,7 +67,17 @@
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<item row="0" column="3">
<widget class="QLabel" name="lbl_FontSize">
<property name="text">
<string>Font size</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="cb_Altitude">
<property name="text">
<string>Altitude (FL)</string>
Expand All @@ -71,20 +87,17 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="cb_GroundSpeed">
<item row="1" column="0">
<widget class="QCheckBox" name="cb_LockNorth">
<property name="text">
<string>GroundSpeed</string>
</property>
<property name="checked">
<bool>true</bool>
<string>Lock North</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cb_Callsign">
<item row="1" column="1">
<widget class="QCheckBox" name="cb_GroundSpeed">
<property name="text">
<string>Callsign</string>
<string>Ground speed</string>
</property>
<property name="checked">
<bool>true</bool>
Expand All @@ -101,10 +114,7 @@
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<widget class="QComboBox" name="cb_RadarRange"/>
</item>
<item row="2" column="0" colspan="2">
<item row="1" column="3">
<widget class="QLabel" name="lbl_Range">
<property name="text">
<string>Range</string>
Expand All @@ -114,6 +124,9 @@
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QComboBox" name="cb_RadarRange"/>
</item>
</layout>
</widget>
</item>
Expand All @@ -131,6 +144,7 @@
<tabstop>cb_Callsign</tabstop>
<tabstop>cb_Heading</tabstop>
<tabstop>cb_Altitude</tabstop>
<tabstop>sb_FontSize</tabstop>
<tabstop>cb_LockNorth</tabstop>
<tabstop>cb_GroundSpeed</tabstop>
<tabstop>cb_Grid</tabstop>
Expand Down