Mercurial > hg > sonic-visualiser
comparison main/main.cpp @ 1523:f73a4e8c7040
Merge from branch 3.0-integration
author | Chris Cannam |
---|---|
date | Tue, 10 Jan 2017 16:21:32 +0000 |
parents | c8183f084ad8 |
children | 9fbaf30a09ab |
comparison
equal
deleted
inserted
replaced
1522:a0a37ed3c07a | 1523:f73a4e8c7040 |
---|---|
12 License, or (at your option) any later version. See the file | 12 License, or (at your option) any later version. See the file |
13 COPYING included with this distribution for more information. | 13 COPYING included with this distribution for more information. |
14 */ | 14 */ |
15 | 15 |
16 #include "MainWindow.h" | 16 #include "MainWindow.h" |
17 #include "SVSplash.h" | |
17 | 18 |
18 #include "system/System.h" | 19 #include "system/System.h" |
19 #include "system/Init.h" | 20 #include "system/Init.h" |
20 #include "base/TempDirectory.h" | 21 #include "base/TempDirectory.h" |
21 #include "base/PropertyContainer.h" | 22 #include "base/PropertyContainer.h" |
23 #include "data/fileio/FileSource.h" | 24 #include "data/fileio/FileSource.h" |
24 #include "widgets/TipDialog.h" | 25 #include "widgets/TipDialog.h" |
25 #include "widgets/InteractiveFileFinder.h" | 26 #include "widgets/InteractiveFileFinder.h" |
26 #include "svapp/framework/TransformUserConfigurator.h" | 27 #include "svapp/framework/TransformUserConfigurator.h" |
27 #include "transform/TransformFactory.h" | 28 #include "transform/TransformFactory.h" |
29 #include "svcore/plugin/PluginScan.h" | |
28 | 30 |
29 #include <QMetaType> | 31 #include <QMetaType> |
30 #include <QApplication> | 32 #include <QApplication> |
31 #include <QDesktopWidget> | 33 #include <QDesktopWidget> |
32 #include <QMessageBox> | 34 #include <QMessageBox> |
34 #include <QLocale> | 36 #include <QLocale> |
35 #include <QSettings> | 37 #include <QSettings> |
36 #include <QIcon> | 38 #include <QIcon> |
37 #include <QSessionManager> | 39 #include <QSessionManager> |
38 #include <QDir> | 40 #include <QDir> |
39 #include <QSplashScreen> | |
40 #include <QTimer> | 41 #include <QTimer> |
41 #include <QPainter> | 42 #include <QPainter> |
42 #include <QFileOpenEvent> | 43 #include <QFileOpenEvent> |
43 | |
44 #include "../version.h" | |
45 | 44 |
46 #include <iostream> | 45 #include <iostream> |
47 #include <signal.h> | 46 #include <signal.h> |
48 | 47 |
49 #ifdef HAVE_FFTW3F | 48 #ifdef HAVE_FFTW3F |
213 bool success = m_mainWindow->commitData(mayAskUser); | 212 bool success = m_mainWindow->commitData(mayAskUser); |
214 manager.release(); | 213 manager.release(); |
215 if (!success) manager.cancel(); | 214 if (!success) manager.cancel(); |
216 } | 215 } |
217 | 216 |
218 void handleFilepathArgument(QString path, QSplashScreen *splash); | 217 void handleFilepathArgument(QString path, SVSplash *splash); |
219 | 218 |
220 bool m_readyForFiles; | 219 bool m_readyForFiles; |
221 QStringList m_filepathQueue; | 220 QStringList m_filepathQueue; |
222 | 221 |
223 protected: | 222 protected: |
224 MainWindow *m_mainWindow; | 223 MainWindow *m_mainWindow; |
225 bool event(QEvent *); | 224 bool event(QEvent *); |
226 | |
227 }; | 225 }; |
228 | 226 |
229 int | 227 int |
230 main(int argc, char **argv) | 228 main(int argc, char **argv) |
231 { | 229 { |
270 | 268 |
271 QApplication::setOrganizationName("sonic-visualiser"); | 269 QApplication::setOrganizationName("sonic-visualiser"); |
272 QApplication::setOrganizationDomain("sonicvisualiser.org"); | 270 QApplication::setOrganizationDomain("sonicvisualiser.org"); |
273 QApplication::setApplicationName(QApplication::tr("Sonic Visualiser")); | 271 QApplication::setApplicationName(QApplication::tr("Sonic Visualiser")); |
274 | 272 |
275 QSplashScreen *splash = 0; | 273 QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); |
274 | |
275 SVSplash *splash = 0; | |
276 | 276 |
277 QSettings settings; | 277 QSettings settings; |
278 | |
279 settings.beginGroup("Preferences"); | |
280 // Default to using Piper server; can change in preferences | |
281 if (!settings.contains("run-vamp-plugins-in-process")) { | |
282 settings.setValue("run-vamp-plugins-in-process", false); | |
283 } | |
284 settings.endGroup(); | |
278 | 285 |
279 settings.beginGroup("Preferences"); | 286 settings.beginGroup("Preferences"); |
280 if (settings.value("show-splash", true).toBool()) { | 287 if (settings.value("show-splash", true).toBool()) { |
281 QPixmap pixmap(":/icons/sv-splash.png"); | 288 splash = new SVSplash(); |
282 QPainter painter; | |
283 painter.begin(&pixmap); | |
284 QString text = QString("v%1").arg(SV_VERSION); | |
285 painter.drawText | |
286 (pixmap.width() - painter.fontMetrics().width(text) - 10, | |
287 10 + painter.fontMetrics().ascent(), | |
288 text); | |
289 painter.end(); | |
290 splash = new QSplashScreen(pixmap); | |
291 splash->show(); | 289 splash->show(); |
292 QTimer::singleShot(5000, splash, SLOT(hide())); | 290 QTimer::singleShot(5000, splash, SLOT(hide())); |
293 application.processEvents(); | 291 application.processEvents(); |
294 } | 292 } |
295 settings.endGroup(); | 293 settings.endGroup(); |
308 icon.addFile(QString(":icons/sv-%1x%2.png").arg(sizes[i]).arg(sizes[i])); | 306 icon.addFile(QString(":icons/sv-%1x%2.png").arg(sizes[i]).arg(sizes[i])); |
309 } | 307 } |
310 QApplication::setWindowIcon(icon); | 308 QApplication::setWindowIcon(icon); |
311 | 309 |
312 QString language = QLocale::system().name(); | 310 QString language = QLocale::system().name(); |
311 SVDEBUG << "System language is: " << language << endl; | |
313 | 312 |
314 settings.beginGroup("Preferences"); | 313 settings.beginGroup("Preferences"); |
315 language = settings.value("locale", language).toString(); | 314 QString prefLanguage = settings.value("locale", language).toString(); |
315 if (prefLanguage != QString()) language = prefLanguage; | |
316 settings.endGroup(); | 316 settings.endGroup(); |
317 | 317 |
318 QTranslator qtTranslator; | 318 QTranslator qtTranslator; |
319 QString qtTrName = QString("qt_%1").arg(language); | 319 QString qtTrName = QString("qt_%1").arg(language); |
320 SVDEBUG << "Loading " << qtTrName << "... "; | 320 SVDEBUG << "Loading " << qtTrName << "... "; |
340 SVDEBUG << "Done" << endl; | 340 SVDEBUG << "Done" << endl; |
341 application.installTranslator(&svTranslator); | 341 application.installTranslator(&svTranslator); |
342 | 342 |
343 StoreStartupLocale(); | 343 StoreStartupLocale(); |
344 | 344 |
345 // Make known-plugins query as early as possible after showing | |
346 // splash screen. | |
347 PluginScan::getInstance()->scan(); | |
348 | |
345 // Permit size_t and PropertyName to be used as args in queued signal calls | 349 // Permit size_t and PropertyName to be used as args in queued signal calls |
346 qRegisterMetaType<PropertyContainer::PropertyName>("PropertyContainer::PropertyName"); | 350 qRegisterMetaType<PropertyContainer::PropertyName>("PropertyContainer::PropertyName"); |
347 | 351 |
348 MainWindow *gui = new MainWindow(audioOutput, oscSupport); | 352 MainWindow::SoundOptions options = MainWindow::WithEverything; |
353 if (!audioOutput) options = 0; | |
354 | |
355 MainWindow *gui = new MainWindow(options, oscSupport); | |
349 application.setMainWindow(gui); | 356 application.setMainWindow(gui); |
350 InteractiveFileFinder::setParentWidget(gui); | 357 InteractiveFileFinder::setParentWidget(gui); |
351 TransformUserConfigurator::setParentWidget(gui); | 358 TransformUserConfigurator::setParentWidget(gui); |
352 if (splash) { | 359 if (splash) { |
353 QObject::connect(gui, SIGNAL(hideSplash()), splash, SLOT(hide())); | 360 QObject::connect(gui, SIGNAL(hideSplash()), splash, SLOT(hide())); |
361 QObject::connect(gui, SIGNAL(hideSplash(QWidget *)), | |
362 splash, SLOT(finishSplash(QWidget *))); | |
354 } | 363 } |
355 | 364 |
356 QDesktopWidget *desktop = QApplication::desktop(); | 365 QDesktopWidget *desktop = QApplication::desktop(); |
357 QRect available = desktop->availableGeometry(); | 366 QRect available = desktop->availableGeometry(); |
358 | 367 |
416 } | 425 } |
417 #endif | 426 #endif |
418 settings.endGroup(); | 427 settings.endGroup(); |
419 #endif | 428 #endif |
420 | 429 |
421 if (splash) splash->finish(gui); | |
422 delete splash; | |
423 | |
424 /* | |
425 TipDialog tipDialog; | |
426 if (tipDialog.isOK()) { | |
427 tipDialog.exec(); | |
428 } | |
429 */ | |
430 int rv = application.exec(); | 430 int rv = application.exec(); |
431 | 431 |
432 gui->hide(); | 432 gui->hide(); |
433 | 433 |
434 cleanupMutex.lock(); | 434 cleanupMutex.lock(); |
488 return QApplication::event(event); | 488 return QApplication::event(event); |
489 } | 489 } |
490 } | 490 } |
491 | 491 |
492 /** Application-global handler for filepaths passed in, e.g. as command-line arguments or apple events */ | 492 /** Application-global handler for filepaths passed in, e.g. as command-line arguments or apple events */ |
493 void SVApplication::handleFilepathArgument(QString path, QSplashScreen *splash){ | 493 void SVApplication::handleFilepathArgument(QString path, SVSplash *splash){ |
494 static bool haveSession = false; | 494 static bool haveSession = false; |
495 static bool haveMainModel = false; | 495 static bool haveMainModel = false; |
496 static bool havePriorCommandLineModel = false; | 496 static bool havePriorCommandLineModel = false; |
497 | 497 |
498 MainWindow::FileOpenStatus status = MainWindow::FileOpenFailed; | 498 MainWindow::FileOpenStatus status = MainWindow::FileOpenFailed; |