diff main/main.cpp @ 246:ddbde90773b0 spectrogram-cache-rejig

* Merge from trunk
author Chris Cannam
date Wed, 27 Feb 2008 11:59:42 +0000
parents 37847fc0b381
children
line wrap: on
line diff
--- a/main/main.cpp	Tue Nov 13 13:51:07 2007 +0000
+++ b/main/main.cpp	Wed Feb 27 11:59:42 2008 +0000
@@ -32,6 +32,7 @@
 #include <QIcon>
 #include <QSessionManager>
 #include <QDir>
+#include <QSplashScreen>
 
 #include <iostream>
 #include <signal.h>
@@ -53,7 +54,11 @@
  Document, SVFileReader
 
  - Turning one model (e.g. audio) into another (e.g. more audio, or a
- curve extracted from it): Transform and subclasses
+ curve extracted from it): Transform, encapsulating the data that need
+ to be stored to be able to reproduce a given transformation;
+ TransformFactory, for discovering the available types of transform;
+ ModelTransformerFactory, ModelTransformer and subclasses, providing
+ the mechanisms for applying transforms to data models
 
  - Creating the plugins used by transforms: RealTimePluginFactory,
  FeatureExtractionPluginFactory.  See also the API documentation for
@@ -229,6 +234,18 @@
     QApplication::setOrganizationDomain("sonicvisualiser.org");
     QApplication::setApplicationName(QApplication::tr("Sonic Visualiser"));
 
+    QPixmap pixmap(":/icons/sv-splash.png");
+    QSplashScreen splash(pixmap);
+
+    QSettings settings;
+
+    settings.beginGroup("Preferences");
+    if (settings.value("show-splash", true).toBool()) {
+        splash.show();
+        application.processEvents();
+    }
+    settings.endGroup();
+
     QIcon icon;
     int sizes[] = { 16, 22, 24, 32, 48, 64, 128 };
     for (int i = 0; i < sizeof(sizes)/sizeof(sizes[0]); ++i) {
@@ -266,8 +283,8 @@
     qRegisterMetaType<size_t>("size_t");
     qRegisterMetaType<PropertyContainer::PropertyName>("PropertyContainer::PropertyName");
 
-    MainWindow gui(audioOutput, oscSupport);
-    application.setMainWindow(&gui);
+    MainWindow *gui = new MainWindow(audioOutput, oscSupport);
+    application.setMainWindow(gui);
 
     QDesktopWidget *desktop = QApplication::desktop();
     QRect available = desktop->availableGeometry();
@@ -277,21 +294,20 @@
     if (height < 450) height = available.height() * 2 / 3;
     if (width > height * 2) width = height * 2;
 
-    QSettings settings;
     settings.beginGroup("MainWindow");
     QSize size = settings.value("size", QSize(width, height)).toSize();
-    gui.resize(size);
+    gui->resize(size);
     if (settings.contains("position")) {
-        gui.move(settings.value("position").toPoint());
+        gui->move(settings.value("position").toPoint());
     }
     settings.endGroup();
     
-    gui.show();
+    gui->show();
 
     // The MainWindow class seems to have trouble dealing with this if
     // it tries to adapt to this preference before the constructor is
     // complete.  As a lazy hack, apply it explicitly from here
-    gui.preferenceChanged("Property Box Layout");
+    gui->preferenceChanged("Property Box Layout");
 
     bool haveSession = false;
     bool haveMainModel = false;
@@ -308,7 +324,7 @@
 
         if (path.endsWith("sv")) {
             if (!haveSession) {
-                status = gui.openSessionFile(path);
+                status = gui->openSessionFile(path);
                 if (status == MainWindow::FileOpenSucceeded) {
                     haveSession = true;
                     haveMainModel = true;
@@ -320,24 +336,24 @@
         }
         if (status != MainWindow::FileOpenSucceeded) {
             if (!haveMainModel) {
-                status = gui.open(path, MainWindow::ReplaceMainModel);
+                status = gui->open(path, MainWindow::ReplaceMainModel);
                 if (status == MainWindow::FileOpenSucceeded) {
                     haveMainModel = true;
                 }
             } else {
                 if (haveSession && !havePriorCommandLineModel) {
-                    status = gui.open(path, MainWindow::AskUser);
+                    status = gui->open(path, MainWindow::AskUser);
                     if (status == MainWindow::FileOpenSucceeded) {
                         havePriorCommandLineModel = true;
                     }
                 } else {
-                    status = gui.open(path, MainWindow::CreateAdditionalModel);
+                    status = gui->open(path, MainWindow::CreateAdditionalModel);
                 }
             }
         }
         if (status == MainWindow::FileOpenFailed) {
 	    QMessageBox::critical
-                (&gui, QMessageBox::tr("Failed to open file"),
+                (gui, QMessageBox::tr("Failed to open file"),
                  QMessageBox::tr("File or URL \"%1\" could not be opened").arg(path));
         }
     }
@@ -351,6 +367,7 @@
     settings.endGroup();
 #endif
 
+    splash.finish(gui);
 
 /*
     TipDialog tipDialog;
@@ -359,10 +376,11 @@
     }
 */
     int rv = application.exec();
-//    std::cerr << "application.exec() returned " << rv << std::endl;
+    std::cerr << "application.exec() returned " << rv << std::endl;
 
     cleanupMutex.lock();
     TempDirectory::getInstance()->cleanup();
+
     application.releaseMainWindow();
 
 #ifdef HAVE_FFTW3F
@@ -375,5 +393,7 @@
     }
 #endif
 
+    delete gui;
+
     return rv;
 }