Mercurial > hg > sonic-visualiser
comparison main/MainWindow.cpp @ 2442:b3330c31ea0e spectrogram-export
Add layer export of selected region as well as whole layer
author | Chris Cannam |
---|---|
date | Wed, 08 Jan 2020 15:41:46 +0000 |
parents | d811380516f6 |
children | 0075f5b8f76c |
comparison
equal
deleted
inserted
replaced
2441:3612bfc24950 | 2442:b3330c31ea0e |
---|---|
3018 if (ModelById::isa<NoteModel>(modelId)) type = FileFinder::LayerFile; | 3018 if (ModelById::isa<NoteModel>(modelId)) type = FileFinder::LayerFile; |
3019 QString path = getSaveFileName(type); | 3019 QString path = getSaveFileName(type); |
3020 | 3020 |
3021 if (path == "") return; | 3021 if (path == "") return; |
3022 | 3022 |
3023 MultiSelection ms = m_viewManager->getSelection(); | |
3024 MultiSelection *selectionToWrite = nullptr; | |
3025 | |
3026 if (!ms.getSelections().empty()) { | |
3027 | |
3028 QStringList items; | |
3029 items << tr("Export the content of the selected area") | |
3030 << tr("Export the whole layer"); | |
3031 | |
3032 bool ok = false; | |
3033 QString item = ListInputDialog::getItem | |
3034 (this, tr("Select region to export"), | |
3035 tr("Which region of the layer do you want to export?"), | |
3036 items, 0, &ok); | |
3037 | |
3038 if (!ok || item.isEmpty()) return; | |
3039 | |
3040 if (item == items[0]) selectionToWrite = &ms; | |
3041 } | |
3042 | |
3023 QString error; | 3043 QString error; |
3024 | 3044 |
3025 if (!exportLayerTo(layer, pane, path, error)) { | 3045 if (!exportLayerTo(layer, pane, selectionToWrite, path, error)) { |
3026 QMessageBox::critical(this, tr("Failed to write file"), error); | 3046 QMessageBox::critical(this, tr("Failed to write file"), error); |
3027 } else { | 3047 } else { |
3028 m_recentFiles.addFile(path); | 3048 m_recentFiles.addFile(path); |
3029 emit activity(tr("Export layer to \"%1\"").arg(path)); | 3049 emit activity(tr("Export layer to \"%1\"").arg(path)); |
3030 } | 3050 } |