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));

View File

@ -9,6 +9,7 @@
#include "comic_db.h"
#include "yacreader_comic_info_helper.h"
#include "yacreader_comics_selection_helper.h"
#include "theme.h"
#include "QsLog.h"
@ -33,48 +34,9 @@ InfoComicsView::InfoComicsView(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("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("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");
}
theme.configureInfoView(ctxt);
view->setSource(QUrl("qrc:/qml/InfoComicsView.qml"));

View File

@ -69,7 +69,7 @@ Rectangle {
samples: 17
color: "#FF000000"
source: realCell
visible: (Qt.platform.os === "osx") ? false : true;
visible: useDropShadows;
}
Rectangle {
@ -130,7 +130,7 @@ Rectangle {
rightMargin : commonBorder ? -commonBorderWidth : -rBorderwidth
}
border.color: (Qt.platform.os === "osx") ? selectedBorderColor : "#ffcc00"
border.color: selectedBorderColor
border.width: 3
opacity: (dummyValue || !dummyValue) && (comicsSelectionHelper.isSelectedIndex(index) || mouseArea.containsMouse) ? 1 : 0
@ -469,7 +469,7 @@ Rectangle {
height: showCurrentComic ? 270 : 20
Rectangle {
color: (Qt.platform.os === "osx") ? "#88FFFFFF" : "#88000000"
color: currentComicBackgroundColor
id: currentComicVisualView
@ -505,7 +505,7 @@ Rectangle {
samples: 17
color: "#FF000000"
source: currentCoverElement
visible: (Qt.platform.os === "osx") ? false : true;
visible: useDropShadows
}
ColumnLayout
@ -673,7 +673,7 @@ Rectangle {
samples: 17
color: "#AA000000"
source: readButton
visible: ((Qt.platform.os === "osx") ? false : true) && !readButton.pressed
visible: useDropShadows && !readButton.pressed
}
}
}

View File

@ -2,6 +2,8 @@
#define THEME_H
#include <QtCore>
#include <QtWidgets>
#include <QtQml>
class Theme
{
@ -12,7 +14,7 @@ public:
Theme t;
#ifdef Q_OS_MAC
bool macosNative = true;
bool macosNative = false;
#else
bool macosNative = false;
#endif
@ -21,18 +23,24 @@ public:
t.isMacosNative = true;
t.useNativeFullScreen = true;
//
t.disableClassicViewCollapsing = true;
//
t.comicsViewTransitionBackground = "#FFFFFF";
//
t.itemLibrarySelectedStyleSheet = "color: white; background-color:#91c4f4; border-bottom:1px solid #91c4f4;";
t.itemLibraryNoSelectedStyleSheet = "background-color:transparent;";
//
t.useNativeFolderIcons = true;
//
t.noComicsContentBackgroundColor = "#FFFFFF";
t.noComicsContentTitleLabelStyle = "QLabel {color:#888888; font-size:24px;font-family:Arial;font-weight:bold;}";
//
t.emptyFolderWidgetImage = ":/images/empty_folder.png";
t.emptyFolderWidgetStyle = "QListView {background-color:transparent; border: none; color:#959595; outline:0; font-size: 18px; show-decoration-selected: 0; margin:0}"
"QListView::item:selected {background-color: #EFEFEF; color:#CCCCCC;}"
@ -49,14 +57,49 @@ public:
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }"
"QScrollBar:horizontal{height:0px;}";
//
t.sidebarBackgroundColor = "#F1F1F1";
t.sidebarSplitterStyle = "QSplitter::handle:vertical { height: 29px; background-color: transparent;}";
//
t.titledToolBarSeparatorColor = "#AFAFAF";
t.titledToolBarTitleColor = "#808080";
t.titledToolBarTitleShadowColor = "#00000000";
//
t.foldersViewCompletedColor = "#AABFFF";
//
t.gridComicsViewBackgroundColor = "#F6F6F6";
t.gridComicsViewCellColor = "#FFFFFF";
t.gridComicsViewCellColorWhenBackgroundImageIsUsed = "#99FFFFFF";
t.gridComicsViewSelectedColor = "#FFFFFF";
t.gridComicsViewSelectedBorderColor = "#007AFF";
t.gridComicsViewBorderColor = "#DBDBDB";
t.gridComicsViewTitleColor = "#121212";
t.gridComicsViewTextColor = "#636363";
t.gridComicsViewFontSize = 11;
t.gridComicsViewFontSpacing = 0.5;
t.useDropShadows = false;
t.gridComicsViewCurrentComicBackground = "#88FFFFFF";
//
t.infoViewInfoBackgroundColor = "#FFFFFF";
t.infoViewTopShadow = QUrl();
t.infoViewInfoShadow = "info-shadow-light.png";
t.infoViewInfoIndicator = "info-indicator-light.png";
t.infoViewInfoTextColor = "#404040";
t.infoViewInfoTitleColor = "#2E2E2E";
t.infoViewRatingUnselectedColor = "#DEDEDE";
t.infoViewRatingSelectedColor = "#2B2B2B";
t.infoViewFavUncheckedColor = "#DEDEDE";
t.infoViewFavCheckedColor = "#E84852";
t.infoViewReadTickUncheckedColor = "#DEDEDE";
t.infoViewReadTickCheckedColor = "#E84852";
} else {
t.isMacosNative = false;
#ifdef Q_OS_MAC
@ -67,16 +110,21 @@ public:
t.disableClassicViewCollapsing = false;
//
t.comicsViewTransitionBackground = "#2A2A2A";
//
t.itemLibrarySelectedStyleSheet = "color: white; background-color:#2E2E2E; font-weight:bold;";
t.itemLibraryNoSelectedStyleSheet = "background-color:transparent; color:#DDDFDF;";
//
t.useNativeFolderIcons = false;
//
t.noComicsContentBackgroundColor = "#2A2A2A";
t.noComicsContentTitleLabelStyle = "QLabel {color:#CCCCCC; font-size:24px;font-family:Arial;font-weight:bold;}";
//
t.emptyFolderWidgetImage = ":/images/empty_folder.png";
t.emptyFolderWidgetStyle = "QListView {background-color:transparent; border: none; color:#858585; outline:0; font-size: 18px; font:bold; show-decoration-selected: 0; margin:0}"
"QListView::item:selected {background-color: #212121; color:#CCCCCC;}"
@ -93,22 +141,102 @@ public:
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }"
"QScrollBar:horizontal{height:0px;}";
//
t.sidebarBackgroundColor = "#454545";
t.sidebarSplitterStyle = "QSplitter::handle:vertical { height: 39px; background-color: transparent;}";/*"QSplitter::handle { "
" image: none; background-color = black; "
" }"
"QSplitter::handle:vertical { height: 39px;}"*/
//
t.titledToolBarSeparatorColor = "#6F6F6F";
t.titledToolBarTitleColor = "#BDBFBF";
t.titledToolBarTitleShadowColor = "#000000";
//
t.foldersViewCompletedColor = "#EDC542";
//
t.gridComicsViewBackgroundColor = "#2A2A2A";
t.gridComicsViewCellColor = "#212121";
t.gridComicsViewCellColorWhenBackgroundImageIsUsed = "#99212121";
t.gridComicsViewSelectedColor = "#121212";
t.gridComicsViewSelectedBorderColor = "#ffcc00";
t.gridComicsViewBorderColor = "#121212";
t.gridComicsViewTitleColor = "#FFFFFF";
t.gridComicsViewTextColor = "#A8A8A8";
t.gridComicsViewFontSize = 0;
t.gridComicsViewFontSpacing = 0.5;
t.useDropShadows = true;
t.gridComicsViewCurrentComicBackground = "#88000000";
//
t.infoViewInfoBackgroundColor = "#2E2E2E";
t.infoViewTopShadow = "info-top-shadow.png";
t.infoViewInfoShadow = "info-shadow.png";
t.infoViewInfoIndicator = "info-indicator.png";
t.infoViewInfoTextColor = "#B0B0B0";
t.infoViewInfoTitleColor = "#FFFFFF";
t.infoViewRatingUnselectedColor = "#1C1C1C";
t.infoViewRatingSelectedColor = "#FFFFFF";
t.infoViewFavUncheckedColor = "#1C1C1C";
t.infoViewFavCheckedColor = "#E84852";
t.infoViewReadTickUncheckedColor = "#1C1C1C";
t.infoViewReadTickCheckedColor = "#E84852";
}
return t;
}
void configureComicsGridView(QQmlContext *ctxt) {
ctxt->setContextProperty("backgroundColor", gridComicsViewBackgroundColor );
ctxt->setContextProperty("cellColor", gridComicsViewCellColor);
ctxt->setContextProperty("selectedColor", gridComicsViewSelectedColor);
ctxt->setContextProperty("selectedBorderColor", gridComicsViewSelectedBorderColor);
ctxt->setContextProperty("borderColor", gridComicsViewBorderColor);
ctxt->setContextProperty("titleColor", gridComicsViewTitleColor);
ctxt->setContextProperty("textColor", gridComicsViewTextColor);
ctxt->setContextProperty("useDropShadows",useDropShadows);
//fonts settings
if (gridComicsViewFontSize < 1) {
int fontSize = QApplication::font().pointSize();
if(fontSize == -1)
fontSize = QApplication::font().pixelSize();
ctxt->setContextProperty("fontSize", fontSize);
} else {
ctxt->setContextProperty("fontSize", gridComicsViewFontSize);
}
ctxt->setContextProperty("fontFamily", QApplication::font().family());
ctxt->setContextProperty("fontSpacing", 0.5);
ctxt->setContextProperty("currentComicBackgroundColor", gridComicsViewCurrentComicBackground);
}
void configureInfoView(QQmlContext *ctxt) {
ctxt->setContextProperty("infoBackgroundColor", infoViewInfoBackgroundColor);
ctxt->setContextProperty("topShadow", infoViewTopShadow);
ctxt->setContextProperty("infoShadow", infoViewInfoShadow);
ctxt->setContextProperty("infoIndicator", infoViewInfoIndicator);
ctxt->setContextProperty("infoTextColor", infoViewInfoTextColor);
ctxt->setContextProperty("infoTitleColor", infoViewInfoTitleColor);
ctxt->setContextProperty("ratingUnselectedColor", infoViewRatingUnselectedColor);
ctxt->setContextProperty("ratingSelectedColor", infoViewRatingSelectedColor);
ctxt->setContextProperty("favUncheckedColor", infoViewFavUncheckedColor);
ctxt->setContextProperty("favCheckedColor", infoViewFavCheckedColor);
ctxt->setContextProperty("readTickUncheckedColor", infoViewReadTickUncheckedColor);
ctxt->setContextProperty("readTickCheckedColor", infoViewReadTickCheckedColor);
}
bool isMacosNative;
bool useNativeFullScreen;
@ -144,6 +272,38 @@ public:
//YACReaderFoldersView (tree view)
QString foldersViewCompletedColor;
//GridComicsView
QString gridComicsViewBackgroundColor;
QString gridComicsViewCellColor;
QString gridComicsViewCellColorWhenBackgroundImageIsUsed;
QString gridComicsViewSelectedColor;
QString gridComicsViewSelectedBorderColor;
QString gridComicsViewBorderColor;
QString gridComicsViewTitleColor;
QString gridComicsViewTextColor;
float gridComicsViewFontSize;
float gridComicsViewFontSpacing;
bool useDropShadows;
QString gridComicsViewCurrentComicBackground;
//InfoView
QString infoViewInfoBackgroundColor;
QVariant infoViewTopShadow;
QString infoViewInfoShadow;
QString infoViewInfoIndicator;
QString infoViewInfoTextColor;
QString infoViewInfoTitleColor;
QString infoViewRatingUnselectedColor;
QString infoViewRatingSelectedColor;
QString infoViewFavUncheckedColor;
QString infoViewFavCheckedColor;
QString infoViewReadTickUncheckedColor;
QString infoViewReadTickCheckedColor;
};
#endif // THEME_H