Files
qt-migration-legatus/qt5-before/dlbo/Lts/Common/LtsWidgets/lts_led_widget.h
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

179 lines
5.2 KiB
C++

/**
* @RDE_HEADER@
* LTS LED Widget
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <QWidget>
#include "lts_widgets_export.h"
namespace LtsWidgets
{
/**
* This class generates a LED with 2D/3D design, customizable colors and animation.
*
* If you need more than two states, simple derive from this class, only use "status=on"
* generate pairs of identifiers and colors and change the colors with appropriate method:
* e.g.:
* DerivedLEDWidget(...) : LtsLedWidget() {}
* enum Status { ST_STATUS1 = 0, ST_STATUS2, ST_STATUS3 };
* static QMap<Status, QColor> cMap; // Fill it respectively
* DerivedLEDWidget::setStatus(Status b) { setOnColor(cMap.value(b, Qt::black)); }
*/
class LTSWIDGETS_EXPORT LtsLedWidget : public QWidget
{
Q_OBJECT
public:
enum class AspectHint
{
WidthIsHeight,
NoHint,
HeightIsWidth
};
Q_ENUM(AspectHint)
Q_PROPERTY(QColor oncolor READ onColor WRITE setOnColor)
Q_PROPERTY(QColor offcolor READ offColor WRITE setOffColor)
Q_PROPERTY(bool status READ status WRITE setStatus)
Q_PROPERTY(bool usesGradient READ usesGradient WRITE setUseGradient)
Q_PROPERTY(int animTime READ animTime WRITE setAnimTime)
Q_PROPERTY(AspectHint aspectHint READ aspectHint WRITE setAspectHint)
Q_PROPERTY(QColor currentcolor READ currentColor WRITE setCurrentColor DESIGNABLE false)
/**
* Constructor
* @param parent The widget's parent. Default value is NULL.
* @param oncolor The color for LED when turned on. Default value is Qt::red, see also setOnColor() for details.
* @param offcolor The color for LED when turned off. Default value is Qt::black (i.e. "Use darker color"), see also setOffColor() for details.
* @param useGradient The 2D/3D design status. Default value is true (3D).
* @param animtime The animation time in msecs. Default value is 0.
*/
explicit LtsLedWidget(QWidget *parent = nullptr, const QColor &oncolor = Qt::red, const QColor &offcolor = Qt::black, bool useGradient = true, int animtime = 0);
void paintEvent(QPaintEvent *pe);
/**
* Set animation time in msec
* Value = 0 shows no animation
* Reasonable value is between 400 and 700 msecs
* @param time time in msecs
*/
void setAnimTime(int time) { m_animTime = time; }
/**
* Get current animation time in msecs
* @return animation time in msecs
*/
int animTime() const { return m_animTime; }
/**
* Get current led status
* @return the LED's status
*/
bool status() const { return m_status; }
/**
* Set 2D/3D design
* Value true set a 3D design of the led widget,
* Value false set a 2D design of the led widget
* @param useGradient
*/
void setUseGradient(bool useGradient);
/**
* Get a state info about the current 2D/3D design
* @return true for 3D and false for 2D design
*/
bool usesGradient() const { return m_gradient; }
/**
* Set the color for the LED when turned "on".
* If status is "on" and the oncolor is changed
* the animation will be run.
* @param oncolor color for LED in state "on"
*/
void setOnColor(const QColor &oncolor);
/**
* Get the current oncolor
* @return the current oncolor
*/
QColor onColor() const { return m_oncolor; }
/**
* Set the color for the LED when turned "off".
* If offcolor is black the wigdet use a darker version of oncolor as offcolor value.
* If status is "off" and the offcolor is changed
* the animation will be run.
* @param offcolor color for LED in state "off"
*/
void setOffColor(const QColor &offcolor);
/**
* Get the current offcolor
* @return the current offcolor
*/
QColor offColor() const { return m_offcolor; }
/**
* Convenience function set oncolor and offcolor in one step
* Default value for offcolor is black.
* If offcolor is black the wigdet use a darker version of oncolor as offcolor value.
* @param oncolor The color for LED when turned on.
* @param offcolor The color for LED when turned off. Default value is Qt::black (i.e. "Use darker color").
*/
void setColor(const QColor &oncolor, const QColor &offcolor = Qt::black);
/**
* Get current color
* @return the currently visible color
*/
QColor currentColor() const { return m_currentcolor; }
void resizeEvent(QResizeEvent *event);
AspectHint aspectHint() const { return m_aspectHint; }
public slots:
/**
* Public slot set current led status
* @param status The LED's status (on/off)
*/
void setStatus(bool status);
void setAspectHint(AspectHint aspectHint)
{
m_aspectHint = aspectHint;
}
private:
/**
* Set current color
* Needed for color animation
* ***This method is private for a reason!***
* @param currentcolor
*/
void setCurrentColor(const QColor &currentcolor);
/**
* Private function to start the color animation
*/
void animate();
bool m_status;
QColor m_oncolor;
QColor m_offcolor;
QColor m_currentcolor;
bool m_gradient;
int m_animTime;
AspectHint m_aspectHint = AspectHint::NoHint;
};
} // namespace LtsWidgets