utils: get svg cursor nominal size from metadata
Instead of assume it to be 24.
This commit is contained in:
parent
b88bce1b2e
commit
31fac8493e
1 changed files with 8 additions and 2 deletions
|
@ -23,6 +23,7 @@ struct SvgCursorMetaDataEntry
|
||||||
static std::optional<SvgCursorMetaDataEntry> parse(const QJsonObject &object);
|
static std::optional<SvgCursorMetaDataEntry> parse(const QJsonObject &object);
|
||||||
|
|
||||||
QString fileName;
|
QString fileName;
|
||||||
|
qreal nominalSize;
|
||||||
QPointF hotspot;
|
QPointF hotspot;
|
||||||
std::chrono::milliseconds delay;
|
std::chrono::milliseconds delay;
|
||||||
};
|
};
|
||||||
|
@ -34,6 +35,11 @@ std::optional<SvgCursorMetaDataEntry> SvgCursorMetaDataEntry::parse(const QJsonO
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QJsonValue nominalSize = object.value(QLatin1String("nominal_size"));
|
||||||
|
if (!nominalSize.isDouble()) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
const QJsonValue hotspotX = object.value(QLatin1String("hotspot_x"));
|
const QJsonValue hotspotX = object.value(QLatin1String("hotspot_x"));
|
||||||
if (!hotspotX.isDouble()) {
|
if (!hotspotX.isDouble()) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
@ -48,6 +54,7 @@ std::optional<SvgCursorMetaDataEntry> SvgCursorMetaDataEntry::parse(const QJsonO
|
||||||
|
|
||||||
return SvgCursorMetaDataEntry{
|
return SvgCursorMetaDataEntry{
|
||||||
.fileName = fileName.toString(),
|
.fileName = fileName.toString(),
|
||||||
|
.nominalSize = nominalSize.toDouble(),
|
||||||
.hotspot = QPointF(hotspotX.toDouble(), hotspotY.toDouble()),
|
.hotspot = QPointF(hotspotX.toDouble(), hotspotY.toDouble()),
|
||||||
.delay = std::chrono::milliseconds(frametime.toInt()),
|
.delay = std::chrono::milliseconds(frametime.toInt()),
|
||||||
};
|
};
|
||||||
|
@ -111,11 +118,10 @@ QList<CursorSprite> SvgCursorReader::load(const QString &containerPath, int desi
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const qreal scale = desiredSize / 24.0;
|
|
||||||
|
|
||||||
QList<CursorSprite> sprites;
|
QList<CursorSprite> sprites;
|
||||||
for (const SvgCursorMetaDataEntry &entry : metadata->entries) {
|
for (const SvgCursorMetaDataEntry &entry : metadata->entries) {
|
||||||
const QString filePath = containerDir.filePath(entry.fileName);
|
const QString filePath = containerDir.filePath(entry.fileName);
|
||||||
|
const qreal scale = desiredSize / entry.nominalSize;
|
||||||
|
|
||||||
QSvgRenderer renderer(filePath);
|
QSvgRenderer renderer(filePath);
|
||||||
if (!renderer.isValid()) {
|
if (!renderer.isValid()) {
|
||||||
|
|
Loading…
Reference in a new issue