Beispiel #1
0
Chord::Chord(const Event& e)
    : m_isUserChord(false)
{
    std::string f;
    bool ok;

    ok = e.get<String>(RootPropertyName, f);
    if (ok)
        m_root = strtoqstr(f);

    ok = e.get<String>(ExtPropertyName, f);
    if (ok) {
        if (f.length() == 0)
            m_ext = QString::null;
        else
            m_ext = strtoqstr(f);
    }
    
    ok = e.get<String>(FingeringPropertyName, f);
    if (ok) {
        QString qf(strtoqstr(f));
        QString errString;
    
        Fingering fingering = Fingering::parseFingering(qf, errString);    
        setFingering(fingering);
    }
}
void
ControlParameterEditDialog::populate()
{
    m_nameEdit->setText(strtoqstr(m_control->getName()));

    m_description->setText(strtoqstr(m_control->getDescription()));
    m_controllerBox->setValue(int(m_control->getControllerValue()));

    QString hexValue;
    hexValue.sprintf("(0x%x)", m_control->getControllerValue());
    m_hexValue->setText(hexValue);

    m_minBox->setValue(m_control->getMin());
    m_maxBox->setValue(m_control->getMax());
    m_defaultBox->setValue(m_control->getDefault());

    int pos = 0, setItem = 0;
    ColourMap &colourMap = m_doc->getComposition().getGeneralColourMap();
    RCMap::const_iterator it;

    // I can't believe we never fixed this in all these years.  The way this was
    // structured, it was impossible for setItem to increment in order to arrive
    // at any useful value, so the color always came out "Default" 100% of the
    // time.
    for (it = colourMap.begin(); it != colourMap.end(); ++it) {
        pos++;
        if (m_control->getColourIndex() == it->first) setItem = (pos - 1);
    }

    m_colourCombo->setCurrentIndex(setItem);

    // set combo position
    m_ipbPosition->setCurrentIndex(m_control->getIPBPosition() + 1);

    // If the type has changed and there are no defaults then we have to
    // supply some.
    //
    if (qstrtostr(m_typeCombo->currentText()) == PitchBend::EventType ||
            qstrtostr(m_typeCombo->currentText()) == KeyPressure::EventType ||
            qstrtostr(m_typeCombo->currentText()) == ChannelPressure::EventType) {
        m_controllerBox->setEnabled(false);
        m_ipbPosition->setEnabled(false);
        m_colourCombo->setEnabled(false);
        m_hexValue->setEnabled(false);
        m_minBox->setEnabled(false);
        m_maxBox->setEnabled(false);
        m_defaultBox->setEnabled(false);
    } else if (qstrtostr(m_typeCombo->currentText()) == Controller::EventType) {
        m_controllerBox->setEnabled(true);
        m_ipbPosition->setEnabled(true);
        m_colourCombo->setEnabled(true);
        m_hexValue->setEnabled(true);
        m_minBox->setEnabled(true);
        m_maxBox->setEnabled(true);
        m_defaultBox->setEnabled(true);
    }

}
Beispiel #3
0
void
MarkerRuler::slotDeleteMarker()
{
    RG_DEBUG << "MarkerRuler::slotDeleteMarker()\n";
    
    Rosegarden::Marker* marker = getMarkerAtClickPosition();
    
    if (marker)
        emit deleteMarker(marker->getID(),
                          marker->getTime(),
                          strtoqstr(marker->getName()),
                          strtoqstr(marker->getDescription()));                          
}
void
UseOrnamentDialog::accept()
{
    QSettings settings;
    settings.beginGroup( NotationViewConfigGroup );

    settings.setValue("useornamentmark", strtoqstr(getMark()));
    settings.setValue("useornamenttiming", strtoqstr(getTimeAdjust()));
    settings.setValue("useornamentretune", m_retune->isChecked());
    settings.setValue("useornamentlastornament", m_ornament->currentIndex());

    settings.endGroup();

    QDialog::accept();
}
void
GuitarChordSelectorDialog::populateFingerings(const Guitar::ChordMap::chordarray& chords, const Guitar::Fingering& refFingering)
{
    m_fingeringsList->clear();

    for(Guitar::ChordMap::chordarray::const_iterator i = chords.begin(); i != chords.end(); ++i) {
        const Guitar::Chord& chord = *i; 
        QString fingeringString = strtoqstr(chord.getFingering().toString() );

// RG_DEBUG << "GuitarChordSelectorDialog::populateFingerings " << chord;

        QIcon fingeringPixmap = getFingeringPixmap(chord.getFingering());
        
        FingeringListBoxItem *item = new FingeringListBoxItem(chord, m_fingeringsList, fingeringPixmap, fingeringString);

// RG_DEBUG << "GuitarChordSelectorDialog::populateFingerings(): " <<
//   fingeringString;

        if (refFingering == chord.getFingering()) {

// RG_DEBUG << "GuitarChordSelectorDialog::populateFingerings - "
//   "fingering found " << fingeringString;

            //m_fingeringsList->setSelected(item, true);
            m_fingeringsList->setCurrentItem(item);
        }
    }

}
void
AudioPluginOSCGUIManager::updateProgram(InstrumentId instrument, int position)
{
    RG_DEBUG << "AudioPluginOSCGUIManager::updateProgram(" << instrument << ","
             << position << ")" << endl;

    if (m_guis.find(instrument) == m_guis.end() ||
            m_guis[instrument].find(position) == m_guis[instrument].end())
        return ;

    PluginContainer *container = 0;
    container = m_studio->getContainerById(instrument);
    if (!container) return;

    AudioPluginInstance *pluginInstance = container->getPlugin(position);
    if (!pluginInstance) return;

    unsigned long rv = StudioControl::getPluginProgram
                       (pluginInstance->getMappedId(),
                        strtoqstr(pluginInstance->getProgram()));

    int bank = rv >> 16;
    int program = rv - (bank << 16);

    RG_DEBUG << "AudioPluginOSCGUIManager::updateProgram(" << instrument << ","
             << position << "): rv " << rv << ", bank " << bank << ", program " << program << endl;

    m_guis[instrument][position]->sendProgram(bank, program);
}
QString
AddIndicationCommand::getGlobalName(std::string indicationType)
{
    if (indicationType == Indication::Slur) {
        return tr("Add S&lur");
    } else if (indicationType == Indication::PhrasingSlur) {
        return tr("Add &Phrasing Slur");
    } else if (indicationType == Indication::QuindicesimaUp) {
        return tr("Add Double-Octave Up");
    } else if (indicationType == Indication::OttavaUp) {
        return tr("Add Octave &Up");
    } else if (indicationType == Indication::OttavaDown) {
        return tr("Add Octave &Down");
    } else if (indicationType == Indication::QuindicesimaDown) {
        return tr("Add Double Octave Down");

        // We used to generate these ones from the internal names plus
        // caps, but that makes them untranslateable:
    } else if (indicationType == Indication::Crescendo) {
        return tr("Add &Crescendo");
    } else if (indicationType == Indication::Decrescendo) {
        return tr("Add &Decrescendo");
    } else if (indicationType == Indication::Glissando) {
        return tr("Add &Glissando");
    } else if (indicationType == Indication::TrillLine) {
        return tr("Add Tri&ll With Line");
    } else if (indicationType == Indication::FigParameterChord) {
        return tr("Add Parameter Chord");
    } else if (indicationType == Indication::Figuration) {
        return tr("Add Figuration");
    }

    QString n = tr("Add &%1%2").arg((char)toupper(indicationType[0])).arg(strtoqstr(indicationType.substr(1)));
    return n;
}
void
KeySignatureDialog::slotKeyNameChanged(int index)
{
    if (m_ignoreComboChanges)
        return ;

    if (m_explanatoryLabel)
        m_explanatoryLabel->hide();

    const QString s = m_keyCombo->itemData(index).toString();
    std::string name(getKeyName(s, m_key.isMinor()));

    try {
        m_key = Rosegarden::Key(name);
        setValid(true);

        int space = name.find(' ');
        if (space > 0)
            name = name.substr(0, space);
        m_keyCombo->setEditText(strtoqstr(name));

    } catch (Rosegarden::Key::BadKeyName s) {
        RG_WARNING << s.getMessage();
        setValid(false);
    }

    redrawKeyPixmap();
}
QString
AudioPluginOSCGUIManager::getFriendlyName(InstrumentId instrument, int position,
        QString)
{
    PluginContainer *container = m_studio->getContainerById(instrument);
    if (!container)
        return tr("Rosegarden Plugin");
    else {
        if (position == int(Instrument::SYNTH_PLUGIN_POSITION)) {
            return tr("Rosegarden: %1").arg(strtoqstr(container->getAlias()));
        } else {
            return tr("Rosegarden: %1: %2").arg(strtoqstr(container->getAlias()))
                   .arg(tr("Plugin slot %1").arg(position + 1));
        }
    }
}
void
AudioPluginOSCGUIManager::startGUI(InstrumentId instrument, int position)
{
    RG_DEBUG << "AudioPluginOSCGUIManager::startGUI: " << instrument << "," << position
             << endl;

    checkOSCThread();

    if (m_guis.find(instrument) != m_guis.end() &&
            m_guis[instrument].find(position) != m_guis[instrument].end()) {
        RG_DEBUG << "stopping GUI first";
        stopGUI(instrument, position);
    }

    // check the label
    PluginContainer *container = 0;
    container = m_studio->getContainerById(instrument);
    if (!container) {
        RG_DEBUG << "AudioPluginOSCGUIManager::startGUI: no such instrument or buss as "
                 << instrument << endl;
        return;
    }

    AudioPluginInstance *pluginInstance = container->getPlugin(position);
    if (!pluginInstance) {
        RG_DEBUG << "AudioPluginOSCGUIManager::startGUI: no plugin at position "
                 << position << " for instrument " << instrument << endl;
        return ;
    }

    try {
        AudioPluginOSCGUI *gui =
            new AudioPluginOSCGUI(pluginInstance,
                                  getOSCUrl(instrument,
                                            position,
                                            strtoqstr(pluginInstance->getIdentifier())),
                                  getFriendlyName(instrument,
                                          position,
                                          strtoqstr(pluginInstance->getIdentifier())));
        m_guis[instrument][position] = gui;

    } catch (Exception e) {

        RG_DEBUG << "AudioPluginOSCGUIManager::startGUI: failed to start GUI: "
                 << e.getMessage() << endl;
    }
}
void
MidiKeyMappingEditor::reset()
{
    if (!m_device)
        return ;

    setTitle(strtoqstr(m_mappingName));

    const MidiKeyMapping *m = m_device->getKeyMappingByName(m_mappingName);

    if (!m) {
        RG_DEBUG << "WARNING: MidiKeyMappingEditor::reset: No such mapping as " << m_mappingName;
        return;
    }

    m_mapping = *m;

    
    blockAllSignals(true);

    // Librarian details
    //
    m_librarian->setText(strtoqstr(m_device->getLibrarianName()));
    m_librarianEmail->setText(strtoqstr(m_device->getLibrarianEmail()));

    // Clear each LineEdit and perform a more secure scan of mappings.
    for (unsigned int i = 0; i < (unsigned int)m_names.size(); i++) {
        m_names[i]->clear();

        for (MidiKeyMapping::KeyNameMap::const_iterator it =
                    m_mapping.getMap().begin();
                it != m_mapping.getMap().end(); ++it) {

            int index = it->first;

            if ( (int)i == index) {
                QString name = strtoqstr(it->second);
                m_completions << name;
                m_names[i]->setText(name);
                m_names[i]->setCursorPosition(0);
            }
        }
    }

    blockAllSignals(false);
}
Beispiel #12
0
void
UseOrnamentDialog::setupFromConfig()
{
    QSettings settings;
    settings.beginGroup( NotationViewConfigGroup );

    Mark mark = qstrtostr(settings.value("useornamentmark", "trill").toString());
    int seg = settings.value("useornamentlastornament", 0).toInt() ;
    std::string timing = qstrtostr(settings.value("useornamenttiming",
            strtoqstr(BaseProperties::TRIGGER_SEGMENT_ADJUST_SQUISH)).toString());
    bool retune = qStrToBool( settings.value("useornamentretune", "true" ) ) ;

    size_t i = 0;
    for (i = 0; i < m_marks.size(); ++i) {
        if (mark == m_marks[i]) {
            m_mark->setCurrentIndex(i);
            m_text->setEnabled(false);
            break;
        }
    }
    if (i >= m_marks.size()) {
        m_mark->setCurrentIndex(m_marks.size());
        m_text->setEnabled(true);
        m_text->setText(strtoqstr(Marks::getTextFromMark(mark)));
    }

    if (seg >= 0 && seg < m_ornament->count())
        m_ornament->setCurrentIndex(seg);

    if (timing == BaseProperties::TRIGGER_SEGMENT_ADJUST_NONE) {
        m_adjustTime->setCurrentIndex(0);
    } else if (timing == BaseProperties::TRIGGER_SEGMENT_ADJUST_SQUISH) {
        m_adjustTime->setCurrentIndex(3);
    } else if (timing == BaseProperties::TRIGGER_SEGMENT_ADJUST_SYNC_START) {
        m_adjustTime->setCurrentIndex(1);
    } else if (timing == BaseProperties::TRIGGER_SEGMENT_ADJUST_SYNC_END) {
        m_adjustTime->setCurrentIndex(2);
    }

    m_retune->setChecked(retune);

    settings.endGroup();
}
void
MidiProgramsEditor::slotKeyMapButtonPressed()
{
    QToolButton* button = dynamic_cast<QToolButton*>(const_cast<QObject *>(sender()));
    if (!button) {
        RG_DEBUG << "MidiProgramsEditor::slotKeyMapButtonPressed() : %%% ERROR - signal sender is not a QPushButton\n";
        return ;
    }

//    std::cout << "editor button name" << button->objectName().toStdString() << std::endl;

    QString senderName = button->objectName();

    if (!m_device)
        return ;

    const KeyMappingList &kml = m_device->getKeyMappings();
    if (kml.empty())
        return ;

    // Adjust value back to zero rated
    //
    unsigned int id = senderName.toUInt() - 1;
    MidiProgram *program = getProgram(*getCurrentBank(), id);
    if (!program)
        return ;
    m_currentMenuProgram = id;

    RosegardenPopupMenu *menu = new RosegardenPopupMenu(button);

    const MidiKeyMapping *currentMapping =
        m_device->getKeyMappingForProgram(*program);

    int currentKeyMap = 0;

    QAction *a = menu->addAction(tr("<no key mapping>"));
    a->setObjectName("0");

    for (size_t i = 0; i < kml.size(); ++i) {
        a = menu->addAction(strtoqstr(kml[i].getName()));
        a->setObjectName(QString("%1").arg(i+1));
        if (currentMapping && (kml[i] == *currentMapping)) currentKeyMap = int(i + 1);
    }

    connect(menu, SIGNAL(triggered(QAction *)),
            this, SLOT(slotKeyMapMenuItemSelected(QAction *)));

    int itemHeight = menu->actionGeometry(actions().value(0)).height() + 2;
    QPoint pos = QCursor::pos();

    pos.rx() -= 10;
    pos.ry() -= (itemHeight / 2 + currentKeyMap * itemHeight);

    menu->popup(pos);
}
Beispiel #14
0
void
TextRuler::paintEvent(QPaintEvent* e)
{
    QPainter paint(this);
    paint.setPen(GUIPalette::getColour(GUIPalette::TextRulerForeground));

    paint.setClipRegion(e->region());
    paint.setClipRect(e->rect().normalized());

    QRect clipRect = paint.clipRegion().boundingRect();

    timeT from = m_rulerScale->getTimeForX
                 (clipRect.x() - m_currentXOffset - 100);
    timeT to = m_rulerScale->getTimeForX
               (clipRect.x() + clipRect.width() - m_currentXOffset + 100);

    for (Segment::iterator i = m_segment->findTime(from);
            i != m_segment->findTime(to) && i != m_segment->end(); ++i) {

        if (!(*i)->isa(Text::EventType))
            continue;

        std::string text;
        if (!(*i)->get
                <String>(Text::TextPropertyName, text)) {
            RG_DEBUG
            << "Warning: TextRuler::paintEvent: No text in text event"
            << endl;
            continue;
        }

        QRect bounds = m_fontMetrics.boundingRect(strtoqstr(text));

        double x = m_rulerScale->getXForTime((*i)->getAbsoluteTime()) +
                   m_currentXOffset - bounds.width() / 2;

        int y = height() / 2 + bounds.height() / 2;

        paint.drawText(static_cast<int>(x), y, strtoqstr(text));
    }
}
void
SegmentLabelCommand::execute()
{
    bool addLabels = false;
    if (m_labels.empty())
        addLabels = true;

    for (size_t i = 0; i < m_segments.size(); ++i) {
        if (addLabels)
            m_labels.push_back(strtoqstr(m_segments[i]->getLabel()));

        m_segments[i]->setLabel(qstrtostr(m_newLabel));
    }
}
void
MidiProgramsEditor::slotKeyMapMenuItemSelected(int i)
{
    if (!m_device)
        return ;

    const KeyMappingList &kml = m_device->getKeyMappings();
    if (kml.empty())
        return ;

    MidiProgram *program = getProgram(*getCurrentBank(), m_currentMenuProgram);
    if (!program)
        return ;

    std::string newMapping;

    if (i == 0) { // no key mapping
        newMapping = "";
    } else {
        --i;
        if (i < (int)kml.size()) {
            newMapping = kml[i].getName();
        }
    }

    m_device->setKeyMappingForProgram(*program, newMapping);
//     QString pixmapDir = KGlobal::dirs()->findResource("appdata", "pixmaps/");
    IconLoader il;
    QIcon icon;

    bool haveKeyMappings = (m_device->getKeyMappings().size() > 0);  //@@@ JAS restored from before port/
    QToolButton *btn = getKeyMapButton(m_currentMenuProgram);

    if (newMapping.empty()) {
        icon = il.load( "key-white" );
        if( ! icon.isNull() ) {
            btn->setIcon( icon );
        }
        // QToolTip::remove(btn);
        btn->setToolTip(QString(""));       //@@@ Usefull ?
    } else {
        icon = il.load( "key-green" );
        if( ! icon.isNull() ){
            btn->setIcon( icon );
        }
        btn->setToolTip(tr("Key Mapping: %1").arg(strtoqstr(newMapping)));
    }
    btn->setEnabled(haveKeyMappings);
}
void
KeySignatureDialog::regenerateKeyCombo()
{
    if (m_explanatoryLabel)
        m_explanatoryLabel->hide();

    m_ignoreComboChanges = true;
    QString currentText = m_keyCombo->currentText();
    Rosegarden::Key::KeyList keys(Rosegarden::Key::getKeys(m_key.isMinor()));
    m_keyCombo->clear();

    std::sort(keys.begin(), keys.end(), KeyNameComparator());
    bool textSet = false;

    for (Rosegarden::Key::KeyList::iterator i = keys.begin();
            i != keys.end(); ++i) {

        QString name(strtoqstr(i->getName()));
        int space = name.indexOf(' ');
        if (space > 0)
            name = name.left(space);

        // translation required; translation from QObject::tr to pull
        // translations from (generated) InstrumentStrings.cpp, must have "note
        // name" to distinguish from keyboard shortcut, even though this is a
        // key name
        // But m_key object needed to display the key pixmap can't be easily
        // obtained from a translated key name. That's why the untranslated key
        // name is now stored in the user data associated to each QComboBox
        // item.
        QVariant untranslatedName(name);
        m_keyCombo->addItem(QObject::tr(name.toStdString().c_str(), "note name"),
                            untranslatedName);

        if (m_valid && (*i == m_key)) {
            m_keyCombo->setCurrentIndex(m_keyCombo->count() - 1);
            textSet = true;
        }
    }

    if (!textSet) {
        m_keyCombo->setEditText(currentText);
    }
    m_ignoreComboChanges = false;
}
bool
AudioPluginOSCGUIManager::hasGUI(InstrumentId instrument, int position)
{
    PluginContainer *container = 0;
    container = m_studio->getContainerById(instrument);
    if (!container) return false;

    AudioPluginInstance *pluginInstance = container->getPlugin(position);
    if (!pluginInstance) return false;

    try {
        QString filePath = AudioPluginOSCGUI::getGUIFilePath
                           (strtoqstr(pluginInstance->getIdentifier()));
        return ( !filePath.isEmpty() );
    } catch (Exception e) { // that's OK
        return false;
    }
}
void
InstrumentAliasButton::slotPressed()
{
    if (!m_instrument) return;

    bool ok = false;

    QString newAlias = InputDialog::getText(this,
                                            tr("Rosegarden"),
                                            tr("Enter instrument alias:"),
                                            LineEdit::Normal,
                                            strtoqstr(m_instrument->getAlias()),
                                            &ok);
    if (ok) {
        m_instrument->setAlias(newAlias.toStdString());
        emit changed();
    }
}
QString ControllerEventsRuler::getName()
{
    if (m_controller) {
        QString name = tr("Unsupported Event Type");

        if (m_controller->getType() == Controller::EventType) {
            QString hexValue;
            hexValue.sprintf("0x%x", m_controller->getControllerValue());

            name = QString("%1 (%2 / %3)").arg(strtoqstr(m_controller->getName()))
                   .arg(int(m_controller->getControllerValue()))
                   .arg(hexValue);
        } else if (m_controller->getType() == PitchBend::EventType) {
            name = tr("Pitch Bend");
        }

        return name;
    } else
        return tr("Controller Events");
}
void
ReconnectDeviceCommand::unexecute()
{
    Device *device = m_studio->getDevice(m_deviceId);

    if (device) {
        RosegardenSequencer::getInstance()->setConnection
            (m_deviceId, strtoqstr(m_oldConnection));
        device->setConnection(m_oldConnection);

        std::cerr << "ReconnectDeviceCommand::unexecute - "
                     << " reconnected device " << m_deviceId
                     << " to " << m_oldConnection << std::endl;
    }

    // ??? Instead of this kludge, we should be calling a Studio::hasChanged()
    //     which would then notify all observers (e.g. MIPP) who, in turn,
    //     would update themselves.
    RosegardenMainWindow::self()->uiUpdateKludge();
}
AudioPluginOSCGUI::AudioPluginOSCGUI(AudioPluginInstance *instance,
                                     QString serverURL, QString friendlyName) :
        m_gui(0),
        m_address(0),
        m_basePath(""),
        m_serverUrl(serverURL)
{
    QString identifier = strtoqstr(instance->getIdentifier());

    QString filePath = getGUIFilePath(identifier);
    if ( filePath.isEmpty() ) {
        throw Exception("No GUI found");
    }

    QString type, soName, label;
    PluginIdentifier::parseIdentifier(identifier, type, soName, label);
    QFileInfo soInfo(soName);

    //setup osc process
    // arguments: osc url, dll name, label, instance tag

    m_gui = new QProcess();
    QStringList guiArgs;
   
    guiArgs << m_serverUrl
    << soInfo.fileName()
    << label
    << friendlyName;

    RG_DEBUG << "AudioPluginOSCGUI::AudioPluginOSCGUI: Starting process "
    << filePath << " " << m_serverUrl << " "
    << soInfo.fileName() << " " << label << " " << friendlyName << endl;

    m_gui->start(filePath, guiArgs);
    if (!m_gui->waitForStarted()) {  //@@@ JAS Check here first for errors
        RG_DEBUG << "AudioPluginOSCGUI::AudioPluginOSCGUI: Couldn't start process " << filePath;
        delete m_gui;
        m_gui = 0;
        throw Exception("Failed to start GUI");
    }
}
Beispiel #23
0
void
ColourTable::populate_table(ColourMap &input, ColourList &list)
{
    m_colours.reserve(input.size());
    setRowCount(input.size());

    QString name;

    unsigned int i = 0;
    QStringList vHeaderLabels;

    for (RCMap::const_iterator it = input.begin(); it != input.end(); ++it) {
        if (it->second.second == std::string(""))
            name = tr("Default Color");
        else
            name = strtoqstr(it->second.second);

//         QTableWidgetItem *text = new QTableWidgetItem(
//                 dynamic_cast<QTableWidget *>(this),
//                                              QTableWidgetItem::Never, name);
        QTableWidgetItem *text = new QTableWidgetItem( );

        setItem(i, 0, text);

        list[i] = it->first;
        m_colours[i] = GUIPalette::convertColour(it->second.first);

        ColourTableItem *temp = new ColourTableItem(this, m_colours[i]);
        setItem(i, 1, temp);

//         verticalHeader()->setLabel(i, QString::number(it->first));
        vHeaderLabels << QString::number(it->first);

        ++i;
    }
    setVerticalHeaderLabels( vHeaderLabels );

}
void
AudioPluginOSCGUIManager::updateConfiguration(InstrumentId instrument, int position,
        QString key)
{
    RG_DEBUG << "AudioPluginOSCGUIManager::updateConfiguration(" << instrument << ","
             << position << "," << key << ")" << endl;

    if (m_guis.find(instrument) == m_guis.end() ||
            m_guis[instrument].find(position) == m_guis[instrument].end())
        return ;

    PluginContainer *container = m_studio->getContainerById(instrument);
    if (!container) return;

    AudioPluginInstance *pluginInstance = container->getPlugin(position);
    if (!pluginInstance) return;

    QString value = strtoqstr(pluginInstance->getConfigurationValue(qstrtostr(key)));

    RG_DEBUG << "AudioPluginOSCGUIManager::updatePort(" << instrument << ","
             << position << "," << key << "): value " << value << endl;

    m_guis[instrument][position]->sendConfiguration(key, value);
}
void
CreateOrDeleteDeviceCommand::execute()
{
    if (!m_deviceCreated) {

        //!DEVPUSH: Not ideal; we probably just want to add it to the studio (and then trigger a re-push) rather than add it twice to studio and sequencer

        // Create

        // don't want to do this again on undo even if it fails -- only on redo
        m_deviceCreated = true;

        m_deviceId = m_studio->getSpareDeviceId(m_baseInstrumentId);

        bool success = RosegardenSequencer::getInstance()->
            addDevice(m_type, m_deviceId, m_baseInstrumentId, m_direction);

        if (!success) {
            SEQMAN_DEBUG << "CreateDeviceCommand::execute - "
                         << "sequencer addDevice failed" << endl;
            return ;
        }

        SEQMAN_DEBUG << "CreateDeviceCommand::execute - "
                     << " added device " << m_deviceId
                     << " with base instrument id " << m_baseInstrumentId
                     << endl;

        RosegardenSequencer::getInstance()->setConnection
            (m_deviceId, strtoqstr(m_connection));

        SEQMAN_DEBUG << "CreateDeviceCommand::execute - "
                     << " reconnected device " << m_deviceId
                     << " to " << m_connection << endl;

        m_studio->addDevice(m_name, m_deviceId, m_baseInstrumentId, m_type);
        Device *device = m_studio->getDevice(m_deviceId);
        if (device) {
            device->setConnection(m_connection);
            MidiDevice *md = dynamic_cast<MidiDevice *>(device);
            if (md) md->setDirection(m_direction);
        }

        /* update view automatically (without pressing refresh button) */
        DeviceManagerDialog *dmd=RosegardenMainWindow::self()->getDeviceManager();
        if (dmd!=NULL) {
          dmd->slotResyncDevicesReceived();
        }
    } else {

        // Delete

        RosegardenSequencer::getInstance()->removeDevice(m_deviceId);

        SEQMAN_DEBUG << "CreateDeviceCommand::unexecute - "
                     << " removed device " << m_deviceId << endl;

        m_studio->removeDevice(m_deviceId);

        m_deviceId = Device::NO_DEVICE;
        m_deviceCreated = false;
    }
}
Beispiel #26
0
bool
ImportDeviceDialog::doImport()
{
    setModal(true);
    setWindowTitle(tr("Import from Device..."));
    QGridLayout *metagrid = new QGridLayout;
    setLayout(metagrid);
    QWidget *mainFrame = new QWidget(this);
    QVBoxLayout *mainFrameLayout = new QVBoxLayout;
    metagrid->addWidget(mainFrame, 0, 0);

    if (m_url.isEmpty()) {
        reject();
        return false;
    }

    QString target;
    FileSource source(m_url);
    if (!source.isAvailable()) {
        QMessageBox::critical(
          dynamic_cast<QWidget*>(this),
          "", /* no title */
          tr("Cannot download file %1").arg(m_url.toString()),
          QMessageBox::Ok,
          QMessageBox::Ok);
        return false;
    }

    source.waitForData();
    target = source.getLocalFilename();
    std::string filename = qStrToStrLocal8(target);

    bool fileRead = false;
    if (SF2PatchExtractor::isSF2File(filename)) {
        fileRead = importFromSF2(target);
    } else if (LSCPPatchExtractor::isLSCPFile(target)) {
        fileRead = importFromLSCP(target);
    } else {
        fileRead = importFromRG(target);
    }
    if (!fileRead) {
        QMessageBox::critical(
          dynamic_cast<QWidget*>(this),
          "", /* no title */
          tr("Cannot open file %1").arg(m_url.toString()),
          QMessageBox::Ok,
          QMessageBox::Ok);
        reject();
        close();
        return false;
    }
    if (m_devices.size() == 0) {
        QMessageBox::warning(
          dynamic_cast<QWidget*>(this),
          "", /* no title */
          tr("No devices found in file %1").arg(m_url.toString()),
          QMessageBox::Ok,
          QMessageBox::Ok);
        reject();
        close();
        return false;
    }

    QGroupBox *groupBox = new QGroupBox(tr("Source device"));
    QHBoxLayout *groupBoxLayout = new QHBoxLayout;
    mainFrameLayout->addWidget(groupBox);

    QWidget *deviceBox = new QWidget(groupBox);
    QHBoxLayout *deviceBoxLayout = new QHBoxLayout( deviceBox );
    groupBoxLayout->addWidget(deviceBox);

    deviceBoxLayout->addWidget(new QLabel(tr("Import from: "), deviceBox));

    bool showRenameOption = false;

    if (m_devices.size() > 1) {
        m_deviceLabel = 0;
        m_deviceCombo = new QComboBox( deviceBox );
        deviceBoxLayout->addWidget(m_deviceCombo);
    } else {
        m_deviceCombo = 0;
        m_deviceLabel = new QLabel( deviceBox );
        deviceBoxLayout->addWidget(m_deviceLabel);
    }

    deviceBoxLayout->addStretch(10);

    int count = 1;
    for (std::vector<MidiDevice *>::iterator i = m_devices.begin();
         i != m_devices.end(); ++i) {
        if ((*i)->getName() != "") {
            showRenameOption = true;
        } else {
            (*i)->setName(qstrtostr(tr("Device %1").arg(count)));
        }
        if (m_devices.size() > 1) {
            m_deviceCombo->addItem(strtoqstr((*i)->getName()));
        } else {
            m_deviceLabel->setText(strtoqstr((*i)->getName()));
        }
        ++count;
    }

    QWidget *optionsBox = new QWidget(mainFrame);
    QHBoxLayout *optionsBoxLayout = new QHBoxLayout;
    mainFrameLayout->addWidget(optionsBox);

    QGroupBox *gb = new QGroupBox(tr("Options"));
    QVBoxLayout *gbLayout = new QVBoxLayout;
    optionsBoxLayout->addWidget(gb);

    m_importBanks = new QCheckBox(tr("Import banks"), gb);
    gbLayout->addWidget(m_importBanks);
    m_importKeyMappings = new QCheckBox(tr("Import key mappings"), gb);
    gbLayout->addWidget(m_importKeyMappings);
    m_importControllers = new QCheckBox(tr("Import controllers"), gb);
    gbLayout->addWidget(m_importControllers);

    if (showRenameOption) {
        m_rename = new QCheckBox(tr("Import device name"), gb);
        gbLayout->addWidget(m_rename);
    } else {
        m_rename = 0;
    }

    QGroupBox *buttonGroupBox = new QGroupBox(tr("Bank import behavior"));
    QVBoxLayout *buttonGroupBoxLayout = new QVBoxLayout;
    optionsBoxLayout->addWidget(buttonGroupBox);
    m_buttonGroup = new QButtonGroup(buttonGroupBox);

    m_mergeBanks = new QRadioButton(tr("Merge banks"));
    buttonGroupBoxLayout->addWidget(m_mergeBanks);
    m_buttonGroup->addButton(m_mergeBanks, 0);

    m_overwriteBanks = new QRadioButton(tr("Overwrite banks"));
    buttonGroupBoxLayout->addWidget(m_overwriteBanks);
    m_buttonGroup->addButton(m_overwriteBanks, 1);

    gb->setLayout(gbLayout);
    buttonGroupBox->setLayout(buttonGroupBoxLayout);
    optionsBox->setLayout(optionsBoxLayout);
    deviceBox->setLayout(deviceBoxLayout);
    groupBox->setLayout(groupBoxLayout);
    mainFrame->setLayout(mainFrameLayout);

    QSettings settings;
    settings.beginGroup( GeneralOptionsConfigGroup );

    m_importBanks->setChecked( qStrToBool( settings.value("importbanks", "true" ) ) );
    m_importKeyMappings->setChecked( qStrToBool( settings.value("importkeymappings", "true" ) ) );
    m_importControllers->setChecked( qStrToBool( settings.value("importcontrollers", "true" ) ) );

    bool rename = qStrToBool( settings.value("importbanksrename", "true" ) ) ;
    if (m_rename)
        m_rename->setChecked(rename);

    bool overwrite = qStrToBool( settings.value("importbanksoverwrite", "true" ) ) ;
    if (overwrite)
        m_buttonGroup->button(1)->setChecked(true);
    else
        m_buttonGroup->button(0)->setChecked(true);

    settings.endGroup();

    QDialogButtonBox *buttonBox
        = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    metagrid->addWidget(buttonBox, 1, 0);
    metagrid->setRowStretch(0, 10);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(slotCancel()));

    return true;
}
Beispiel #27
0
void
LyricEditDialog::unparse()
{
    // This and SetLyricsCommand::execute() are opposites that will
    // need to be kept in sync with any changes in one another.  (They
    // should really both be in a common lyric management class.)

    countVerses();

    Composition *comp = m_segment->getComposition();

    bool firstNote = true;
    timeT lastTime = m_segment->getStartTime();
    int lastBarNo = comp->getBarNumber(lastTime);
    std::map<int, bool> haveLyric;

    QString fragment = QString("[%1] ").arg(lastBarNo + 1);

    m_skeleton = fragment;
    m_texts.clear();
    for (int v = 0; v < m_verseCount; ++v) {
        m_texts.push_back(fragment);
        haveLyric[v] = false;
    }

    for (Segment::iterator i = m_segment->begin();
         m_segment->isBeforeEndMarker(i); ++i) {

        bool isNote = (*i)->isa(Note::EventType);
        bool isLyric = false;

        if (!isNote) {
            if ((*i)->isa(Text::EventType)) {
                std::string textType;
                if ((*i)->get<String>(Text::TextTypePropertyName, textType) &&
                    textType == Text::Lyric) {
                    isLyric = true;
                }
            }
        } else {
            if ((*i)->has(BaseProperties::TIED_BACKWARD) &&
                (*i)->get<Bool>(BaseProperties::TIED_BACKWARD)) {
                continue;
            }
        }

        if (!isNote && !isLyric) continue;

        timeT myTime = (*i)->getNotationAbsoluteTime();
        int myBarNo = comp->getBarNumber(myTime);

        if (myBarNo > lastBarNo) {

            fragment = "";

            while (myBarNo > lastBarNo) {
                fragment += " /";
                ++lastBarNo;
            }

            fragment += QString("\n[%1] ").arg(myBarNo + 1);

            m_skeleton += fragment;
            for (int v = 0; v < m_verseCount; ++v) m_texts[v] += fragment;
        }

        if (isNote) {
            if ((myTime > lastTime) || firstNote) {
                m_skeleton += " .";
                for (int v = 0; v < m_verseCount; ++v) {
                    if (!haveLyric[v]) m_texts[v] += " .";
                    haveLyric[v] = false;
                }
                lastTime = myTime;
                firstNote = false;
            }
        }

        if (isLyric) {

            std::string ssyllable;
            (*i)->get<String>(Text::TextPropertyName, ssyllable);

            long verse = 0;
            (*i)->get<Int>(Text::LyricVersePropertyName, verse);

            QString syllable(strtoqstr(ssyllable));
            syllable.replace(QRegExp("\\s+"), "~");

            m_texts[verse] += " " + syllable;
            haveLyric[verse] = true;
        }
    }

    if (!m_texts.empty()) {
        m_textEdit->setPlainText(m_texts[0]);
    } else {
        m_texts.push_back(m_skeleton);
    }
}
void
MidiProgramsEditor::populate(QTreeWidgetItem* item)
{
    RG_DEBUG << "MidiProgramsEditor::populate\n";

    MidiBankTreeWidgetItem* bankItem = dynamic_cast<MidiBankTreeWidgetItem*>(item);
    if (!bankItem) {
        RG_DEBUG << "MidiProgramsEditor::populate : not a bank item - returning\n";
        return ;
    }

    DeviceId deviceId = bankItem->getDeviceId();
    m_device = m_bankEditor->getMidiDevice(deviceId);
    if (!m_device)
        return ;

    setEnabled(true);

    setBankName(item->text(0));

    RG_DEBUG << "MidiProgramsEditor::populate : bankItem->getBank = "
    << bankItem->getBank() << endl;

    m_currentBank = &(m_bankList[bankItem->getBank()]); // m_device->getBankByIndex(bankItem->getBank());

    blockAllSignals(true);

    // set the bank values
    m_percussion->setChecked(m_currentBank->isPercussion());
    m_msb->setValue(m_currentBank->getMSB());
    m_lsb->setValue(m_currentBank->getLSB());

    m_oldBank = *m_currentBank;

    // Librarian details
    //
    m_librarian->setText(strtoqstr(m_device->getLibrarianName()));
    m_librarianEmail->setText(strtoqstr(m_device->getLibrarianEmail()));

    ProgramList programSubset = getBankSubset(*m_currentBank);
    ProgramList::iterator it;

    QPixmap noKeyPixmap, keyPixmap;

    IconLoader il;
    noKeyPixmap = il.loadPixmap("key-white");
    keyPixmap = il.loadPixmap("key-green");

    bool haveKeyMappings = m_device->getKeyMappings().size() > 0;

    for (unsigned int i = 0; i < (unsigned int)m_names.size(); i++) {

        m_names[i]->clear();
        getKeyMapButton(i)->setEnabled(haveKeyMappings);
        getKeyMapButton(i)->setIcon(QIcon(noKeyPixmap));
        // QToolTip::remove
        //    ( getKeyMapButton(i) );
        getKeyMapButton(i)->setToolTip(QString(""));  //@@@ Usefull ?
        getKeyMapButton(i)->setMaximumHeight( 12 );

        for (it = programSubset.begin(); it != programSubset.end(); ++it) {
            if (it->getProgram() == i) {

                // zero in on "Harpsichord" vs. "Coupled Harpsichord to cut down
                // on noise (0-based)
//                if (i == 6) std::cout << "it->getName(): " << it->getName() << std::endl;
                QString programName = strtoqstr(it->getName());
                m_completions << programName;
                m_names[i]->setText(programName);

                if (m_device->getKeyMappingForProgram(*it)) {
                    getKeyMapButton(i)->setIcon(QIcon(keyPixmap));
                    getKeyMapButton(i)->setToolTip
                        (tr("Key Mapping: %1") 
                              .arg(strtoqstr(m_device->getKeyMappingForProgram(*it)->getName())));
                }

                break;
            }
        }

        // show start of label
        m_names[i]->setCursorPosition(0);
    }

    blockAllSignals(false);
}
void PercussionPitchRuler::paintEvent(QPaintEvent*)
{
    QPainter paint(this);

    paint.setFont(*m_font);

    int minPitch = m_mapping->getPitchForOffset(0);
    int extent = m_mapping->getPitchExtent();

    // Draw the ruler

    for (int i = 0; i < extent; ++i) {
        paint.drawLine(0, i * (m_lineSpacing + 1),
                       m_width, i * (m_lineSpacing + 1));
    }

    //: Note to the translators: Don't translate literally.
    //: This string is never displayed but defines the largest width of the
    //: pitch name in the percussion ruler text.
    int lw = m_fontMetrics->width(tr("A#2"));
    int offset = m_fontMetrics->ascent() + 1;

    for (int i = 0; i < extent; ++i) {

        MidiPitchLabel label(minPitch + i);
        std::string key = m_mapping->getMapForKeyName(minPitch + i);
        //RG_DEBUG << "PercussionPitchRuler::paintEvent()" << i << ": " << label.getQString() << ": " << key;

        int yi = (extent - i - 1) * (m_lineSpacing + 1) + offset;
        paint.drawText(2, yi, label.getQString());

        if (i != m_hoverNotePitch) {
            // Draw an unhighlighted note
            paint.drawText(9 + lw, yi, strtoqstr(key));
        } else {
            // Highlight the hover note
            int iHover = m_hoverNotePitch - minPitch;
            int y = (extent - iHover - 1) * (m_lineSpacing + 1);
            paint.save();
            paint.setBrush(paint.pen().color());
            paint.drawRect(lw + 7, y, m_width - lw, m_lineSpacing + 1);
            paint.setPen(QColor(Qt::black));
            std::string key = m_mapping->getMapForKeyName(m_hoverNotePitch);
            paint.drawText(9 + lw, y + offset, strtoqstr(key));
            paint.restore();
        }
    }

    if (m_lastHoverHighlight != m_hoverNotePitch) {
        m_lastHoverHighlight = m_hoverNotePitch;

        // Unhilight the last hover note
        if (m_lastHoverHighlight >= 0) {
            int iLastHover = m_lastHoverHighlight - minPitch;
            int y = (extent - iLastHover - 1) * (m_lineSpacing + 1);
            paint.drawRect(lw + 7, y + 1, m_width - lw, m_lineSpacing);
            std::string key = m_mapping->getMapForKeyName(m_lastHoverHighlight);
            paint.setPen(QColor(Qt::black));
            paint.drawText(9 + lw, y + offset, strtoqstr(key));
        }
    }
}
Beispiel #30
0
ROSEGARDENPRIVATE_EXPORT QDebug &operator<<(QDebug &dbg, const std::string &s)
{
    dbg << strtoqstr(s);

    return dbg;
}