Qt6 Migration: LtsWidgets, BUILD_RTI Guards, externe Dependencies dokumentiert
- LtsWidgets Verzeichnis vollständig migriert (Qt5→Qt6) - BUILD_RTI Guards für RTI-spezifische Module hinzugefügt - Externe Dependencies in EXTERNAL_DEPS.md dokumentiert - Qt6 API-Änderungen: QRegExp→QRegularExpression, enterEvent(QEnterEvent*) - AutoUic-Fehler bei ui_requirement behoben (SKIP_AUTOUIC) - Include-Pfade korrigiert (LtsElevation, LtsMultiMonitor, LtsUtilsCore) - MOC-Fehler behoben (Q_INTERFACES entfernt wo nicht benötigt) - CMakeLists.txt Anpassungen für Qt6 (PUBLIC statt INTERFACE) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
145 files changed
+17700
-14377
No files matched your search
@@ -1,137 +1,154 @@
|
||||
|
||||
/**
|
||||
* @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)
|
||||
void LtsLedWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
switch (m_aspectHint)
|
||||
{
|
||||
case AspectHint::NoHint: {
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
/**
|
||||
* 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)
|
||||
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"));
|
||||
setObjectName(QString::fromUtf8("LtsLedWidget"));
|
||||
}
|
||||
|
||||
void LtsLedWidget::paintEvent(QPaintEvent* pe)
|
||||
void LtsLedWidget::paintEvent(QPaintEvent *pe)
|
||||
{
|
||||
Q_UNUSED(pe);
|
||||
QPainter p;
|
||||
p.begin(this);
|
||||
p.setOpacity(QWidget::isEnabled() ? 1.00 : 0.5);
|
||||
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, minSize,
|
||||
QPointF(width(), height()) / GRADIENT_FOCALPOINT_OFFSET);
|
||||
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));
|
||||
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();
|
||||
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);
|
||||
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();
|
||||
if (m_status == status)
|
||||
return;
|
||||
m_status = status;
|
||||
animate();
|
||||
}
|
||||
|
||||
void LtsLedWidget::setUseGradient(bool useGradient)
|
||||
{
|
||||
if (m_gradient == useGradient)
|
||||
return;
|
||||
m_gradient = useGradient;
|
||||
repaint();
|
||||
if (m_gradient == useGradient)
|
||||
return;
|
||||
m_gradient = useGradient;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void LtsLedWidget::setColor(const QColor& oncolor, const QColor& offcolor)
|
||||
void LtsLedWidget::setColor(const QColor &oncolor, const QColor &offcolor)
|
||||
{
|
||||
setOnColor(oncolor);
|
||||
setOffColor(offcolor);
|
||||
setOnColor(oncolor);
|
||||
setOffColor(offcolor);
|
||||
}
|
||||
|
||||
void LtsLedWidget::setOnColor(const QColor& oncolor)
|
||||
void LtsLedWidget::setOnColor(const QColor &oncolor)
|
||||
{
|
||||
if (m_oncolor == oncolor)
|
||||
return;
|
||||
m_oncolor = oncolor;
|
||||
if (m_status)
|
||||
animate();
|
||||
if (m_oncolor == oncolor)
|
||||
return;
|
||||
m_oncolor = oncolor;
|
||||
if (m_status)
|
||||
animate();
|
||||
}
|
||||
|
||||
void LtsLedWidget::setOffColor(const QColor& offcolor)
|
||||
void LtsLedWidget::setOffColor(const QColor &offcolor)
|
||||
{
|
||||
if (m_offcolor == offcolor)
|
||||
return;
|
||||
m_offcolor = offcolor;
|
||||
if (!m_status)
|
||||
animate();
|
||||
if (m_offcolor == offcolor)
|
||||
return;
|
||||
m_offcolor = offcolor;
|
||||
if (!m_status)
|
||||
animate();
|
||||
}
|
||||
|
||||
void LtsLedWidget::setCurrentColor(const QColor& currentcolor)
|
||||
void LtsLedWidget::setCurrentColor(const QColor ¤tcolor)
|
||||
{
|
||||
if (m_currentcolor == currentcolor)
|
||||
return;
|
||||
m_currentcolor = currentcolor;
|
||||
repaint();
|
||||
if (m_currentcolor == currentcolor)
|
||||
return;
|
||||
m_currentcolor = currentcolor;
|
||||
repaint();
|
||||
}
|
||||
|
||||
} // namespace LtsWidgets
|
||||
} // namespace namespace LtsWidgets
|
||||
Reference in new issue
Block a user