diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-03-04 11:56:59 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-03-04 11:56:59 +0000 |
| commit | dca857498e15d000b6ba27dd07380302a47d1fcc (patch) | |
| tree | 3a6e837a792b73ec7ce47418050a561431f5888f /src/ui/mainwindow.cpp | |
| parent | b65e2c52cca85895d8af0186cec2b32be4fc19b7 (diff) | |
| download | qmmp-dca857498e15d000b6ba27dd07380302a47d1fcc.tar.gz qmmp-dca857498e15d000b6ba27dd07380302a47d1fcc.tar.bz2 qmmp-dca857498e15d000b6ba27dd07380302a47d1fcc.zip | |
improved command line support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1597 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/ui/mainwindow.cpp')
| -rw-r--r-- | src/ui/mainwindow.cpp | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 4fad52ce8..46cde2af1 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -526,47 +526,57 @@ void MainWindow::playPause() play(); } -bool MainWindow::processCommandArgs(const QStringList &slist,const QString& cwd) +bool MainWindow::processCommandArgs(const QStringList &slist, const QString& cwd) { - if (slist.count() > 0) + if(slist.isEmpty()) + return TRUE; + QString paths; + foreach(QString arg, slist) { - QString str = slist[0]; - - if (str.startsWith("--enqueue") || str.startsWith("-e")) //check for "--enqueue" modifier - { - if (slist.count() < 2) - return FALSE; - QStringList full_path_list; - for (int i = 1; i < slist.count(); ++i) - { - if ((slist.at(i).startsWith("/")) || (slist.at(i).contains("://"))) //is it absolute path or url? - full_path_list << slist.at(i); - else - full_path_list << cwd + "/" + slist.at(i); - } - m_pl_manager->currentPlayList()->addFileList(full_path_list); //TODO url support - } - else if (str.startsWith("-")) // is it a command? + if(arg.startsWith("-")) + break; + else + paths.append(arg); + } + if(!paths.isEmpty()) + { + QStringList full_path_list; + foreach(QString s, paths) { - if (CommandLineManager::hasOption(str)) - m_generalHandler->executeCommand(str); - else if (m_option_manager->identify(str)) - m_option_manager->executeCommand(str, this); + if ((s.startsWith("/")) || (s.contains("://"))) //is it absolute path or url? + full_path_list << s; else - return FALSE; + full_path_list << cwd + "/" + s; } - else// maybe it is a list of files or dirs + setFileList(full_path_list); + return TRUE; + } + QHash<QString, QStringList> commands = m_option_manager->splitArgs(slist); + if(commands.isEmpty()) + return FALSE; + foreach(QString key, commands.keys()) + { + if(key == "--enqueue" || key == "-e") { + QStringList args = commands.value(key); + if(args.isEmpty()) + return FALSE; QStringList full_path_list; - foreach(QString s,slist) + foreach(QString s, args) { if ((s.startsWith("/")) || (s.contains("://"))) //is it absolute path or url? full_path_list << s; else full_path_list << cwd + "/" + s; } - setFileList(full_path_list); //TODO url support + m_pl_manager->currentPlayList()->addFileList(full_path_list); } + else if (CommandLineManager::hasOption(key)) + m_generalHandler->executeCommand(key, commands.value(key)); + else if (m_option_manager->identify(key)) + m_option_manager->executeCommand(key, commands.value(key), this); + else + return FALSE; } return TRUE; } |
