Files
qt-migration-legatus/qt5-before/dlbo/Lts/Common/LtsNotification/lts_notification_ctl.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

181 lines
4.1 KiB
C++

// TODO: hdr
#include "lts_notification_ctl.h"
#include <QToolButton>
#include <QImage>
#include <QPainter>
#include <QIcon>
#include <QColor>
#include <QDebug>
namespace LtsNotification
{
LtsNotificationController::LtsNotificationController(const QString &identifier)
: QObject()
, m_count(0)
, m_identifier(QStringLiteral("LtsNotification%1").arg(identifier))
{}
LtsNotificationController::~LtsNotificationController()
{
qDeleteAll(m_notiList);
}
void LtsNotificationController::setIcon(const QIcon& icon)
{
m_icon = icon;
setAllIcons();
}
void LtsNotificationController::setCount(const int count)
{
m_count = count;
setAllIcons();
}
/*!
* \brief LtsNotificationController::setBackground
* \param r red
* \param g green
* \param b yellow
* \author Niklas Schmidt
* \details If all params(r,g,b) are -1, than reset Stylesheet = non stylesheet
*/
//TODO: Extra function resetBackground instead of -1 params
void LtsNotificationController::setBackground(const int r, const int g, const int b)
{
for (QToolButton *tb : qAsConst(m_notiList))
{
QString stylesheet;
if(r == -1 && g == -1 && b == -1)
stylesheet = QStringLiteral("");
else
stylesheet = QStringLiteral("QToolButton {background-color: rgb(") +
QString::number(r) + QStringLiteral(",") +
QString::number(g) + QStringLiteral(",") +
QString::number(b) + QStringLiteral(");}");
tb->setStyleSheet(stylesheet);
}
}
void LtsNotificationController::setEnabled(bool enable)
{
m_enable = enable;
setAllIcons();
}
void LtsNotificationController::setAction(const std::function<void(void)> &action)
{
m_action = action;
}
void LtsNotificationController::setToolTip(const QString &toolTip)
{
m_toolTip = toolTip;
for (QToolButton *tb : qAsConst(m_notiList))
{
tb->setToolTip(toolTip);
tb->setIconSize(QSize(30,30));
}
}
void LtsNotificationController::setAllIcons()
{
if (m_icon.isNull())
return;
// prepare new Icon (add count), then set to all ToolButtons
QIcon icon = modifyIcon(m_icon);
for (QToolButton *tb : qAsConst(m_notiList))
{
tb->setIcon(icon);
tb->setIconSize(QSize(30,30));
tb->setEnabled(m_enable);
}
}
#define SIZE 40
QIcon LtsNotificationController::modifyIcon(const QIcon &icon) // TODO: automatic advanced scope ??!
{
/* FIXME: it is impossible to check if QIcon is valid, so calling modifyIcon will start
* a painter on an invalid QPixmap (hence the QIcon) which produces error messages in
* the log file & stdout.
*/
if (m_count < 1) // do not draw '0' on it..
return icon;
QPixmap iconImage(icon.pixmap(SIZE * 8 / 10, SIZE * 8 / 10));
QPainter painter(&iconImage);
painter.save();
painter.setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform);
QFont f;
f.setFamily(QStringLiteral("Monospace"));
f.setPointSize(16);
f.setBold(true);
painter.setFont(f);
QColor color(Qt::red);
painter.setBrush(color);
painter.setPen(QPen(color, 3.1));
painter.drawText(QRect(0, 0, 30, 30), QString::number(m_count)); // TODO: working version of this: , QTextOption(Qt::AlignRight | Qt::AlignBottom));
painter.restore();
return iconImage;
}
QToolButton *LtsNotificationController::createWidget()
{
QToolButton *b = new QToolButton();
b->setToolButtonStyle(Qt::ToolButtonIconOnly);
b->setObjectName(m_identifier);
//qWarning() << "object name" << b->objectName() << "==" << m_identifier;
// FIXME: variable sizes !! LtsDragIcon ?
b->setMinimumSize(SIZE, SIZE);
b->setMaximumSize(SIZE, SIZE);
connect(b, &QToolButton::destroyed,
this, &LtsNotificationController::slotNotiWidgetDestroyed);
connect(b, &QToolButton::clicked,
this, [this](){ if (m_action) m_action(); }); // TODO: FIXME: BAD, BAD HACK?!
if (!m_icon.isNull())
b->setIcon(modifyIcon(m_icon));
b->setToolTip(m_toolTip);
m_notiList.append(b);
return b;
}
void LtsNotificationController::slotNotiWidgetDestroyed(QObject *obj)
{
m_notiList.removeAll(static_cast<QToolButton*>(obj)); // no qobject_cast for destroyed objects
}
} // namespace LtsNotification