Skip to content

Commit

Permalink
feat: add support for "lore" tag on e621 (fix #3059)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Nov 21, 2023
1 parent 7512899 commit 9a2ec55
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/gui/src/settings/options-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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]);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/src/filename/filename.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/lib/src/models/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ QMap<QString, Token> 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)));
Expand Down
1 change: 1 addition & 0 deletions src/lib/src/tags/tag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion src/sites/E621/e621.net/tag-types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
3,copyright
4,character
5,species
7,meta
7,meta
8,lore

0 comments on commit 9a2ec55

Please # to comment.