refactor: Use SVG for cursor rendering
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -30,6 +30,8 @@ ViewportWidget::ViewportWidget(QWidget *parent)
|
|||||||
m_toolIcons.insert(static_cast<int>(ApplicationController::ToolType::Line), new QSvgRenderer(QString(":/icons/line.svg"), this));
|
m_toolIcons.insert(static_cast<int>(ApplicationController::ToolType::Line), new QSvgRenderer(QString(":/icons/line.svg"), this));
|
||||||
m_toolIcons.insert(static_cast<int>(ApplicationController::ToolType::Rectangle), new QSvgRenderer(QString(":/icons/rectangle.svg"), this));
|
m_toolIcons.insert(static_cast<int>(ApplicationController::ToolType::Rectangle), new QSvgRenderer(QString(":/icons/rectangle.svg"), this));
|
||||||
m_toolIcons.insert(static_cast<int>(ApplicationController::ToolType::Circle), new QSvgRenderer(QString(":/icons/circle.svg"), this));
|
m_toolIcons.insert(static_cast<int>(ApplicationController::ToolType::Circle), new QSvgRenderer(QString(":/icons/circle.svg"), this));
|
||||||
|
|
||||||
|
m_cursorRenderer = new QSvgRenderer(QString(":/icons/cursor.svg"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewportWidget::~ViewportWidget()
|
ViewportWidget::~ViewportWidget()
|
||||||
@@ -400,12 +402,10 @@ void ViewportWidget::onActiveToolChanged(int tool)
|
|||||||
QPainter painter(&cursorPixmap);
|
QPainter painter(&cursorPixmap);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
// Draw arrow cursor manually
|
// Render arrow cursor from SVG
|
||||||
QPolygon arrowPolygon;
|
if (m_cursorRenderer && m_cursorRenderer->isValid()) {
|
||||||
arrowPolygon << QPoint(0, 0) << QPoint(0, 11) << QPoint(4, 11) << QPoint(4, 16) << QPoint(7, 16) << QPoint(7, 11) << QPoint(11, 11);
|
m_cursorRenderer->render(&painter, QRectF(0, 0, 16, 16));
|
||||||
painter.setPen(Qt::white);
|
}
|
||||||
painter.setBrush(Qt::black);
|
|
||||||
painter.drawPolygon(arrowPolygon);
|
|
||||||
|
|
||||||
// Render tool icon
|
// Render tool icon
|
||||||
const QSize iconSize(32, 32);
|
const QSize iconSize(32, 32);
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ private:
|
|||||||
QPoint m_currentMousePos;
|
QPoint m_currentMousePos;
|
||||||
|
|
||||||
QMap<int, QSvgRenderer*> m_toolIcons;
|
QMap<int, QSvgRenderer*> m_toolIcons;
|
||||||
|
QSvgRenderer* m_cursorRenderer = nullptr;
|
||||||
|
|
||||||
float m_xRot = 35.264f * 16.0f; // Default to isometric view
|
float m_xRot = 35.264f * 16.0f; // Default to isometric view
|
||||||
float m_yRot = -45.0f * 16.0f; // Default to isometric view
|
float m_yRot = -45.0f * 16.0f; // Default to isometric view
|
||||||
|
|||||||
Reference in New Issue
Block a user