diff main/MainWindow.cpp @ 369:8b3038e55d50 macness

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.
author Dan Stowell <dan.stowell@eecs.qmul.ac.uk>
date Tue, 12 Oct 2010 16:02:02 +0100
parents dbc1d2d72cf1
children ca9f27734349
line wrap: on
line diff
--- 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("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
+	}
+    }
+}
+#endif
+
 void
 MainWindow::exportAudio()
 {