MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / handleImageFileOpenRequest

Method handleImageFileOpenRequest

Gui/GuiApplicationManager10.cpp:391–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389}
390
391bool
392GuiApplicationManager::handleImageFileOpenRequest(const std::string& filename)
393{
394 QString fileCopy( QString::fromUtf8( filename.c_str() ) );
395 QString ext = QtCompat::removeFileExtension(fileCopy);
396 std::string readerFileType = appPTR->getReaderPluginIDForFileType( ext.toStdString() );
397 AppInstancePtr mainInstance = appPTR->getTopLevelInstance();
398 bool instanceCreated = false;
399
400 if ( !mainInstance || !mainInstance->getProject()->isGraphWorthLess() ) {
401 CLArgs cl;
402 mainInstance = appPTR->newAppInstance(cl, false);
403 instanceCreated = true;
404 }
405 if (!mainInstance) {
406 return false;
407 }
408
409 CreateNodeArgs args(readerFileType, mainInstance->getProject() );
410 args.addParamDefaultValue<std::string>(kOfxImageEffectFileParamName, filename);
411 args.setProperty<bool>(kCreateNodeArgsPropAddUndoRedoCommand, false);
412 args.setProperty<bool>(kCreateNodeArgsPropAutoConnect, false);
413 NodePtr readerNode = mainInstance->createNode(args);
414 if (!readerNode && instanceCreated) {
415 mainInstance->quit();
416
417 return false;
418 }
419
420 ///Find and connect the viewer
421 NodesList allNodes = mainInstance->getProject()->getNodes();
422 NodePtr viewerFound;
423 for (NodesList::iterator it = allNodes.begin(); it != allNodes.end(); ++it) {
424 if ( (*it)->isEffectViewer() ) {
425 viewerFound = *it;
426 break;
427 }
428 }
429
430 ///If no viewer is found, create it
431 if (!viewerFound) {
432 CreateNodeArgs args(PLUGINID_NATRON_VIEWER, mainInstance->getProject() );
433 args.setProperty<bool>(kCreateNodeArgsPropAddUndoRedoCommand, false);
434 args.setProperty<bool>(kCreateNodeArgsPropAutoConnect, false);
435 viewerFound = mainInstance->createNode(args);
436 }
437 if (viewerFound) {
438 viewerFound->connectInput(readerNode, 0);
439 } else {
440 return false;
441 }
442
443 return true;
444}
445
446void
447GuiApplicationManager::handleOpenFileRequest()

Callers 1

handleFileOpenEventMethod · 0.80

Calls 13

removeFileExtensionFunction · 0.85
toStdStringMethod · 0.80
getTopLevelInstanceMethod · 0.80
isGraphWorthLessMethod · 0.80
getProjectMethod · 0.80
newAppInstanceMethod · 0.80
getNodesMethod · 0.80
createNodeMethod · 0.45
quitMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected