MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / onScreenshotReply

Method onScreenshotReply

app/src/Misc/Examples.cpp:292–320  ·  view source on GitHub ↗

* @brief Handles the screenshot fetch response and caches it. */

Source from the content-addressed store, hash-verified

290 * @brief Handles the screenshot fetch response and caches it.
291 */
292void Misc::Examples::onScreenshotReply()
293{
294 auto* reply = qobject_cast<QNetworkReply*>(sender());
295 if (!reply)
296 return;
297
298 reply->deleteLater();
299
300 if (reply->error() == QNetworkReply::NoError) {
301 const auto data = reply->readAll();
302 const auto id = reply->property("exampleId").toString();
303 if (!id.isEmpty()) {
304 const auto path = exampleCachePath(id) + "/doc";
305 QDir().mkpath(path);
306 auto name = reply->property("fileName").toString();
307 if (name.isEmpty())
308 name = QStringLiteral("screenshot.png");
309
310 const auto file_path = path + "/" + name;
311 QFile file(file_path);
312 if (file.open(QIODevice::WriteOnly)) {
313 file.write(data);
314 file.close();
315 m_selectedScreenshot = QUrl::fromLocalFile(file_path);
316 Q_EMIT selectedScreenshotChanged();
317 }
318 }
319 }
320}
321
322/**
323 * @brief Handles the GitHub Contents API response listing all files in an

Callers

nothing calls this directly

Calls 6

senderFunction · 0.85
errorMethod · 0.80
isEmptyMethod · 0.80
openMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected