Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Common/LtsWidgets/lts_image_editor.cpp
T
torstenandCopilot bafed3705f Qt6 migration: LtsWidgets API fixes, LtsWebSocket logger init, RTI Docker install
- LtsWidgets: Fixed Qt6 API compatibility issues
  - QWheelEvent::delta() → angleDelta().y()
  - QStyleOption::init() → initFrom()
  - QComboBox activated signal signature change
  - QTextCodec removal (UTF-8 default in Qt6)
  - Missing widget includes added

- LtsWebSocket: Fixed m_logger reference initialization
  - Added NGLLoggerBootstrap includes
  - Proper initialization in constructor initializer lists

- CMake: Added BUILD_LTSWEBSOCKET option for temporary exclusion

- Docker: RTI Connext permanent installation script added
  - ci/install-rti-in-docker.sh for persistent RTI setup
  - Removes need for volume mounting RTI into container

- BUILD options: FilterManagement, RTI, Codification, Grantlee, LtsWebSocket
  can be disabled for partial builds during migration

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-19 14:04:26 +02:00

102 lines
2.4 KiB
C++

#include "lts_image_editor.h"
#include <QBrush>
#include <QEvent>
#include <QPaintEvent>
#include <QPainter>
#include <QPen>
#include <QRect>
using namespace LtsWidgets;
LtsImageEditor::LtsImageEditor(QWidget* parent)
: QWidget(parent), m_isHovered(false), m_menuEnabled(true), m_bDrawOuterRect(true)
{
}
void LtsImageEditor::setPixmap(const QPixmap& pixmap)
{
if (pixmap.isNull())
m_pixmap = QPixmap(QStringLiteral(":style/noimage.png"));
else
m_pixmap = pixmap;
update();
emit imageChanged();
}
void LtsImageEditor::enterEvent(QEnterEvent*)
{
m_isHovered = true;
update();
}
void LtsImageEditor::leaveEvent(QEvent*)
{
m_isHovered = false;
update();
}
bool LtsImageEditor::event(QEvent* event)
{
if (event->type() == QEvent::MouseButtonPress && m_menuEnabled)
{
emit signalClicked();
event->accept();
m_isHovered = false;
update();
return true;
}
return QWidget::event(event);
}
void LtsImageEditor::paintEvent(QPaintEvent* event)
{
QPainter p(this);
p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
QBrush brush = QColor(QStringLiteral("white"));
if (!m_pixmap.isNull())
{
if (!(m_isHovered && m_menuEnabled))
{
const QSize s(size());
const QPixmap pixmap(m_pixmap.scaled(s, Qt::KeepAspectRatio, Qt::SmoothTransformation));
const int x = qRound((s.width() - pixmap.width()) / 2.);
const int y = qRound((s.height() - pixmap.height()) / 2.);
if (m_bDrawOuterRect)
{
p.setPen(QPen(QColor("gray"), 2));
p.drawRect(rect());
}
p.drawPixmap(x, y, pixmap);
event->accept();
return;
}
}
p.setPen(QPen(QColor("gray"), 2));
p.setBrush(brush);
p.drawRect(rect());
if (m_isHovered && m_menuEnabled)
{
p.setPen(QPen(QColor(QStringLiteral("gray")), (size().height() / 48 * 2)));
double xc = size().width() / 2.012;
double yc = size().height() / 2.012;
p.drawLine(QPointF(xc - (xc / 2.01f), yc - (yc / 3.01f)), QPointF(xc + (xc / 2.02f), yc - (yc / 3.02f)));
p.drawLine(QPointF(xc - (xc / 2.01f), yc - 0.01f), QPointF(xc + (xc / 2.02f), yc - 0));
p.drawLine(QPointF(xc - (xc / 2.01f), yc + (yc / 3.01f)), QPointF(xc + (xc / 2.02f), yc + (yc / 3.02f)));
}
event->accept();
}