void MainWindow::showSongsContextMenu(QPoint point)
{
    QTreeView *songs = (QTreeView*)ui->tvSongs;
    if(songs->indexAt(point).isValid()) {
        QList<QAction *> actions;

        QAction *action = new QAction(songs);
        action->setText(tr("Play"));
        connect(action, SIGNAL(triggered()), this, SLOT(playAudio()));
        actions.append(action);

        action = new QAction(songs);
        action->setText(tr("Delete"));
        connect(action, SIGNAL(triggered()), this, SLOT(deleteAudio()));
        actions.append(action);

        action = new QAction(songs);
        action->setSeparator(true);
        actions.append(action);

        QList<Playlist> pls = dp->getPlaylists();
        int n = pls.count();
        QSignalMapper* signalMapper = new QSignalMapper (this);
        for( int i=0; i<n; i++ )
        {
            action = new QAction(songs);
            action->setText("Add to " + pls[i].title);
            connect(action, SIGNAL(triggered()), signalMapper, SLOT(map()));
            signalMapper->setMapping (action, pls[i].id) ;
            actions.append(action);
        }
        connect (signalMapper, SIGNAL(mapped(int)), this, SLOT(addAudioToPlaylist(int)));
        QMenu::exec(actions, songs->mapToGlobal(point));
    }
Beispiel #2
0
int main(int argc, char *argv[])
{
	int i, result;

	progname = strrchr(argv[0], '/');
	if (progname == NULL)
		progname = argv[0];
	else
		progname++;
	if (argc == 1)
		usage();

	for (i = 0; i < MAX_SCORES; i++) {
		scoreNames[i] = NULL;
		scores[i] = NULL;
	}

	for (i = 1; i < argc; i++) {
		char *arg = argv[i];
		if (arg[0] == '-') {
			switch (arg[1]) {
				case 'a':
					if (++i >= argc)
						usage();
					rescaleFactor = atof(argv[i]);
					if (fabs(rescaleFactor) > 2.0)
						rescaleFactor = 2.0;
					break;
				case 'B':
					if (++i >= argc)
						usage();
					framesPerBuffer = atof(argv[i]);
					if (framesPerBuffer < MIN_FRAMES_PER_BUF)
						framesPerBuffer = MIN_FRAMES_PER_BUF;
					break;
				case 'c':
					if (++i >= argc)
						usage();
					numOutChannels = atof(argv[i]);
					if (numOutChannels < 1)
						numOutChannels = 1;
					break;
				case 'd':
					if (++i >= argc)
						usage();
					totalDuration = atof(argv[i]);
					if (totalDuration < 0.0)
						totalDuration = 0.0;	// kinda stupid
					break;
				case 'h':
					usage();
					break;
#ifdef HAVE_PORTAUDIO
				case 'n':
					withAudio = 0;
					scoreDelayTime = 0.0;
					break;
#endif
				case 'q':
					printJobOutput = 0;
					break;
				case 'r':
					if (++i >= argc)
						usage();
					sampleRate = atof(argv[i]);
					if (sampleRate < 8000) // be more stringent?
						sampleRate = 8000;
					break;
				case 'v':
					verbose = 1;
					break;
				case 'y':
					if (++i >= argc)
						usage();
					scoreDelayTime = atof(argv[i]);
					if (scoreDelayTime < 0.0)
						scoreDelayTime = 0.0;
					break;
//FIXME: others: call flush after each score? call destroy after each?
				default:
					usage();
			}
		}
		else {
			const char *name = arg;

			/* verify that filename ends in ".sco" */
			char *p = strrchr(name, '.');
			if (p == NULL || strncmp(p, ".sco", 4L)) {
				fprintf(stderr, "Score names must end in \".sco\" (%s).\n", name);
				exit(-1);
			}

			if (numScores < MAX_SCORES) {
				scoreNames[numScores] = name;
				numScores++;
			}
			else {
				fprintf(stderr, "No more than %d scores allowed.\n", MAX_SCORES);
				exit(-1);
			}
		}
	}

#ifdef HAVE_PORTAUDIO
	if (withAudio) {
		result = initAudio();
		if (result)
			return -1;
	}
#endif

	result = initRTcmix();
	if (result)
		return -1;

	result = loadScores();
	if (result)
		return -1;

	printSettings();

	playScores();

	for (i = 0; i < numScores; i++)
		if (scores[i])
			free(scores[i]);

	result = deleteRTcmix();

#ifdef HAVE_PORTAUDIO
	if (withAudio)
		result = deleteAudio();
#endif

	return result;
}