fix: Eliminate tool icon lag with custom QCursor
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -159,26 +159,6 @@ void ViewportWidget::paintGL()
|
|||||||
}
|
}
|
||||||
m_featureBrowser->paint(painter, width(), height());
|
m_featureBrowser->paint(painter, width(), height());
|
||||||
|
|
||||||
if (m_currentPlane != SketchPlane::NONE && m_activeTool != static_cast<int>(ApplicationController::ToolType::None) && m_toolIcons.contains(m_activeTool)) {
|
|
||||||
QSvgRenderer* renderer = m_toolIcons.value(m_activeTool);
|
|
||||||
if (renderer && renderer->isValid()) {
|
|
||||||
const QSize iconSize(32, 32);
|
|
||||||
const QPoint iconPos = m_currentMousePos + QPoint(15, 15);
|
|
||||||
const QRect iconRect(iconPos, iconSize);
|
|
||||||
|
|
||||||
QPixmap pixmap(iconSize);
|
|
||||||
pixmap.fill(Qt::transparent);
|
|
||||||
QPainter pixmapPainter(&pixmap);
|
|
||||||
renderer->render(&pixmapPainter);
|
|
||||||
pixmapPainter.end();
|
|
||||||
|
|
||||||
QImage image = pixmap.toImage();
|
|
||||||
image.invertPixels(QImage::InvertRgb);
|
|
||||||
|
|
||||||
painter.drawImage(iconRect, image);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
painter.end();
|
painter.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,6 +387,30 @@ void ViewportWidget::onActiveToolChanged(int tool)
|
|||||||
{
|
{
|
||||||
m_activeTool = tool;
|
m_activeTool = tool;
|
||||||
m_isDefiningLine = false;
|
m_isDefiningLine = false;
|
||||||
|
|
||||||
|
if (tool == static_cast<int>(ApplicationController::ToolType::None)) {
|
||||||
|
unsetCursor();
|
||||||
|
} else {
|
||||||
|
if (m_toolIcons.contains(tool)) {
|
||||||
|
QSvgRenderer* renderer = m_toolIcons.value(tool);
|
||||||
|
if (renderer && renderer->isValid()) {
|
||||||
|
const QSize iconSize(32, 32);
|
||||||
|
|
||||||
|
QPixmap pixmap(iconSize);
|
||||||
|
pixmap.fill(Qt::transparent);
|
||||||
|
QPainter pixmapPainter(&pixmap);
|
||||||
|
renderer->render(&pixmapPainter);
|
||||||
|
pixmapPainter.end();
|
||||||
|
|
||||||
|
QImage image = pixmap.toImage();
|
||||||
|
image.invertPixels(QImage::InvertRgb);
|
||||||
|
|
||||||
|
setCursor(QCursor(QPixmap::fromImage(image), 16, 16));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unsetCursor();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector3D ViewportWidget::unproject(const QPoint& screenPos)
|
QVector3D ViewportWidget::unproject(const QPoint& screenPos)
|
||||||
|
|||||||
Reference in New Issue
Block a user