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