MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / updateWithMod

Method updateWithMod

launcher/ui/widgets/InfoFrame.cpp:79–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void InfoFrame::updateWithMod(const Mod& m)
80{
81 if (m.type() == ResourceType::FOLDER) {
82 clear();
83 return;
84 }
85
86 QString text = "";
87 QString name = "";
88 QString link = m.homepage();
89 if (m.name().isEmpty())
90 name = m.internal_id();
91 else
92 name = renderColorCodes(m.name());
93
94 if (link.isEmpty())
95 text = name;
96 else {
97 text = "<a href=\"" + QUrl(link).toEncoded() + "\">" + name + "</a>";
98 }
99 if (!m.authors().isEmpty())
100 text += " by " + m.authors().join(", ");
101
102 setName(text);
103
104 if (m.description().isEmpty()) {
105 setDescription(QString());
106 } else {
107 setDescription(renderColorCodes(m.description()));
108 }
109
110 setImage(m.icon({ 64, 64 }));
111
112 auto licenses = m.licenses();
113 QString licenseText = "";
114 if (!licenses.empty()) {
115 for (auto l : licenses) {
116 if (!licenseText.isEmpty()) {
117 licenseText += "\n"; // add newline between licenses
118 }
119 if (!l.name.isEmpty()) {
120 if (l.url.isEmpty()) {
121 licenseText += l.name;
122 } else {
123 licenseText += "<a href=\"" + l.url + "\">" + l.name + "</a>";
124 }
125 } else if (!l.url.isEmpty()) {
126 licenseText += "<a href=\"" + l.url + "\">" + l.url + "</a>";
127 }
128 if (!l.description.isEmpty() && l.description != l.name) {
129 licenseText += " " + l.description;
130 }
131 }
132 }
133 if (!licenseText.isEmpty()) {
134 setLicense(tr("License: %1").arg(licenseText));
135 } else {
136 setLicense();

Callers 1

updateFrameMethod · 0.80

Calls 13

QUrlClass · 0.85
internal_idMethod · 0.80
authorsMethod · 0.80
licensesMethod · 0.80
issueTrackerMethod · 0.80
QStringClass · 0.50
typeMethod · 0.45
homepageMethod · 0.45
isEmptyMethod · 0.45
nameMethod · 0.45
descriptionMethod · 0.45
iconMethod · 0.45

Tested by

no test coverage detected