Exemple #1
0
void KMLpdManager::checkStatus()
{
	KPipeProcess	proc;
	QString		cmd = programName(0) + " status all";
	if (proc.open(cmd))
	{
		QTextStream	t(&proc);
		QString		line;
		KMPrinter	*printer(0);
		int		p(-1);
		while (!t.eof())
		{
			line = t.readLine().stripWhiteSpace();
			if (line.isEmpty())
				continue;
			if ((p=line.find(':')) != -1)
				printer = findPrinter(line.left(p));
			else if (line.startsWith("printing") && printer)
				printer->setState(line.find("enabled") != -1 ? KMPrinter::Idle : KMPrinter::Stopped);
			else if (line.find("entries") != -1 && printer)
				if (!line.startsWith("no") && printer->state() == KMPrinter::Idle)
					printer->setState(KMPrinter::Processing);
		}
	}
}
Exemple #2
0
bool KMLpdManager::enablePrinter(KMPrinter *printer, bool state)
{
	KPipeProcess	proc;
	QString		cmd = programName(0);
	cmd += " ";
	cmd += state ? "up" : "down";
	cmd += " ";
	cmd += KProcess::quote(printer->printerName());
	if (proc.open(cmd))
	{
		QTextStream	t(&proc);
		QString		buffer;
		while (!t.eof())
			buffer.append(t.readLine());
		if (buffer.startsWith("?Privilege"))
		{
			setErrorMsg(i18n("Permission denied: you must be root."));
			return false;
		}
		return true;
	}
	else
	{
		setErrorMsg(i18n("Unable to execute command \"%1\".").arg(cmd));
		return false;
	}
}
void Getopt::printHelp() const
{
  // prepare list of all positional parameters
  GetoptPositionalParameterList positional_parameters = m_required_positional_parameters;
  std::copy(m_optional_positional_parameters.begin(), m_optional_positional_parameters.end(), std::back_inserter(positional_parameters));

  std::cerr << programName();
  if (programVersion() != "")
  {
    std::cerr << " (version " << programVersion() << ")";
  }
  std::cerr << std::endl << std::endl;

  std::cerr << "Usage: ";
  std::cerr << programName();

  std::cerr << " [OPTIONS...]";

  BOOST_FOREACH(const GetoptPositionalParameter param, positional_parameters)
  {
    if (param.isOptional())
    {
      std::cerr  << " [<" << param.name() << ">]";
    }
    else
    {
      std::cerr  << " <" << param.name() << ">";
    }
  }

  std::cerr << std::endl << std::endl << programDescription() << std::endl << std::endl;

  if (positional_parameters.size() > 0 )
  {
    std::cerr << "Positional Parameters:" << std::endl;

    BOOST_FOREACH(const GetoptPositionalParameter param, positional_parameters)
    {
      std::cerr << "  <" << param.name() << ">" << ":" << std::endl << "\t"
                << boost::regex_replace(param.help(), boost::regex("\\n"), "\n\t")
                << std::endl;
    }
Exemple #4
0
// replace some of the strings
void KrashConfig :: expandString(QString &str, bool shell, const QString &tempFile) const
{
  QMap<QString,QString> map;
  map[QString::fromLatin1("appname")] = QString::fromLatin1(appName());
  map[QString::fromLatin1("execname")] = startedByKdeinit() ? QString::fromLatin1("kdeinit") : m_execname;
  map[QString::fromLatin1("signum")] = QString::number(signalNumber());
  map[QString::fromLatin1("signame")] = signalName();
  map[QString::fromLatin1("progname")] = programName();
  map[QString::fromLatin1("pid")] = QString::number(pid());
  map[QString::fromLatin1("tempfile")] = tempFile;
  if (shell)
    str = KMacroExpander::expandMacrosShellQuote( str, map );
  else
    str = KMacroExpander::expandMacros( str, map );
}
Exemple #5
0
DvdWizard::DvdWizard(MonitorManager *manager, const QString &url, QWidget *parent) :
        QWizard(parent)
        , m_dvdauthor(NULL)
        , m_mkiso(NULL)
        , m_vobitem(NULL)
        , m_burnMenu(new QMenu(this))
{
    setWindowTitle(i18n("DVD Wizard"));
    //setPixmap(QWizard::WatermarkPixmap, QPixmap(KStandardDirs::locate("appdata", "banner.png")));
    m_pageVob = new DvdWizardVob(this);
    m_pageVob->setTitle(i18n("Select Files For Your DVD"));
    addPage(m_pageVob);

    m_pageChapters = new DvdWizardChapters(manager, m_pageVob->dvdFormat(), this);
    m_pageChapters->setTitle(i18n("DVD Chapters"));
    addPage(m_pageChapters);
    
    if (!url.isEmpty()) m_pageVob->setUrl(url);
    connect(m_pageVob, SIGNAL(prepareMonitor()), this, SLOT(slotprepareMonitor()));



    m_pageMenu = new DvdWizardMenu(m_pageVob->dvdFormat(), this);
    m_pageMenu->setTitle(i18n("Create DVD Menu"));
    addPage(m_pageMenu);

    QWizardPage *page4 = new QWizardPage;
    page4->setTitle(i18n("Creating DVD Image"));
    m_status.setupUi(page4);
    m_status.error_box->setHidden(true);
    m_status.error_box->setTabBarHidden(true);
    m_status.tmp_folder->setUrl(KUrl(KdenliveSettings::currenttmpfolder()));
    m_status.tmp_folder->setMode(KFile::Directory | KFile::ExistingOnly);
    m_status.iso_image->setUrl(KUrl(QDir::homePath() + "/untitled.iso"));
    m_status.iso_image->setFilter("*.iso");
    m_status.iso_image->setMode(KFile::File);
    m_status.iso_image->fileDialog()->setOperationMode(KFileDialog::Saving);

#if KDE_IS_VERSION(4,7,0)
    m_isoMessage = new KMessageWidget;
    QGridLayout *s =  static_cast <QGridLayout*> (page4->layout());
    s->addWidget(m_isoMessage, 5, 0, 1, -1);
    m_isoMessage->hide();
#endif

    addPage(page4);

    connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(slotPageChanged(int)));
    connect(m_status.button_start, SIGNAL(clicked()), this, SLOT(slotGenerate()));
    connect(m_status.button_abort, SIGNAL(clicked()), this, SLOT(slotAbort()));
    connect(m_status.button_preview, SIGNAL(clicked()), this, SLOT(slotPreview()));

    QString programName("k3b");
    QString exec = KStandardDirs::findExe(programName);
    if (!exec.isEmpty()) {
        //Add K3b action
        QAction *k3b = m_burnMenu->addAction(KIcon(programName), i18n("Burn with %1", programName), this, SLOT(slotBurn()));
        k3b->setData(exec);
    }
    programName = "brasero";
    exec = KStandardDirs::findExe(programName);
    if (!exec.isEmpty()) {
        //Add Brasero action
        QAction *brasero = m_burnMenu->addAction(KIcon(programName), i18n("Burn with %1", programName), this, SLOT(slotBurn()));
        brasero->setData(exec);
    }
    if (m_burnMenu->isEmpty()) m_burnMenu->addAction(i18n("No burning program found (K3b, Brasero)"));
    m_status.button_burn->setMenu(m_burnMenu);
    m_status.button_burn->setIcon(KIcon("tools-media-optical-burn"));
    m_status.button_burn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    m_status.button_preview->setIcon(KIcon("media-playback-start"));

    setButtonText(QWizard::CustomButton1, i18n("Load"));
    setButtonText(QWizard::CustomButton2, i18n("Save"));
    button(QWizard::CustomButton1)->setIcon(KIcon("document-open"));
    button(QWizard::CustomButton2)->setIcon(KIcon("document-save"));
    connect(button(QWizard::CustomButton1), SIGNAL(clicked()), this, SLOT(slotLoad()));
    connect(button(QWizard::CustomButton2), SIGNAL(clicked()), this, SLOT(slotSave()));
    setOption(QWizard::HaveCustomButton1, true);
    setOption(QWizard::HaveCustomButton2, true);
    QList<QWizard::WizardButton> layout;
    layout << QWizard::CustomButton1 << QWizard::CustomButton2 << QWizard::Stretch << QWizard::BackButton << QWizard::NextButton << QWizard::CancelButton << QWizard::FinishButton;
    setButtonLayout(layout);
}
void
ManageMetronomeDialog::populate(int deviceIndex)
{
    m_metronomeInstrument->clear();

    DeviceList *devices = m_doc->getStudio().getDevices();
    DeviceListConstIterator it;
    int count = 0;
    Device *dev = 0;

    for (it = devices->begin(); it != devices->end(); it++) {

        dev = *it;
        if (!isSuitable(dev)) continue;

        if (count == deviceIndex) break;
        count++;
    }

    // sanity
    if (count < 0 || dev == 0 || !isSuitable(dev)) {
        return ;
    }

    // populate instrument list
    InstrumentList list = dev->getPresentationInstruments();
    InstrumentList::iterator iit;

    const MidiMetronome *metronome = getMetronome(dev);

    // if we've got no metronome against this device then create one
    if (metronome == 0) {
        InstrumentId id = SystemInstrumentBase;

        for (iit = list.begin(); iit != list.end(); ++iit) {
            if ((*iit)->isPercussion()) {
                id = (*iit)->getId();
                break;
            }
        }

        setMetronome(dev, MidiMetronome(id));

        metronome = getMetronome(dev);
    }

    // metronome should now be set but we still check it
    if (metronome) {
        int position = 0;
        int count = 0;

        for (iit = list.begin(); iit != list.end(); ++iit) {

            QString iname(QObject::tr((*iit)->getName().c_str()));
            QString ipname((*iit)->getLocalizedPresentationName());
            QString programName(QObject::tr((*iit)->getProgramName().c_str()));

            QString text;

            if ((*iit)->getType() == Instrument::SoftSynth) {

                iname.replace(QObject::tr("Synth plugin "), "");
                programName = "";

                AudioPluginInstance *plugin = (*iit)->getPlugin
                    (Instrument::SYNTH_PLUGIN_POSITION);
                if (plugin)
                    programName = strtoqstr(plugin->getDisplayName());

            } else {

                iname = ipname;
            }

            if (programName != "") {
                text = tr("%1 (%2)").arg(iname).arg(programName);
            } else {
                text = iname;
            }

            m_metronomeInstrument->addItem(text);

            if ((*iit)->getId() == metronome->getInstrument()) {
                position = count;
            }
            count++;
        }
        m_metronomeInstrument->setCurrentIndex(position);

        m_barPitch = metronome->getBarPitch();
        m_beatPitch = metronome->getBeatPitch();
        m_subBeatPitch = metronome->getSubBeatPitch();
        slotPitchSelectorChanged(0);
        m_metronomeResolution->setCurrentIndex(metronome->getDepth());
        m_metronomeBarVely->setValue(metronome->getBarVelocity());
        m_metronomeBeatVely->setValue(metronome->getBeatVelocity());
        m_metronomeSubBeatVely->setValue(metronome->getSubBeatVelocity());
        m_playEnabled->setChecked(m_doc->getComposition().usePlayMetronome());
        m_recordEnabled->setChecked(m_doc->getComposition().useRecordMetronome());
        slotResolutionChanged(metronome->getDepth());
    }
}
Exemple #7
0
int main(int argc, char **argv)
{
    std::string programName(argv[0]);
    if (argc < 4)
    {
        std::cout << "usage:\n";
        std::cout << programName << "INPUT_FILE OUTPUT_C_ARRAY_NAME OUTPUT_FILE\n";
        return -1;
    }

    std::string inputFile(argv[1]);
    std::string outputName(argv[2]);
    std::string outputFile(argv[3]);
    std::ifstream readFile(inputFile, std::ios::binary | std::ios::in);

    readFile.seekg(0, std::ios::end);
    std::streamoff fileSize = readFile.tellg();
    readFile.seekg(0, std::ios::beg);

    const std::size_t minSize = sizeof(DDSURFACEDESC2) + sizeof(DWORD);
    if (fileSize < minSize)
    {
        std::cout << inputFile << " is only " << fileSize << " bytes, must be at greater than " << minSize
                  << " bytes to be a correct DDS image file.\n";
        return -2;
    }

    DWORD magicWord;
    readFile.read(reinterpret_cast<char*>(&magicWord), sizeof(DWORD));
    if (magicWord != MAKEFOURCC('D','D','S',' '))
    {
        std::cout << "Magic word must be " << MAKEFOURCC('D','D','S',' ') << ".\n";
        return -3;
    }

    DDSURFACEDESC2 header;
    readFile.read(reinterpret_cast<char*>(&header), sizeof(DDSURFACEDESC2));

    std::string formatName;
    std::size_t blockSize = 0;
    std::size_t blockWidth = 0;
    std::size_t blockHeight = 0;

    if (header.ddpfPixelFormat.dwFlags & DDPF_RGB)
    {
        blockSize = header.ddpfPixelFormat.dwRGBBitCount / 8;
        blockWidth = 1;
        blockHeight = 1;

        if (blockSize == 4)
        {
            if (header.ddpfPixelFormat.dwRBitMask        == 0x000000FF &&
                header.ddpfPixelFormat.dwGBitMask        == 0x0000FF00 &&
                header.ddpfPixelFormat.dwBBitMask        == 0x00FF0000 &&
                header.ddpfPixelFormat.dwRGBAlphaBitMask == 0xFF000000)
            {
                formatName = "RGBA8";
            }
            else if (header.ddpfPixelFormat.dwRBitMask       == 0x000000FF &&
                    header.ddpfPixelFormat.dwGBitMask        == 0x0000FF00 &&
                    header.ddpfPixelFormat.dwBBitMask        == 0x00FF0000 &&
                    header.ddpfPixelFormat.dwRGBAlphaBitMask == 0x00000000)
            {
                formatName = "RGBX8";
            }
            else if (header.ddpfPixelFormat.dwRBitMask       == 0x000003FF &&
                    header.ddpfPixelFormat.dwGBitMask        == 0x000FFC00 &&
                    header.ddpfPixelFormat.dwBBitMask        == 0x3FF00000 &&
                    header.ddpfPixelFormat.dwRGBAlphaBitMask == 0xC0000000)
            {
                formatName = "RGB10A2";
            }
            else if (header.ddpfPixelFormat.dwRBitMask       == 0x0000FFFF &&
                    header.ddpfPixelFormat.dwGBitMask        == 0xFFFF0000 &&
                    header.ddpfPixelFormat.dwBBitMask        == 0x00000000 &&
                    header.ddpfPixelFormat.dwRGBAlphaBitMask == 0x00000000)
            {
                formatName = "RG16";
            }
            else if (header.ddpfPixelFormat.dwRBitMask       == 0xFFFFFFFF &&
                    header.ddpfPixelFormat.dwGBitMask        == 0x00000000 &&
                    header.ddpfPixelFormat.dwBBitMask        == 0x00000000 &&
                    header.ddpfPixelFormat.dwRGBAlphaBitMask == 0x00000000)
            {
                formatName = "R32";
            }
            else
            {
                formatName = "UKNOWN";
            }
        }
    }
    else if (header.ddpfPixelFormat.dwFlags & DDPF_FOURCC)
    {
        switch (header.ddpfPixelFormat.dwFourCC)
        {
          case MAKEFOURCC('D','X','T','1'):
            formatName = "DXT1";
            blockSize = 8;
            blockWidth = 4;
            blockHeight = 4;
            break;

          case MAKEFOURCC('D','X','T','3'):
            formatName = "DXT3";
            blockSize = 16;
            blockWidth = 4;
            blockHeight = 4;
            break;

          case MAKEFOURCC('D','X','T','5'):
            formatName = "DXT5";
            blockSize = 16;
            blockWidth = 4;
            blockHeight = 4;
            break;

          case D3DFMT_R32F:
            formatName = "R32F";
            blockSize = 4;
            blockWidth = 1;
            blockHeight = 1;

          case D3DFMT_G32R32F:
            formatName = "RG32F";
            blockSize = 8;
            blockWidth = 1;
            blockHeight = 1;

          case D3DFMT_A32B32G32R32F:
            formatName = "RGBA32F";
            blockSize = 16;
            blockWidth = 1;
            blockHeight = 1;

          case D3DFMT_R16F:
            formatName = "R16F";
            blockSize = 2;
            blockWidth = 1;
            blockHeight = 1;

          case D3DFMT_G16R16F:
            formatName = "RG16F";
            blockSize = 4;
            blockWidth = 1;
            blockHeight = 1;

          case D3DFMT_A16B16G16R16F:
            formatName = "RGBA16F";
            blockSize = 8;
            blockWidth = 1;
            blockHeight = 1;

          default:
            std::cout << "Unsupported FourCC format.\n";
            return -5;
        }
    }
    else
    {
        std::cout << "Unsupported DDS format.\n";
        return -6;
    }

    std::size_t height = header.dwHeight;
    std::size_t width = header.dwWidth;
    std::size_t levels = std::max<size_t>(1, header.dwMipMapCount);

    std::ofstream oss(outputFile);
    oss << "// Automatically generated header from " << inputFile << ", a " << width << "x" << height;
    if (levels > 1)
    {
        oss << " (" << levels << " mip levels)";
    }
    oss << "\n// " << formatName << " texture using " << programName << ".\n";

    oss << "static const size_t " << outputName << "_width = " << width << ";\n";
    oss << "static const size_t " << outputName << "_height = " << height << ";\n";
    oss << "static const size_t " << outputName << "_levels = " << levels << ";\n";
    oss << "\n";

    for (std::size_t i = 0; i < levels; ++i)
    {
        std::size_t widthAtLevel = std::max<size_t>(width >> i, 1);
        std::size_t heightAtLevel = std::max<size_t>(height >> i, 1);
        std::size_t sizeAtLevel = static_cast<std::size_t>(std::ceil(widthAtLevel / static_cast<float>(blockWidth)) *
                                                           std::ceil(heightAtLevel / static_cast<float>(blockHeight))) *
                                  blockSize;

        std::vector<unsigned char> data(sizeAtLevel);
        readFile.read(reinterpret_cast<char*>(data.data()), sizeAtLevel);

        oss << "static const size_t " << outputName << "_" << i << "_width = " << widthAtLevel << ";\n";
        oss << "static const size_t " << outputName << "_" << i << "_height = " << heightAtLevel << ";\n";
        oss << "static const size_t " << outputName << "_" << i << "_size = " << sizeAtLevel << ";\n";
        oss << "static const unsigned char " << outputName << "_" << i << "_data[" << sizeAtLevel << "] =\n";
        oss << "{";
        for (std::size_t j = 0; j < sizeAtLevel; j++)
        {
            if (j % 16 == 0)
            {
                oss << "\n    ";
            }

            char buffer[32];
            sprintf_s(buffer, "0x%02X,", data[j]);
            oss << std::string(buffer);
        }
        oss << "\n";
        oss << "};\n";

        if (i + 1 < levels)
        {
            oss << "\n";
        }
    }

    oss.close();
    readFile.close();

    return 0;
}
void
TrackParameterBox::updateInstrument(const Instrument *instrument)
{
    // As with the Device field above, this will rarely change and it is
    // expensive to clear and reload.  So, we should cache enough info to
    // detect a real change.  This would be Instrument names and IDs.

    const DeviceId deviceId = instrument->getDevice()->getId();
    const Device &device = *(m_doc->getStudio().getDevice(deviceId));

    const InstrumentList instrumentList = device.getPresentationInstruments();

    // Generate local instrument name and ID lists to compare against the
    // members.

    std::vector<InstrumentId> instrumentIds;
    std::vector<QString> instrumentNames;

    // For each instrument
    for (size_t instrumentIndex = 0;
         instrumentIndex < instrumentList.size();
         ++instrumentIndex) {
        const Instrument &loopInstrument = *(instrumentList[instrumentIndex]);

        instrumentIds.push_back(loopInstrument.getId());

        QString instrumentName(QObject::tr(loopInstrument.getName().c_str()));
        QString programName(
                QObject::tr(loopInstrument.getProgramName().c_str()));

        if (loopInstrument.getType() == Instrument::SoftSynth) {

            instrumentName.replace(QObject::tr("Synth plugin"), "");

            programName = "";

            AudioPluginInstance *plugin =
                    instrument->getPlugin(Instrument::SYNTH_PLUGIN_POSITION);
            if (plugin)
                programName = strtoqstr(plugin->getDisplayName());
        }

        if (programName != "")
            instrumentName += " (" + programName + ")";

        // cut off the redundant eg. "General MIDI Device" that appears in the
        // combo right above here anyway
        instrumentName = instrumentName.mid(
                instrumentName.indexOf("#"), instrumentName.length());

        instrumentNames.push_back(instrumentName);
    }

    // If there has been an actual change
    if (instrumentIds != m_instrumentIds2  ||
        instrumentNames != m_instrumentNames2) {

        // Update the cache.
        m_instrumentIds2 = instrumentIds;
        m_instrumentNames2 = instrumentNames;

        // Reload the combobox

        m_instrument->clear();

        // For each instrument, add the name to the combobox.
        // ??? If we used a QStringList, we could just call addItems().
        for (size_t instrumentIndex = 0;
             instrumentIndex < m_instrumentNames2.size();
             ++instrumentIndex) {
            m_instrument->addItem(m_instrumentNames2[instrumentIndex]);
        }
    }

    // Find the current instrument in the instrument ID list.

    const InstrumentId instrumentId = instrument->getId();

    // Assume not found.
    int currentIndex = -1;

    // For each Instrument
    for (size_t instrumentIndex = 0;
         instrumentIndex < m_instrumentIds2.size();
         ++instrumentIndex) {
        // If this is the selected Instrument
        if (m_instrumentIds2[instrumentIndex] == instrumentId) {
            currentIndex = instrumentIndex;
            break;
        }
    }

    // Set the index.
    m_instrument->setCurrentIndex(currentIndex);
}
Exemple #9
0
void DexedAudioProcessorEditor::storeProgram() {
    String currentName = Cartridge::normalizePgmName((const char *) processor->data+145);
    Cartridge destSysex = processor->currentCart;
    File *externalFile = NULL;

    bool activeCartridgeFound = processor->activeFileCartridge.exists();
    
    while (true) {
        String msg;
        
        if ( externalFile == NULL ) {
            if ( activeCartridgeFound )
                msg = "Store program to current (" + processor->activeFileCartridge.getFileName() + ") / new cartridge";
            else
                msg = "Store program to current / new cartridge";
        } else {
            msg = "Store program to " + externalFile->getFileName();
        }
        
        AlertWindow dialog("Store Program", msg, AlertWindow::NoIcon, this);
        dialog.addTextEditor("Name", currentName, String("Name"), false);
        // TODO: fix the name length to 10

        StringArray programs;
        destSysex.getProgramNames(programs);
        dialog.addComboBox("Dest", programs, "Program Destination");


        if ( externalFile == NULL ) {
            StringArray saveAction;
            saveAction.add("Store program to DAW plugin song state");
            saveAction.add("Store program and create a new copy of the .syx cartridge");
            if ( activeCartridgeFound )
                saveAction.add("Store program and overwrite current .syx cartridge");
        
            dialog.addComboBox("SaveAction", saveAction, "Store Action");
        }
                
        dialog.addButton("OK", 0, KeyPress(KeyPress::returnKey));
        dialog.addButton("CANCEL", 1, KeyPress(KeyPress::escapeKey));
        dialog.addButton("EXTERNAL FILE", 2, KeyPress());
        int response = dialog.runModalLoop();

        if ( response == 2 ) {
            FileChooser fc("Destination Sysex", processor->dexedCartDir, "*.syx;*.SYX;*.*", 1);

            if ( fc.browseForFileToOpen() ) {
                if ( externalFile != NULL ) 
                    delete externalFile;

                externalFile = new File(fc.getResults().getReference(0));
                if ( destSysex.load(*externalFile) )
                    continue;
                AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "Read error", "Unable to read file");
            }
        }

        if ( response == 0 ) {
            TextEditor *name = dialog.getTextEditor("Name");
            ComboBox *dest = dialog.getComboBoxComponent("Dest");
            
            int programNum = dest->getSelectedItemIndex();
            String programName(name->getText());
            if ( programName.length() > 10 ) {
                int toStrip = programName.length() - 10;
                programName = programName.dropLastCharacters(toStrip);
            }

            if ( externalFile == NULL ) {
                processor->currentCart.packProgram((uint8_t *) processor->data, programNum, programName);
                rebuildProgramCombobox();
                processor->setCurrentProgram(programNum);
                processor->updateHostDisplay();
                
                int action = dialog.getComboBoxComponent("SaveAction")->getSelectedItemIndex();
                if ( action > 0 ) {                  
                    File destination = processor->activeFileCartridge;
                    if ( ! destination.exists() ) {
                        FileChooser fc("Destination Sysex", processor->dexedCartDir, "*.syx", 1);
                        if ( ! fc.browseForFileToSave(true) )
                            break;
                        destination = fc.getResult();
                    }
                    
                    processor->currentCart.saveVoice(destination);
                    processor->activeFileCartridge = destination;
                }
            } else {
                destSysex.packProgram((uint8_t *) processor->data, programNum, programName);
                if ( ! destSysex.saveVoice(*externalFile)) {
                    AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "Write error", "Unable to write file");
                }
            }
        }
        break;
    }

    if ( externalFile != NULL )
        delete externalFile;
    cartManager.resetActiveSysex();
}
Exemple #10
0
    void Application::parseArguments(QStringList args)
    {
        QFileInfo program(args.at(0));

        QString programName("renderer");
        if (program.exists())
            programName = program.baseName();

        if (args.contains("-h") || args.contains("-help") || args.contains("--help"))
        {
            std::cout
                << "Usage: " << programName.toLatin1().data()
                << " [-version]"
                << " [-gui]"
                << " [-bookjs path]"
                << " [-custom-css path]"
                << " [-output path]"
                << " URL"
                << std::endl;

            appQuit(0);
        }

        if (args.contains("-version"))
        {
            std::cout
                << applicationName().toLatin1().data()
                << " " << applicationVersion().toLatin1().data()
#if defined(Q_PROCESSOR_X86_32)
                << " x86"
#elif defined(Q_PROCESSOR_X86_64)
                << " amd64"
#endif
                << std::endl;
            appQuit(0);
        }

        m_gui = args.contains("-gui");

        int bookjsPathIndex = args.indexOf("-bookjs");
        if (bookjsPathIndex != -1)
        {
            QString path = takeOptionValue(&args, bookjsPathIndex);

            QDir dir(path);

            if (! dir.exists())
            {
                appQuit(1, QString("path does not point to a directory: %1").arg(path));
            }

            m_rendererOptions.bookjsPath = dir.absolutePath();
        }

        int cssPathIndex = args.indexOf("-custom-css");
        if (cssPathIndex != -1)
        {
            QString path = takeOptionValue(&args, cssPathIndex);

            if (! QFileInfo(path).isReadable())
            {
                appQuit(1, QString("file does not exist or is not readable: %1").arg(path));
            }

            QFile file(path);

            if (! file.open(QFile::ReadOnly))
            {
                appQuit(1, QString("cout not open file: %1").arg(path));
            }

            m_rendererOptions.customCSS = QTextStream(&file).readAll();
        }

        int outputPathIndex = args.indexOf("-output");
        if (outputPathIndex != -1)
            m_rendererOptions.outputFilePath = takeOptionValue(&args, outputPathIndex);

        int lastArg = args.lastIndexOf(QRegExp("^-.*"));
        m_urls = (lastArg != -1) ? args.mid(++lastArg) : args.mid(1);
    }
Exemple #11
0
// ??? 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) {
Exemple #12
0
void checkIfRunAsInstalled(char* arg0) {
    std::string programName(arg0);
    if (programName.find("framework/") == 0
        || programName.find("./framework/") == 0)
        Configurator::getInstance().setRunAsInstalled(false);
}