mirror of
https://github.com/YACReader/yacreader
synced 2026-03-02 10:50:04 -05:00
Initial implementation of theming
This commit is contained in:
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
17
common/themes/shared/whats_new_dialog_theme.h
Normal file
17
common/themes/shared/whats_new_dialog_theme.h
Normal 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
|
||||
@ -6,6 +6,8 @@
|
||||
#include <QGuiApplication>
|
||||
#include <QStyleHints>
|
||||
|
||||
// TODO: add API to force color scheme //styleHints->setColorScheme(Qt::ColorScheme::Dark);
|
||||
|
||||
ThemeManager::ThemeManager()
|
||||
{
|
||||
}
|
||||
|
||||
@ -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 += \
|
||||
|
||||
Reference in New Issue
Block a user