comparison 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
comparison
equal deleted inserted replaced
2241:c517286ee999 2242:e9c77a4c865e
112 if (!ms.getSelections().empty()) { 112 if (!ms.getSelections().empty()) {
113 writer.writeModel(getMainModel(), &ms); 113 writer.writeModel(getMainModel(), &ms);
114 } else { 114 } else {
115 writer.writeModel(getMainModel()); 115 writer.writeModel(getMainModel());
116 } 116 }
117 }
118 }
119 }
120
121 } else if (message.getMethod() == "exportlayer") {
122
123 QString path;
124 if (message.getArgCount() == 1 &&
125 message.getArg(0).canConvert(QVariant::String)) {
126 path = message.getArg(0).toString();
127 if (QFileInfo(path).exists()) {
128 SVDEBUG << "OSCHandler: Refusing to overwrite existing file in layer export" << endl;
129 } else {
130 Pane *currentPane = nullptr;
131 Layer *currentLayer = nullptr;
132 if (m_paneStack) currentPane = m_paneStack->getCurrentPane();
133 if (currentPane) currentLayer = currentPane->getSelectedLayer();
134 if (currentLayer) {
135 QString error;
136 if (!exportLayerTo(currentLayer, path, error)) {
137 SVCERR << "OSCHandler: Failed to export current layer to " << path << ": " << error << endl;
138 }
139 } else {
140 SVCERR << "OSCHandler: No current layer to export" << endl;
117 } 141 }
118 } 142 }
119 } 143 }
120 144
121 } else if (message.getMethod() == "jump" || 145 } else if (message.getMethod() == "jump" ||