Files
qt-migration-legatus/qt5-before/dlbo/Lts/Tools/QLedLine/qledchar.cpp
T
torstenandCopilot 7173785915 Qt6 Migration: Complete migration with DDS/RTI support and build validation
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>
2026-09-15 18:20:26 +00:00

211 lines
3.7 KiB
C++

/**
* @RDE_HEADER@
* Implements a QLedMatrix to display a single character
* $Id$
* $HeadURL$
* $Author$
* Created by Florian Schult, SLSE, 2016-03-18
*/
#include "qledchar.h"
#include <QFontMetrics>
#include <QPainter>
#define s_fontName QStringLiteral("monospace")
QLedChar::QLedChar(int height, QWidget *parent, const QChar &letter)
: QLedMatrix(parent)
, m_ptHeight(findPtHeight(height))
, m_font()
, m_color()
, m_bgColor(QColor(34,34,34))
, m_image()
, m_size()
, m_letter(letter)
, m_isTransparent(false)
, m_isLetterVisible(true)
{
init();
}
void QLedChar::init()
{
m_font = QFont(s_fontName, m_ptHeight);
m_font.setStyleStrategy(QFont::NoAntialias);
QFontMetrics metrics(m_font);
m_size.setWidth(metrics.maxWidth());
m_size.setHeight(metrics.height());
setSize(m_size);
}
QChar QLedChar::letter() const
{
return m_letter;
}
QLedChar::~QLedChar()
{
}
void QLedChar::setLetter(const QChar &letter)
{
m_letter = letter;
if (!m_isLetterVisible)
{
for(int row = 0; row < m_size.height(); ++row)
{
for(int col = 0; col < m_size.width(); ++col)
{
setColorAt(row, col, NoColor);
}
}
return;
}
QImage image(m_size,QImage::Format_RGB32);
QPainter painter;
painter.begin(&image);
painter.setFont(m_font);
painter.fillRect(image.rect(), m_bgColor);
painter.setPen(m_color);
painter.drawText(QPoint(0,m_ptHeight), letter);
painter.end();
setImage(image);
drawImage();
}
void QLedChar::drawImage()
{
for(int row = 0; row < m_size.height(); ++row)
{
for(int col = 0; col < m_size.width(); ++col)
{
setColorAt(row, col, m_image.pixel(col, row));
}
}
}
QImage QLedChar::image() const
{
return m_image;
}
void QLedChar::setImage(const QImage &image)
{
m_image = image;
drawImage();
}
int QLedChar::findPtHeight(int maxPxHeight)
{
int bestPtHeight = 0;
// Starting difference, should be at least 0.35
float difference = 0.4f;
float differenceStep = difference / 2;
bool heightFound = false;
while(!heightFound)
{
differenceStep /= 2;
float ptHeight = maxPxHeight - (maxPxHeight * difference);
QFont font(s_fontName,ptHeight);
QFontMetrics metrics(font);
int pxHeight = metrics.height();
if(pxHeight < maxPxHeight)
difference -= differenceStep;
else if(pxHeight > maxPxHeight)
difference += differenceStep;
else
{
bestPtHeight = ptHeight;
heightFound = true;
}
if(differenceStep == 0)
{
// Catches invalid pixelsizes, which lack proper pointsizes
bestPtHeight = ptHeight-1;
heightFound = true;
}
}
return bestPtHeight;
}
QSize QLedChar::charSize() const
{
return m_size;
}
void QLedChar::setLetterVisible(bool visible)
{
m_isLetterVisible = visible;
setLetter(m_letter);
}
bool QLedChar::isTransparent() const
{
return m_isTransparent;
}
void QLedChar::setTransparent(bool isTransparent)
{
m_isTransparent = isTransparent;
if (isTransparent)
setBackgroundMode(Qt::TransparentMode);
else
setBackgroundMode(Qt::OpaqueMode);
}
bool QLedChar::letterVisible() const
{
return m_isLetterVisible;
}
void QLedChar::setCharHeight(int height)
{
m_ptHeight = findPtHeight(height);
init();
}
int QLedChar::charHeight() const
{
return m_size.height();
}
QColor QLedChar::color() const
{
return m_color;
}
void QLedChar::setColor(const QColor &color)
{
m_color = color;
setLetter(m_letter);
}
QColor QLedChar::bgColor() const
{
return m_bgColor;
}
void QLedChar::setBgColor(const QColor &bgColor)
{
m_bgColor = bgColor;
setLetter(m_letter);
}
void QLedChar::onFlashTimerTimeout()
{
m_isLetterVisible = !m_isLetterVisible;
setLetter(m_letter);
}