Give people options from a dropdown.

Took 1 hour 6 minutes

Took 3 seconds
This commit is contained in:
Lukas Brübach 2026-04-12 08:19:41 +02:00
parent 64885f4c20
commit 37cb86f16a
7 changed files with 173 additions and 47 deletions

View file

@ -189,9 +189,19 @@ void CardPictureLoader::saveCardImageToLocalStorage(const ExactCard &card, const
}
const QString picsRoot = SettingsCache::instance().getPicsPath();
const QString scheme = SettingsCache::instance().getLocalCardImageStorageNamingScheme();
CardPictureLoaderLocalSchemes::NamingScheme scheme =
SettingsCache::instance().getLocalCardImageStorageNamingScheme();
if (picsRoot.isEmpty() || scheme.isEmpty()) {
QString pattern;
for (const auto &s : CardPictureLoaderLocalSchemes::exportSchemes()) {
if (s.id == scheme) {
pattern = s.pattern;
break;
}
}
if (picsRoot.isEmpty() || pattern.isEmpty()) {
return;
}
@ -217,18 +227,26 @@ void CardPictureLoader::saveCardImageToLocalStorage(const ExactCard &card, const
}
// Build path from scheme
QString relativePath = scheme;
QString relativePath =
CardPictureLoaderLocalSchemes::expandPattern(pattern, cardName, setName, collectorNumber, uuid);
relativePath.replace("{name}", cardName);
relativePath.replace("{set}", setName);
relativePath.replace("{collector}", collectorNumber);
relativePath.replace("{uuid}", uuid);
relativePath.replace("{ext}", "png");
if (relativePath.isEmpty()) {
return;
}
// append extension
relativePath += ".png";
// Normalize slashes
relativePath = QDir::cleanPath(relativePath);
QFileInfo outInfo(baseDir.filePath(relativePath));
// Do not overwrite existing files
if (outInfo.exists()) {
return;
}
QDir outDir = outInfo.dir();
// Ensure directory exists
@ -239,11 +257,6 @@ void CardPictureLoader::saveCardImageToLocalStorage(const ExactCard &card, const
}
}
// Do not overwrite existing files
if (outInfo.exists()) {
return;
}
// Save image
QImage image = pixmap.toImage();
if (!image.save(outInfo.absoluteFilePath(), "PNG")) {