Пример #1
0
void Master::processCommandLine(QStringList args) {
	if (args.count() < 3) return;
	QString command = args.at(1);
	QStringList files = args.mid(2);
	if (QString::compare(command, "play", Qt::CaseInsensitive) == 0) {
		emit playMidiFiles(files);
	} else if (QString::compare(command, "convert", Qt::CaseInsensitive) == 0) {
		if (args.count() > 3) emit convertMidiFiles(files);
	}
}
Пример #2
0
void Master::processCommandLine(QStringList args) {
	int argIx = 1;
	QString command = args.at(argIx++);
	while (command.startsWith('-')) {
		if (QString::compare(command, "-profile", Qt::CaseInsensitive) == 0) {
			if (args.count() > argIx) {
				QString profile = args.at(argIx++);
				if (enumSynthProfiles().contains(profile, Qt::CaseInsensitive)) {
					synthProfileName = profile;
				} else {
					QMessageBox::warning(NULL, "Error", "The profile name specified in command line is invalid.\nOption \"-profile\" ignored.");
				}
			} else {
				QMessageBox::warning(NULL, "Error", "The profile name must be specified in command line with \"-profile\" option.");
				showCommandLineHelp();
			}
		} else if (QString::compare(command, "-max_sessions", Qt::CaseInsensitive) == 0) {
			if (args.count() > argIx) {
				maxSessions = args.at(argIx++).toUInt();
				if (maxSessions == 0) QMessageBox::warning(NULL, "Error", "The maximum number of sessions specified in command line is invalid.\nOption \"-max_sessions\" ignored.");
			} else {
				QMessageBox::warning(NULL, "Error", "The maximum number of sessions must be specified in command line with \"-max_sessions\" option.");
				showCommandLineHelp();
			}
		} else {
			QMessageBox::warning(NULL, "Error", "Illegal command line option " + command + " specified.");
			showCommandLineHelp();
		}
		if (args.count() == argIx) return;
		command = args.at(argIx++);
	}
	if (args.count() == argIx) {
		QMessageBox::warning(NULL, "Error", "The file list must be specified in command line with a command.");
		showCommandLineHelp();
		return;
	}
	QStringList files = args.mid(argIx);
	if (QString::compare(command, "play", Qt::CaseInsensitive) == 0) {
		emit playMidiFiles(files);
	} else if (QString::compare(command, "convert", Qt::CaseInsensitive) == 0) {
		if (args.count() > (argIx + 1)) {
			emit convertMidiFiles(files);
		} else {
			QMessageBox::warning(NULL, "Error", "The file list must be specified in command line with " + command + " command.");
			showCommandLineHelp();
		}
	} else {
		QMessageBox::warning(NULL, "Error", "Illegal command " + command + " specified in command line.");
		showCommandLineHelp();
	}
}