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

@ -1,7 +1,28 @@
#include "icon_utils.h"
#include <QSvgRenderer>
#include "yacreader_global.h"
QPixmap renderSvgToPixmap(const QString &svgPath, int logicalSize, qreal devicePixelRatio)
{
return renderSvgToPixmap(svgPath, logicalSize, logicalSize, devicePixelRatio);
}
QPixmap renderSvgToPixmap(const QString &svgPath, int logicalWidth, int logicalHeight, qreal devicePixelRatio)
{
const int pixelWidth = qRound(logicalWidth * devicePixelRatio);
const int pixelHeight = qRound(logicalHeight * devicePixelRatio);
QPixmap pixmap(pixelWidth, pixelHeight);
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
QSvgRenderer renderer(svgPath);
renderer.render(&painter);
painter.end();
pixmap.setDevicePixelRatio(devicePixelRatio);
return pixmap;
}
QString readSvg(const QString &resourcePath)
{
QFile in(resourcePath);

View File

@ -3,6 +3,11 @@
#include <QtGui>
// Render an SVG file to a QPixmap at a specific logical size with HiDPI support.
// Uses QSvgRenderer to rasterize directly at the target resolution (no upscaling).
QPixmap renderSvgToPixmap(const QString &svgPath, int logicalSize, qreal devicePixelRatio);
QPixmap renderSvgToPixmap(const QString &svgPath, int logicalWidth, int logicalHeight, qreal devicePixelRatio);
struct RecolorOptions {
QString suffix;
QString fileName;

View File

@ -0,0 +1,17 @@
#ifndef WHATS_NEW_DIALOG_THEME_H
#define WHATS_NEW_DIALOG_THEME_H
#include <QColor>
#include <QPixmap>
struct WhatsNewDialogTheme {
QColor backgroundColor;
QColor headerTextColor;
QColor versionTextColor;
QColor contentTextColor;
QColor linkColor;
QPixmap closeButtonIcon;
QPixmap headerDecoration;
};
#endif // WHATS_NEW_DIALOG_THEME_H

View File

@ -6,6 +6,8 @@
#include <QGuiApplication>
#include <QStyleHints>
// TODO: add API to force color scheme //styleHints->setColorScheme(Qt::ColorScheme::Dark);
ThemeManager::ThemeManager()
{
}

View File

@ -8,6 +8,7 @@ HEADERS += \
$$PWD/themable.h \
$$PWD/yacreader_icon.h \
$$PWD/shared/help_about_dialog_theme.h \
$$PWD/shared/whats_new_dialog_theme.h \
SOURCES += \