Example #1
0
EditStaff::EditStaff(Staff* s, QWidget* parent)
   : QDialog(parent)
      {
      staff = s;
      setupUi(this);
      setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);

      Part* part = staff->part();
      instrument = *part->instr();
      Score* score = part->score();

      // hide string data controls if instrument has no strings
      stringDataFrame->setVisible(instrument.stringData() && instrument.stringData()->strings() > 0);
      fillStaffTypeCombo();
      small->setChecked(staff->small());
      invisible->setChecked(staff->invisible());
      spinExtraDistance->setValue(s->userDist() / score->spatium());
      color->setColor(s->color());
      partName->setText(part->partName());

      updateInstrument();

      connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(bboxClicked(QAbstractButton*)));
      connect(changeInstrument, SIGNAL(clicked()), SLOT(showInstrumentDialog()));
      connect(editShortName,    SIGNAL(clicked()), SLOT(editShortNameClicked()));
      connect(editLongName,     SIGNAL(clicked()), SLOT(editLongNameClicked()));
      connect(minPitchASelect,  SIGNAL(clicked()), SLOT(minPitchAClicked()));
      connect(maxPitchASelect,  SIGNAL(clicked()), SLOT(maxPitchAClicked()));
      connect(minPitchPSelect,  SIGNAL(clicked()), SLOT(minPitchPClicked()));
      connect(maxPitchPSelect,  SIGNAL(clicked()), SLOT(maxPitchPClicked()));
      connect(editStringData,   SIGNAL(clicked()), SLOT(editStringDataClicked()));
      }
Example #2
0
void EditStaff::showInstrumentDialog()
      {
      SelectInstrument si(instrument, this);
      if (si.exec()) {
            instrument = Instrument::fromTemplate(si.instrTemplate());
            updateInstrument();
            fillStaffTypeCombo();
            }
      }
Example #3
0
void EditStaff::showInstrumentDialog()
      {
      SelectInstrument si(&instrument, this);
      si.setWindowModality(Qt::WindowModal);
      if (si.exec()) {
            instrument = Instrument::fromTemplate(si.instrTemplate());
            updateInstrument();
            }
      }
Example #4
0
void EditStaff::setStaff(Staff* s)
      {
      if (staff != nullptr)
            delete staff;

      orgStaff = s;
      Part* part        = orgStaff->part();
      instrument        = *part->instrument(/*tick*/);
      Score* score      = part->score();
      staff             = new Staff(score);
      staff->setStaffType(Fraction(0,1), *orgStaff->staffType(Fraction(0,1)));
      staff->setSmall(Fraction(0,1), orgStaff->small(Fraction(0,1)));
      staff->setInvisible(orgStaff->invisible());
      staff->setUserDist(orgStaff->userDist());
      staff->setColor(orgStaff->color());
      staff->setPart(part);
      staff->setCutaway(orgStaff->cutaway());
      staff->setHideWhenEmpty(orgStaff->hideWhenEmpty());
      staff->setShowIfEmpty(orgStaff->showIfEmpty());
      staff->setUserMag(Fraction(0,1), orgStaff->userMag(Fraction(0,1)));
      staff->setHideSystemBarLine(orgStaff->hideSystemBarLine());

      // get tick range for instrument
      auto i = part->instruments()->upper_bound(0);   // tick
      if (i == part->instruments()->end())
            _tickEnd = Fraction(-1,1);
      else
            _tickEnd = Fraction::fromTicks(i->first);
#if 1
      _tickStart = Fraction(-1,1);
#else
      --i;
      if (i == part->instruments()->begin())
            _tickStart = 0;
      else
            _tickStart = i->first;
#endif

      // set dlg controls
      spinExtraDistance->setValue(s->userDist() / score->spatium());
      invisible->setChecked(staff->invisible());
      small->setChecked(staff->small(Fraction(0,1)));
      color->setColor(s->color());
      partName->setText(part->partName());
      cutaway->setChecked(staff->cutaway());
      hideMode->setCurrentIndex(int(staff->hideWhenEmpty()));
      showIfEmpty->setChecked(staff->showIfEmpty());
      hideSystemBarLine->setChecked(staff->hideSystemBarLine());
      mag->setValue(staff->userMag(Fraction(0,1)) * 100.0);
      updateStaffType();
      updateInstrument();
      updateNextPreviousButtons();
      }
