From 880e17acff19d1e2bbcf248e760bd6d373471a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Tue, 16 May 2023 21:47:59 +0200 Subject: [PATCH] Display new metadata in the info views --- YACReaderLibrary/qml/ComicInfoView.qml | 260 +++++++++++++++++++---- YACReaderLibrary/qml/GridComicsView.qml | 27 +++ YACReaderLibrary/qml/GridComicsView6.qml | 27 +++ common/comic_db.cpp | 91 ++++++++ common/comic_db.h | 8 + 5 files changed, 377 insertions(+), 36 deletions(-) diff --git a/YACReaderLibrary/qml/ComicInfoView.qml b/YACReaderLibrary/qml/ComicInfoView.qml index 1814332b..a8600836 100644 --- a/YACReaderLibrary/qml/ComicInfoView.qml +++ b/YACReaderLibrary/qml/ComicInfoView.qml @@ -140,7 +140,7 @@ Rectangle { font.pixelSize: mainContainer.compact ? 18 : 21; wrapMode: Text.WordWrap - text: comic ? comic.getTitleIncludingNumber() ?? "" : "" + text: comic ? comic.getInfoTitle() ?? "" : "" } RowLayout @@ -202,6 +202,33 @@ Rectangle { visible : comicInfo ? comicInfo.number ?? false : false } + Text { + id: arc + color: infoColor + font: mainContainer.infoFont + text: comicInfo ? comicInfo.getStoryArcInfoString() : "" + rightPadding: 20 + visible : comicInfo ? comicInfo.getStoryArcInfoString().length : false + } + + Text { + id: alternate + color: infoColor + font: mainContainer.infoFont + text: comicInfo ? comicInfo.getAlternateSeriesString() : "" + rightPadding: 20 + visible : comicInfo ? comicInfo.getAlternateSeriesString().length : false + } + + Text { + id: seriesGroup + color: infoColor + font: mainContainer.infoFont + text: comicInfo ? comicInfo.seriesGroup ?? "" : "" + rightPadding: 20 + visible: comicInfo ? comicInfo.seriesGroup ?? false : false + } + Text { id: genre color: infoColor @@ -266,6 +293,129 @@ Rectangle { textFormat: Text.RichText } + Text { + Layout.topMargin: 25 + Layout.bottomMargin: 5 + + id: characters_title + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 18 + font.bold: true + + text: qsTr("Characters") + + visible: comicInfo ? comicInfo.getCharacters().length > 0 : false + } + + Flow { + Layout.fillWidth: true + spacing: 20 + Repeater { + id: characters + model: comicInfo ? comicInfo.getCharacters().length : null + + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo ? comicInfo.getCharacters()[index] : "" + } + } + } + + Text { + Layout.topMargin: 25 + Layout.bottomMargin: 5 + + id: main_character_or_team_title + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 18 + font.bold: true + + text: qsTr("Main character or team") + + visible: comicInfo ? comicInfo.mainCharacterOrTeam.length > 0 : false + } + + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo ? comicInfo.mainCharacterOrTeam : "" + + visible: comicInfo ? comicInfo.mainCharacterOrTeam.length > 0 : false + } + + Text { + Layout.topMargin: 25 + Layout.bottomMargin: 5 + + id: teams_title + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 18 + font.bold: true + + text: qsTr("Teams") + + visible: comicInfo ? comicInfo.getTeams().length > 0 : false + } + + + + Flow { + Layout.fillWidth: true + spacing: 20 + Repeater { + id: teams + model: comicInfo ? comicInfo.getTeams().length : null + + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo ? comicInfo.getTeams()[index] : "" + } + } + } + + Text { + Layout.topMargin: 25 + Layout.bottomMargin: 5 + + id: locations_title + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 18 + font.bold: true + + text: qsTr("Locations") + + visible: comicInfo ? comicInfo.getLocations().length > 0 : false + } + + Flow { + Layout.fillWidth: true + spacing: 20 + Repeater { + id: locations + model: comicInfo ? comicInfo.getLocations().length : null + + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo ? comicInfo.getLocations()[index] : "" + } + } + } + Text { Layout.topMargin: 25 Layout.bottomMargin: 5 @@ -283,7 +433,9 @@ Rectangle { comicInfo.getInkers().length + comicInfo.getColorists().length + comicInfo.getLetterers().length + - comicInfo.getCoverArtists().length > 0) : false + comicInfo.getCoverArtists().length + + comicInfo.getEditors().length + + comicInfo.getImprint().length > 0) : false } Flow { @@ -379,7 +531,7 @@ Rectangle { Repeater { id: letterers - model: comicInfo ? comicInfo.getLetterers().length : null + model: comicInfo ? comicInfo.getLetterers().length : nul Column{ Text { color: infoTitleColor @@ -401,7 +553,7 @@ Rectangle { Repeater { id: cover_artist - model: comicInfo ? comicInfo.getCoverArtists().length : "" + model: comicInfo ? comicInfo.getCoverArtists().length : null Column{ Text { color: infoTitleColor @@ -420,6 +572,50 @@ Rectangle { } } } + + Repeater { + id: editors + model: comicInfo ? comicInfo.getEditors().length : null + Column{ + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo ? comicInfo.getEditors()[index] : "" + } + + Text { + color: infoTextColor + font.family: "Arial" + font.pixelSize: 13 + font.italic: true + text: qsTr("editor") + } + } + } + + Repeater { + id: imprint + model: comicInfo ? comicInfo.getImprint().length : null + Column{ + Text { + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo ? comicInfo.getImprint()[index] : "" + } + + Text { + color: infoTextColor + font.family: "Arial" + font.pixelSize: 13 + font.italic: true + text: qsTr("imprint") + } + } + } } Text { @@ -464,6 +660,18 @@ Rectangle { visible: comicInfo ? comicInfo.format ?? false : false } + Text { + id: type + + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo ? comicInfo.getTypeString() : "" + + visible: comicInfo ? comicInfo.getTypeString() : false + } + Text { id: color @@ -476,6 +684,18 @@ Rectangle { visible: comicInfo ? comicInfo.color ?? false : false } + Text { + id: language + + color: infoTitleColor + font.family: "Arial" + font.pixelSize: 15 + + text: comicInfo ? comicInfo.languageISO : "" + + visible: comicInfo ? comicInfo.languageISO.length > 0 : false + } + Text { id: age_rating @@ -488,38 +708,6 @@ Rectangle { visible: comicInfo ? comicInfo.ageRating ?? false : false } } - - Text { - Layout.topMargin: 25 - Layout.bottomMargin: 5 - - id: characters_title - color: infoTitleColor - font.family: "Arial" - font.pixelSize: 18 - font.bold: true - - text: qsTr("Characters") - - visible: comicInfo ? comicInfo.getCharacters().length > 0 : false - } - - Flow { - Layout.fillWidth: true - spacing: 20 - Repeater { - id: characters - model: comicInfo ? comicInfo.getCharacters().length : null - - Text { - color: infoTitleColor - font.family: "Arial" - font.pixelSize: 15 - - text: comicInfo ? comicInfo.getCharacters()[index] : "" - } - } - } } Item { diff --git a/YACReaderLibrary/qml/GridComicsView.qml b/YACReaderLibrary/qml/GridComicsView.qml index f8c37b2a..4d2072c8 100644 --- a/YACReaderLibrary/qml/GridComicsView.qml +++ b/YACReaderLibrary/qml/GridComicsView.qml @@ -523,6 +523,33 @@ SplitView { visible : currentComicInfo.number ? true : false } + Text { + id: currentComicInfoArc + color: currentComicDetailsFlowView.infoFlowTextColor + font: currentComicDetailsFlowView.infoFont + text: currentComicInfo.getStoryArcInfoString() + rightPadding: 20 + visible : currentComicInfo.getStoryArcInfoString().length > 0 + } + + Text { + id: currentComicInfoAlternate + color: currentComicDetailsFlowView.infoFlowTextColor + font: currentComicDetailsFlowView.infoFont + text: currentComicInfo.getAlternateSeriesString() + rightPadding: 20 + visible : currentComicInfo.getStoryArcInfoString().length > 0 + } + + Text { + id: currentComicInfoSeriesGroup + color: currentComicDetailsFlowView.infoFlowTextColor + font: currentComicDetailsFlowView.infoFont + text: currentComicInfo.seriesGroup ? currentComicInfo.seriesGroup : "" + rightPadding: 20 + visible: currentComicInfo.seriesGroup ? true : false + } + Text { id: currentComicInfoGenre color: currentComicDetailsFlowView.infoFlowTextColor diff --git a/YACReaderLibrary/qml/GridComicsView6.qml b/YACReaderLibrary/qml/GridComicsView6.qml index 3269c586..4cb7c1ce 100644 --- a/YACReaderLibrary/qml/GridComicsView6.qml +++ b/YACReaderLibrary/qml/GridComicsView6.qml @@ -527,6 +527,33 @@ SplitView { visible : currentComicInfo.number ? true : false } + Text { + id: currentComicInfoArc + color: currentComicDetailsFlowView.infoFlowTextColor + font: currentComicDetailsFlowView.infoFont + text: currentComicInfo.getStoryArcInfoString() + rightPadding: 20 + visible : currentComicInfo.getStoryArcInfoString().length > 0 + } + + Text { + id: currentComicInfoAlternate + color: currentComicDetailsFlowView.infoFlowTextColor + font: currentComicDetailsFlowView.infoFont + text: currentComicInfo.getAlternateSeriesString() + rightPadding: 20 + visible : currentComicInfo.getStoryArcInfoString().length > 0 + } + + Text { + id: currentComicInfoSeriesGroup + color: currentComicDetailsFlowView.infoFlowTextColor + font: currentComicDetailsFlowView.infoFont + text: currentComicInfo.seriesGroup ? currentComicInfo.seriesGroup : "" + rightPadding: 20 + visible: currentComicInfo.seriesGroup ? true : false + } + Text { id: currentComicInfoGenre color: currentComicDetailsFlowView.infoFlowTextColor diff --git a/common/comic_db.cpp b/common/comic_db.cpp index 8a3afbc4..6673249e 100644 --- a/common/comic_db.cpp +++ b/common/comic_db.cpp @@ -1,5 +1,7 @@ #include "comic_db.h" +#include "yacreader_global.h" + #include #include @@ -214,6 +216,35 @@ QString ComicDB::getTitleIncludingNumber() const return getTitleOrFileName(); } +QString ComicDB::getInfoTitle() const +{ + if (!info.number.isNull() && !info.title.isNull() && !info.series.isNull()) + return "#" + info.number.toString() + " - " + info.title.toString() + " (" + info.series.toString() + ")"; + + if (!info.title.isNull() && !info.series.isNull()) + return info.title.toString() + " (" + info.series.toString() + ")"; + + if (!info.number.isNull() && !info.title.isNull()) + return "#" + info.number.toString() + " - " + info.title.toString(); + + if (!info.number.isNull() && !info.series.isNull()) + return "#" + info.number.toString() + " - " + info.series.toString(); + + if (!info.number.isNull()) + return "#" + info.number.toString() + " - " + getTitleOrFileName(); + + if (!info.title.isNull() && !info.series.isNull()) + return info.title.toString() + " (" + info.series.toString() + ")"; + + if (!info.title.isNull()) + return info.title.toString(); + + if (!info.series.isNull()) + return info.series.toString(); + + return QFileInfo(path).fileName(); +} + //----------------------------------------------------------------------------- // COMIC_INFO------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -436,6 +467,24 @@ QStringList ComicInfo::getCoverArtists() return QStringList(); } +QStringList ComicInfo::getEditors() +{ + if (editor.toString().length() > 0) { + return editor.toString().split("\n"); + } + + return QStringList(); +} + +QStringList ComicInfo::getImprint() +{ + if (imprint.toString().length() > 0) { + return imprint.toString().split("\n"); + } + + return QStringList(); +} + QStringList ComicInfo::getCharacters() { if (characters.toString().length() > 0) { @@ -472,6 +521,48 @@ QStringList ComicInfo::getTags() return QStringList(); } +QString ComicInfo::getTypeString() +{ + switch (type.value()) { + case YACReader::FileType::Comic: + return "Comic"; + case YACReader::FileType::Manga: + return "Manga"; + case YACReader::FileType::WesternManga: + return "Western Manga"; + case YACReader::FileType::WebComic: + return "Web Comic"; + case YACReader::FileType::Yonkoma: + return "4-Koma"; + } +} + +QString ComicInfo::getStoryArcInfoString() +{ + if (arcNumber.toString().length() > 0 && arcCount.toString().length() > 0 && storyArc.toString().length() > 0) { + return "(" + arcNumber.toString() + "/" + arcCount.toString() + ") " + storyArc.toString(); + } + + if (arcNumber.toString().length() > 0 && storyArc.toString().length() > 0) { + return "(" + arcNumber.toString() + ") " + storyArc.toString(); + } + + return storyArc.toString().length() > 0 ? storyArc.toString() : ""; +} + +QString ComicInfo::getAlternateSeriesString() +{ + if (alternateNumber.toString().length() > 0 && alternateCount.toString().length() > 0 && alternateSeries.toString().length() > 0) { + return "(" + alternateNumber.toString() + "/" + alternateCount.toString() + ") " + alternateSeries.toString(); + } + + if (alternateNumber.toString().length() > 0 && alternateSeries.toString().length() > 0) { + return "(" + alternateNumber.toString() + ") " + alternateSeries.toString(); + } + + return alternateSeries.toString().length() > 0 ? alternateSeries.toString() : ""; +} + void ComicInfo::setRead(bool r) { if (r != read) { diff --git a/common/comic_db.h b/common/comic_db.h index 8b130fba..a492b624 100644 --- a/common/comic_db.h +++ b/common/comic_db.h @@ -118,6 +118,8 @@ public: Q_INVOKABLE QStringList getColorists(); Q_INVOKABLE QStringList getLetterers(); Q_INVOKABLE QStringList getCoverArtists(); + Q_INVOKABLE QStringList getEditors(); + Q_INVOKABLE QStringList getImprint(); Q_INVOKABLE QStringList getCharacters(); @@ -126,6 +128,11 @@ public: Q_INVOKABLE QStringList getTags(); + Q_INVOKABLE QString getTypeString(); + + Q_INVOKABLE QString getStoryArcInfoString(); + Q_INVOKABLE QString getAlternateSeriesString(); + friend QDataStream &operator<<(QDataStream &stream, const ComicInfo &comicInfo); friend QDataStream &operator>>(QDataStream &stream, ComicInfo &comicInfo); @@ -252,6 +259,7 @@ public: Q_INVOKABLE qulonglong getFileSize() const; Q_INVOKABLE QString getTitleIncludingNumber() const; + Q_INVOKABLE QString getInfoTitle() const; QString toTXT();