From 9a2ec55048c9f8fbd8cf0da1771d0c32a6312046 Mon Sep 17 00:00:00 2001 From: Bionus Date: Tue, 21 Nov 2023 18:56:30 +0100 Subject: [PATCH] feat: add support for "lore" tag on e621 (fix #3059) --- src/gui/src/settings/options-window.cpp | 2 ++ src/lib/src/filename/filename.cpp | 6 +++--- src/lib/src/models/image.cpp | 1 + src/lib/src/tags/tag.cpp | 1 + src/sites/E621/e621.net/tag-types.txt | 3 ++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/src/settings/options-window.cpp b/src/gui/src/settings/options-window.cpp index a8316a474..41b83f107 100644 --- a/src/gui/src/settings/options-window.cpp +++ b/src/gui/src/settings/options-window.cpp @@ -276,6 +276,7 @@ OptionsWindow::OptionsWindow(Profile *profile, ThemeLoader *themeLoader, QWidget tagsTree->addChild(new QTreeWidgetItem({ "Photo set" }, tagsTree->type())); tagsTree->addChild(new QTreeWidgetItem({ "Species" }, tagsTree->type())); tagsTree->addChild(new QTreeWidgetItem({ "Meta" }, tagsTree->type())); + tagsTree->addChild(new QTreeWidgetItem({ "Lore" }, tagsTree->type())); m_tokenSettings.append(new TokenSettingsWidget(settings, "general", false, "", "", " ", this)); m_tokenSettings.append(new TokenSettingsWidget(settings, "artist", false, "anonymous", "multiple artists", "+", this)); m_tokenSettings.append(new TokenSettingsWidget(settings, "copyright", true, "misc", "crossover", "+", this)); @@ -284,6 +285,7 @@ OptionsWindow::OptionsWindow(Profile *profile, ThemeLoader *themeLoader, QWidget m_tokenSettings.append(new TokenSettingsWidget(settings, "photo_set", false, "unknown", "multiple", "+", this)); m_tokenSettings.append(new TokenSettingsWidget(settings, "species", false, "unknown", "multiple", "+", this)); m_tokenSettings.append(new TokenSettingsWidget(settings, "meta", false, "none", "multiple", "+", this)); + m_tokenSettings.append(new TokenSettingsWidget(settings, "lore", false, "none", "multiple", "+", this)); const int tagsStackIndex = ui->stackedWidget->indexOf(ui->pageTags); for (int i = 0; i < m_tokenSettings.count(); ++i) { ui->stackedWidget->insertWidget(i + tagsStackIndex + 1, m_tokenSettings[i]); diff --git a/src/lib/src/filename/filename.cpp b/src/lib/src/filename/filename.cpp index a47a1114e..5e10d5778 100644 --- a/src/lib/src/filename/filename.cpp +++ b/src/lib/src/filename/filename.cpp @@ -327,7 +327,7 @@ bool Filename::isValid(Profile *profile, QString *error) const } // Looking for unknown tokens - QStringList knownTokens {"tags", "artist", "general", "copyright", "character", "model", "photo_set", "species", "meta", "filename", "rating", "md5", "website", "websitename", "ext", "all", "id", "search", "search_(\\d+)", "allo", "date", "score", "count", "width", "height", "pool", "url_file", "url_page", "num", "name", "position", "current_date", "author", "authorid", "parentid" }; + QStringList knownTokens {"tags", "artist", "general", "copyright", "character", "model", "photo_set", "species", "lore", "meta", "filename", "rating", "md5", "website", "websitename", "ext", "all", "id", "search", "search_(\\d+)", "allo", "date", "score", "count", "width", "height", "pool", "url_file", "url_page", "num", "name", "position", "current_date", "author", "authorid", "parentid" }; if (profile != nullptr) { knownTokens.append(profile->getAdditionalTokens()); knownTokens.append(getCustoms(profile->getSettings()).keys()); @@ -429,7 +429,7 @@ int Filename::needExactTags(const QStringList &forcedTokens, const QStringList & // Some sources require loading to get the tag list if (forcedTokens.contains("tags")) { // The filename use tags - static const QStringList forbidden { "tags", "all", "allo", "artist", "copyright", "character", "model", "photo_set", "species", "meta", "general" }; + static const QStringList forbidden { "tags", "all", "allo", "artist", "copyright", "character", "model", "photo_set", "species", "lore", "meta", "general" }; for (const QString &token : forbidden) { if (toks.contains(token)) { return 2; @@ -445,7 +445,7 @@ int Filename::needExactTags(const QStringList &forcedTokens, const QStringList & } // The filename contains one of the special tags - static const QStringList forbidden { "artist", "copyright", "character", "model", "photo_set", "species", "meta", "general" }; + static const QStringList forbidden { "artist", "copyright", "character", "model", "photo_set", "species", "lore", "meta", "general" }; for (const QString &token : forbidden) { if (toks.contains(token)) { return 1; diff --git a/src/lib/src/models/image.cpp b/src/lib/src/models/image.cpp index 66e0e3d9a..32c04fc4f 100644 --- a/src/lib/src/models/image.cpp +++ b/src/lib/src/models/image.cpp @@ -1186,6 +1186,7 @@ QMap Image::generateTokens(Profile *profile) const tokens.insert("photo_set", Token(details["photo_set"], "keepAll", "unknown", "multiple")); tokens.insert("species", Token(details["species"], "keepAll", "unknown", "multiple")); tokens.insert("meta", Token(details["meta"], "keepAll", "none", "multiple")); + tokens.insert("lore", Token(details["lore"], "keepAll", "none", "multiple")); tokens.insert("allos", Token(details["allos"])); tokens.insert("allo", Token(details["allos"].join(' '))); tokens.insert("tags", Token(QVariant::fromValue(tags))); diff --git a/src/lib/src/tags/tag.cpp b/src/lib/src/tags/tag.cpp index 73e290613..47c3e4131 100644 --- a/src/lib/src/tags/tag.cpp +++ b/src/lib/src/tags/tag.cpp @@ -180,6 +180,7 @@ bool sortTagsByType(const Tag &s1, const Tag &s2) << QStringLiteral("unknown") << QStringLiteral("model") << QStringLiteral("meta") + << QStringLiteral("lore") << QStringLiteral("species") << QStringLiteral("artist") << QStringLiteral("character") diff --git a/src/sites/E621/e621.net/tag-types.txt b/src/sites/E621/e621.net/tag-types.txt index e32f5573d..ee4e57aea 100644 --- a/src/sites/E621/e621.net/tag-types.txt +++ b/src/sites/E621/e621.net/tag-types.txt @@ -3,4 +3,5 @@ 3,copyright 4,character 5,species -7,meta \ No newline at end of file +7,meta +8,lore \ No newline at end of file