void
TrackParameterBox::updateWidgets2()
{
    Track *track = getTrack();
    if (!track)
        return;

    Instrument *instrument = m_doc->getStudio().getInstrumentFor(track);
    if (!instrument)
        return;

    // *** Track Label

    QString trackName = strtoqstr(track->getLabel());
    if (trackName.isEmpty())
        trackName = tr("<untitled>");
    else
        trackName.truncate(20);

    const int trackNum = track->getPosition() + 1;

    m_trackLabel->setText(tr("[ Track %1 - %2 ]").arg(trackNum).arg(trackName));

    // *** Playback parameters

    // Device
    updatePlaybackDevice(instrument->getDevice()->getId());

    // Instrument
    updateInstrument(instrument);

    // Archive
    m_archive->setChecked(track->isArchived());

    // If the current Instrument is an Audio Instrument...
    if (instrument->getInstrumentType() == Instrument::Audio) {

        // Hide irrelevant portions.

        m_recordingFiltersFrame->setVisible(false);
        m_staffExportOptionsFrame->setVisible(false);

        // In the Create segments with... frame, only the color combo is
        // useful for an Audio track.
        m_presetLabel->setVisible(false);
        m_preset->setVisible(false);
        m_load->setVisible(false);
        m_clefLabel->setVisible(false);
        m_clef->setVisible(false);
        m_transposeLabel->setVisible(false);
        m_transpose->setVisible(false);
        m_pitchLabel->setVisible(false);
        m_lowestLabel->setVisible(false);
        m_lowest->setVisible(false);
        m_highestLabel->setVisible(false);
        m_highest->setVisible(false);

    } else {  // MIDI or soft synth

        // Show everything.

        m_recordingFiltersFrame->setVisible(true);
        m_staffExportOptionsFrame->setVisible(true);

        // Create segments with... frame
        m_presetLabel->setVisible(true);
        m_preset->setVisible(true);
        m_load->setVisible(true);
        m_clefLabel->setVisible(true);
        m_clef->setVisible(true);
        m_transposeLabel->setVisible(true);
        m_transpose->setVisible(true);
        m_pitchLabel->setVisible(true);
        m_lowestLabel->setVisible(true);
        m_lowest->setVisible(true);
        m_highestLabel->setVisible(true);
        m_highest->setVisible(true);
    }

    // *** Recording filters

    // Device
    updateRecordingDevice(track->getMidiInputDevice());

    // Channel
    m_recordingChannel->setCurrentIndex((int)track->getMidiInputChannel() + 1);

    // Thru Routing
    m_thruRouting->setCurrentIndex((int)track->getThruRouting());

    // *** Staff export options

    // Notation size
    m_notationSize->setCurrentIndex(track->getStaffSize());

    // Bracket type
    m_bracketType->setCurrentIndex(track->getStaffBracket());

    // *** Create segments with

    // Preset (Label)
    m_preset->setText(strtoqstr(track->getPresetLabel()));

    // Clef
    m_clef->setCurrentIndex(track->getClef());

    // Transpose
    m_transpose->setCurrentIndex(
            m_transpose->findText(QString("%1").arg(track->getTranspose())));

    // Pitch Lowest

    QSettings settings;
    settings.beginGroup(GeneralOptionsConfigGroup);
    const int octaveBase = settings.value("midipitchoctave", -2).toInt() ;
    settings.endGroup();

    const bool includeOctave = false;

    const Pitch lowest(track->getLowestPlayable(), Accidentals::NoAccidental);

    // NOTE: this now uses a new, overloaded version of Pitch::getAsString()
    // that explicitly works with the key of C major, and does not allow the
    // calling code to specify how the accidentals should be written out.
    //
    // Separate the note letter from the octave to avoid undue burden on
    // translators having to retranslate the same thing but for a number
    // difference
    QString tmp = QObject::tr(lowest.getAsString(includeOctave, octaveBase).c_str(), "note name");
    tmp += tr(" %1").arg(lowest.getOctave(octaveBase));
    m_lowest->setText(tmp);

    // Pitch Highest

    const Pitch highest(track->getHighestPlayable(), Accidentals::NoAccidental);

    tmp = QObject::tr(highest.getAsString(includeOctave, octaveBase).c_str(), "note name");
    tmp += tr(" %1").arg(highest.getOctave(octaveBase));
    m_highest->setText(tmp);

    // Color
    // Note: We only update the combobox contents if there is an actual
    //       change to the document's colors.  See slotDocColoursChanged().
    m_color->setCurrentIndex(track->getColor());
}
Example #6
0
EditStaff::EditStaff(Staff* s, int /*tick*/, QWidget* parent)
   : QDialog(parent)
      {
      orgStaff = s;
      setupUi(this);
      setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
      setModal(true);

      const QIcon &editIcon = *icons[int(Icons::edit_ICON)];
      minPitchASelect->setIcon(editIcon);
      maxPitchASelect->setIcon(editIcon);
      minPitchPSelect->setIcon(editIcon);
      maxPitchPSelect->setIcon(editIcon);

      Part* part        = orgStaff->part();
      instrument        = *part->instrument(/*tick*/);
      Score* score      = part->score();
      staff             = new Staff(score);
      staff->setSmall(orgStaff->small());
      staff->setInvisible(orgStaff->invisible());
      staff->setUserDist(orgStaff->userDist());
      staff->setColor(orgStaff->color());
      staff->setStaffType(orgStaff->staffType());
      staff->setPart(part);
      staff->setCutaway(orgStaff->cutaway());
      staff->setHideWhenEmpty(orgStaff->hideWhenEmpty());
      staff->setShowIfEmpty(orgStaff->showIfEmpty());
      staff->setUserMag(orgStaff->userMag());
      staff->setHideSystemBarLine(orgStaff->hideSystemBarLine());

      // get tick range for instrument
      auto i = part->instruments()->upper_bound(0);   // tick
      if (i == part->instruments()->end())
            _tickEnd = -1;
      else
            _tickEnd = i->first;
#if 1
      _tickStart = -1;
#else
      --i;
      if (i == part->instruments()->begin())
            _tickStart = 0;
      else
            _tickStart = i->first;
#endif

      // set dlg controls
      spinExtraDistance->setValue(s->userDist() / score->spatium());
      invisible->setChecked(staff->invisible());
      small->setChecked(staff->small());
      color->setColor(s->color());
      partName->setText(part->partName());
      cutaway->setChecked(staff->cutaway());
      hideMode->setCurrentIndex(int(staff->hideWhenEmpty()));
      showIfEmpty->setChecked(staff->showIfEmpty());
      hideSystemBarLine->setChecked(staff->hideSystemBarLine());
      mag->setValue(staff->userMag() * 100.0);
      updateStaffType();
      updateInstrument();

      if (!useFactorySettings) {
            QSettings settings;
            settings.beginGroup("EditStaff");
            resize(settings.value("size", QSize(484, 184)).toSize());
            move(settings.value("pos", QPoint(10, 10)).toPoint());
            settings.endGroup();
            }

      connect(buttonBox,            SIGNAL(clicked(QAbstractButton*)), SLOT(bboxClicked(QAbstractButton*)));
      connect(changeInstrument,     SIGNAL(clicked()),            SLOT(showInstrumentDialog()));
      connect(changeStaffType,      SIGNAL(clicked()),            SLOT(showStaffTypeDialog()));
      connect(minPitchASelect,      SIGNAL(clicked()),            SLOT(minPitchAClicked()));
      connect(maxPitchASelect,      SIGNAL(clicked()),            SLOT(maxPitchAClicked()));
      connect(minPitchPSelect,      SIGNAL(clicked()),            SLOT(minPitchPClicked()));
      connect(maxPitchPSelect,      SIGNAL(clicked()),            SLOT(maxPitchPClicked()));
      connect(editStringData,       SIGNAL(clicked()),            SLOT(editStringDataClicked()));
      connect(lines,                SIGNAL(valueChanged(int)),    SLOT(numOfLinesChanged()));
      connect(lineDistance,         SIGNAL(valueChanged(double)), SLOT(lineDistanceChanged()));
      connect(showClef,             SIGNAL(clicked()),            SLOT(showClefChanged()));
      connect(showTimesig,          SIGNAL(clicked()),            SLOT(showTimeSigChanged()));
      connect(showBarlines,         SIGNAL(clicked()),            SLOT(showBarlinesChanged()));
      addAction(getAction("local-help"));  // why is this needed?
      }
