changeset 334:f50fa43143ae

* Fixes to newer-version and survey-offering logic
author Chris Cannam
date Thu, 27 Aug 2009 16:49:29 +0000
parents faff9cd8f663
children 8fdfdd85881a
files main/MainWindow.cpp main/Surveyer.cpp
diffstat 2 files changed, 25 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/main/MainWindow.cpp	Thu Aug 27 16:31:45 2009 +0000
+++ b/main/MainWindow.cpp	Thu Aug 27 16:49:29 2009 +0000
@@ -79,6 +79,7 @@
 #include "rdf/RDFExporter.h"
 
 #include "Surveyer.h"
+#include "framework/VersionTester.h"
 
 // For version information
 #include <vamp/vamp.h>
@@ -294,6 +295,12 @@
             this, SLOT(midiEventsAvailable()));
     
     TransformFactory::getInstance()->startPopulationThread();
+
+    Surveyer *surveyer = new Surveyer(this);
+    VersionTester *vt = new VersionTester
+        ("sonicvisualiser.org", "/latest-version.txt", SV_VERSION);
+    connect(vt, SIGNAL(newerVersionAvailable(QString)),
+            this, SLOT(newerVersionAvailable(QString)));
 }
 
 MainWindow::~MainWindow()
@@ -349,8 +356,6 @@
     setupTransformsMenu();
 
     m_mainMenusCreated = true;
-
-    Surveyer *surveyer = new Surveyer(this);
 }
 
 void
@@ -4007,9 +4012,16 @@
 void
 MainWindow::newerVersionAvailable(QString version)
 {
-    QString title(tr("Newer version available"));
-    QString text(tr("<h3>Newer version available</h3><p>You are using version %1 of Sonic Visualiser.  Version %3 is now available.</p><p>Please consult the <a href=\"http://sonicvisualiser.org/\">Sonic Visualiser website</a> for more information.</p>").arg(SV_VERSION).arg(version));
-    QMessageBox::information(this, title, text);
+    QSettings settings;
+    settings.beginGroup("NewerVersionWarning");
+    QString tag = QString("version-%1-available-show").arg(version);
+    if (settings.value(tag, true).toBool()) {
+        QString title(tr("Newer version available"));
+        QString text(tr("<h3>Newer version available</h3><p>You are using version %1 of Sonic Visualiser, but version %3 is now available.</p><p>Please see the <a href=\"http://sonicvisualiser.org/\">Sonic Visualiser website</a> for more information.</p>").arg(SV_VERSION).arg(version));
+        QMessageBox::information(this, title, text);
+        settings.setValue(tag, false);
+    }
+    settings.endGroup();
 }
 
 
--- a/main/Surveyer.cpp	Thu Aug 27 16:31:45 2009 +0000
+++ b/main/Surveyer.cpp	Thu Aug 27 16:49:29 2009 +0000
@@ -96,17 +96,22 @@
 //    if (response != "yes") return;
 
     QString title = "Sonic Visualiser - User Survey";
-    QString text = "<h3>Sonic Visualiser: Take part in our survey!</h3><p>We at Queen Mary, University of London are running a short survey for users of Sonic Visualiser.  We are trying to find out how useful Sonic Visualiser is to people, and what we can do to improve it.</p><p>We do not ask for any personal information, and there's absolutely nothing commercial about it, and it should only take five minutes!</p><p>Would you like to take part?</p>";
+    QString text = "<h3>Sonic Visualiser: Take part in our survey!</h3><p>We at Queen Mary, University of London are running a short survey for users of Sonic Visualiser.  We are trying to find out how useful Sonic Visualiser is to people, and what we can do to improve it.</p><p>We do not ask for any personal information, and it should only take five minutes.</p><p>Would you like to take part?</p>";
 
     QMessageBox mb(dynamic_cast<QWidget *>(parent()));
     mb.setWindowTitle(title);
     mb.setText(text);
 
     QPushButton *yes = mb.addButton(tr("Yes! Take me to the survey"), QMessageBox::ActionRole);
-    mb.addButton(tr("No thanks"), QMessageBox::RejectRole);
+    mb.addButton(tr("No, thanks"), QMessageBox::RejectRole);
 
     mb.exec();
 
+    QSettings settings;
+    settings.beginGroup("Survey");
+    settings.setValue("countdown", -1);
+    settings.endGroup();
+
     if (mb.clickedButton() == yes) {
         QString svarg = SV_VERSION;
         QString platformarg = "unknown";
@@ -131,7 +136,7 @@
                 QString plugid = t.getPluginIdentifier();
                 QString type, soname, label;
                 PluginIdentifier::parseIdentifier(plugid, type, soname, label);
-                packages.insert(soname);
+                if (type == "vamp") packages.insert(soname);
             }
             for (std::set<QString>::const_iterator i = packages.begin();
                  i != packages.end(); ++i) {