MCPcopy Create free account
hub / github.com/BatchDrake/SigDigger / onSaveSymView

Method onSaveSymView

Default/GenericInspector/SymViewTab.cpp:357–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355}
356
357void
358SymViewTab::onSaveSymView(void)
359{
360 QFileDialog dialog(this->ui->symView);
361 QStringList filters;
362 enum SymView::FileFormat fmt = SymView::FILE_FORMAT_TEXT;
363
364 filters << "Text file (*.txt)"
365 << "Binary file (*.bin)"
366 << "C source file (*.c)"
367 << "Microsoft Windows Bitmap (*.bmp)"
368 << "PNG Image (*.png)"
369 << "JPEG Image (*.jpg)"
370 << "Portable Pixel Map (*.ppm)";
371
372 dialog.setFileMode(QFileDialog::AnyFile);
373 dialog.setAcceptMode(QFileDialog::AcceptSave);
374 dialog.setWindowTitle(QString("Save current symbol capture as..."));
375 dialog.setNameFilters(filters);
376
377 if (dialog.exec()) {
378 // This sucks
379 QString filter = dialog.selectedNameFilter();
380 QString path = dialog.selectedFiles().first();
381 QFileInfo fi(path);
382 QString ext = fi.suffix().size() > 0
383 ? fi.suffix()
384 : SuWidgetsHelpers::extractFilterExtension(filter);
385
386 if (ext == "txt")
387 fmt = SymView::FILE_FORMAT_TEXT;
388 else if (ext == "bin")
389 fmt = SymView::FILE_FORMAT_RAW;
390 else if (ext == "c" || ext == "h" || ext == "cpp")
391 fmt = SymView::FILE_FORMAT_C_ARRAY;
392 else if (ext == "bmp")
393 fmt = SymView::FILE_FORMAT_BMP;
394 else if (ext == "png")
395 fmt = SymView::FILE_FORMAT_PNG;
396 else if (ext == "jpg" || ext == "jpeg")
397 fmt = SymView::FILE_FORMAT_JPEG;
398 else if (ext == "ppm")
399 fmt = SymView::FILE_FORMAT_PPM;
400
401 try {
402 this->ui->symView->save(
403 SuWidgetsHelpers::ensureExtension(path, ext),
404 fmt);
405 } catch (std::ios_base::failure const &) {
406 (void) QMessageBox::critical(
407 this->ui->symView,
408 "Save symbol file",
409 "Failed to save file in the specified location. Please verify if "
410 "permission and disk space allow this operation.",
411 QMessageBox::Close);
412 }
413 }
414}

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected