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

@ -7,6 +7,7 @@
#include "yacreader_tool_bar_stretch.h"
#include "comic.h"
#include "comic_files_manager.h"
#include "theme_manager.h"
#include "QsLog.h"
@ -17,7 +18,7 @@
using namespace YACReader;
FolderContentView::FolderContentView(QAction *toogleRecentVisibilityAction, QWidget *parent)
: QWidget { parent }, parent(QModelIndex()), comicModel(new ComicModel()), folderModel(new FolderModel())
: QWidget { parent }, parent(QModelIndex()), comicModel(new ComicModel()), folderModel(new FolderModel()), smallZoomLabel(nullptr), bigZoomLabel(nullptr)
{
qmlRegisterType<FolderModel>("com.yacreader.FolderModel", 1, 0, "FolderModel");
@ -41,14 +42,16 @@ FolderContentView::FolderContentView(QAction *toogleRecentVisibilityAction, QWid
coverSizeSlider->setOrientation(Qt::Horizontal);
coverSizeSlider->setRange(YACREADER_MIN_GRID_ZOOM_WIDTH, YACREADER_MAX_GRID_ZOOM_WIDTH);
const auto &comicsToolbar = theme.comicsViewToolbar;
auto horizontalLayout = new QHBoxLayout();
QLabel *smallLabel = new QLabel();
smallLabel->setPixmap(hdpiPixmap(":/images/comics_view_toolbar/small_size_grid_zoom.svg", QSize(18, 18)));
horizontalLayout->addWidget(smallLabel);
smallZoomLabel = new QLabel();
smallZoomLabel->setPixmap(comicsToolbar.smallGridZoomIcon.pixmap(18, 18));
horizontalLayout->addWidget(smallZoomLabel);
horizontalLayout->addWidget(coverSizeSlider, 0, Qt::AlignVCenter);
QLabel *bigLabel = new QLabel();
bigLabel->setPixmap(hdpiPixmap(":/images/comics_view_toolbar/big_size_grid_zoom.svg", QSize(18, 18)));
horizontalLayout->addWidget(bigLabel);
bigZoomLabel = new QLabel();
bigZoomLabel->setPixmap(comicsToolbar.bigGridZoomIcon.pixmap(18, 18));
horizontalLayout->addWidget(bigZoomLabel);
horizontalLayout->addSpacing(10);
horizontalLayout->setContentsMargins(0, 0, 0, 0);
@ -57,10 +60,6 @@ FolderContentView::FolderContentView(QAction *toogleRecentVisibilityAction, QWid
connect(coverSizeSlider, &QAbstractSlider::valueChanged, this, &FolderContentView::setCoversSize);
toolbar = new QToolBar();
toolbar->setStyleSheet(R"(
QToolBar { border: none; }
QToolButton:checked { background-color: #cccccc; }
)");
toolbar->setIconSize(QSize(18, 18));
toolbar->addWidget(new YACReaderToolBarStretch);
toolbar->addAction(toogleRecentVisibilityAction);
@ -77,84 +76,16 @@ FolderContentView::FolderContentView(QAction *toogleRecentVisibilityAction, QWid
QQmlContext *ctxt = view->rootContext();
LibraryUITheme theme;
#ifdef Y_MAC_UI
theme = Light;
#else
theme = Dark;
#endif
// fonts settings (not theme-dependent)
int fontSize = QApplication::font().pointSize();
if (fontSize == -1)
fontSize = QApplication::font().pixelSize();
ctxt->setContextProperty("fontSize", fontSize);
ctxt->setContextProperty("fontFamily", QApplication::font().family());
ctxt->setContextProperty("fontSpacing", 0.5);
if (theme == Light) {
ctxt->setContextProperty("continueReadingBackgroundColor", "#E8E8E8");
ctxt->setContextProperty("continueReadingColor", "#000000");
ctxt->setContextProperty("backgroundColor", "#F6F6F6");
ctxt->setContextProperty("cellColor", "#FFFFFF");
ctxt->setContextProperty("selectedColor", "#FFFFFF");
ctxt->setContextProperty("selectedBorderColor", "#007AFF");
ctxt->setContextProperty("borderColor", "#DBDBDB");
ctxt->setContextProperty("titleColor", "#121212");
ctxt->setContextProperty("textColor", "#636363");
// fonts settings
ctxt->setContextProperty("fontSize", 11);
ctxt->setContextProperty("fontFamily", QApplication::font().family());
ctxt->setContextProperty("fontSpacing", 0.5);
// info - copy/pasted from info_comics_view TODO create helpers for setting the UI config
ctxt->setContextProperty("infoBackgroundColor", "#FFFFFF");
ctxt->setContextProperty("topShadow", QUrl());
ctxt->setContextProperty("infoShadow", "info-shadow-light.png");
ctxt->setContextProperty("infoIndicator", "info-indicator-light.png");
ctxt->setContextProperty("infoTextColor", "#404040");
ctxt->setContextProperty("infoTitleColor", "#2E2E2E");
ctxt->setContextProperty("ratingUnselectedColor", "#DEDEDE");
ctxt->setContextProperty("ratingSelectedColor", "#2B2B2B");
ctxt->setContextProperty("favUncheckedColor", "#DEDEDE");
ctxt->setContextProperty("favCheckedColor", "#E84852");
ctxt->setContextProperty("readTickUncheckedColor", "#DEDEDE");
ctxt->setContextProperty("readTickCheckedColor", "#E84852");
} else {
ctxt->setContextProperty("continueReadingBackgroundColor", "#88000000");
ctxt->setContextProperty("continueReadingColor", "#FFFFFF");
ctxt->setContextProperty("backgroundColor", "#2A2A2A");
ctxt->setContextProperty("cellColor", "#212121");
ctxt->setContextProperty("selectedColor", "#121212");
ctxt->setContextProperty("selectedBorderColor", "#121212");
ctxt->setContextProperty("borderColor", "#121212");
ctxt->setContextProperty("titleColor", "#FFFFFF");
ctxt->setContextProperty("textColor", "#A8A8A8");
ctxt->setContextProperty("dropShadow", QVariant(false));
// fonts settings
int fontSize = QApplication::font().pointSize();
if (fontSize == -1)
fontSize = QApplication::font().pixelSize();
ctxt->setContextProperty("fontSize", fontSize);
ctxt->setContextProperty("fontFamily", QApplication::font().family());
ctxt->setContextProperty("fontSpacing", 0.5);
// info - copy/pasted from info_comics_view TODO create helpers for setting the UI config
ctxt->setContextProperty("infoBackgroundColor", "#2E2E2E");
ctxt->setContextProperty("topShadow", "info-top-shadow.png");
ctxt->setContextProperty("infoShadow", "info-shadow.png");
ctxt->setContextProperty("infoIndicator", "info-indicator.png");
ctxt->setContextProperty("infoTextColor", "#B0B0B0");
ctxt->setContextProperty("infoTitleColor", "#FFFFFF");
ctxt->setContextProperty("ratingUnselectedColor", "#1C1C1C");
ctxt->setContextProperty("ratingSelectedColor", "#FFFFFF");
ctxt->setContextProperty("favUncheckedColor", "#1C1C1C");
ctxt->setContextProperty("favCheckedColor", "#E84852");
ctxt->setContextProperty("readTickUncheckedColor", "#1C1C1C");
ctxt->setContextProperty("readTickCheckedColor", "#E84852");
}
// Apply theme colors
initTheme(this);
updateCoversSizeInContext(YACREADER_MIN_COVER_WIDTH, ctxt);
@ -328,3 +259,49 @@ void FolderContentView::droppedFiles(const QList<QUrl> &urls, Qt::DropAction act
emit copyComicsToCurrentFolder(droppedFiles);
}
}
void FolderContentView::applyTheme(const Theme &theme)
{
QQmlContext *ctxt = view->rootContext();
const auto &qv = theme.qmlView;
toolbar->setStyleSheet(theme.comicsViewToolbar.toolbarQSS);
// Continue reading section colors
ctxt->setContextProperty("continueReadingBackgroundColor", qv.continueReadingBackgroundColor);
ctxt->setContextProperty("continueReadingColor", qv.continueReadingColor);
// Grid colors
ctxt->setContextProperty("backgroundColor", qv.backgroundColor);
ctxt->setContextProperty("cellColor", qv.cellColor);
ctxt->setContextProperty("selectedColor", qv.selectedColor);
ctxt->setContextProperty("selectedBorderColor", qv.selectedBorderColor);
ctxt->setContextProperty("borderColor", qv.borderColor);
ctxt->setContextProperty("titleColor", qv.titleColor);
ctxt->setContextProperty("textColor", qv.textColor);
ctxt->setContextProperty("dropShadow", QVariant(qv.showDropShadow));
// Info panel colors
ctxt->setContextProperty("infoBackgroundColor", qv.infoBackgroundColor);
ctxt->setContextProperty("topShadow", qv.topShadow.isEmpty() ? QUrl() : QUrl(qv.topShadow));
ctxt->setContextProperty("infoShadow", qv.infoShadow);
ctxt->setContextProperty("infoIndicator", qv.infoIndicator);
ctxt->setContextProperty("infoTextColor", qv.infoTextColor);
ctxt->setContextProperty("infoTitleColor", qv.infoTitleColor);
// Rating and favorite colors
ctxt->setContextProperty("ratingUnselectedColor", qv.ratingUnselectedColor);
ctxt->setContextProperty("ratingSelectedColor", qv.ratingSelectedColor);
ctxt->setContextProperty("favUncheckedColor", qv.favUncheckedColor);
ctxt->setContextProperty("favCheckedColor", qv.favCheckedColor);
ctxt->setContextProperty("readTickUncheckedColor", qv.readTickUncheckedColor);
ctxt->setContextProperty("readTickCheckedColor", qv.readTickCheckedColor);
// Update zoom slider icons
if (smallZoomLabel) {
smallZoomLabel->setPixmap(theme.comicsViewToolbar.smallGridZoomIcon.pixmap(18, 18));
}
if (bigZoomLabel) {
bigZoomLabel->setPixmap(theme.comicsViewToolbar.bigGridZoomIcon.pixmap(18, 18));
}
}