示例#1
0
void MainContentComponent::buttonClicked(Button* button)
{
	if (button == &_rescanButton)
	{
		// Re-enumerate MIDI IN and OUT devices
		MIDIProcessor::getInstance().rescanDevices();
		MIDISender::getInstance().rescanDevices();
	}
	else if (button == &_removeRowButton)
	{
		if (_commandTable.getSelectedRow() != -1)
		{
			_commandTableModel.removeRow(_commandTable.getSelectedRow());
			_commandTable.updateContent();
		}
	}
	else if (button == &_saveButton)
	{
		bool profileDirSet = SettingsManager::getInstance().getProfileDirectory().isNotEmpty();
		FileBrowserComponent browser(FileBrowserComponent::canSelectFiles | FileBrowserComponent::saveMode |
			FileBrowserComponent::warnAboutOverwriting,
			profileDirSet ? SettingsManager::getInstance().getProfileDirectory() : File::getCurrentWorkingDirectory(),
			nullptr,
			nullptr);
		FileChooserDialogBox dialogBox("Save profile",
			"Enter filename to save profile",
			browser,
			true,
			Colours::lightgrey);
		if (dialogBox.show())
		{
			File selectedFile = browser.getSelectedFile(0).withFileExtension("xml");
			CommandMap::getInstance().toXMLDocument(selectedFile);
		}
	}
	else if (button == &_loadButton)
	{
		bool profileDirSet = SettingsManager::getInstance().getProfileDirectory().isNotEmpty();
		WildcardFileFilter wildcardFilter("*.xml", String::empty, "MIDI2LR profiles");
		FileBrowserComponent browser(FileBrowserComponent::canSelectFiles | FileBrowserComponent::openMode,
			profileDirSet ? SettingsManager::getInstance().getProfileDirectory() : File::getCurrentWorkingDirectory(),
			&wildcardFilter,
			nullptr);
		FileChooserDialogBox dialogBox("Open profile",
			"Select a profile to open",
			browser,
			true,
			Colours::lightgrey);

		if (dialogBox.show())
		{
			ScopedPointer<XmlElement> elem = XmlDocument::parse(browser.getSelectedFile(0));
			if (elem)
			{
				_profileNameLabel.setText(browser.getSelectedFile(0).getFileName(), NotificationType::dontSendNotification);
				_commandTableModel.buildFromXml(elem);
				_commandTable.updateContent();
				_commandTable.repaint();
			}
		}
	}
	else if (button == &_settingsButton)
	{
		DialogWindow::LaunchOptions dwOpt;
		dwOpt.dialogTitle = "Settings";
		dwOpt.content.setOwned(new SettingsComponent());
		dwOpt.content->setSize(300, 200);
		dwOpt.escapeKeyTriggersCloseButton = true;
		dwOpt.useNativeTitleBar = false;
		_settingsDialog = dwOpt.create();
		_settingsDialog->setVisible(true);
	}
}
示例#2
0
void MainContentComponent::buttonClicked(Button* button)
{
    if (button == &_rescanButton)
    {
        // Re-enumerate MIDI IN and OUT devices	

		if (m_midiProcessor)
		{
			m_midiProcessor->rescanDevices();
		}

		if (m_midiSender)
		{
			m_midiSender->rescanDevices();
		}
        // Send new CC parameters to MIDI Out devices
		if (m_lr_IPC_IN)
		{
			m_lr_IPC_IN->refreshMIDIOutput();
		}		
    }
    else if (button == &_removeRowButton)
    {
        if (_commandTable.getSelectedRow() != -1)
        {
            _commandTableModel.removeRow(_commandTable.getSelectedRow());
            _commandTable.updateContent();
        }
    }
    else if (button == &_saveButton)
    {
        
		File profileDir;

		if (m_settingsManager)
		{
			profileDir = m_settingsManager->getProfileDirectory();
		}

		if (!profileDir.exists())
		{
			profileDir = File::getCurrentWorkingDirectory();
		}

		WildcardFileFilter wildcardFilter("*.xml", String::empty, "MIDI2LR profiles");
        FileBrowserComponent browser(FileBrowserComponent::canSelectFiles | FileBrowserComponent::saveMode |
            FileBrowserComponent::warnAboutOverwriting,	profileDir,	&wildcardFilter,  nullptr);
        FileChooserDialogBox dialogBox("Save profile",
            "Enter filename to save profile",
            browser,
            true,
            Colours::lightgrey);
        if (dialogBox.show())
        {
            File selectedFile = browser.getSelectedFile(0).withFileExtension("xml");

			if (m_commandMap)
			{
				m_commandMap->toXMLDocument(selectedFile);
			}
        }
    }
    else if (button == &_loadButton)
    {
        File profileDir;

		if (m_settingsManager)
		{
			profileDir = m_settingsManager->getProfileDirectory();
		}

		if (!profileDir.exists())
		{
			profileDir = File::getCurrentWorkingDirectory();
		}


        WildcardFileFilter wildcardFilter("*.xml", String::empty, "MIDI2LR profiles");
        FileBrowserComponent browser(FileBrowserComponent::canSelectFiles | FileBrowserComponent::openMode,		profileDir, &wildcardFilter, nullptr);
        FileChooserDialogBox dialogBox("Open profile", "Select a profile to open", browser, true, Colours::lightgrey);

        if (dialogBox.show())
        {
            ScopedPointer<XmlElement> elem = XmlDocument::parse(browser.getSelectedFile(0));
            if (elem)
            {
                File newprofile = browser.getSelectedFile(0);
                String command = String("ChangedToFullPath ") + newprofile.getFullPathName() + "\n";

				if (m_lr_IPC_OUT)
				{
					m_lr_IPC_OUT->sendCommand(command);
				}
                _profileNameLabel.setText(newprofile.getFileName(), NotificationType::dontSendNotification);
                _commandTableModel.buildFromXml(elem);
                _commandTable.updateContent();
                _commandTable.repaint();
            }
        }
    }
    else if (button == &_settingsButton)
    {
        DialogWindow::LaunchOptions dwOpt;
        dwOpt.dialogTitle = "Settings";
		//create new object
		SettingsComponent *comp = new SettingsComponent();
		comp->Init(m_settingsManager);
        dwOpt.content.setOwned(comp);
        dwOpt.content->setSize(400, 300);
        dwOpt.escapeKeyTriggersCloseButton = true;
        dwOpt.useNativeTitleBar = false;
        _settingsDialog = dwOpt.create();
        _settingsDialog->setVisible(true);
    }
}