📄 trackparameterbox.cpp
字号:
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: *//* Rosegarden A MIDI and audio sequencer and musical notation editor. This program is Copyright 2000-2007 Guillaume Laurent <glaurent@telegraph-road.org>, Chris Cannam <cannam@all-day-breakfast.com>, Richard Bown <richard.bown@ferventsoftware.com> The moral rights of Guillaume Laurent, Chris Cannam, and Richard Bown to claim authorship of this work have been asserted. This file is Copyright 2006 Pedro Lopez-Cabanillas <plcl@users.sourceforge.net> D. Michael McIntyre <dmmcintyr@users.sourceforge.net> Other copyrights also apply to some parts of this work. Please see the AUTHORS file and individual file headers for details. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING included with this distribution for more information.*/#include "TrackParameterBox.h"#include <qlayout.h>#include <kapplication.h>#include <klocale.h>#include "misc/Debug.h"#include "misc/Strings.h"#include "gui/general/ClefIndex.h"#include "document/ConfigGroups.h"#include "base/AudioPluginInstance.h"#include "base/Colour.h"#include "base/ColourMap.h"#include "base/Composition.h"#include "base/Device.h"#include "base/Exception.h"#include "base/Instrument.h"#include "base/MidiDevice.h"#include "base/MidiProgram.h"#include "base/NotationTypes.h"#include "base/Studio.h"#include "base/Track.h"#include "document/RosegardenGUIDoc.h"#include "gui/dialogs/PitchPickerDialog.h"#include "gui/general/GUIPalette.h"#include "gui/general/PresetHandlerDialog.h"#include "gui/widgets/CollapsingFrame.h"#include "gui/widgets/ColourTable.h"#include "RosegardenParameterArea.h"#include "RosegardenParameterBox.h"#include "sound/PluginIdentifier.h"#include <kcolordialog.h>#include <kcombobox.h>#include <kconfig.h>#include <klineeditdlg.h>#include <kmessagebox.h>#include <ksqueezedtextlabel.h>#include <ktabwidget.h>#include <qcolor.h>#include <qdialog.h>#include <qfont.h>#include <qfontmetrics.h>#include <qframe.h>#include <qlabel.h>#include <qpixmap.h>#include <qpushbutton.h>#include <qregexp.h>#include <qscrollview.h>#include <qstring.h>#include <qtooltip.h>#include <qvbox.h>#include <qwidget.h>#include <qwidgetstack.h>namespace Rosegarden{TrackParameterBox::TrackParameterBox( RosegardenGUIDoc *doc, QWidget *parent) : RosegardenParameterBox(i18n("Track"), i18n("Track Parameters"), parent), m_doc(doc), m_highestPlayable(127), m_lowestPlayable(0), m_selectedTrackId( -1){ QFont font(m_font); QFont title_font(m_font); QFontMetrics metrics(font); int width11 = metrics.width("12345678901"); int width20 = metrics.width("12345678901234567890"); int width22 = metrics.width("1234567890123456789012"); int width25 = metrics.width("1234567890123456789012345"); setFont(m_font); title_font.setBold(true); // Set up default expansions for the collapsing elements KConfig *config = kapp->config(); QString groupTemp = config->group(); config->setGroup("CollapsingFrame"); bool expanded = config->readBoolEntry("trackparametersplayback", true); config->writeEntry("trackparametersplayback", expanded); expanded = config->readBoolEntry("trackparametersrecord", false); config->writeEntry("trackparametersrecord", expanded); expanded = config->readBoolEntry("trackparametersdefaults", false); config->writeEntry("trackparametersdefaults", expanded); config->setGroup(groupTemp); QGridLayout *mainLayout = new QGridLayout(this, 5, 1, 2, 1); int row = 0; // track label // m_trackLabel = new KSqueezedTextLabel(i18n("<untitled>"), this); m_trackLabel->setAlignment(Qt::AlignCenter); //mainLayout->addMultiCellWidget(m_trackLabel, 0, 0, 0, 5, AlignCenter); mainLayout->addWidget(m_trackLabel, 0, 0); // playback group // CollapsingFrame *cframe = new CollapsingFrame(i18n("Playback parameters"), this, "trackparametersplayback"); m_playbackGroup = new QFrame(cframe); cframe->setWidget(m_playbackGroup); QGridLayout *groupLayout = new QGridLayout(m_playbackGroup, 3, 3, 3, 2); // playback group title // row = 0; // playback device // // row++; QLabel *devLabel = new QLabel(i18n("Device"), m_playbackGroup); groupLayout->addWidget(devLabel, row, 0); m_playDevice = new KComboBox(m_playbackGroup); m_playDevice->setMinimumWidth(width25); groupLayout->addMultiCellWidget(m_playDevice, row, row, 1, 2); // playback instrument // row++; QLabel *insLabel = new QLabel(i18n("Instrument"), m_playbackGroup); groupLayout->addMultiCellWidget(insLabel, row, row, 0, 1); m_instrument = new KComboBox(m_playbackGroup); m_instrument->setSizeLimit( 16 ); m_instrument->setMinimumWidth(width22); groupLayout->addWidget(m_instrument, row, 2); groupLayout->setColStretch(groupLayout->numCols() - 1, 1); mainLayout->addWidget(cframe, 1, 0); // record group // cframe = new CollapsingFrame(i18n("Recording filters"), this, "trackparametersrecord"); m_recordGroup = new QFrame(cframe); cframe->setWidget(m_recordGroup); groupLayout = new QGridLayout(m_recordGroup, 3, 3, 3, 2); // recording group title // row = 0; // recording device groupLayout->addWidget(new QLabel(i18n("Device"), m_recordGroup), row, 0); m_recDevice = new KComboBox(m_recordGroup); m_recDevice->setMinimumWidth(width25); groupLayout->addMultiCellWidget(m_recDevice, row, row, 1, 2); // recording channel // row++; groupLayout->addMultiCellWidget(new QLabel(i18n("Channel"), m_recordGroup), row, row, 0, 1); m_recChannel = new KComboBox(m_recordGroup); m_recChannel->setSizeLimit( 17 ); m_recChannel->setMinimumWidth(width11); groupLayout->addWidget(m_recChannel, row, 2); groupLayout->setColStretch(groupLayout->numCols() - 1, 1); mainLayout->addWidget(cframe, 2, 0); // default segment group // cframe = new CollapsingFrame(i18n("Create segments with:"), this, "trackparametersdefaults"); m_defaultsGroup = new QFrame(cframe); cframe->setWidget(m_defaultsGroup); groupLayout = new QGridLayout(m_defaultsGroup, 6, 6, 3, 2); groupLayout->setColStretch(1, 1); row = 0; // preset picker m_psetLbl = new QLabel(i18n("Preset"), m_defaultsGroup); groupLayout->addWidget(m_psetLbl, row, 0, AlignLeft); m_presetLbl = new QLabel(i18n("<none>"), m_defaultsGroup); m_presetLbl->setFrameStyle(QFrame::Panel | QFrame::Sunken); m_presetLbl->setFixedWidth(width20); groupLayout->addMultiCellWidget(m_presetLbl, row, row, 1, 3); m_presetButton = new QPushButton(i18n("Load"), m_defaultsGroup); groupLayout->addMultiCellWidget(m_presetButton, row, row, 4, 5); // default clef // row++; m_clefLbl = new QLabel(i18n("Clef"), m_defaultsGroup); groupLayout->addWidget(m_clefLbl, row, 0, AlignLeft); m_defClef = new KComboBox(m_defaultsGroup); m_defClef->setMinimumWidth(width11); m_defClef->insertItem(i18n("treble"), TrebleClef); m_defClef->insertItem(i18n("bass"), BassClef); m_defClef->insertItem(i18n("crotales"), CrotalesClef); m_defClef->insertItem(i18n("xylophone"), XylophoneClef); m_defClef->insertItem(i18n("guitar"), GuitarClef); m_defClef->insertItem(i18n("contrabass"), ContrabassClef); m_defClef->insertItem(i18n("celesta"), CelestaClef); m_defClef->insertItem(i18n("old celesta"), OldCelestaClef); m_defClef->insertItem(i18n("french"), FrenchClef); m_defClef->insertItem(i18n("soprano"), SopranoClef); m_defClef->insertItem(i18n("mezzosoprano"), MezzosopranoClef); m_defClef->insertItem(i18n("alto"), AltoClef); m_defClef->insertItem(i18n("tenor"), TenorClef); m_defClef->insertItem(i18n("baritone"), BaritoneClef); m_defClef->insertItem(i18n("varbaritone"), VarbaritoneClef); m_defClef->insertItem(i18n("subbass"), SubbassClef); /* clef types in the datbase that are not yet supported must be ignored for * now: m_defClef->insertItem(i18n("two bar"), TwoBarClef); */ groupLayout->addMultiCellWidget(m_defClef, row, row, 1, 2); // default transpose // m_transpLbl = new QLabel(i18n("Transpose"), m_defaultsGroup); groupLayout->addMultiCellWidget(m_transpLbl, row, row, 3, 4, AlignRight); m_defTranspose = new KComboBox(m_defaultsGroup); connect(m_defTranspose, SIGNAL(activated(int)), SLOT(slotTransposeIndexChanged(int))); int transposeRange = 48; for (int i = -transposeRange; i < transposeRange + 1; i++) { m_defTranspose->insertItem(QString("%1").arg(i)); if (i == 0) m_defTranspose->setCurrentItem(m_defTranspose->count() - 1); } groupLayout->addMultiCellWidget(m_defTranspose, row, row, 5, 5); // highest/lowest playable note // row++; m_rangeLbl = new QLabel(i18n("Pitch"), m_defaultsGroup); groupLayout->addMultiCellWidget(m_rangeLbl, row, row, 0, 0); groupLayout->addWidget(new QLabel(i18n("Lowest"), m_defaultsGroup), row, 1, AlignRight); m_lowButton = new QPushButton(i18n("---"), m_defaultsGroup); QToolTip::add (m_lowButton, i18n("Choose the lowest suggested playable note, using a staff")); groupLayout->addMultiCellWidget(m_lowButton, row, row, 2, 2); groupLayout->addWidget(new QLabel(i18n("Highest"), m_defaultsGroup), row, 3, AlignRight); m_highButton = new QPushButton(i18n("---"), m_defaultsGroup); QToolTip::add (m_highButton, i18n("Choose the highest suggested playable note, using a staff")); groupLayout->addMultiCellWidget(m_highButton, row, row, 4, 5); updateHighLow(); // default color // row++; m_colorLbl = new QLabel(i18n("Color"), m_defaultsGroup); groupLayout->addWidget(m_colorLbl, row, 0, AlignLeft); m_defColor = new KComboBox(false, m_defaultsGroup); m_defColor->setSizeLimit(20); groupLayout->addMultiCellWidget(m_defColor, row, row, 1, 5); // populate combo from doc colors slotDocColoursChanged(); mainLayout->addWidget(cframe, 3, 0); // Configure the empty final row to accomodate any extra vertical space. //// mainLayout->setColStretch(mainLayout->numCols() - 1, 1); mainLayout->setRowStretch(mainLayout->numRows() - 1, 1); // Connections connect( m_playDevice, SIGNAL(activated(int)), this, SLOT(slotPlaybackDeviceChanged(int))); connect( m_instrument, SIGNAL(activated(int)), this, SLOT(slotInstrumentChanged(int))); connect( m_recDevice, SIGNAL(activated(int)), this, SLOT(slotRecordingDeviceChanged(int))); connect( m_recChannel, SIGNAL(activated(int)), this, SLOT(slotRecordingChannelChanged(int))); connect( m_defClef, SIGNAL(activated(int)), this, SLOT(slotClefChanged(int))); // Detect when the document colours are updated connect(m_doc, SIGNAL(docColoursChanged()), this, SLOT(slotDocColoursChanged())); // handle colour combo changes connect(m_defColor, SIGNAL(activated(int)), SLOT(slotColorChanged(int))); connect(m_highButton, SIGNAL(released()), SLOT(slotHighestPressed())); connect(m_lowButton, SIGNAL(released()), SLOT(slotLowestPressed())); connect(m_presetButton, SIGNAL(released()), SLOT(slotPresetPressed()));}TrackParameterBox::~TrackParameterBox(){}voidTrackParameterBox::setDocument( RosegardenGUIDoc *doc ){ if (m_doc != doc) { RG_DEBUG << "TrackParameterBox::setDocument\n"; m_doc = doc; populateDeviceLists(); }}voidTrackParameterBox::populateDeviceLists(){ RG_DEBUG << "TrackParameterBox::populateDeviceLists()\n"; populatePlaybackDeviceList(); //populateRecordingDeviceList(); slotUpdateControls( -1); m_lastInstrumentType = -1;}voidTrackParameterBox::populatePlaybackDeviceList(){ RG_DEBUG << "TrackParameterBox::populatePlaybackDeviceList()\n"; m_playDevice->clear(); m_playDeviceIds.clear(); m_instrument->clear(); m_instrumentIds.clear(); m_instrumentNames.clear(); Studio &studio = m_doc->getStudio(); // Get the list InstrumentList list = studio.getPresentationInstruments(); InstrumentList::iterator it; int currentDevId = -1; for (it = list.begin(); it != list.end(); it++) { if (! (*it)) continue; // sanity check //QString iname(strtoqstr((*it)->getPresentationName())); QString iname(strtoqstr((*it)->getName())); QString pname(strtoqstr((*it)->getProgramName())); Device *device = (*it)->getDevice(); DeviceId devId = device->getId(); if ((*it)->getType() == Instrument::SoftSynth) { iname.replace("Synth plugin ", ""); pname = ""; AudioPluginInstance *plugin = (*it)->getPlugin (Instrument::SYNTH_PLUGIN_POSITION); if (plugin) { pname = strtoqstr(plugin->getProgram()); QString identifier = strtoqstr(plugin->getIdentifier()); if (identifier != "") { QString type, soName, label; PluginIdentifier::parseIdentifier (identifier, type, soName, label); if (pname == "") { pname = strtoqstr(plugin->getDistinctiveConfigurationText()); } if (pname != "") { pname = QString("%1: %2").arg(label).arg(pname); } else { pname = label; } } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -