Mercurial > hg > tony
comparison src/main.cpp @ 402:a0eedd10dee3 cxx11-types
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 23 Mar 2015 10:33:32 +0000 |
parents | ffd1a89a68fa 0649ac148bf7 |
children | ea7ca3335a1a |
comparison
equal
deleted
inserted
replaced
400:4b9b7ff3f19c | 402:a0eedd10dee3 |
---|---|
59 } | 59 } |
60 | 60 |
61 class TonyApplication : public QApplication | 61 class TonyApplication : public QApplication |
62 { | 62 { |
63 public: | 63 public: |
64 TonyApplication(int argc, char **argv) : | 64 TonyApplication(int &argc, char **argv) : |
65 QApplication(argc, argv), | 65 QApplication(argc, argv), |
66 m_mainWindow(0), | 66 m_mainWindow(0), |
67 m_readyForFiles(false) | 67 m_readyForFiles(false) |
68 { | 68 { |
69 } | 69 } |
98 | 98 |
99 bool m_readyForFiles; | 99 bool m_readyForFiles; |
100 QStringList m_filepathQueue; | 100 QStringList m_filepathQueue; |
101 | 101 |
102 virtual bool event(QEvent *event) { | 102 virtual bool event(QEvent *event) { |
103 | |
103 if (event->type() == QEvent::FileOpen) { | 104 if (event->type() == QEvent::FileOpen) { |
104 QString path = static_cast<QFileOpenEvent *>(event)->file(); | 105 QString path = static_cast<QFileOpenEvent *>(event)->file(); |
105 if (m_readyForFiles) { | 106 if (m_readyForFiles) { |
106 handleFilepathArgument(path, NULL); | 107 handleFilepathArgument(path, NULL); |
107 } else { | 108 } else { |
126 } | 127 } |
127 #endif | 128 #endif |
128 | 129 |
129 TonyApplication application(argc, argv); | 130 TonyApplication application(argc, argv); |
130 | 131 |
131 // For some weird reason, Mac builds are crashing on startup when | |
132 // this line is present. Eliminate it on that platform for now. | |
133 #ifndef Q_OS_MAC | |
134 QStringList args = application.arguments(); | 132 QStringList args = application.arguments(); |
135 #else | |
136 cerr << "NOTE: Command-line arguments are currently disabled on Mac, see comments in main.cpp" << endl; | |
137 QStringList args; | |
138 #endif | |
139 | 133 |
140 signal(SIGINT, signalHandler); | 134 signal(SIGINT, signalHandler); |
141 signal(SIGTERM, signalHandler); | 135 signal(SIGTERM, signalHandler); |
142 | 136 |
143 #ifndef Q_OS_WIN32 | 137 #ifndef Q_OS_WIN32 |
144 signal(SIGHUP, signalHandler); | 138 signal(SIGHUP, signalHandler); |
145 signal(SIGQUIT, signalHandler); | 139 signal(SIGQUIT, signalHandler); |
146 #endif | 140 #endif |
147 | 141 |
148 bool audioOutput = true; | 142 bool audioOutput = true; |
143 bool sonification = true; | |
144 bool spectrogram = true; | |
149 | 145 |
150 if (args.contains("--help") || args.contains("-h") || args.contains("-?")) { | 146 if (args.contains("--help") || args.contains("-h") || args.contains("-?")) { |
151 std::cerr << QApplication::tr( | 147 std::cerr << QApplication::tr( |
152 "\nTony is a program for interactive note and pitch analysis and annotation.\n\nUsage:\n\n %1 [--no-audio] [<file> ...]\n\n --no-audio: Do not attempt to open an audio output device\n <file>: One or more Tony (.ton) and audio files may be provided.\n").arg(argv[0]).toStdString() << std::endl; | 148 "\nTony is a program for interactive note and pitch analysis and annotation.\n\nUsage:\n\n %1 [--no-audio] [--no-sonification] [--no-spectrogram] [<file> ...]\n\n --no-audio: Do not attempt to open an audio output device\n --no-sonification: Disable sonification of pitch tracks and notes and hide their toggles.\n --no-spectrogram: Disable spectrogram.\n <file>: One or more Tony (.ton) and audio files may be provided.").arg(argv[0]).toStdString() << std::endl; |
153 exit(2); | 149 exit(2); |
154 } | 150 } |
155 | 151 |
156 if (args.contains("--no-audio")) audioOutput = false; | 152 if (args.contains("--no-audio")) audioOutput = false; |
153 | |
154 if (args.contains("--no-sonification")) sonification = false; | |
155 | |
156 if (args.contains("--no-spectrogram")) spectrogram = false; | |
157 | 157 |
158 QApplication::setOrganizationName("QMUL"); | 158 QApplication::setOrganizationName("QMUL"); |
159 QApplication::setOrganizationDomain("qmul.ac.uk"); | 159 QApplication::setOrganizationDomain("qmul.ac.uk"); |
160 QApplication::setApplicationName("Tony"); | 160 QApplication::setApplicationName("Tony"); |
161 | 161 |
193 | 193 |
194 // Permit size_t and PropertyName to be used as args in queued signal calls | 194 // Permit size_t and PropertyName to be used as args in queued signal calls |
195 qRegisterMetaType<size_t>("size_t"); | 195 qRegisterMetaType<size_t>("size_t"); |
196 qRegisterMetaType<PropertyContainer::PropertyName>("PropertyContainer::PropertyName"); | 196 qRegisterMetaType<PropertyContainer::PropertyName>("PropertyContainer::PropertyName"); |
197 | 197 |
198 MainWindow *gui = new MainWindow(audioOutput); | 198 MainWindow *gui = new MainWindow(audioOutput, sonification, spectrogram); |
199 application.setMainWindow(gui); | 199 application.setMainWindow(gui); |
200 if (splash) { | 200 if (splash) { |
201 QObject::connect(gui, SIGNAL(hideSplash()), splash, SLOT(hide())); | 201 QObject::connect(gui, SIGNAL(hideSplash()), splash, SLOT(hide())); |
202 } | 202 } |
203 | 203 |