| 2303 | } |
| 2304 | |
| 2305 | void 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 | |
| 2327 | void LibraryWindow::deleteCustomFolderCover() |
| 2328 | { |
nothing calls this directly
no test coverage detected