comparison 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
comparison
equal deleted inserted replaced
368:d0c6a13ae6d2 369:8b3038e55d50
77 #include "base/UnitDatabase.h" 77 #include "base/UnitDatabase.h"
78 #include "layer/ColourDatabase.h" 78 #include "layer/ColourDatabase.h"
79 #include "widgets/ModelDataTableDialog.h" 79 #include "widgets/ModelDataTableDialog.h"
80 #include "rdf/PluginRDFIndexer.h" 80 #include "rdf/PluginRDFIndexer.h"
81 #include "rdf/RDFExporter.h" 81 #include "rdf/RDFExporter.h"
82 #ifdef Q_WS_MAC
83 #include "osx/svitunes.h"
84 #endif
82 85
83 #include "Surveyer.h" 86 #include "Surveyer.h"
84 #include "framework/VersionTester.h" 87 #include "framework/VersionTester.h"
85 88
86 // For version information 89 // For version information
439 action->setStatusTip(tr("Import an extra audio file as a separate layer")); 442 action->setStatusTip(tr("Import an extra audio file as a separate layer"));
440 connect(action, SIGNAL(triggered()), this, SLOT(importMoreAudio())); 443 connect(action, SIGNAL(triggered()), this, SLOT(importMoreAudio()));
441 connect(this, SIGNAL(canImportMoreAudio(bool)), action, SLOT(setEnabled(bool))); 444 connect(this, SIGNAL(canImportMoreAudio(bool)), action, SLOT(setEnabled(bool)));
442 m_keyReference->registerShortcut(action); 445 m_keyReference->registerShortcut(action);
443 menu->addAction(action); 446 menu->addAction(action);
447
448 #ifdef Q_WS_MAC
449 action = new QAction(tr("Import current track from iTunes"), this);
450 action->setShortcut(tr("Ctrl+Alt+I"));
451 action->setStatusTip(tr("Import currently playing/selected iTunes track"));
452 connect(action, SIGNAL(triggered()), this, SLOT(importITunesAudio()));
453 //connect(this, SIGNAL(canImportITunesAudio(bool)), action, SLOT(setEnabled(bool)));
454 m_keyReference->registerShortcut(action);
455 menu->addAction(action);
456 #endif
444 457
445 action = new QAction(tr("&Export Audio File..."), this); 458 action = new QAction(tr("&Export Audio File..."), this);
446 action->setStatusTip(tr("Export selection as an audio file")); 459 action->setStatusTip(tr("Export selection as an audio file"));
447 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio())); 460 connect(action, SIGNAL(triggered()), this, SLOT(exportAudio()));
448 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool))); 461 connect(this, SIGNAL(canExportAudio(bool)), action, SLOT(setEnabled(bool)));
2145 QMessageBox::critical(this, tr("Failed to open file"), 2158 QMessageBox::critical(this, tr("Failed to open file"),
2146 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path)); 2159 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
2147 } 2160 }
2148 } 2161 }
2149 } 2162 }
2163
2164 #ifdef Q_WS_MAC
2165 void
2166 MainWindow::importITunesAudio()
2167 {
2168 QString path = iTunesNowPlayingPath();
2169
2170 if (path != "") {
2171 if (openAudio(path, ReplaceMainModel) == FileOpenFailed) {
2172 emit hideSplash();
2173 QMessageBox::critical(this, tr("Failed to open file"),
2174 tr("<b>File open failed</b><p>Audio file \"%1\" could not be opened").arg(path));
2175 }
2176 }
2177 }
2178 #endif
2150 2179
2151 void 2180 void
2152 MainWindow::exportAudio() 2181 MainWindow::exportAudio()
2153 { 2182 {
2154 if (!getMainModel()) return; 2183 if (!getMainModel()) return;