Warning, file /graphics/glaxnimate/src/gui/emoji/emoji_set.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #include "emoji_set.hpp" 0008 0009 glaxnimate::emoji::GitHubTemplate glaxnimate::emoji::GitHubTemplate::load(const QJsonObject& json) 0010 { 0011 GitHubTemplate obj; 0012 obj.repo = json["repo"].toString(); 0013 obj.org = json["org"].toString(); 0014 if ( json.contains("tag") ) 0015 { 0016 obj.ref_type = Tag; 0017 obj.ref = json["tag"].toString(); 0018 } 0019 else 0020 { 0021 obj.ref_type = Branch; 0022 obj.ref = json["branch"].toString(); 0023 } 0024 return obj; 0025 } 0026 0027 void glaxnimate::emoji::GitHubTemplate::apply(EmojiSet& set) const 0028 { 0029 set.url = QUrl("https://github.com/" + org + "/" + repo); 0030 QString ref_url; 0031 QString ref_path = ref; 0032 if ( ref_type == Branch ) 0033 { 0034 ref_url = "heads/"; 0035 } 0036 else 0037 { 0038 ref_url = "tags/"; 0039 if ( ref.size() && ref[0] == 'v' ) 0040 ref_path.remove(0, 1); 0041 } 0042 set.download.url = QUrl("https://github.com/" + org + "/" + repo + "/archive/refs/" + ref_url + ref + ".tar.gz"); 0043 for ( auto& path : set.download.paths ) 0044 { 0045 if ( path.second.size == EmojiSetDirectory::Scalable ) 0046 set.preview_template = "https://raw.githubusercontent.com/" + org + "/" + repo + "/" + ref + "/" + path.second.path + "%1.svg"; 0047 path.second.path = repo + "-" + ref_path + "/" + path.second.path; 0048 } 0049 } 0050 0051 glaxnimate::emoji::EmojiSet glaxnimate::emoji::EmojiSet::load(const QJsonObject& json) 0052 { 0053 EmojiSet obj; 0054 obj.name = json["name"].toString(); 0055 obj.url = QUrl(json["url"].toString()); 0056 obj.license = json["license"].toString(); 0057 obj.preview_template = json["preview"].toString(); 0058 QString slug_format = json["slug_format"].toString(); 0059 obj.slug.upper = slug_format[0].isUpper(); 0060 obj.slug.separator = slug_format.back(); 0061 obj.slug.prefix = json["slug_prefix"].toString(); 0062 0063 obj.download = EmojiSetDownload::load(json["download"].toObject()); 0064 if ( json.contains("template") ) 0065 GitHubTemplate::load(json["template"].toObject()).apply(obj); 0066 0067 return obj; 0068 }