# HG changeset patch # User Chris Cannam # Date 1578498106 0 # Node ID b3330c31ea0e3c896bcb7dc382743d025ba72dd1 # Parent 3612bfc249508871109ade0d05a6dd4b5db3ec97 Add layer export of selected region as well as whole layer diff -r 3612bfc24950 -r b3330c31ea0e main/MainWindow.cpp --- a/main/MainWindow.cpp Wed Jan 08 15:40:58 2020 +0000 +++ b/main/MainWindow.cpp Wed Jan 08 15:41:46 2020 +0000 @@ -3020,9 +3020,29 @@ if (path == "") return; + MultiSelection ms = m_viewManager->getSelection(); + MultiSelection *selectionToWrite = nullptr; + + if (!ms.getSelections().empty()) { + + QStringList items; + items << tr("Export the content of the selected area") + << tr("Export the whole layer"); + + bool ok = false; + QString item = ListInputDialog::getItem + (this, tr("Select region to export"), + tr("Which region of the layer do you want to export?"), + items, 0, &ok); + + if (!ok || item.isEmpty()) return; + + if (item == items[0]) selectionToWrite = &ms; + } + QString error; - if (!exportLayerTo(layer, pane, path, error)) { + if (!exportLayerTo(layer, pane, selectionToWrite, path, error)) { QMessageBox::critical(this, tr("Failed to write file"), error); } else { m_recentFiles.addFile(path); diff -r 3612bfc24950 -r b3330c31ea0e main/OSCHandler.cpp --- a/main/OSCHandler.cpp Wed Jan 08 15:40:58 2020 +0000 +++ b/main/OSCHandler.cpp Wed Jan 08 15:41:46 2020 +0000 @@ -156,10 +156,19 @@ Layer *currentLayer = nullptr; if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); if (currentPane) currentLayer = currentPane->getSelectedLayer(); + MultiSelection ms = m_viewManager->getSelection(); if (currentLayer) { QString error; - if (!exportLayerTo(currentLayer, currentPane, path, error)) { - SVCERR << "OSCHandler: Failed to export current layer to " << path << ": " << error << endl; + if (exportLayerTo + (currentLayer, currentPane, + ms.getSelections().empty() ? nullptr : &ms, + path, error)) { + SVDEBUG << "OSCHandler: Exported layer \"" + << currentLayer->getLayerPresentationName() + << "\" to path \"" << path << "\"" << endl; + } else { + SVCERR << "OSCHandler: Export failed to path \"" + << path << "\"" << endl; } } else { SVCERR << "OSCHandler: No current layer to export" << endl; diff -r 3612bfc24950 -r b3330c31ea0e repoint-lock.json --- a/repoint-lock.json Wed Jan 08 15:40:58 2020 +0000 +++ b/repoint-lock.json Wed Jan 08 15:41:46 2020 +0000 @@ -4,13 +4,13 @@ "pin": "c42e50a5c297" }, "svcore": { - "pin": "ee3b248bda25" + "pin": "1318e069906b" }, "svgui": { - "pin": "3607b0092019" + "pin": "e6e7a8dc3b38" }, "svapp": { - "pin": "b06b18c15fd4" + "pin": "1e2e03197b8c" }, "checker": { "pin": "ef64b3f171d9"