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

Method refreshPluginSelectorKnob

Engine/WriteNode.cpp:889–934  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

887} // WriteNodePrivate::createWriteNode
888
889void
890WriteNodePrivate::refreshPluginSelectorKnob()
891{
892 KnobOutputFilePtr fileKnob = outputFileKnob.lock();
893
894 assert(fileKnob);
895 std::string filePattern = fileKnob->getValue();
896 std::vector<ChoiceOption> entries;
897 entries.push_back(ChoiceOption(kPluginSelectorParamEntryDefault, "", tr("Use the default plug-in chosen from the Preferences to write this file format").toStdString()));
898
899 QString qpattern = QString::fromUtf8( filePattern.c_str() );
900 std::string ext = QtCompat::removeFileExtension(qpattern).toLower().toStdString();
901 std::string pluginID;
902 if ( !ext.empty() ) {
903 pluginID = appPTR->getWriterPluginIDForFileType(ext);
904 IOPluginSetForFormat writersForFormat;
905 appPTR->getWritersForFormat(ext, &writersForFormat);
906
907 // Reverse it so that we sort them by decreasing score order
908 for (IOPluginSetForFormat::reverse_iterator it = writersForFormat.rbegin(); it != writersForFormat.rend(); ++it) {
909 Plugin* plugin = appPTR->getPluginBinary(QString::fromUtf8( it->pluginID.c_str() ), -1, -1, false);
910 std::stringstream ss;
911 ss << "Use " << plugin->getPluginLabel().toStdString() << " version ";
912 ss << plugin->getMajorVersion() << "." << plugin->getMinorVersion();
913 ss << " to write this file format";
914 entries.push_back( ChoiceOption(plugin->getPluginID().toStdString(), "", ss.str()));
915 }
916 }
917
918 KnobChoicePtr pluginChoice = pluginSelectorKnob.lock();
919
920 pluginChoice->populateChoices(entries);
921 pluginChoice->blockValueChanges();
922 pluginChoice->resetToDefaultValue(0);
923 pluginChoice->unblockValueChanges();
924 if (entries.size() <= 2) {
925 pluginChoice->setSecret(true);
926 } else {
927 pluginChoice->setSecret(false);
928 }
929
930 KnobStringPtr pluginIDKnob = pluginIDStringKnob.lock();
931 pluginIDKnob->blockValueChanges();
932 pluginIDKnob->setValue(pluginID);
933 pluginIDKnob->unblockValueChanges();
934}
935
936bool
937WriteNode::isWriter() const

Callers 3

onEffectCreatedMethod · 0.45
knobChangedMethod · 0.45

Calls 15

ChoiceOptionFunction · 0.85
removeFileExtensionFunction · 0.85
toStdStringMethod · 0.80
emptyMethod · 0.80
getWritersForFormatMethod · 0.80
getPluginBinaryMethod · 0.80
populateChoicesMethod · 0.80
blockValueChangesMethod · 0.80
resetToDefaultValueMethod · 0.80
unblockValueChangesMethod · 0.80
lockMethod · 0.45

Tested by

no test coverage detected