MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / logoLoaded

Method logoLoaded

launcher/ui/pages/modplatform/ftb/FtbListModel.cpp:216–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216void ListModel::logoLoaded(QString logo, bool stale)
217{
218 auto & logoObj = m_logoMap[logo];
219 logoObj.downloadJob.reset();
220 QString smallPath = logoObj.fullpath + ".small";
221
222 QFileInfo smallInfo(smallPath);
223
224 if(stale || !smallInfo.exists()) {
225 QImage image(logoObj.fullpath);
226 if (image.isNull())
227 {
228 logoObj.failed = true;
229 return;
230 }
231 QImage small;
232 if (image.width() > image.height()) {
233 small = image.scaledToWidth(512).scaledToWidth(256, Qt::SmoothTransformation);
234 }
235 else {
236 small = image.scaledToHeight(512).scaledToHeight(256, Qt::SmoothTransformation);
237 }
238 QPoint offset((256 - small.width()) / 2, (256 - small.height()) / 2);
239 QImage square(QSize(256, 256), QImage::Format_ARGB32);
240 square.fill(Qt::transparent);
241
242 QPainter painter(&square);
243 painter.drawImage(offset, small);
244 painter.end();
245
246 square.save(logoObj.fullpath + ".small", "PNG");
247 }
248
249 logoObj.result = QIcon(logoObj.fullpath + ".small");
250 for(int i = 0; i < modpacks.size(); i++) {
251 if(modpacks[i].name == logo) {
252 emit dataChanged(createIndex(i, 0), createIndex(i, 0), {Qt::DecorationRole});
253 }
254 }
255}
256
257void ListModel::logoFailed(QString logo)
258{

Callers

nothing calls this directly

Calls 6

existsMethod · 0.80
fillMethod · 0.80
endMethod · 0.80
resetMethod · 0.45
saveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected