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); }
DocumentConfigureDialog::DocumentConfigureDialog(RosegardenDocument *doc, QWidget *parent, const char *name) : ConfigureDialogBase(parent, tr("Document Properties"), name )//, QMessageBox::StandardButtons buttons ) { QWidget *page = 0; // Document Meta Page // IconLoader il; page = new DocumentMetaConfigurationPage(doc, this); addPage(DocumentMetaConfigurationPage::iconLabel(),DocumentMetaConfigurationPage::title(),il.loadPixmap( DocumentMetaConfigurationPage::iconName()),page); m_configurationPages.push_back((ConfigurationPage *)page); // Audio Page // page = new AudioPropertiesPage(doc, this); addPage(AudioPropertiesPage::iconLabel(),AudioPropertiesPage::title(),il.loadPixmap(AudioPropertiesPage::iconName()),page); m_configurationPages.push_back((ConfigurationPage *)page); }
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); }
ModelDataTableDialog::ModelDataTableDialog(TabularModel *model, QString title, QWidget *parent) : QMainWindow(parent), m_currentRow(0), m_trackPlayback(true) { setWindowTitle(tr("Data Editor")); QToolBar *toolbar; toolbar = addToolBar(tr("Playback Toolbar")); m_playToolbar = toolbar; toolbar = addToolBar(tr("Play Mode Toolbar")); IconLoader il; QAction *action = new QAction(il.load("playfollow"), tr("Track Playback"), this); action->setStatusTip(tr("Toggle tracking of playback position")); action->setCheckable(true); action->setChecked(m_trackPlayback); connect(action, SIGNAL(triggered()), this, SLOT(togglePlayTracking())); toolbar->addAction(action); toolbar = addToolBar(tr("Edit Toolbar")); action = new QAction(il.load("datainsert"), tr("Insert New Item"), this); action->setShortcut(tr("Insert")); action->setStatusTip(tr("Insert a new item")); connect(action, SIGNAL(triggered()), this, SLOT(insertRow())); toolbar->addAction(action); action = new QAction(il.load("datadelete"), tr("Delete Selected Items"), this); action->setShortcut(tr("Delete")); action->setStatusTip(tr("Delete the selected item or items")); connect(action, SIGNAL(triggered()), this, SLOT(deleteRows())); toolbar->addAction(action); CommandHistory::getInstance()->registerToolbar(toolbar); /* action = new QAction(il.load("dataedit"), tr("Edit Selected Item"), this); action->setShortcut(tr("Edit")); action->setStatusTip(tr("Edit the selected item")); connect(action, SIGNAL(triggered()), this, SLOT(editRow())); toolbar->addAction(action); */ QFrame *mainFrame = new QFrame; setCentralWidget(mainFrame); QGridLayout *grid = new QGridLayout; mainFrame->setLayout(grid); QGroupBox *box = new QGroupBox; if (title != "") { box->setTitle(title); } else { box->setTitle(tr("Data in Layer")); } grid->addWidget(box, 0, 0); grid->setRowStretch(0, 15); QGridLayout *subgrid = new QGridLayout; box->setLayout(subgrid); subgrid->setSpacing(0); subgrid->setMargin(5); subgrid->addWidget(new QLabel(tr("Find:")), 1, 0); subgrid->addWidget(new QLabel(tr(" ")), 1, 1); m_find = new QLineEdit; subgrid->addWidget(m_find, 1, 2); connect(m_find, SIGNAL(textChanged(const QString &)), this, SLOT(searchTextChanged(const QString &))); connect(m_find, SIGNAL(returnPressed()), this, SLOT(searchRepeated())); m_tableView = new QTableView; subgrid->addWidget(m_tableView, 0, 0, 1, 3); m_tableView->setSortingEnabled(true); m_tableView->sortByColumn(0, Qt::AscendingOrder); m_table = new ModelDataTableModel(model); m_tableView->setModel(m_table); m_tableView->horizontalHeader()->setStretchLastSection(true); connect(m_tableView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(viewClicked(const QModelIndex &))); connect(m_tableView, SIGNAL(pressed(const QModelIndex &)), this, SLOT(viewPressed(const QModelIndex &))); connect(m_tableView->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(currentChanged(const QModelIndex &, const QModelIndex &))); connect(m_table, SIGNAL(addCommand(Command *)), this, SLOT(addCommand(Command *))); connect(m_table, SIGNAL(currentChanged(const QModelIndex &)), this, SLOT(currentChangedThroughResort(const QModelIndex &))); connect(m_table, SIGNAL(modelRemoved()), this, SLOT(modelRemoved())); QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close); connect(bb, SIGNAL(rejected()), this, SLOT(close())); grid->addWidget(bb, 2, 0); grid->setRowStretch(2, 0); QDesktopWidget *desktop = QApplication::desktop(); QRect available = desktop->availableGeometry(); int width = available.width() / 3; int height = available.height() / 2; if (height < 370) { if (available.height() > 500) height = 370; } if (width < 650) { if (available.width() > 750) width = 650; else if (width < 500) { if (available.width() > 650) width = 500; } } resize(width, height); }
// ??? Break this stuff off into an InstrumentPopup class. This class is too // big. void TrackButtons::populateInstrumentPopup(Instrument *thisTrackInstr, QMenu* instrumentPopup) { // pixmaps for icons to show connection states as variously colored boxes // ??? Factor out the icon-related stuff to make this routine clearer. // getIcon(Instrument *) would be ideal, but might not be easy. // getIcon(Device *) would also be needed. static QPixmap connectedPixmap, unconnectedPixmap, connectedUsedPixmap, unconnectedUsedPixmap, connectedSelectedPixmap, unconnectedSelectedPixmap; static bool havePixmaps = false; if (!havePixmaps) { IconLoader il; connectedPixmap = il.loadPixmap("connected"); connectedUsedPixmap = il.loadPixmap("connected-used"); connectedSelectedPixmap = il.loadPixmap("connected-selected"); unconnectedPixmap = il.loadPixmap("unconnected"); unconnectedUsedPixmap = il.loadPixmap("unconnected-used"); unconnectedSelectedPixmap = il.loadPixmap("unconnected-selected"); havePixmaps = true; } Composition &comp = m_doc->getComposition(); // clear the popup instrumentPopup->clear(); QMenu *currentSubMenu = 0; // position index int count = 0; int currentDevId = -1; // Get the list Studio &studio = m_doc->getStudio(); InstrumentList list = studio.getPresentationInstruments(); // For each instrument for (InstrumentList::iterator it = list.begin(); it != list.end(); ++it) { if (!(*it)) continue; // sanity check // get the Localized instrument name, with the string hackery performed // in Instrument QString iname((*it)->getLocalizedPresentationName()); // translate the program name // // Note we are converting the string from std to Q back to std then to // C. This is obviously ridiculous, but the fact that we have programName // here at all makes me think it exists as some kind of necessary hack // to coax tr() into behaving nicely. I decided to change it as little // as possible to get it to compile, and not refactor this down to the // simplest way to call tr() on a C string. QString programName(strtoqstr((*it)->getProgramName())); programName = QObject::tr(programName.toStdString().c_str()); Device *device = (*it)->getDevice(); DeviceId devId = device->getId(); bool connectedIcon = false; // Determine the proper program name and whether it is connected if ((*it)->getType() == Instrument::SoftSynth) { programName = ""; AudioPluginInstance *plugin = (*it)->getPlugin(Instrument::SYNTH_PLUGIN_POSITION); if (plugin) { // we don't translate any plugin program names or other texts programName = strtoqstr(plugin->getDisplayName()); connectedIcon = (plugin->getIdentifier() != ""); } } else if ((*it)->getType() == Instrument::Audio) { connectedIcon = true; } else { QString conn = RosegardenSequencer::getInstance()-> getConnection(devId); connectedIcon = (conn != ""); } // These two are for selecting the correct icon to display. bool instrUsedByMe = false; bool instrUsedByAnyone = false; if (thisTrackInstr && thisTrackInstr->getId() == (*it)->getId()) { instrUsedByMe = true; instrUsedByAnyone = true; } // If we have switched to a new device, we'll create a new submenu if (devId != (DeviceId)(currentDevId)) { currentDevId = int(devId); // For selecting the correct icon to display. bool deviceUsedByAnyone = false; if (instrUsedByMe) deviceUsedByAnyone = true; else { for (Composition::trackcontainer::iterator tit = comp.getTracks().begin(); tit != comp.getTracks().end(); ++tit) { if (tit->second->getInstrument() == (*it)->getId()) { instrUsedByAnyone = true; deviceUsedByAnyone = true; break; } Instrument *instr = studio.getInstrumentById(tit->second->getInstrument()); if (instr && (instr->getDevice()->getId() == devId)) { deviceUsedByAnyone = true; } } } QIcon icon (connectedIcon ? (deviceUsedByAnyone ? connectedUsedPixmap : connectedPixmap) : (deviceUsedByAnyone ? unconnectedUsedPixmap : unconnectedPixmap)); // Create a submenu for this device QMenu *subMenu = new QMenu(instrumentPopup); subMenu->setMouseTracking(true); subMenu->setIcon(icon); // Not needed so long as AA_DontShowIconsInMenus is false. //subMenu->menuAction()->setIconVisibleInMenu(true); // Menu title QString deviceName = QObject::tr(device->getName().c_str()); subMenu->setTitle(deviceName); // QObject name subMenu->setObjectName(deviceName); // Add the submenu to the popup menu instrumentPopup->addMenu(subMenu); // Connect the submenu to slotInstrumentSelected() connect(subMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotInstrumentSelected(QAction*))); currentSubMenu = subMenu; } else if (!instrUsedByMe) {