changeset 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 d0c6a13ae6d2
children ca9f27734349
files main/MainWindow.cpp main/MainWindow.h
diffstat 2 files changed, 32 insertions(+), 0 deletions(-) [+]
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()
 {
--- 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();