# HG changeset patch # User Dan Stowell # Date 1286895722 -3600 # Node ID 8b3038e55d50d75c63a8a285a3a6d48441fb185f # Parent d0c6a13ae6d25224759a591b4b9e44e891d1cb63 on mac, add item to File menu "Import current track from iTunes". TODO: set inactive if itunes not open; connect up with the dock menu stuff. diff -r d0c6a13ae6d2 -r 8b3038e55d50 main/MainWindow.cpp --- a/main/MainWindow.cpp Tue Oct 12 13:59:06 2010 +0100 +++ b/main/MainWindow.cpp Tue Oct 12 16:02:02 2010 +0100 @@ -79,6 +79,9 @@ #include "widgets/ModelDataTableDialog.h" #include "rdf/PluginRDFIndexer.h" #include "rdf/RDFExporter.h" +#ifdef Q_WS_MAC + #include "osx/svitunes.h" +#endif #include "Surveyer.h" #include "framework/VersionTester.h" @@ -442,6 +445,16 @@ m_keyReference->registerShortcut(action); menu->addAction(action); +#ifdef Q_WS_MAC + action = new QAction(tr("Import current track from iTunes"), this); + action->setShortcut(tr("Ctrl+Alt+I")); + action->setStatusTip(tr("Import currently playing/selected iTunes track")); + connect(action, SIGNAL(triggered()), this, SLOT(importITunesAudio())); + //connect(this, SIGNAL(canImportITunesAudio(bool)), action, SLOT(setEnabled(bool))); + m_keyReference->registerShortcut(action); + menu->addAction(action); +#endif + action = new QAction(tr("&Export Audio File..."), this); action->setStatusTip(tr("Export selection as an audio file")); connect(action, SIGNAL(triggered()), this, SLOT(exportAudio())); @@ -2148,6 +2161,22 @@ } } +#ifdef Q_WS_MAC +void +MainWindow::importITunesAudio() +{ + QString path = iTunesNowPlayingPath(); + + if (path != "") { + 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)); + } + } +} +#endif + void MainWindow::exportAudio() { diff -r d0c6a13ae6d2 -r 8b3038e55d50 main/MainWindow.h --- a/main/MainWindow.h Tue Oct 12 13:59:06 2010 +0100 +++ b/main/MainWindow.h Tue Oct 12 16:02:02 2010 +0100 @@ -80,6 +80,9 @@ virtual void openSession(); virtual void importAudio(); virtual void importMoreAudio(); +#ifdef Q_WS_MAC + virtual void importITunesAudio(); +#endif virtual void openSomething(); virtual void openLocation(); virtual void openRecentFile();