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

Method onSaveSymView

Components/SamplerDialog.cpp:414–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414void
415SamplerDialog::onSaveSymView(void)
416{
417 QFileDialog dialog(this->ui->symView);
418 QStringList filters;
419 enum SymView::FileFormat fmt = SymView::FILE_FORMAT_TEXT;
420
421 filters << "Text file (*.txt)"
422 << "Binary file (*.bin)"
423 << "C source file (*.c)"
424 << "Microsoft Windows Bitmap (*.bmp)"
425 << "PNG Image (*.png)"
426 << "JPEG Image (*.jpg)"
427 << "Portable Pixel Map (*.ppm)";
428
429 dialog.setFileMode(QFileDialog::AnyFile);
430 dialog.setAcceptMode(QFileDialog::AcceptSave);
431 dialog.setWindowTitle(QString("Save current symbol capture as..."));
432 dialog.setNameFilters(filters);
433
434 if (dialog.exec()) {
435 // This sucks
436 QString filter = dialog.selectedNameFilter();
437 QString path = dialog.selectedFiles().first();
438 QFileInfo fi(path);
439 QString ext = fi.size() > 0
440 ? fi.suffix()
441 : SuWidgetsHelpers::extractFilterExtension(filter);
442
443 if (ext == "txt")
444 fmt = SymView::FILE_FORMAT_TEXT;
445 else if (ext == "bin")
446 fmt = SymView::FILE_FORMAT_RAW;
447 else if (ext == "c" || ext == "h" || ext == "cpp")
448 fmt = SymView::FILE_FORMAT_C_ARRAY;
449 else if (ext == "bmp")
450 fmt = SymView::FILE_FORMAT_BMP;
451 else if (ext == "png")
452 fmt = SymView::FILE_FORMAT_PNG;
453 else if (ext == "jpg" || ext == "jpeg")
454 fmt = SymView::FILE_FORMAT_JPEG;
455 else if (ext == "ppm")
456 fmt = SymView::FILE_FORMAT_PPM;
457
458 try {
459 this->ui->symView->save(
460 SuWidgetsHelpers::ensureExtension(path, ext),
461 fmt);
462 } catch (std::ios_base::failure const &) {
463 (void) QMessageBox::critical(
464 this->ui->symView,
465 "Save symbol file",
466 "Failed to save file in the specified location. Please try again.",
467 QMessageBox::Close);
468 }
469 }
470}

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected