MCPcopy Create free account
hub / github.com/YACReader/yacreader / setCustomFolderCover

Method setCustomFolderCover

YACReaderLibrary/library_window.cpp:2305–2325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2303}
2304
2305void LibraryWindow::setCustomFolderCover(Folder folder)
2306{
2307 auto customCoverPath = YACReader::imageFileLoader(this);
2308 if (!customCoverPath.isEmpty()) {
2309 QImage cover(customCoverPath);
2310 if (cover.isNull()) {
2311 QMessageBox::warning(this, tr("Invalid image"), tr("The selected file is not a valid image."));
2312 return;
2313 }
2314
2315 auto folderCoverPath = LibraryPaths::customFolderCoverPath(libraries.getPath(selectedLibrary->currentText()), QString::number(folder.id));
2316 if (!YACReader::saveCover(folderCoverPath, cover)) {
2317 QMessageBox::warning(this, tr("Error saving cover"), tr("There was an error saving the cover image."));
2318 }
2319
2320 QModelIndex folderIndex = foldersModel->getIndexFromFolder(folder);
2321 auto coversPath = LibraryPaths::libraryCoversFolderPath(libraries.getPath(selectedLibrary->currentText()));
2322 auto relativePath = folderCoverPath.remove(coversPath);
2323 foldersModel->setCustomFolderCover(folderIndex, relativePath);
2324 }
2325}
2326
2327void LibraryWindow::deleteCustomFolderCover()
2328{

Callers

nothing calls this directly

Calls 5

isEmptyMethod · 0.80
getPathMethod · 0.80
currentTextMethod · 0.80
getIndexFromFolderMethod · 0.80
removeMethod · 0.45

Tested by

no test coverage detected