Mercurial > hg > sonic-visualiser
comparison main/MainWindow.cpp @ 121:3fff180a254b
* Add basics of an Export Image File function
author | Chris Cannam |
---|---|
date | Mon, 12 Mar 2007 15:36:31 +0000 |
parents | b4110b17bca8 |
children | a45733cc3939 |
comparison
equal
deleted
inserted
replaced
120:863a470df510 | 121:3fff180a254b |
---|---|
309 return ff->getOpenFileName(type, m_audioFile); | 309 return ff->getOpenFileName(type, m_audioFile); |
310 case FileFinder::LayerFile: | 310 case FileFinder::LayerFile: |
311 return ff->getOpenFileName(type, m_sessionFile); | 311 return ff->getOpenFileName(type, m_sessionFile); |
312 case FileFinder::SessionOrAudioFile: | 312 case FileFinder::SessionOrAudioFile: |
313 return ff->getOpenFileName(type, m_sessionFile); | 313 return ff->getOpenFileName(type, m_sessionFile); |
314 case FileFinder::ImageFile: | |
315 return ff->getOpenFileName(type, m_sessionFile); | |
314 case FileFinder::AnyFile: | 316 case FileFinder::AnyFile: |
315 if (getMainModel() != 0 && | 317 if (getMainModel() != 0 && |
316 m_paneStack != 0 && | 318 m_paneStack != 0 && |
317 m_paneStack->getCurrentPane() != 0) { // can import a layer | 319 m_paneStack->getCurrentPane() != 0) { // can import a layer |
318 return ff->getOpenFileName(FileFinder::AnyFile, m_sessionFile); | 320 return ff->getOpenFileName(FileFinder::AnyFile, m_sessionFile); |
335 return ff->getSaveFileName(type, m_audioFile); | 337 return ff->getSaveFileName(type, m_audioFile); |
336 case FileFinder::LayerFile: | 338 case FileFinder::LayerFile: |
337 return ff->getSaveFileName(type, m_sessionFile); | 339 return ff->getSaveFileName(type, m_sessionFile); |
338 case FileFinder::SessionOrAudioFile: | 340 case FileFinder::SessionOrAudioFile: |
339 return ff->getSaveFileName(type, m_sessionFile); | 341 return ff->getSaveFileName(type, m_sessionFile); |
342 case FileFinder::ImageFile: | |
343 return ff->getSaveFileName(type, m_sessionFile); | |
340 case FileFinder::AnyFile: | 344 case FileFinder::AnyFile: |
341 return ff->getSaveFileName(type, m_sessionFile); | 345 return ff->getSaveFileName(type, m_sessionFile); |
342 } | 346 } |
343 return ""; | 347 return ""; |
344 } | 348 } |
478 | 482 |
479 action = new QAction(tr("Export Annotation Layer..."), this); | 483 action = new QAction(tr("Export Annotation Layer..."), this); |
480 action->setStatusTip(tr("Export layer data to a file")); | 484 action->setStatusTip(tr("Export layer data to a file")); |
481 connect(action, SIGNAL(triggered()), this, SLOT(exportLayer())); | 485 connect(action, SIGNAL(triggered()), this, SLOT(exportLayer())); |
482 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool))); | 486 connect(this, SIGNAL(canExportLayer(bool)), action, SLOT(setEnabled(bool))); |
487 menu->addAction(action); | |
488 | |
489 menu->addSeparator(); | |
490 | |
491 action = new QAction(tr("Export Image File..."), this); | |
492 action->setStatusTip(tr("Export a single pane to an image file")); | |
493 connect(action, SIGNAL(triggered()), this, SLOT(exportImage())); | |
494 connect(this, SIGNAL(canExportImage(bool)), action, SLOT(setEnabled(bool))); | |
483 menu->addAction(action); | 495 menu->addAction(action); |
484 | 496 |
485 menu->addSeparator(); | 497 menu->addSeparator(); |
486 | 498 |
487 action = new QAction(tr("Open Lo&cation..."), this); | 499 action = new QAction(tr("Open Lo&cation..."), this); |
1617 emit canImportMoreAudio(haveMainModel); | 1629 emit canImportMoreAudio(haveMainModel); |
1618 emit canImportLayer(haveMainModel && haveCurrentPane); | 1630 emit canImportLayer(haveMainModel && haveCurrentPane); |
1619 emit canExportAudio(haveMainModel); | 1631 emit canExportAudio(haveMainModel); |
1620 emit canExportLayer(haveMainModel && | 1632 emit canExportLayer(haveMainModel && |
1621 (haveCurrentEditableLayer || haveCurrentColour3DPlot)); | 1633 (haveCurrentEditableLayer || haveCurrentColour3DPlot)); |
1634 emit canExportImage(haveMainModel && haveCurrentPane); | |
1622 emit canDeleteCurrentLayer(haveCurrentLayer); | 1635 emit canDeleteCurrentLayer(haveCurrentLayer); |
1623 emit canRenameLayer(haveCurrentLayer); | 1636 emit canRenameLayer(haveCurrentLayer); |
1624 emit canEditLayer(haveCurrentEditableLayer); | 1637 emit canEditLayer(haveCurrentEditableLayer); |
1625 emit canSelect(haveMainModel && haveCurrentPane); | 1638 emit canSelect(haveMainModel && haveCurrentPane); |
1626 emit canPlay(/*!!! haveMainModel && */ havePlayTarget); | 1639 emit canPlay(/*!!! haveMainModel && */ havePlayTarget); |
2274 if (error != "") { | 2287 if (error != "") { |
2275 QMessageBox::critical(this, tr("Failed to write file"), error); | 2288 QMessageBox::critical(this, tr("Failed to write file"), error); |
2276 } else { | 2289 } else { |
2277 m_recentFiles.addFile(path); | 2290 m_recentFiles.addFile(path); |
2278 } | 2291 } |
2292 } | |
2293 | |
2294 void | |
2295 MainWindow::exportImage() | |
2296 { | |
2297 Pane *pane = m_paneStack->getCurrentPane(); | |
2298 if (!pane) return; | |
2299 | |
2300 QString path = getSaveFileName(FileFinder::ImageFile); | |
2301 | |
2302 if (path == "") return; | |
2303 | |
2304 if (QFileInfo(path).suffix() == "") path += ".png"; | |
2305 | |
2306 QImage *image = pane->toNewImage(); | |
2307 if (!image) return; | |
2308 | |
2309 if (!image->save(path, "PNG")) { | |
2310 QMessageBox::critical(this, tr("Failed to save image file"), | |
2311 tr("Failed to save image file %1").arg(path)); | |
2312 } | |
2313 | |
2314 delete image; | |
2279 } | 2315 } |
2280 | 2316 |
2281 MainWindow::FileOpenStatus | 2317 MainWindow::FileOpenStatus |
2282 MainWindow::openAudioFile(QString path, AudioFileOpenMode mode) | 2318 MainWindow::openAudioFile(QString path, AudioFileOpenMode mode) |
2283 { | 2319 { |