Initial implementation of theming

This commit is contained in:
luisangelsm
2026-02-19 17:39:22 +01:00
parent ed28c94f66
commit 044176d6b7
303 changed files with 4634 additions and 2119 deletions

View File

@ -85,28 +85,17 @@ ImportWidget::ImportWidget(QWidget *parent)
: QWidget(parent)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QPalette p(palette());
p.setColor(QPalette::Window, QColor(250, 250, 250));
setAutoFillBackground(true);
setPalette(p);
QPixmap icon(":/images/importingIcon.png");
iconLabel = new QLabel();
iconLabel->setPixmap(icon);
/*QPixmap line(":/images/noLibrariesLine.png");
QLabel * lineLabel = new QLabel();
lineLabel->setPixmap(line);*/
auto activityIndicator = new YACReaderActivityIndicatorWidget();
text = new QLabel(); //"<font color=\"#495252\">"+tr("Importing comics")+"</font>");
text->setStyleSheet("QLabel {font-size:25px;font-weight:bold;}");
textDescription = new QLabel(); //"<font color=\"#565959\">"+tr("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")+"</font>");
text = new QLabel();
textDescription = new QLabel();
textDescription->setWordWrap(true);
textDescription->setMaximumWidth(330);
currentComicLabel = new QLabel("<font color=\"#565959\">...</font>");
currentComicLabel = new QLabel("...");
coversViewContainer = new QWidget(this);
auto coversViewLayout = new QVBoxLayout;
@ -115,11 +104,9 @@ ImportWidget::ImportWidget(QWidget *parent)
coversViewContainer->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum);
coversView = new QGraphicsView();
// coversView->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
coversView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
coversView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
coversView->setMaximumHeight(300);
coversView->setStyleSheet("QGraphicsView {background-color: #E6E6E6;border:none;}");
coversScene = new QGraphicsScene();
coversView->setAlignment(Qt::AlignLeft);
@ -130,16 +117,10 @@ ImportWidget::ImportWidget(QWidget *parent)
scrollAnimation = new QPropertyAnimation(coversView->horizontalScrollBar(), "value");
QLabel *topDecorator = new QLabel();
QLabel *bottomDecorator = new QLabel();
QPixmap top(":/images/importTopCoversDecoration.png");
QPixmap bottom(":/images/importBottomCoversDecoration.png");
topDecorator->setPixmap(top);
bottomDecorator->setPixmap(bottom);
topDecorator = new QLabel();
bottomDecorator = new QLabel();
topDecorator->setScaledContents(true);
bottomDecorator->setScaledContents(true);
topDecorator->setFixedHeight(top.height());
bottomDecorator->setFixedHeight(bottom.height());
coversViewLayout->addWidget(topDecorator, 0);
coversViewLayout->addWidget(coversView, 1);
@ -187,12 +168,13 @@ ImportWidget::ImportWidget(QWidget *parent)
layout->addLayout(buttonLayout, 0);
layout->addSpacing(10);
layout->addStretch();
coversLabel = new QLabel("<font color=\"#565959\">" + tr("Some of the comics being added...") + "</font>");
coversLabel = new QLabel(tr("Some of the comics being added..."));
hideButton = new QToolButton(this);
hideButton->setFixedSize(25, 18);
hideButton->setStyleSheet("QToolButton {background: url(\":/images/shownCovers.png\"); border:none;}"
" QToolButton:checked {background:url(\":/images/hiddenCovers.png\"); border:none;}");
hideButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"
"QToolButton:pressed { border: none; padding: 0px; }"
"QToolButton:checked { border: none; padding: 0px; }");
hideButton->setCheckable(true);
connect(hideButton, &QAbstractButton::toggled, this, &ImportWidget::showCovers);
@ -210,6 +192,8 @@ ImportWidget::ImportWidget(QWidget *parent)
updatingCovers = false;
elapsedTimer = new QElapsedTimer();
elapsedTimer->start();
initTheme(this);
}
void ImportWidget::newComic(const QString &path, const QString &coverPath)
@ -217,7 +201,7 @@ void ImportWidget::newComic(const QString &path, const QString &coverPath)
if (!this->isVisible())
return;
currentComicLabel->setText("<font color=\"#565959\">" + path + "</font>");
currentComicLabel->setText(path);
if (((elapsedTimer->elapsed() >= 1100) || ((previousWidth < coversView->width()) && (elapsedTimer->elapsed() >= 500))) && scrollAnimation->state() != QAbstractAnimation::Running) // todo elapsed time
{
@ -323,16 +307,16 @@ void ImportWidget::clear()
updatingCovers = false;
currentComicLabel->setText("<font color=\"#565959\">...</font>");
currentComicLabel->setText("...");
this->i = 0;
}
void ImportWidget::setImportLook()
{
iconLabel->setPixmap(QPixmap(":/images/importingIcon.png"));
text->setText("<font color=\"#495252\">" + tr("Importing comics") + "</font>");
textDescription->setText("<font color=\"#565959\">" + tr("<p>YACReaderLibrary is now creating a new library.</p><p>Create a library could take several minutes. You can stop the process and update the library later for completing the task.</p>") + "</font>");
iconLabel->setPixmap(theme.importWidget.importingIcon);
text->setText(tr("Importing comics"));
textDescription->setText(tr("<p>YACReaderLibrary is now creating a new library.</p><p>Create a library could take several minutes. You can stop the process and update the library later for completing the task.</p>"));
stopButton->setVisible(true);
coversLabel->setVisible(true);
@ -342,9 +326,9 @@ void ImportWidget::setImportLook()
void ImportWidget::setUpdateLook()
{
iconLabel->setPixmap(QPixmap(":/images/updatingIcon.png"));
text->setText("<font color=\"#495252\">" + tr("Updating the library") + "</font>");
textDescription->setText("<font color=\"#565959\">" + tr("<p>The current library is being updated. For faster updates, please, update your libraries frequently.</p><p>You can stop the process and continue updating this library later.</p>") + "</font>");
iconLabel->setPixmap(theme.importWidget.updatingIcon);
text->setText(tr("Updating the library"));
textDescription->setText(tr("<p>The current library is being updated. For faster updates, please, update your libraries frequently.</p><p>You can stop the process and continue updating this library later.</p>"));
stopButton->setVisible(true);
coversLabel->setVisible(true);
@ -354,9 +338,9 @@ void ImportWidget::setUpdateLook()
void ImportWidget::setUpgradeLook()
{
iconLabel->setPixmap(QPixmap(":/images/updatingIcon.png"));
text->setText("<font color=\"#495252\">" + tr("Upgrading the library") + "</font>");
textDescription->setText("<font color=\"#565959\">" + tr("<p>The current library is being upgraded, please wait.</p>") + "</font>");
iconLabel->setPixmap(theme.importWidget.updatingIcon);
text->setText(tr("Upgrading the library"));
textDescription->setText(tr("<p>The current library is being upgraded, please wait.</p>"));
stopButton->setVisible(false);
coversLabel->setVisible(false);
@ -366,9 +350,9 @@ void ImportWidget::setUpgradeLook()
void ImportWidget::setXMLScanLook()
{
iconLabel->setPixmap(QPixmap(":/images/updatingIcon.png"));
text->setText("<font color=\"#495252\">" + tr("Scanning the library") + "</font>");
textDescription->setText("<font color=\"#565959\">" + tr("<p>Current library is being scanned for legacy XML metadata information.</p><p>This is only needed once, and only if the library was crated with YACReaderLibrary 9.8.2 or earlier.</p>") + "</font>");
iconLabel->setPixmap(theme.importWidget.updatingIcon);
text->setText(tr("Scanning the library"));
textDescription->setText(tr("<p>Current library is being scanned for legacy XML metadata information.</p><p>This is only needed once, and only if the library was crated with YACReaderLibrary 9.8.2 or earlier.</p>"));
stopButton->setVisible(true);
coversLabel->setVisible(false);
@ -392,3 +376,53 @@ void ImportWidget::resizeEvent(QResizeEvent *event)
QWidget::resizeEvent(event);
}
void ImportWidget::applyTheme(const Theme &theme)
{
const auto &importTheme = theme.importWidget;
// Covers toggle button
hideButton->setIcon(importTheme.coversToggleIcon);
hideButton->setIconSize(hideButton->size());
// Background
QPalette p(palette());
p.setColor(QPalette::Window, importTheme.backgroundColor);
setPalette(p);
// Covers view background
coversView->setStyleSheet(QString("QGraphicsView {background-color: %1; border:none;}")
.arg(importTheme.coversViewBackgroundColor.name()));
// Covers decorations
topDecorator->setPixmap(importTheme.topCoversDecoration);
topDecorator->setFixedHeight(importTheme.topCoversDecoration.height());
bottomDecorator->setPixmap(importTheme.bottomCoversDecoration);
bottomDecorator->setFixedHeight(importTheme.bottomCoversDecoration.height());
// Apply text colors
updateTextColors();
}
void ImportWidget::updateTextColors()
{
const auto &importTheme = theme.importWidget;
// Title text
text->setStyleSheet(importTheme.titleLabelQSS);
// Description text
QPalette descPalette = textDescription->palette();
descPalette.setColor(QPalette::WindowText, importTheme.descriptionTextColor);
textDescription->setPalette(descPalette);
// Current comic label
QPalette comicPalette = currentComicLabel->palette();
comicPalette.setColor(QPalette::WindowText, importTheme.currentComicTextColor);
currentComicLabel->setPalette(comicPalette);
// Covers label
QPalette coversLabelPalette = coversLabel->palette();
coversLabelPalette.setColor(QPalette::WindowText, importTheme.coversLabelColor);
coversLabel->setPalette(coversLabelPalette);
}