From f10631fc11d02c3b3d9bf7602190c924885ac1cc Mon Sep 17 00:00:00 2001 From: Max Wilfinger Date: Sat, 5 Jul 2025 11:15:31 +0200 Subject: [PATCH] Gui: Use BitmapFactory for generating cursors --- src/Gui/View3DInventorViewer.cpp | 31 +++++++++---------------------- src/Gui/View3DInventorViewer.h | 2 +- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 94f0cc7fa3..e8ae9449fc 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -101,8 +101,7 @@ #include #include #include -#include -#include +#include #include "View3DInventorViewer.h" #include "Application.h" @@ -557,7 +556,7 @@ void View3DInventorViewer::init() } //create the cursors - createStandardCursors(devicePixelRatio()); + createStandardCursors(); connect(this, &View3DInventorViewer::devicePixelRatioChanged, this, &View3DInventorViewer::createStandardCursors); @@ -642,27 +641,15 @@ View3DInventorViewer::~View3DInventorViewer() delete glAction; } -static QCursor createSvgCursor(const QString& resourcePath, const QSize& logicalSize, const QPoint& hotSpot, qreal dpr) +void View3DInventorViewer::createStandardCursors() { - QSize physicalSize = logicalSize * dpr; + QPixmap panPixmap = BitmapFactory().pixmapFromSvg("cursor-pan", QSize(16,16)); + QPixmap spinPixmap = BitmapFactory().pixmapFromSvg("cursor-rotate", QSize(16,16)); + QPixmap zoomPixmap = BitmapFactory().pixmapFromSvg("cursor-zoom", QSize(16,16)); - QPixmap pixmap(physicalSize); - pixmap.fill(Qt::transparent); - - QSvgRenderer renderer(resourcePath); - QPainter painter(&pixmap); - renderer.render(&painter); - painter.end(); - - pixmap.setDevicePixelRatio(dpr); - return QCursor(pixmap, hotSpot.x(), hotSpot.y()); -} - -void View3DInventorViewer::createStandardCursors(double dpr) -{ - this->panCursor = createSvgCursor(QStringLiteral(":/icons/cursor-pan.svg"), QSize(16, 16), QPoint(8, 8), dpr); - this->spinCursor = createSvgCursor(QStringLiteral(":/icons/cursor-rotate.svg"), QSize(16, 16), QPoint(8, 8), dpr); - this->zoomCursor = createSvgCursor(QStringLiteral(":/icons/cursor-zoom.svg"), QSize(16, 16), QPoint(8, 8), dpr); + this->panCursor = QCursor(panPixmap, 8, 8); + this->spinCursor = QCursor(spinPixmap, 8, 8); + this->zoomCursor = QCursor(zoomPixmap, 8, 8); } void View3DInventorViewer::aboutToDestroyGLContext() diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index 242d80bef3..7d510620d4 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -510,7 +510,7 @@ private: static void drawSingleBackground(const QColor&); void setCursorRepresentation(int mode); void aboutToDestroyGLContext(); - void createStandardCursors(double); + void createStandardCursors(); private: NaviCube* naviCube;