Use theme in grids comic view.

This commit is contained in:
Luis Ángel San Martín
2018-09-13 14:58:01 +02:00
committed by Luis Ángel San Martín
parent ac0aa6ded5
commit 36e76d28e8
4 changed files with 180 additions and 134 deletions

View File

@ -13,6 +13,7 @@
#include "yacreader_comics_selection_helper.h"
#include "yacreader_comic_info_helper.h"
#include "current_comic_view_helper.h"
#include "theme.h"
//values relative to visible cells
const unsigned int YACREADER_MIN_GRID_ZOOM_WIDTH = 156;
@ -59,84 +60,10 @@ GridComicsView::GridComicsView(QWidget *parent)
QQmlContext *ctxt = view->rootContext();
LibraryUITheme theme;
#ifdef Q_OS_MAC
theme = Light;
#else
theme = Dark;
#endif
auto theme = Theme::currentTheme();
if (theme == Light) {
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("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", 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");
}
#ifdef Q_OS_MAC
#else
#endif
theme.configureComicsGridView(ctxt);
theme.configureInfoView(ctxt);
ctxt->setContextProperty("backgroundImage", QUrl());
ctxt->setContextProperty("backgroundBlurOpacity", 0.0);
@ -236,7 +163,7 @@ void GridComicsView::setToolBar(QToolBar *toolBar)
void GridComicsView::setModel(ComicModel *model)
{
if (model == NULL)
if (model == nullptr)
return;
ComicsView::setModel(model);
@ -276,7 +203,7 @@ void GridComicsView::setModel(ComicModel *model)
void GridComicsView::updateBackgroundConfig()
{
if (this->model == NULL)
if (this->model == nullptr)
return;
QQmlContext *ctxt = view->rootContext();
@ -301,13 +228,10 @@ void GridComicsView::updateBackgroundConfig()
ctxt->setContextProperty("backgroundBlurVisible", false);
}
#ifdef Q_OS_MAC
ctxt->setContextProperty("cellColor", useBackgroundImage ? "#99FFFFFF" : "#FFFFFF");
ctxt->setContextProperty("selectedColor", "#FFFFFF");
#else
ctxt->setContextProperty("cellColor", useBackgroundImage ? "#99212121" : "#212121");
ctxt->setContextProperty("selectedColor", "#121212");
#endif
auto theme = Theme::currentTheme();
ctxt->setContextProperty("cellColor", useBackgroundImage ? theme.gridComicsViewCellColorWhenBackgroundImageIsUsed : theme.gridComicsViewCellColor);
ctxt->setContextProperty("selectedColor", theme.gridComicsViewSelectedColor);
}
void GridComicsView::showInfo()
@ -411,7 +335,7 @@ void GridComicsView::setCoversSize(int width)
auto grid = view->rootObject()->findChild<QQuickItem *>(QStringLiteral("grid"));
if (grid != 0) {
if (grid != nullptr) {
QVariant cellCustomWidth = (width * YACREADER_MIN_CELL_CUSTOM_WIDTH) / YACREADER_MIN_GRID_ZOOM_WIDTH;
QMetaObject::invokeMethod(grid, "calculateCellWidths",
Q_ARG(QVariant, cellCustomWidth));