Make Themable pass the current Theme through applyTheme

This reduces boilerplate code and remove the ThemeManager dependency at Thamable subclasses level.
This commit is contained in:
luisangelsm
2026-01-20 15:57:22 +01:00
parent b662e4975b
commit edd5bbc69c
33 changed files with 55 additions and 77 deletions

View File

@ -18,7 +18,6 @@
#include "yacreader_global.h"
#include "edit_shortcuts_dialog.h"
#include "shortcuts_manager.h"
#include "theme_manager.h"
#include "whats_new_controller.h"
@ -1556,9 +1555,9 @@ void MainWindowViewer::setLoadedComicActionsEnabled(bool enabled)
a->setEnabled(enabled);
}
void MainWindowViewer::applyTheme()
void MainWindowViewer::applyTheme(const Theme &theme)
{
const auto toolbarTheme = ThemeManager::instance().getCurrentTheme().toolbar;
const auto toolbarTheme = theme.toolbar;
if (comicToolBar) {
comicToolBar->setStyleSheet(toolbarTheme.toolbarQSS);

View File

@ -174,7 +174,7 @@ private:
void setMglassActionsEnabled(bool enabled);
void setLoadedComicActionsEnabled(bool enabled);
void applyTheme() override;
void applyTheme(const Theme &theme) override;
//! Manejadores de evento:
// void resizeEvent(QResizeEvent * event);

View File

@ -2,8 +2,6 @@
#include <QtWidgets>
#include "theme_manager.h"
PageLabelWidget::PageLabelWidget(QWidget *parent)
: QWidget(parent)
{
@ -111,9 +109,9 @@ void PageLabelWidget::updatePosition()
move(QPoint((parent->geometry().size().width() - this->width()), -this->height()));
}
void PageLabelWidget::applyTheme()
void PageLabelWidget::applyTheme(const Theme &theme)
{
const auto viewerTheme = ThemeManager::instance().getCurrentTheme().viewer;
const auto viewerTheme = theme.viewer;
infoBackgroundColor = viewerTheme.infoBackgroundColor;

View File

@ -19,7 +19,7 @@ private:
protected:
void paintEvent(QPaintEvent *) override;
void applyTheme() override;
void applyTheme(const Theme &theme) override;
public:
PageLabelWidget(QWidget *parent);

View File

@ -1019,11 +1019,11 @@ void Viewer::updateBackgroundColor(const QColor &color)
setPalette(palette);
}
void Viewer::applyTheme()
void Viewer::applyTheme(const Theme &theme)
{
const auto viewerTheme = ThemeManager::instance().getCurrentTheme().viewer;
const auto viewerTheme = theme.viewer;
updateBackgroundColor(Configuration::getConfiguration().getBackgroundColor(ThemeManager::instance().getCurrentTheme().viewer.defaultBackgroundColor));
updateBackgroundColor(Configuration::getConfiguration().getBackgroundColor(theme.viewer.defaultBackgroundColor));
const QString textColor = viewerTheme.defaultTextColor.name(QColor::HexArgb);
content->setStyleSheet(QStringLiteral("QLabel { color : %1; background: transparent; }").arg(textColor));

View File

@ -188,7 +188,7 @@ private:
std::unique_ptr<YACReader::MouseHandler> mouseHandler;
protected:
void applyTheme() override;
void applyTheme(const Theme &theme) override;
public:
Viewer(QWidget *parent = nullptr);