mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Update properties dialog to be able to edit comics sequentially
This commit is contained in:
parent
769214fe5c
commit
c37bc33161
@ -2284,7 +2284,14 @@ void LibraryWindow::showProperties()
|
|||||||
|
|
||||||
propertiesDialog->databasePath = foldersModel->getDatabase();
|
propertiesDialog->databasePath = foldersModel->getDatabase();
|
||||||
propertiesDialog->basePath = currentPath();
|
propertiesDialog->basePath = currentPath();
|
||||||
|
|
||||||
|
if (indexList.length() > 1) { // edit common properties
|
||||||
propertiesDialog->setComics(comics);
|
propertiesDialog->setComics(comics);
|
||||||
|
} else {
|
||||||
|
auto allComics = comicsModel->getAllComics();
|
||||||
|
int index = allComics.indexOf(c);
|
||||||
|
propertiesDialog->setComicsForSequentialEditing(index, comicsModel->getAllComics());
|
||||||
|
}
|
||||||
|
|
||||||
propertiesDialog->show();
|
propertiesDialog->show();
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
using namespace YACReader;
|
using namespace YACReader;
|
||||||
|
|
||||||
PropertiesDialog::PropertiesDialog(QWidget *parent)
|
PropertiesDialog::PropertiesDialog(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent), updated(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
createCoverBox();
|
createCoverBox();
|
||||||
@ -302,11 +302,13 @@ void PropertiesDialog::createButtonBox()
|
|||||||
|
|
||||||
closeButton = buttonBox->addButton(QDialogButtonBox::Close);
|
closeButton = buttonBox->addButton(QDialogButtonBox::Close);
|
||||||
saveButton = buttonBox->addButton(QDialogButtonBox::Save);
|
saveButton = buttonBox->addButton(QDialogButtonBox::Save);
|
||||||
// rotateWidgetsButton = buttonBox->addButton(tr("Rotate &Widgets"),QDialogButtonBox::ActionRole);
|
previousButton = buttonBox->addButton("<", QDialogButtonBox::ButtonRole::NoRole);
|
||||||
|
nextButton = buttonBox->addButton(">", QDialogButtonBox::ButtonRole::NoRole);
|
||||||
|
|
||||||
// connect(rotateWidgetsButton, SIGNAL(clicked()), this, SLOT(rotateWidgets()));
|
connect(closeButton, &QAbstractButton::clicked, this, &PropertiesDialog::close);
|
||||||
connect(closeButton, &QAbstractButton::clicked, this, &QWidget::close);
|
connect(saveButton, &QAbstractButton::clicked, this, &PropertiesDialog::saveAndClose);
|
||||||
connect(saveButton, &QAbstractButton::clicked, this, &PropertiesDialog::save);
|
connect(previousButton, &QAbstractButton::clicked, this, &PropertiesDialog::saveAndOpenPrevious);
|
||||||
|
connect(nextButton, &QAbstractButton::clicked, this, &PropertiesDialog::saveAndOpenNext);
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage blurred(const QImage &image, const QRect &rect, int radius, bool alphaOnly = false)
|
QImage blurred(const QImage &image, const QRect &rect, int radius, bool alphaOnly = false)
|
||||||
@ -377,12 +379,8 @@ QImage blurred(const QImage &image, const QRect &rect, int radius, bool alphaOnl
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesDialog::setComics(QList<ComicDB> comics)
|
void PropertiesDialog::loadComic(ComicDB &comic)
|
||||||
{
|
{
|
||||||
this->comics = comics;
|
|
||||||
|
|
||||||
ComicDB comic = comics.at(0);
|
|
||||||
|
|
||||||
if (!comic.info.title.isNull())
|
if (!comic.info.title.isNull())
|
||||||
title->setText(comic.info.title.toString());
|
title->setText(comic.info.title.toString());
|
||||||
if (!comic.info.comicVineID.isNull()) {
|
if (!comic.info.comicVineID.isNull()) {
|
||||||
@ -391,7 +389,7 @@ void PropertiesDialog::setComics(QList<ComicDB> comics)
|
|||||||
} else
|
} else
|
||||||
comicVineLink->setHidden(true);
|
comicVineLink->setHidden(true);
|
||||||
|
|
||||||
if (comics.length() == 1 && !comic.info.coverPage.isNull()) {
|
if (!comic.info.coverPage.isNull()) {
|
||||||
coverPageEdit->setText(comic.info.coverPage.toString());
|
coverPageEdit->setText(comic.info.coverPage.toString());
|
||||||
coverPageValidator.setRange(1, comic.info.numPages.toInt());
|
coverPageValidator.setRange(1, comic.info.numPages.toInt());
|
||||||
coverPageEdit->setValidator(&coverPageValidator);
|
coverPageEdit->setValidator(&coverPageValidator);
|
||||||
@ -411,7 +409,7 @@ void PropertiesDialog::setComics(QList<ComicDB> comics)
|
|||||||
coverChanged = false;
|
coverChanged = false;
|
||||||
coverBox->show();
|
coverBox->show();
|
||||||
|
|
||||||
if (!QFileInfo(basePath + comics[0].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."));
|
||||||
showPreviousCoverPageButton->setDisabled(true);
|
showPreviousCoverPageButton->setDisabled(true);
|
||||||
showNextCoverPageButton->setDisabled(true);
|
showNextCoverPageButton->setDisabled(true);
|
||||||
@ -485,6 +483,36 @@ void PropertiesDialog::setComics(QList<ComicDB> comics)
|
|||||||
if (!comic.info.notes.isNull())
|
if (!comic.info.notes.isNull())
|
||||||
notes->setPlainText(comic.info.notes.toString());
|
notes->setPlainText(comic.info.notes.toString());
|
||||||
|
|
||||||
|
this->setWindowTitle(tr("Edit comic information"));
|
||||||
|
setCover(comic.info.getCover(basePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesDialog::updateButtons()
|
||||||
|
{
|
||||||
|
if (sequentialEditing) {
|
||||||
|
previousButton->setDisabled(currentComicIndex == 0);
|
||||||
|
nextButton->setDisabled(currentComicIndex == comics.length() - 1);
|
||||||
|
previousButton->setHidden(false);
|
||||||
|
nextButton->setHidden(false);
|
||||||
|
} else {
|
||||||
|
previousButton->setHidden(true);
|
||||||
|
nextButton->setHidden(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesDialog::setComics(QList<ComicDB> comics)
|
||||||
|
{
|
||||||
|
updated = false;
|
||||||
|
sequentialEditing = false;
|
||||||
|
|
||||||
|
this->comics = comics;
|
||||||
|
|
||||||
|
ComicDB comic = comics[0];
|
||||||
|
|
||||||
|
loadComic(comic);
|
||||||
|
|
||||||
|
updateButtons();
|
||||||
|
|
||||||
if (comics.length() > 1) {
|
if (comics.length() > 1) {
|
||||||
coverBox->hide();
|
coverBox->hide();
|
||||||
|
|
||||||
@ -555,12 +583,22 @@ void PropertiesDialog::setComics(QList<ComicDB> comics)
|
|||||||
if (itr->info.notes.isNull() || itr->info.notes.toString() != notes->toPlainText())
|
if (itr->info.notes.isNull() || itr->info.notes.toString() != notes->toPlainText())
|
||||||
notes->clear();
|
notes->clear();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this->setWindowTitle(tr("Edit comic information"));
|
|
||||||
setCover(comic.info.getCover(basePath));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertiesDialog::setComicsForSequentialEditing(int currentComicIndex, QList<ComicDB> comics)
|
||||||
|
{
|
||||||
|
updated = false;
|
||||||
|
sequentialEditing = true;
|
||||||
|
|
||||||
|
this->comics = comics;
|
||||||
|
this->currentComicIndex = currentComicIndex;
|
||||||
|
|
||||||
|
loadComic(comics[currentComicIndex]);
|
||||||
|
|
||||||
|
updateButtons();
|
||||||
|
}
|
||||||
|
|
||||||
void PropertiesDialog::updateComics()
|
void PropertiesDialog::updateComics()
|
||||||
{
|
{
|
||||||
QString connectionName = "";
|
QString connectionName = "";
|
||||||
@ -569,9 +607,13 @@ void PropertiesDialog::updateComics()
|
|||||||
db.open();
|
db.open();
|
||||||
db.transaction();
|
db.transaction();
|
||||||
QList<ComicDB>::iterator itr;
|
QList<ComicDB>::iterator itr;
|
||||||
for (itr = comics.begin(); itr != comics.end(); itr++) {
|
QList<ComicDB>::iterator begin = sequentialEditing ? comics.begin() + currentComicIndex : comics.begin();
|
||||||
if (itr->info.edited)
|
QList<ComicDB>::iterator end = sequentialEditing ? comics.begin() + currentComicIndex + 1 : comics.end();
|
||||||
|
for (itr = begin; itr != end; itr++) {
|
||||||
|
if (itr->info.edited) {
|
||||||
DBHelper::update(&(itr->info), db);
|
DBHelper::update(&(itr->info), db);
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
db.commit();
|
db.commit();
|
||||||
connectionName = db.connectionName();
|
connectionName = db.connectionName();
|
||||||
@ -610,8 +652,9 @@ void PropertiesDialog::setSize(float sizeFloat)
|
|||||||
void PropertiesDialog::save()
|
void PropertiesDialog::save()
|
||||||
{
|
{
|
||||||
QList<ComicDB>::iterator itr;
|
QList<ComicDB>::iterator itr;
|
||||||
for (itr = comics.begin(); itr != comics.end(); itr++) {
|
QList<ComicDB>::iterator begin = sequentialEditing ? comics.begin() + currentComicIndex : comics.begin();
|
||||||
// Comic & comic = comics[0];
|
QList<ComicDB>::iterator end = sequentialEditing ? comics.begin() + currentComicIndex + 1 : comics.end();
|
||||||
|
for (itr = begin; itr != end; itr++) {
|
||||||
bool edited = false;
|
bool edited = false;
|
||||||
|
|
||||||
if (title->isModified()) {
|
if (title->isModified()) {
|
||||||
@ -620,15 +663,15 @@ void PropertiesDialog::save()
|
|||||||
edited = true;
|
edited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comics.size() == 1)
|
if (sequentialEditing)
|
||||||
if (coverChanged) {
|
if (coverChanged) {
|
||||||
itr->info.coverPage = coverPageNumberLabel->text();
|
itr->info.coverPage = coverPageNumberLabel->text().toInt();
|
||||||
edited = true;
|
edited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(comic.info.numPages != NULL)
|
/*if(comic.info.numPages != NULL)
|
||||||
numPagesEdit->setText(QString::number(*comic.info.numPages));*/
|
numPagesEdit->setText(QString::number(*comic.info.numPages));*/
|
||||||
if (comics.size() == 1)
|
if (sequentialEditing)
|
||||||
if (numberEdit->isModified()) {
|
if (numberEdit->isModified()) {
|
||||||
if (numberEdit->text().isEmpty())
|
if (numberEdit->text().isEmpty())
|
||||||
itr->info.number = QVariant();
|
itr->info.number = QVariant();
|
||||||
@ -636,7 +679,7 @@ void PropertiesDialog::save()
|
|||||||
itr->info.number = numberEdit->text();
|
itr->info.number = numberEdit->text();
|
||||||
edited = true;
|
edited = true;
|
||||||
}
|
}
|
||||||
if (comics.size() == 1)
|
if (sequentialEditing)
|
||||||
if (!itr->info.isBis.isNull() || isBisCheck->isChecked()) {
|
if (!itr->info.isBis.isNull() || isBisCheck->isChecked()) {
|
||||||
itr->info.isBis = isBisCheck->isChecked();
|
itr->info.isBis = isBisCheck->isChecked();
|
||||||
edited = true;
|
edited = true;
|
||||||
@ -655,7 +698,7 @@ void PropertiesDialog::save()
|
|||||||
itr->info.storyArc = storyArcEdit->text();
|
itr->info.storyArc = storyArcEdit->text();
|
||||||
edited = true;
|
edited = true;
|
||||||
}
|
}
|
||||||
if (comics.size() == 1)
|
if (sequentialEditing)
|
||||||
if (arcNumberEdit->isModified() && !arcNumberEdit->text().isEmpty()) {
|
if (arcNumberEdit->isModified() && !arcNumberEdit->text().isEmpty()) {
|
||||||
itr->info.arcNumber = arcNumberEdit->text();
|
itr->info.arcNumber = arcNumberEdit->text();
|
||||||
edited = true;
|
edited = true;
|
||||||
@ -738,23 +781,61 @@ void PropertiesDialog::save()
|
|||||||
itr->info.edited = edited;
|
itr->info.edited = edited;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comics.count() == 1) {
|
if (sequentialEditing) {
|
||||||
if (coverChanged) // && coverPageEdit->text().toInt() != *comics[0].info.coverPage)
|
if (coverChanged) {
|
||||||
{
|
InitialComicInfoExtractor ie(basePath + comics[currentComicIndex].path, basePath + "/.yacreaderlibrary/covers/" + comics[currentComicIndex].info.hash + ".jpg", comics[currentComicIndex].info.coverPage.toInt());
|
||||||
InitialComicInfoExtractor ie(basePath + comics[0].path, basePath + "/.yacreaderlibrary/covers/" + comics[0].info.hash + ".jpg", comics[0].info.coverPage.toInt());
|
|
||||||
ie.extract();
|
ie.extract();
|
||||||
|
|
||||||
if (ie.getOriginalCoverSize().second > 0) {
|
if (ie.getOriginalCoverSize().second > 0) {
|
||||||
comics[0].info.originalCoverSize = QString("%1x%2").arg(ie.getOriginalCoverSize().first).arg(ie.getOriginalCoverSize().second);
|
comics[currentComicIndex].info.originalCoverSize = QString("%1x%2").arg(ie.getOriginalCoverSize().first).arg(ie.getOriginalCoverSize().second);
|
||||||
comics[0].info.coverSizeRatio = static_cast<float>(ie.getOriginalCoverSize().first) / ie.getOriginalCoverSize().second;
|
comics[currentComicIndex].info.coverSizeRatio = static_cast<float>(ie.getOriginalCoverSize().first) / ie.getOriginalCoverSize().second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesDialog::saveAndOpenPrevious()
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
|
||||||
|
updateComics();
|
||||||
|
|
||||||
|
coverChanged = false;
|
||||||
|
|
||||||
|
currentComicIndex--;
|
||||||
|
|
||||||
|
loadComic(comics[currentComicIndex]);
|
||||||
|
|
||||||
|
updateButtons();
|
||||||
|
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesDialog::saveAndOpenNext()
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
|
||||||
|
updateComics();
|
||||||
|
|
||||||
|
coverChanged = false;
|
||||||
|
|
||||||
|
currentComicIndex++;
|
||||||
|
|
||||||
|
loadComic(comics[currentComicIndex]);
|
||||||
|
|
||||||
|
updateButtons();
|
||||||
|
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesDialog::saveAndClose()
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
|
||||||
updateComics();
|
updateComics();
|
||||||
|
|
||||||
close();
|
close();
|
||||||
emit(accepted());
|
emit accepted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesDialog::setDisableUniqueValues(bool disabled)
|
void PropertiesDialog::setDisableUniqueValues(bool disabled)
|
||||||
@ -822,7 +903,7 @@ void PropertiesDialog::paintEvent(QPaintEvent *event)
|
|||||||
// QPixmap shadow(":/images/social_dialog/shadow.png");
|
// QPixmap shadow(":/images/social_dialog/shadow.png");
|
||||||
// p.drawPixmap(280-shadow.width(),0,shadow.width(),444,shadow);
|
// p.drawPixmap(280-shadow.width(),0,shadow.width(),444,shadow);
|
||||||
p.drawLine(279, 0, 279, 444);
|
p.drawLine(279, 0, 279, 444);
|
||||||
if (comics.length() == 1)
|
if (sequentialEditing)
|
||||||
p.fillRect(0, 444 - 28, 280, 28, QColor(0, 0, 0, 153));
|
p.fillRect(0, 444 - 28, 280, 28, QColor(0, 0, 0, 153));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,21 +916,21 @@ void PropertiesDialog::updateCoverPageNumberLabel(int n)
|
|||||||
void PropertiesDialog::loadNextCover()
|
void PropertiesDialog::loadNextCover()
|
||||||
{
|
{
|
||||||
int current = coverPageNumberLabel->text().toInt();
|
int current = coverPageNumberLabel->text().toInt();
|
||||||
if (current < comics.at(0).info.numPages.toInt()) {
|
if (current < comics[currentComicIndex].info.numPages.toInt()) {
|
||||||
updateCoverPageNumberLabel(current + 1);
|
updateCoverPageNumberLabel(current + 1);
|
||||||
|
|
||||||
InitialComicInfoExtractor ie(basePath + comics[0].path, "", current + 1);
|
InitialComicInfoExtractor ie(basePath + comics[currentComicIndex].path, "", current + 1);
|
||||||
ie.extract();
|
ie.extract();
|
||||||
setCover(ie.getCover());
|
setCover(ie.getCover());
|
||||||
repaint();
|
repaint();
|
||||||
|
|
||||||
if ((current + 1) == comics.at(0).info.numPages.toInt()) {
|
if ((current + 1) == comics[currentComicIndex].info.numPages.toInt()) {
|
||||||
showNextCoverPageButton->setDisabled(true);
|
showNextCoverPageButton->setDisabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
showPreviousCoverPageButton->setEnabled(true);
|
showPreviousCoverPageButton->setEnabled(true);
|
||||||
// busyIndicator->show();
|
// busyIndicator->show();
|
||||||
if (current + 1 != comics.at(0).info.coverPage)
|
if (current + 1 != comics[currentComicIndex].info.coverPage)
|
||||||
coverChanged = true;
|
coverChanged = true;
|
||||||
else
|
else
|
||||||
coverChanged = false;
|
coverChanged = false;
|
||||||
@ -861,7 +942,7 @@ void PropertiesDialog::loadPreviousCover()
|
|||||||
int current = coverPageNumberLabel->text().toInt();
|
int current = coverPageNumberLabel->text().toInt();
|
||||||
if (current != 1) {
|
if (current != 1) {
|
||||||
updateCoverPageNumberLabel(current - 1);
|
updateCoverPageNumberLabel(current - 1);
|
||||||
InitialComicInfoExtractor ie(basePath + comics[0].path, "", current - 1);
|
InitialComicInfoExtractor ie(basePath + comics[currentComicIndex].path, "", current - 1);
|
||||||
ie.extract();
|
ie.extract();
|
||||||
setCover(ie.getCover());
|
setCover(ie.getCover());
|
||||||
repaint();
|
repaint();
|
||||||
@ -872,9 +953,18 @@ void PropertiesDialog::loadPreviousCover()
|
|||||||
|
|
||||||
showNextCoverPageButton->setEnabled(true);
|
showNextCoverPageButton->setEnabled(true);
|
||||||
// busyIndicator->show();
|
// busyIndicator->show();
|
||||||
if (current - 1 != comics.at(0).info.coverPage.toInt())
|
if (current - 1 != comics[currentComicIndex].info.coverPage.toInt())
|
||||||
coverChanged = true;
|
coverChanged = true;
|
||||||
else
|
else
|
||||||
coverChanged = false;
|
coverChanged = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PropertiesDialog::close()
|
||||||
|
{
|
||||||
|
if (updated) {
|
||||||
|
emit accepted();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QDialog::close();
|
||||||
|
}
|
||||||
|
@ -91,6 +91,8 @@ private:
|
|||||||
QDialogButtonBox *buttonBox;
|
QDialogButtonBox *buttonBox;
|
||||||
QPushButton *closeButton;
|
QPushButton *closeButton;
|
||||||
QPushButton *saveButton;
|
QPushButton *saveButton;
|
||||||
|
QPushButton *nextButton;
|
||||||
|
QPushButton *previousButton;
|
||||||
QPushButton *restoreButton; //??
|
QPushButton *restoreButton; //??
|
||||||
|
|
||||||
QPixmap coverImage;
|
QPixmap coverImage;
|
||||||
@ -111,11 +113,16 @@ private:
|
|||||||
void setDisableUniqueValues(bool disabled);
|
void setDisableUniqueValues(bool disabled);
|
||||||
|
|
||||||
QList<ComicDB> comics;
|
QList<ComicDB> comics;
|
||||||
|
int currentComicIndex;
|
||||||
void closeEvent(QCloseEvent *e) override;
|
void closeEvent(QCloseEvent *e) override;
|
||||||
void updateCoverPageNumberLabel(int n);
|
void updateCoverPageNumberLabel(int n);
|
||||||
|
void loadComic(ComicDB &comic);
|
||||||
|
void updateButtons();
|
||||||
|
|
||||||
|
bool sequentialEditing;
|
||||||
bool coverChanged;
|
bool coverChanged;
|
||||||
float coverSizeRatio;
|
float coverSizeRatio;
|
||||||
|
bool updated;
|
||||||
QString originalCoverSize;
|
QString originalCoverSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -130,8 +137,12 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setComics(QList<ComicDB> comics);
|
void setComics(QList<ComicDB> comics);
|
||||||
|
void setComicsForSequentialEditing(int currentComicIndex, QList<ComicDB> comics);
|
||||||
void updateComics();
|
void updateComics();
|
||||||
void save();
|
void save();
|
||||||
|
void saveAndOpenPrevious();
|
||||||
|
void saveAndOpenNext();
|
||||||
|
void saveAndClose();
|
||||||
// Deprecated
|
// Deprecated
|
||||||
void setCover(const QPixmap &cover);
|
void setCover(const QPixmap &cover);
|
||||||
void setMultipleCover();
|
void setMultipleCover();
|
||||||
@ -140,5 +151,6 @@ public slots:
|
|||||||
void setSize(float size);
|
void setSize(float size);
|
||||||
void loadNextCover();
|
void loadNextCover();
|
||||||
void loadPreviousCover();
|
void loadPreviousCover();
|
||||||
|
bool close();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user