mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Support editing the cover image of various comics at once
This commit is contained in:
parent
8b159c9da6
commit
5950c52e19
@ -482,7 +482,7 @@ void PropertiesDialog::loadComic(ComicDB &comic)
|
|||||||
showNextCoverPageButton->setEnabled(true);
|
showNextCoverPageButton->setEnabled(true);
|
||||||
|
|
||||||
coverChanged = false;
|
coverChanged = false;
|
||||||
coverBox->show();
|
updateCoverBoxForSingleComic();
|
||||||
|
|
||||||
if (!QFileInfo(basePath + comic.path).exists()) {
|
if (!QFileInfo(basePath + comic.path).exists()) {
|
||||||
QMessageBox::warning(this, tr("Not found"), tr("Comic not found. You should update your library."));
|
QMessageBox::warning(this, tr("Not found"), tr("Comic not found. You should update your library."));
|
||||||
@ -617,7 +617,7 @@ void PropertiesDialog::setComics(QList<ComicDB> comics)
|
|||||||
updateButtons();
|
updateButtons();
|
||||||
|
|
||||||
if (comics.length() > 1) {
|
if (comics.length() > 1) {
|
||||||
coverBox->hide();
|
updateCoverBoxForMultipleComics();
|
||||||
|
|
||||||
setDisableUniqueValues(true);
|
setDisableUniqueValues(true);
|
||||||
this->setWindowTitle(tr("Edit selected comics information"));
|
this->setWindowTitle(tr("Edit selected comics information"));
|
||||||
@ -753,6 +753,40 @@ void PropertiesDialog::updateComics()
|
|||||||
DBHelper::update(&(itr->info), db);
|
DBHelper::update(&(itr->info), db);
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!sequentialEditing && coverChanged) {
|
||||||
|
auto coverPath = LibraryPaths::coverPath(basePath, itr->info.hash);
|
||||||
|
|
||||||
|
if (customCover.isNull()) { // reseted, we need to restore the default cover
|
||||||
|
itr->info.coverPage = QVariant();
|
||||||
|
|
||||||
|
InitialComicInfoExtractor ie(basePath + itr->path, coverPath, 1);
|
||||||
|
ie.extract();
|
||||||
|
|
||||||
|
if (ie.getOriginalCoverSize().second > 0) {
|
||||||
|
itr->info.originalCoverSize = QString("%1x%2").arg(ie.getOriginalCoverSize().first).arg(ie.getOriginalCoverSize().second);
|
||||||
|
itr->info.coverSizeRatio = static_cast<float>(ie.getOriginalCoverSize().first) / ie.getOriginalCoverSize().second;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit coverChangedSignal(*itr);
|
||||||
|
|
||||||
|
DBHelper::update(&(itr->info), db);
|
||||||
|
updated = true;
|
||||||
|
} else {
|
||||||
|
itr->info.coverPage = QVariant();
|
||||||
|
YACReader::saveCover(coverPath, customCover);
|
||||||
|
|
||||||
|
auto width = customCover.width();
|
||||||
|
auto height = customCover.height();
|
||||||
|
itr->info.originalCoverSize = QString("%1x%2").arg(width).arg(height);
|
||||||
|
itr->info.coverSizeRatio = static_cast<float>(width) / height;
|
||||||
|
|
||||||
|
DBHelper::update(&(itr->info), db);
|
||||||
|
updated = true;
|
||||||
|
|
||||||
|
emit coverChangedSignal(*itr);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
db.commit();
|
db.commit();
|
||||||
connectionName = db.connectionName();
|
connectionName = db.connectionName();
|
||||||
@ -782,13 +816,14 @@ void PropertiesDialog::setFilename(const QString &nameString)
|
|||||||
{
|
{
|
||||||
title->setText(nameString);
|
title->setText(nameString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesDialog::setNumpages(int pagesNum)
|
void PropertiesDialog::setNumpages(int pagesNum)
|
||||||
{
|
{
|
||||||
numPagesEdit->setText(QString::number(pagesNum));
|
numPagesEdit->setText(QString::number(pagesNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesDialog::setSize(float sizeFloat)
|
void PropertiesDialog::setSize(float sizeFloat)
|
||||||
{
|
{
|
||||||
|
|
||||||
size->setText(QString::number(sizeFloat, 'f', 2) + " MB");
|
size->setText(QString::number(sizeFloat, 'f', 2) + " MB");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -996,8 +1031,17 @@ void PropertiesDialog::save()
|
|||||||
comics[currentComicIndex].info.coverSizeRatio = static_cast<float>(ie.getOriginalCoverSize().first) / ie.getOriginalCoverSize().second;
|
comics[currentComicIndex].info.coverSizeRatio = static_cast<float>(ie.getOriginalCoverSize().first) / ie.getOriginalCoverSize().second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
comics[currentComicIndex].info.edited = true;
|
||||||
|
|
||||||
emit coverChangedSignal(comics[currentComicIndex]);
|
emit coverChangedSignal(comics[currentComicIndex]);
|
||||||
} else {
|
} else {
|
||||||
|
auto width = customCover.width();
|
||||||
|
auto height = customCover.height();
|
||||||
|
|
||||||
|
comics[currentComicIndex].info.originalCoverSize = QString("%1x%2").arg(width).arg(height);
|
||||||
|
comics[currentComicIndex].info.coverSizeRatio = static_cast<float>(width) / height;
|
||||||
|
|
||||||
|
comics[currentComicIndex].info.edited = true;
|
||||||
|
|
||||||
YACReader::saveCover(coverPath, customCover);
|
YACReader::saveCover(coverPath, customCover);
|
||||||
emit coverChangedSignal(comics[currentComicIndex]);
|
emit coverChangedSignal(comics[currentComicIndex]);
|
||||||
@ -1160,8 +1204,22 @@ void PropertiesDialog::loadPreviousCover()
|
|||||||
|
|
||||||
void PropertiesDialog::resetCover()
|
void PropertiesDialog::resetCover()
|
||||||
{
|
{
|
||||||
setCoverPage(1);
|
if (sequentialEditing) {
|
||||||
coverChanged = true; // it could be that the cover is a custom cover, so we need to always update it
|
setCoverPage(1);
|
||||||
|
coverChanged = true; // it could be that the cover is a custom cover, so we need to always update it
|
||||||
|
} else {
|
||||||
|
InitialComicInfoExtractor ie(basePath + comics.last().path, "", 1);
|
||||||
|
ie.extract();
|
||||||
|
auto cover = ie.getCover();
|
||||||
|
cover = cover.scaledToHeight(575, Qt::SmoothTransformation);
|
||||||
|
|
||||||
|
auto coverImage = QPixmap::fromImage(blurred(cover.toImage(), QRect(0, 0, cover.width(), cover.height()), 15));
|
||||||
|
|
||||||
|
this->cover->setPixmap(coverImage);
|
||||||
|
|
||||||
|
customCover = QImage();
|
||||||
|
coverChanged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesDialog::loadCustomCoverImage()
|
void PropertiesDialog::loadCustomCoverImage()
|
||||||
@ -1206,3 +1264,17 @@ bool PropertiesDialog::close()
|
|||||||
|
|
||||||
return QDialog::close();
|
return QDialog::close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertiesDialog::updateCoverBoxForMultipleComics()
|
||||||
|
{
|
||||||
|
showPreviousCoverPageButton->hide();
|
||||||
|
showNextCoverPageButton->hide();
|
||||||
|
coverPageNumberLabel->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesDialog::updateCoverBoxForSingleComic()
|
||||||
|
{
|
||||||
|
showPreviousCoverPageButton->show();
|
||||||
|
showNextCoverPageButton->show();
|
||||||
|
coverPageNumberLabel->show();
|
||||||
|
}
|
||||||
|
@ -182,6 +182,8 @@ public slots:
|
|||||||
void loadCustomCoverImageFromPath(const QString &path);
|
void loadCustomCoverImageFromPath(const QString &path);
|
||||||
void setCoverPage(int pageNumber);
|
void setCoverPage(int pageNumber);
|
||||||
bool close();
|
bool close();
|
||||||
|
void updateCoverBoxForMultipleComics();
|
||||||
|
void updateCoverBoxForSingleComic();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void coverChangedSignal(const ComicDB &comic);
|
void coverChangedSignal(const ComicDB &comic);
|
||||||
|
Loading…
Reference in New Issue
Block a user