From 689a782d5ac0f78d9b2a5b8465d4720edc275639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Mon, 24 Apr 2017 21:53:55 +0200 Subject: [PATCH] Enabled light theme for info views in osx. --- YACReaderLibrary/grid_comics_view.cpp | 104 ++++++++++++++++++------ YACReaderLibrary/info_comics_view.cpp | 49 ++++++++++- YACReaderLibrary/qml.qrc | 4 + YACReaderLibrary/qml/ComicInfo.qml | 48 +++++------ YACReaderLibrary/qml/GridComicsView.qml | 2 +- YACReaderLibrary/qml/InfoComicsView.qml | 10 +-- YACReaderLibrary/qml/InfoFavorites.qml | 2 +- YACReaderLibrary/qml/InfoRating.qml | 2 +- YACReaderLibrary/qml/InfoTick.qml | 2 +- 9 files changed, 163 insertions(+), 60 deletions(-) diff --git a/YACReaderLibrary/grid_comics_view.cpp b/YACReaderLibrary/grid_comics_view.cpp index 250cf55a..13861a18 100644 --- a/YACReaderLibrary/grid_comics_view.cpp +++ b/YACReaderLibrary/grid_comics_view.cpp @@ -52,35 +52,87 @@ GridComicsView::GridComicsView(QWidget *parent) : QQmlContext *ctxt = view->rootContext(); + LibraryUITheme theme; + #ifdef Q_OS_MAC + theme = Light + #else + theme = Dark; + #endif + + 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 - 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); + #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); + #endif ctxt->setContextProperty("backgroundImage", QUrl()); diff --git a/YACReaderLibrary/info_comics_view.cpp b/YACReaderLibrary/info_comics_view.cpp index 5912686b..1c6166fb 100644 --- a/YACReaderLibrary/info_comics_view.cpp +++ b/YACReaderLibrary/info_comics_view.cpp @@ -23,8 +23,55 @@ InfoComicsView::InfoComicsView(QWidget *parent) container->setFocusPolicy(Qt::StrongFocus); - view->setSource(QUrl("qrc:/qml/InfoComicsView.qml")); + QQmlContext *ctxt = view->rootContext(); + LibraryUITheme theme; + #ifdef Q_OS_MAC + theme = Light + #else + theme = Dark; + #endif + + 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"); + } + + view->setSource(QUrl("qrc:/qml/InfoComicsView.qml")); QObject *rootObject = dynamic_cast(view->rootObject()); flow = rootObject->findChild("flow"); diff --git a/YACReaderLibrary/qml.qrc b/YACReaderLibrary/qml.qrc index 69bcc0fd..d3d279ea 100644 --- a/YACReaderLibrary/qml.qrc +++ b/YACReaderLibrary/qml.qrc @@ -10,6 +10,10 @@ qml/FlowView.qml qml/info-indicator.png qml/info-shadow.png + qml/info-indicator-light.png + qml/info-shadow-light.png + qml/info-indicator-light@2x.png + qml/info-shadow-light@2x.png qml/info-top-shadow.png qml/ComicInfo.qml qml/info-favorites.png diff --git a/YACReaderLibrary/qml/ComicInfo.qml b/YACReaderLibrary/qml/ComicInfo.qml index ce6f86e2..ea5b6ccb 100644 --- a/YACReaderLibrary/qml/ComicInfo.qml +++ b/YACReaderLibrary/qml/ComicInfo.qml @@ -15,7 +15,7 @@ Rectangle { height: info.height + 2 * topMargin - property string infoColor: "#b0b0b0" + property string infoColor: infoTextColor property font infoFont: Qt.font({ family: "Arial", @@ -136,7 +136,7 @@ Rectangle { id: title - color: "#ffffff" + color: infoTitleColor font.family: "Arial" font.bold: true font.pixelSize: mainContainer.compact ? 18 : 21; @@ -232,7 +232,7 @@ Rectangle { } Text { - id: showInComicVinw + id: showInComicVine font: mainContainer.infoFont color: "#ffcc00" text: "Show in Comic Vine" @@ -253,7 +253,7 @@ Rectangle { Layout.fillWidth: true id: sinopsis - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 15 wrapMode: Text.WordWrap @@ -267,7 +267,7 @@ Rectangle { Layout.bottomMargin: 5 id: authors_title - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 18 font.bold: true @@ -290,7 +290,7 @@ Rectangle { model: comicInfo.getWriters().length Column{ Text { - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 15 @@ -298,7 +298,7 @@ Rectangle { } Text { - color: "#b0b0b0" + color: infoTextColor font.family: "Arial" font.pixelSize: 13 font.italic: true @@ -312,7 +312,7 @@ Rectangle { model: comicInfo.getPencillers().length Column{ Text { - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 15 @@ -320,7 +320,7 @@ Rectangle { } Text { - color: "#b0b0b0" + color: infoTextColor font.family: "Arial" font.pixelSize: 13 font.italic: true @@ -334,7 +334,7 @@ Rectangle { model: comicInfo.getInkers().length Column{ Text { - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 15 @@ -342,7 +342,7 @@ Rectangle { } Text { - color: "#b0b0b0" + color: infoTextColor font.family: "Arial" font.pixelSize: 13 font.italic: true @@ -356,7 +356,7 @@ Rectangle { model: comicInfo.getColorists().length Column{ Text { - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 15 @@ -364,7 +364,7 @@ Rectangle { } Text { - color: "#b0b0b0" + color: infoTextColor font.family: "Arial" font.pixelSize: 13 font.italic: true @@ -378,7 +378,7 @@ Rectangle { model: comicInfo.getLetterers().length Column{ Text { - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 15 @@ -386,7 +386,7 @@ Rectangle { } Text { - color: "#b0b0b0" + color: infoTextColor font.family: "Arial" font.pixelSize: 13 font.italic: true @@ -400,7 +400,7 @@ Rectangle { model: comicInfo.getCoverArtists().length Column{ Text { - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 15 @@ -408,7 +408,7 @@ Rectangle { } Text { - color: "#b0b0b0" + color: infoTextColor font.family: "Arial" font.pixelSize: 13 font.italic: true @@ -422,7 +422,7 @@ Rectangle { Layout.topMargin: 25 id: publisher_title - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 18 font.bold: true @@ -439,7 +439,7 @@ Rectangle { Text { id: publisher - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 15 @@ -451,7 +451,7 @@ Rectangle { Text { id: format - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 15 @@ -463,7 +463,7 @@ Rectangle { Text { id: color - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 15 @@ -475,7 +475,7 @@ Rectangle { Text { id: age_rating - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 15 @@ -490,7 +490,7 @@ Rectangle { Layout.bottomMargin: 5 id: characters_title - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 18 font.bold: true @@ -508,7 +508,7 @@ Rectangle { model: comicInfo.getCharacters().length Text { - color: "white" + color: infoTitleColor font.family: "Arial" font.pixelSize: 15 diff --git a/YACReaderLibrary/qml/GridComicsView.qml b/YACReaderLibrary/qml/GridComicsView.qml index dc24bf83..56b45fde 100644 --- a/YACReaderLibrary/qml/GridComicsView.qml +++ b/YACReaderLibrary/qml/GridComicsView.qml @@ -587,7 +587,7 @@ Rectangle { Layout.maximumWidth: 960 height: parent.height - color: "#2e2e2e" + color: infoBackgroundColor visible: showInfo diff --git a/YACReaderLibrary/qml/InfoComicsView.qml b/YACReaderLibrary/qml/InfoComicsView.qml index 6ffb35c3..b6835de0 100644 --- a/YACReaderLibrary/qml/InfoComicsView.qml +++ b/YACReaderLibrary/qml/InfoComicsView.qml @@ -9,7 +9,7 @@ import com.yacreader.ComicModel 1.0 Rectangle { id: main - color: "#2e2e2e" + color: infoBackgroundColor width: parent.width height: parent.height @@ -29,7 +29,7 @@ Rectangle { Image { id: top_shadow - source: "info-top-shadow.png" + source: topShadow width: parent.width fillMode: Image.TileHorizontally } @@ -41,14 +41,14 @@ Rectangle { Image { id: indicator - source: "info-indicator.png" + source: infoIndicator } Image { id: bottom_shadow x: indicator.width width: parent.width - indicator.width - source: "info-shadow.png" + source: infoShadow fillMode: Image.TileHorizontally } } @@ -59,7 +59,7 @@ Rectangle { y: flow.height + flow.additionalBottomSpace - 6 height: parent.height - y - color: "#2e2e2e" + color: infoBackgroundColor ScrollView { __wheelAreaScrollSpeed: 75 diff --git a/YACReaderLibrary/qml/InfoFavorites.qml b/YACReaderLibrary/qml/InfoFavorites.qml index daf6b956..d490ab17 100644 --- a/YACReaderLibrary/qml/InfoFavorites.qml +++ b/YACReaderLibrary/qml/InfoFavorites.qml @@ -26,7 +26,7 @@ Item { ColorOverlay { anchors.fill: favorites_button_compact source: favorites_button_compact - color: active ? "#e84852" : "#1c1c1c" + color: active ? favCheckedColor : favUncheckedColor } } diff --git a/YACReaderLibrary/qml/InfoRating.qml b/YACReaderLibrary/qml/InfoRating.qml index 9a2e5e76..d865358b 100644 --- a/YACReaderLibrary/qml/InfoRating.qml +++ b/YACReaderLibrary/qml/InfoRating.qml @@ -24,7 +24,7 @@ Row { ColorOverlay { anchors.fill: star source: star - color: index < (mouseIndex > 0 ? mouseIndex : rating) ? "#ffffff" : "#1c1c1c" + color: index < (mouseIndex > 0 ? mouseIndex : rating) ? ratingSelectedColor : ratingUnselectedColor } MouseArea { diff --git a/YACReaderLibrary/qml/InfoTick.qml b/YACReaderLibrary/qml/InfoTick.qml index f52e5402..f91d65a8 100644 --- a/YACReaderLibrary/qml/InfoTick.qml +++ b/YACReaderLibrary/qml/InfoTick.qml @@ -23,7 +23,7 @@ Item { ColorOverlay { anchors.fill: read_compact source: read_compact - color: read ? "#e84852" : "#1c1c1c" + color: read ? readTickCheckedColor : readTickUncheckedColor } }