# HG changeset patch # User Dan Stowell # Date 1287137231 -3600 # Node ID ca9f277343494184f710a6e7e7930d6c07143bd8 # Parent 8b3038e55d50d75c63a8a285a3a6d48441fb185f svitunes: retrieve the genre metadata, as well as the path diff -r 8b3038e55d50 -r ca9f27734349 main/MainWindow.cpp --- a/main/MainWindow.cpp Tue Oct 12 16:02:02 2010 +0100 +++ b/main/MainWindow.cpp Fri Oct 15 11:07:11 2010 +0100 @@ -2165,14 +2165,17 @@ void MainWindow::importITunesAudio() { - QString path = iTunesNowPlayingPath(); + QStringList nowPlaying = iTunesNowPlaying(); + QString path = nowPlaying.at(0); + QString genre = (nowPlaying.size() > 1) ? nowPlaying.at(1) : ""; + std::cerr << "MainWindow::importITunesAudio(): genre is " << genre.toStdString() << std::endl; if (path != "") { - if (openAudio(path, ReplaceMainModel) == FileOpenFailed) { + if (openAudio(path, ReplaceMainModel) == FileOpenFailed) { emit hideSplash(); - QMessageBox::critical(this, tr("Failed to open file"), - tr("File open failed

Audio file \"%1\" could not be opened").arg(path)); - } + QMessageBox::critical(this, tr("Failed to open file"), + tr("File open failed

Audio file \"%1\" could not be opened").arg(path)); + } } } #endif diff -r 8b3038e55d50 -r ca9f27734349 main/main.cpp --- a/main/main.cpp Tue Oct 12 16:02:02 2010 +0100 +++ b/main/main.cpp Fri Oct 15 11:07:11 2010 +0100 @@ -220,7 +220,8 @@ void setupDockMenu() { std::cerr << "SV adding mac dock menu" << std::endl; QMenu *dockMenu = new QMenu(); - QString theText = iTunesNowPlayingPath(); + QStringList nowPlaying = iTunesNowPlaying(); + QString theText = nowPlaying.at(0); if (theText == ""){ theText = "[[No current track in iTunes]]"; } diff -r 8b3038e55d50 -r ca9f27734349 osx/svitunes.h --- a/osx/svitunes.h Tue Oct 12 16:02:02 2010 +0100 +++ b/osx/svitunes.h Fri Oct 15 11:07:11 2010 +0100 @@ -17,7 +17,8 @@ //LATER: bool iTunesRunning(); -QString iTunesNowPlayingPath(); +// Returns a list containing [posixpath, genre] +QStringList iTunesNowPlaying(); //LATER: QStringList iTunesSelectedPaths(); diff -r 8b3038e55d50 -r ca9f27734349 osx/svitunes.mm --- a/osx/svitunes.mm Tue Oct 12 16:02:02 2010 +0100 +++ b/osx/svitunes.mm Fri Oct 15 11:07:11 2010 +0100 @@ -32,7 +32,7 @@ return result; } -QString iTunesNowPlayingPath(){ +QStringList iTunesNowPlaying(){ NSDictionary *errorDict; NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource:@" \ tell application \"System Events\" to set iTunesIsRunning to (name of processes) contains \"iTunes\" \n\ @@ -50,7 +50,7 @@ end if \n\ end if \n\ \ - return the POSIX path of (location of aTrack as text) \n\ + return the POSIX path of (location of aTrack as text) & \"\n\" & (genre of aTrack) \n\ end tell \n\ " ]; @@ -73,5 +73,5 @@ QString resultString = qt_mac_NSStringToQString(nsResultString); [scriptObject release]; - return resultString; + return resultString.split(QChar('\n')); }