Example #7
0
  /**
  * Populate list with instruments from the named facility. Note the current list is cleared.
  * @param name :: The name of the facility whose instruments should be placed in the list. An empty string uses the default
  * facility defined in Mantid.
  */
  void InstrumentSelector::fillWithInstrumentsFromFacility(const QString & name)
  {
    ConfigServiceImpl & mantidSettings = ConfigService::Instance();

    this->blockSignals(true);
    this->clear();

    try
    {
      if( name.isEmpty() )
      {
        m_currentFacility = &(mantidSettings.getFacility());
      }
      else
      {
        m_currentFacility = &(mantidSettings.getFacility(name.toStdString()));
      }
    }
    catch (Mantid::Kernel::Exception::NotFoundError&)
    {
      //could not find the facility
      //pick the first facility from the valid list
      m_currentFacility = &(mantidSettings.getFacility(mantidSettings.getFacilityNames()[0]));
    }

    const std::vector<InstrumentInfo> & instruments = m_currentFacility->instruments();
    std::vector<InstrumentInfo>::const_iterator iend = instruments.end();
    std::set<std::string> alphabetizedNames;
    for( std::vector<InstrumentInfo>::const_iterator itr = instruments.begin(); itr != iend; ++itr )
    {
      alphabetizedNames.insert(itr->name());
    }
    std::set<std::string>::const_iterator namesEnd = alphabetizedNames.end();
    for( std::set<std::string>::const_iterator itr = alphabetizedNames.begin(); itr != namesEnd; ++itr )
    {
      QString name = QString::fromStdString(*itr);
      std::string prefix = m_currentFacility->instrument(*itr).shortName();
      QString shortName = QString::fromStdString(prefix);
      this->addItem(name, QVariant(shortName));
    }
    filterByTechniquesAtFacility(m_techniques, *m_currentFacility);

    QString defaultName;
    try
    {
      defaultName = QString::fromStdString(m_currentFacility->instrument().name());
    }
    catch( Exception::NotFoundError &)
    {
      defaultName = "";
    }
    int index = this->findText(defaultName);
    if( index < 0 )
    {
      index = 0;
    }

    // Don't affect the default instrument
    this->setCurrentIndex(index);
    this->blockSignals(false);

    emit instrumentListUpdated();
    updateInstrument(this->currentText());
  }