Add button for reseting the cover of a comic to the default one

This commit is contained in:
Luis Ángel San Martín 2025-05-09 15:23:00 +02:00
parent 97685dca73
commit 0457c08fca
4 changed files with 29 additions and 17 deletions

View File

@ -70,6 +70,7 @@
<file>../images/previousCoverPage.png</file> <file>../images/previousCoverPage.png</file>
<file>../images/readingRibbon.png</file> <file>../images/readingRibbon.png</file>
<file>../images/readRibbon.png</file> <file>../images/readRibbon.png</file>
<file>../images/resetCover.svg</file>
<file>../images/searching_icon.png</file> <file>../images/searching_icon.png</file>
<file>../images/serverConfigBackground.png</file> <file>../images/serverConfigBackground.png</file>
<file>../images/shortcuts_group_comics.svg</file> <file>../images/shortcuts_group_comics.svg</file>

View File

@ -107,6 +107,10 @@ void PropertiesDialog::createCoverBox()
showNextCoverPageButton->setIcon(QIcon(":/images/nextCoverPage.png")); showNextCoverPageButton->setIcon(QIcon(":/images/nextCoverPage.png"));
showNextCoverPageButton->setStyleSheet("QToolButton {border:none;}"); showNextCoverPageButton->setStyleSheet("QToolButton {border:none;}");
resetCoverButton = new QToolButton();
resetCoverButton->setIcon(QIcon(":/images/resetCover.svg"));
resetCoverButton->setStyleSheet("QToolButton {border:none;}");
coverPageNumberLabel = new QLabel("-"); coverPageNumberLabel = new QLabel("-");
coverPageNumberLabel->setStyleSheet("QLabel {color: white; font-weight:bold; font-size:14px;}"); coverPageNumberLabel->setStyleSheet("QLabel {color: white; font-weight:bold; font-size:14px;}");
@ -116,6 +120,8 @@ void PropertiesDialog::createCoverBox()
layout->addWidget(coverPageNumberLabel, 0, Qt::AlignVCenter); layout->addWidget(coverPageNumberLabel, 0, Qt::AlignVCenter);
layout->addSpacing(5); layout->addSpacing(5);
layout->addWidget(showNextCoverPageButton, 0, Qt::AlignVCenter); layout->addWidget(showNextCoverPageButton, 0, Qt::AlignVCenter);
layout->addSpacing(5);
layout->addWidget(resetCoverButton, 0, Qt::AlignVCenter);
coverPageEdit->setStyleSheet("QLineEdit {border:none;}"); coverPageEdit->setStyleSheet("QLineEdit {border:none;}");
layout->setSpacing(0); layout->setSpacing(0);
@ -132,6 +138,7 @@ void PropertiesDialog::createCoverBox()
connect(showPreviousCoverPageButton, &QAbstractButton::clicked, this, &PropertiesDialog::loadPreviousCover); connect(showPreviousCoverPageButton, &QAbstractButton::clicked, this, &PropertiesDialog::loadPreviousCover);
connect(showNextCoverPageButton, &QAbstractButton::clicked, this, &PropertiesDialog::loadNextCover); connect(showNextCoverPageButton, &QAbstractButton::clicked, this, &PropertiesDialog::loadNextCover);
connect(resetCoverButton, &QAbstractButton::clicked, this, &PropertiesDialog::resetCover);
} }
void PropertiesDialog::createGeneralInfoBox() void PropertiesDialog::createGeneralInfoBox()
@ -1095,17 +1102,9 @@ void PropertiesDialog::loadNextCover()
else else
next = current + 1; next = current + 1;
updateCoverPageNumberLabel(next); setCoverPage(next);
InitialComicInfoExtractor ie(basePath + comics[currentComicIndex].path, "", next); coverChanged = next != comics[currentComicIndex].info.coverPage;
ie.extract();
setCover(ie.getCover());
repaint();
if (next != comics[currentComicIndex].info.coverPage)
coverChanged = true;
else
coverChanged = false;
} }
void PropertiesDialog::loadPreviousCover() void PropertiesDialog::loadPreviousCover()
@ -1118,16 +1117,24 @@ void PropertiesDialog::loadPreviousCover()
else else
previous = current - 1; previous = current - 1;
updateCoverPageNumberLabel(previous); setCoverPage(previous);
InitialComicInfoExtractor ie(basePath + comics[currentComicIndex].path, "", previous);
coverChanged = previous != comics[currentComicIndex].info.coverPage.toInt();
}
void PropertiesDialog::resetCover()
{
setCoverPage(1);
coverChanged = 1 != comics[currentComicIndex].info.coverPage.toInt();
}
void PropertiesDialog::setCoverPage(int pageNumber)
{
updateCoverPageNumberLabel(pageNumber);
InitialComicInfoExtractor ie(basePath + comics[currentComicIndex].path, "", pageNumber);
ie.extract(); ie.extract();
setCover(ie.getCover()); setCover(ie.getCover());
repaint(); repaint();
if (previous != comics[currentComicIndex].info.coverPage.toInt())
coverChanged = true;
else
coverChanged = false;
} }
bool PropertiesDialog::close() bool PropertiesDialog::close()

View File

@ -117,6 +117,8 @@ private:
QToolButton *showNextCoverPageButton; QToolButton *showNextCoverPageButton;
QLabel *coverPageNumberLabel; QLabel *coverPageNumberLabel;
QToolButton *resetCoverButton;
void createTabBar(); void createTabBar();
void createCoverBox(); void createCoverBox();
void createGeneralInfoBox(); void createGeneralInfoBox();
@ -168,6 +170,8 @@ public slots:
void setSize(float size); void setSize(float size);
void loadNextCover(); void loadNextCover();
void loadPreviousCover(); void loadPreviousCover();
void resetCover();
void setCoverPage(int pageNumber);
bool close(); bool close();
signals: signals:

BIN
images/resetCover.svg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 B