| 887 | } // WriteNodePrivate::createWriteNode |
| 888 | |
| 889 | void |
| 890 | WriteNodePrivate::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 | |
| 936 | bool |
| 937 | WriteNode::isWriter() const |
no test coverage detected