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

Method refreshPluginSelectorKnob

Engine/ReadNode.cpp:825–873  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823}
824
825void
826ReadNodePrivate::refreshPluginSelectorKnob()
827{
828 KnobFilePtr fileKnob = inputFileKnob.lock();
829
830 assert(fileKnob);
831 std::string filePattern = fileKnob->getValue();
832 std::vector<ChoiceOption> entries, help;
833 entries.push_back(ChoiceOption(kPluginSelectorParamEntryDefault, "", ReadNode::tr("Use the default plug-in chosen from the Preferences to read this file format").toStdString()));
834
835 QString qpattern = QString::fromUtf8( filePattern.c_str() );
836 std::string ext = QtCompat::removeFileExtension(qpattern).toLower().toStdString();
837 std::string pluginID;
838 if ( !ext.empty() ) {
839 pluginID = appPTR->getReaderPluginIDForFileType(ext);
840 IOPluginSetForFormat readersForFormat;
841 appPTR->getReadersForFormat(ext, &readersForFormat);
842
843 // Reverse it so that we sort them by decreasing score order
844 for (IOPluginSetForFormat::reverse_iterator it = readersForFormat.rbegin(); it != readersForFormat.rend(); ++it) {
845 Plugin* plugin = appPTR->getPluginBinary(QString::fromUtf8( it->pluginID.c_str() ), -1, -1, false);
846 std::stringstream ss;
847 ss << "Use " << plugin->getPluginLabel().toStdString() << " version ";
848 ss << plugin->getMajorVersion() << "." << plugin->getMinorVersion();
849 ss << " to read this file format";
850 entries.push_back( ChoiceOption(plugin->getPluginID().toStdString(), "", ss.str()));
851 }
852 }
853
854 KnobChoicePtr pluginChoice = pluginSelectorKnob.lock();
855
856 pluginChoice->populateChoices(entries);
857 pluginChoice->blockValueChanges();
858 pluginChoice->resetToDefaultValue(0);
859 pluginChoice->unblockValueChanges();
860 if (entries.size() <= 2) {
861 pluginChoice->setSecret(true);
862 } else {
863 pluginChoice->setSecret(false);
864 }
865
866 KnobStringPtr pluginIDKnob = pluginIDStringKnob.lock();
867 pluginIDKnob->blockValueChanges();
868 pluginIDKnob->setValue(pluginID);
869 pluginIDKnob->unblockValueChanges();
870
871 refreshFileInfoVisibility(pluginID);
872
873} // ReadNodePrivate::refreshPluginSelectorKnob
874
875bool
876ReadNode::isReader() const

Callers 3

onEffectCreatedMethod · 0.45
knobChangedMethod · 0.45

Calls 15

ChoiceOptionFunction · 0.85
removeFileExtensionFunction · 0.85
toStdStringMethod · 0.80
emptyMethod · 0.80
getReadersForFormatMethod · 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