Mercurial > hg > sonic-visualiser
diff main/OSCHandler.cpp @ 2242:e9c77a4c865e single-point
Add /exportlayer OSC command
author | Chris Cannam |
---|---|
date | Thu, 28 Mar 2019 14:34:29 +0000 |
parents | 76b1c50f1f6d |
children | eb7f4579e5cc |
line wrap: on
line diff
--- a/main/OSCHandler.cpp Thu Mar 28 13:42:03 2019 +0000 +++ b/main/OSCHandler.cpp Thu Mar 28 14:34:29 2019 +0000 @@ -118,6 +118,30 @@ } } + } else if (message.getMethod() == "exportlayer") { + + QString path; + if (message.getArgCount() == 1 && + message.getArg(0).canConvert(QVariant::String)) { + path = message.getArg(0).toString(); + if (QFileInfo(path).exists()) { + SVDEBUG << "OSCHandler: Refusing to overwrite existing file in layer export" << endl; + } else { + Pane *currentPane = nullptr; + Layer *currentLayer = nullptr; + if (m_paneStack) currentPane = m_paneStack->getCurrentPane(); + if (currentPane) currentLayer = currentPane->getSelectedLayer(); + if (currentLayer) { + QString error; + if (!exportLayerTo(currentLayer, path, error)) { + SVCERR << "OSCHandler: Failed to export current layer to " << path << ": " << error << endl; + } + } else { + SVCERR << "OSCHandler: No current layer to export" << endl; + } + } + } + } else if (message.getMethod() == "jump" || message.getMethod() == "play") {