Fix loading hiDPI version of cursors.

This commit is contained in:
Roman Telezhynskyi 2023-08-28 19:57:39 +03:00
parent 29a89de9b4
commit d0ddc4d108

View File

@ -813,14 +813,16 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons
CancelTool(); CancelTool();
emit EnableItemMove(false); emit EnableItemMove(false);
m_currentTool = m_lastUsedTool = t; m_currentTool = m_lastUsedTool = t;
auto cursorResource = VTheme::GetResourceName(QStringLiteral("cursor"), cursor); const QString resource = QStringLiteral("toolcursor");
auto cursorResource = VTheme::GetResourceName(resource, cursor);
if (qApp->devicePixelRatio() >= 2) // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) if (qApp->devicePixelRatio() >= 2) // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
{ {
// Try to load HiDPI versions of the cursors if availible // Try to load HiDPI versions of the cursors if availible
auto cursorHidpiResource = QString(cursor).replace(QLatin1String(".png"), QLatin1String("@2x.png")); auto hiDPICursor = QString(cursor).replace(QLatin1String(".png"), QLatin1String("@2x.png"));
if (QFileInfo::exists(cursorResource)) auto cursorHiDPIResource = VTheme::GetResourceName(resource, hiDPICursor);
if (QFileInfo::exists(cursorHiDPIResource))
{ {
cursorResource = cursorHidpiResource; cursorResource = cursorHiDPIResource;
} }
} }
QPixmap pixmap(cursorResource); QPixmap pixmap(cursorResource);