Exemple #1
0
void
KnobGuiChoice::onEntryAppended(const QString& entry,
                               const QString& help)
{
    KnobChoicePtr knob = _knob.lock();

    if ( knob->getHostCanAddOptions() &&
         ( ( knob->getName() == kNatronOfxParamOutputChannels) || ( knob->getName() == kOutputChannelsKnobName) ) ) {
        _comboBox->insertItem(_comboBox->count() - 1, entry, QIcon(), QKeySequence(), help);
    } else {
        _comboBox->addItem(entry, QIcon(), QKeySequence(), help);
    }
    int activeIndex = knob->getValue();
    if (activeIndex >= 0) {
        _comboBox->setCurrentIndex_no_emit(activeIndex);
    } else {
        _comboBox->setCurrentText( QString::fromUtf8( knob->getActiveEntryText_mt_safe().c_str() ) );
    }
}
Exemple #2
0
void
KnobGuiChoice::onEntriesPopulated()
{
    KnobChoicePtr knob = _knob.lock();

    _comboBox->clear();
    std::vector<std::string> entries = knob->getEntries_mt_safe();
    const std::vector<std::string> help =  knob->getEntriesHelp_mt_safe();
    std::string activeEntry = knob->getActiveEntryText_mt_safe();

    for (U32 i = 0; i < entries.size(); ++i) {
        std::string helpStr;
        if ( !help.empty() && !help[i].empty() ) {
            helpStr = help[i];
        }

        _comboBox->addItem( QString::fromUtf8( entries[i].c_str() ), QIcon(), QKeySequence(), QString::fromUtf8( helpStr.c_str() ) );
    }
    // the "New" menu is only added to known parameters (e.g. the choice of output channels)
    if ( knob->getHostCanAddOptions() &&
         ( ( knob->getName() == kNatronOfxParamOutputChannels) || ( knob->getName() == kOutputChannelsKnobName) ) ) {
        _comboBox->addItemNew();
    }
    ///we don't use setCurrentIndex because the signal emitted by combobox will call onCurrentIndexChanged and
    ///we don't want that to happen because the index actually didn't change.
    if ( _comboBox->isCascading() || activeEntry.empty() ) {
        _comboBox->setCurrentIndex_no_emit( knob->getValue() );
    } else {
        _comboBox->setCurrentText_no_emit( QString::fromUtf8( activeEntry.c_str() ) );
    }


    if ( !activeEntry.empty() ) {
        bool activeIndexPresent = knob->isActiveEntryPresentInEntries();
        if (!activeIndexPresent) {
            QString error = tr("The value set to this parameter no longer exist in the menu. Right click and press Refresh Menu to update the menu and then pick a new value.");
            setWarningValue( KnobGui::eKnobWarningChoiceMenuOutOfDate, GuiUtils::convertFromPlainText(error, Qt::WhiteSpaceNormal) );
        } else {
            setWarningValue( KnobGui::eKnobWarningChoiceMenuOutOfDate, QString() );
        }
    }
}