- 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>
111 lines
2.7 KiB
C++
111 lines
2.7 KiB
C++
|
|
|
|
#include "lts_profile_button.h"
|
|
|
|
#include <QBrush>
|
|
#include <QEvent>
|
|
#include <QPaintEvent>
|
|
#include <QPainter>
|
|
#include <QPainterPath>
|
|
#include <QPen>
|
|
#include <QRect>
|
|
|
|
using namespace LtsWidgets;
|
|
|
|
LtsProfileButton::LtsProfileButton(QWidget* parent) : QWidget(parent), m_isHovered(false), m_menuEnabled(true)
|
|
{
|
|
QSizePolicy qsp = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
qsp.setHeightForWidth(true);
|
|
setSizePolicy(qsp);
|
|
}
|
|
|
|
void LtsProfileButton::setPixmap(const QPixmap& pixmap)
|
|
{
|
|
if (pixmap.isNull())
|
|
m_pixmap = QPixmap(QStringLiteral("icon:no_pic.svg"));
|
|
else
|
|
m_pixmap = pixmap;
|
|
|
|
update();
|
|
}
|
|
|
|
void LtsProfileButton::enterEvent(QEvent* event)
|
|
{
|
|
|
|
m_isHovered = true;
|
|
update();
|
|
QWidget::enterEvent(static_cast<QEnterEvent*>(event));
|
|
}
|
|
|
|
void LtsProfileButton::leaveEvent(QEvent* event)
|
|
{
|
|
|
|
m_isHovered = false;
|
|
update();
|
|
QWidget::leaveEvent(event);
|
|
}
|
|
|
|
bool LtsProfileButton::event(QEvent* event)
|
|
{
|
|
if (event->type() == QEvent::MouseButtonPress && m_menuEnabled)
|
|
{
|
|
emit signalClicked();
|
|
event->accept();
|
|
|
|
update();
|
|
return true;
|
|
}
|
|
|
|
return QWidget::event(event);
|
|
}
|
|
|
|
void LtsProfileButton::paintEvent(QPaintEvent* event)
|
|
{
|
|
QPainter p(this);
|
|
p.save();
|
|
|
|
int minSize;
|
|
QPointF center;
|
|
minSize = height() > width() ? width() : height();
|
|
center = QPointF(width() / 2.0, height() / 2.0);
|
|
|
|
p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
|
|
|
QPixmap pixmap(minSize, minSize);
|
|
pixmap.fill(Qt::white);
|
|
|
|
if (!m_pixmap.isNull())
|
|
{
|
|
if (!(m_isHovered && m_menuEnabled))
|
|
{
|
|
pixmap = m_pixmap.scaled(minSize, minSize, Qt::KeepAspectRatioByExpanding);
|
|
}
|
|
}
|
|
|
|
QPainterPath path;
|
|
path.addEllipse(center, minSize / 2.0 - 4, minSize / 2.0 - 4);
|
|
p.setClipPath(path);
|
|
p.drawPixmap(center - QPointF(minSize / 2.0, minSize / 2.0), pixmap);
|
|
|
|
p.setPen(QPen(QColor("gray"), 2));
|
|
p.drawEllipse(center, minSize / 2.0 - 4, minSize / 2.0 - 4);
|
|
|
|
if (m_isHovered && m_menuEnabled)
|
|
{
|
|
p.setPen(QPen(QColor(QStringLiteral("gray")), (minSize / 48 * 2)));
|
|
|
|
double xc = size().width() / 2.012;
|
|
double yc = size().height() / 2.012;
|
|
double diff = minSize / 2.012;
|
|
|
|
p.drawLine(QPointF(xc - (diff / 2.01f), yc - (diff / 3.01f)),
|
|
QPointF(xc + (diff / 2.02f), yc - (diff / 3.02f)));
|
|
p.drawLine(QPointF(xc - (diff / 2.01f), yc - 0.01f), QPointF(xc + (diff / 2.02f), yc - 0));
|
|
p.drawLine(QPointF(xc - (diff / 2.01f), yc + (diff / 3.01f)),
|
|
QPointF(xc + (diff / 2.02f), yc + (diff / 3.02f)));
|
|
}
|
|
|
|
event->accept();
|
|
p.restore();
|
|
}
|