Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list
Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF
Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
- Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
- Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)
Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified
Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
155 lines
4.1 KiB
C++
155 lines
4.1 KiB
C++
/**
|
|
* @RDE_HEADER@
|
|
* Class of Led Widget
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#include "lts_led_widget.h"
|
|
#include <QPainter>
|
|
#include <QPropertyAnimation>
|
|
#include <QResizeEvent>
|
|
namespace LtsWidgets
|
|
{
|
|
|
|
void LtsLedWidget::resizeEvent(QResizeEvent *event)
|
|
{
|
|
switch (m_aspectHint) {
|
|
case AspectHint::NoHint:
|
|
{
|
|
// NOTE: the next 4 lines would overwrite set properties from ui files
|
|
// setMinimumWidth(0);
|
|
// setMaximumWidth(65000);
|
|
// setMinimumHeight(0);
|
|
// setMaximumHeight(65000);
|
|
QWidget::resizeEvent(event);
|
|
break;
|
|
}
|
|
case AspectHint::HeightIsWidth:
|
|
setMinimumHeight(event->size().width());
|
|
setMaximumHeight(event->size().width());
|
|
setMinimumWidth(0);
|
|
setMaximumWidth(65000);
|
|
break;
|
|
case AspectHint::WidthIsHeight:
|
|
setMinimumHeight(0);
|
|
setMaximumHeight(65000);
|
|
setMinimumWidth(event->size().height());
|
|
setMaximumWidth(event->size().height());
|
|
break;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* The following values were determined by trial and error:
|
|
*/
|
|
static constexpr double GRADIENT_KEY_LOWER = 0.3;
|
|
static constexpr double GRADIENT_KEY_UPPER = 0.9;
|
|
static constexpr int GRADIENT_VALUE_LOWER = 125;
|
|
static constexpr int GRADIENT_VALUE_UPPER = 165;
|
|
static constexpr double GRADIENT_CENTER_OFFSET = 5.0;
|
|
static constexpr double GRADIENT_FOCALPOINT_OFFSET = 2.7;
|
|
static constexpr double PERCENTAGE_OF_BORDER = 0.1;
|
|
static constexpr int DARK_FACTOR = 200;
|
|
|
|
LtsLedWidget::LtsLedWidget(QWidget *parent, const QColor &oncolor, const QColor &offcolor, bool useGradient, int animtime)
|
|
: QWidget(parent)
|
|
, m_status(true)
|
|
, m_oncolor(oncolor)
|
|
, m_offcolor(offcolor)
|
|
, m_currentcolor(oncolor)
|
|
, m_gradient(useGradient)
|
|
, m_animTime(animtime)
|
|
{
|
|
setObjectName(QString::fromUtf8("LtsLedWidget"));
|
|
}
|
|
|
|
void LtsLedWidget::paintEvent(QPaintEvent *pe)
|
|
{
|
|
Q_UNUSED(pe);
|
|
QPainter p;
|
|
p.begin(this);
|
|
p.setOpacity(QWidget::isEnabled() ? 1.00 : 0.5);
|
|
|
|
int minSize = height() > width() ? width() : height();
|
|
if (m_gradient)
|
|
{
|
|
QRadialGradient grad(QPointF(width(), height()) / GRADIENT_CENTER_OFFSET, // Center
|
|
minSize, // Radius
|
|
QPointF(width(), height()) / GRADIENT_FOCALPOINT_OFFSET); // FocalPoint
|
|
grad.setColorAt(GRADIENT_KEY_LOWER, m_currentcolor.lighter(GRADIENT_VALUE_LOWER));
|
|
grad.setColorAt(GRADIENT_KEY_UPPER, m_currentcolor.darker(GRADIENT_VALUE_UPPER));
|
|
p.setBrush(grad);
|
|
}
|
|
else
|
|
p.setBrush(QBrush(m_currentcolor, Qt::SolidPattern));
|
|
|
|
p.setRenderHint(QPainter::Antialiasing);
|
|
p.setPen(QPen(Qt::black, PERCENTAGE_OF_BORDER * minSize, Qt::SolidLine, Qt::SquareCap));
|
|
p.drawEllipse(QPointF(width(), height()) / 2.0,
|
|
width() / (2.0 * (1.00 + PERCENTAGE_OF_BORDER)),
|
|
height() / (2.0 * (1.00 + PERCENTAGE_OF_BORDER)));
|
|
p.end();
|
|
}
|
|
|
|
void LtsLedWidget::animate()
|
|
{
|
|
QPropertyAnimation *anim = new QPropertyAnimation(this, "currentcolor");
|
|
anim->setDuration(m_animTime);
|
|
anim->setEasingCurve(QEasingCurve::OutBack);
|
|
anim->setStartValue(m_currentcolor);
|
|
anim->setEndValue(m_status ? m_oncolor : m_offcolor == Qt::black ? m_oncolor.darker(DARK_FACTOR) : m_offcolor);
|
|
anim->start(QPropertyAnimation::DeleteWhenStopped);
|
|
}
|
|
|
|
void LtsLedWidget::setStatus(bool status)
|
|
{
|
|
if (m_status == status)
|
|
return;
|
|
m_status = status;
|
|
animate();
|
|
}
|
|
|
|
void LtsLedWidget::setUseGradient(bool useGradient)
|
|
{
|
|
if (m_gradient == useGradient)
|
|
return;
|
|
m_gradient = useGradient;
|
|
repaint();
|
|
}
|
|
|
|
void LtsLedWidget::setColor(const QColor &oncolor, const QColor &offcolor)
|
|
{
|
|
setOnColor(oncolor);
|
|
setOffColor(offcolor);
|
|
}
|
|
|
|
void LtsLedWidget::setOnColor(const QColor &oncolor)
|
|
{
|
|
if (m_oncolor == oncolor)
|
|
return;
|
|
m_oncolor = oncolor;
|
|
if (m_status)
|
|
animate();
|
|
}
|
|
|
|
void LtsLedWidget::setOffColor(const QColor &offcolor)
|
|
{
|
|
if (m_offcolor == offcolor)
|
|
return;
|
|
m_offcolor = offcolor;
|
|
if (!m_status)
|
|
animate();
|
|
}
|
|
|
|
void LtsLedWidget::setCurrentColor(const QColor ¤tcolor)
|
|
{
|
|
if (m_currentcolor == currentcolor)
|
|
return;
|
|
m_currentcolor = currentcolor;
|
|
repaint();
|
|
}
|
|
|
|
} // namespace namespace LtsWidgets
|