mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
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:
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ private:
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *) override;
|
||||
void applyTheme() override;
|
||||
void applyTheme(const Theme &theme) override;
|
||||
|
||||
public:
|
||||
PageLabelWidget(QWidget *parent);
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user