changeset 95:a67f0e5ec654

Add initial dialog / network permission tester; lower default zoom level
author Chris Cannam
date Wed, 04 Dec 2013 18:31:39 +0000
parents ab624c319eb7
children 291381b0340c
files .hgsubstate icons/qm-logo-larger.png icons/qm-logo-smaller.png src/MainWindow.cpp src/MainWindow.h src/NetworkPermissionTester.cpp src/NetworkPermissionTester.h tony.qrc tonyapp.pro
diffstat 9 files changed, 141 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate	Wed Dec 04 18:22:59 2013 +0000
+++ b/.hgsubstate	Wed Dec 04 18:31:39 2013 +0000
@@ -1,4 +1,4 @@
 236814e07bd07473958c1ff89103124536a0c3c8 dataquay
-055ff09f7a0897863299642f7d14814a05fcd9ac svapp
-23ecd10c2eb63af570fdc510c94ae66dd2992e0c svcore
+febd49356ef308ee10f07257b239cf66742bfedc svapp
+cc3f78e89df010bf6e87c735688738b980f51385 svcore
 cc6b219762614a33cf00614c4a6e200c0da8efe6 svgui
Binary file icons/qm-logo-larger.png has changed
Binary file icons/qm-logo-smaller.png has changed
--- a/src/MainWindow.cpp	Wed Dec 04 18:22:59 2013 +0000
+++ b/src/MainWindow.cpp	Wed Dec 04 18:31:39 2013 +0000
@@ -16,9 +16,11 @@
 #include "../version.h"
 
 #include "MainWindow.h"
+#include "NetworkPermissionTester.h"
 #include "Analyser.h"
 
 #include "framework/Document.h"
+#include "framework/VersionTester.h"
 
 #include "view/Pane.h"
 #include "view/PaneStack.h"
@@ -216,9 +218,23 @@
 
     statusBar();
 
-    // m_analyser = new Analyser();
+    newSession();
 
-    newSession();
+    settings.beginGroup("MainWindow");
+    settings.setValue("zoom-default", 512);
+    settings.endGroup();
+    zoomDefault();
+
+    NetworkPermissionTester tester;
+    bool networkPermission = tester.havePermission();
+    if (networkPermission) {
+        m_versionTester = new VersionTester
+            ("sonicvisualiser.org", "latest-tony-version.txt", TONY_VERSION);
+        connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)),
+                this, SLOT(newerVersionAvailable(QString)));
+    } else {
+        m_versionTester = 0;
+    }
 }
 
 MainWindow::~MainWindow()
--- a/src/MainWindow.h	Wed Dec 04 18:22:59 2013 +0000
+++ b/src/MainWindow.h	Wed Dec 04 18:31:39 2013 +0000
@@ -19,6 +19,7 @@
 #include "framework/MainWindowBase.h"
 
 class Analyser;
+class VersionTester;
 
 class MainWindow : public MainWindowBase
 {
@@ -127,6 +128,7 @@
     bool           m_intelligentActionOn; // GF: !!! temporary
     
     KeyReference  *m_keyReference;
+    VersionTester *m_versionTester;
 
     QString exportToSVL(QString path, Layer *layer);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/NetworkPermissionTester.cpp	Wed Dec 04 18:31:39 2013 +0000
@@ -0,0 +1,88 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Tony
+    An intonation analysis and annotation tool
+    Centre for Digital Music, Queen Mary, University of London.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#include "NetworkPermissionTester.h"
+
+#include "../version.h"
+
+#include <QWidget>
+#include <QString>
+#include <QSettings>
+#include <QCoreApplication>
+#include <QDialog>
+#include <QGridLayout>
+#include <QLabel>
+#include <QDialogButtonBox>
+#include <QCheckBox>
+
+bool
+NetworkPermissionTester::havePermission()
+{
+    QSettings settings;
+    settings.beginGroup("Preferences");
+    
+    QString tag = QString("network-permission-%1").arg(TONY_VERSION);
+
+    bool permish = false;
+
+    if (settings.contains(tag)) {
+	permish = settings.value(tag, false).toBool();
+    } else {
+
+	QDialog d;
+	d.setWindowTitle(QCoreApplication::translate
+                         ("NetworkPermissionTester", 
+                          "Tony: a tool for melody annotation"));
+
+	QGridLayout *layout = new QGridLayout;
+	d.setLayout(layout);
+
+	QLabel *label = new QLabel;
+	label->setWordWrap(true);
+	label->setText
+	    (QCoreApplication::translate
+	     ("NetworkPermissionTester",
+	      "<h2>Tony: a tool for melody annotation</h2>"
+	      "<p><img src=\":icons/qm-logo-smaller.png\" style=\"float:right\">Tony is a program for computer-aided melody annotation.<br>This is a very preliminary release, with many unfinished and provisional features.</p>"
+	      "<p>Developed in the Centre for Digital Music at Queen Mary, University of London, Tony is provided free as open source software under the GNU General Public License.</p>"
+              "<p><hr></p>"
+	      "<p><b>Before we go on...</b></p>"
+	      "<p>Tony needs to make occasional network requests to our servers.</p>"
+	      "<p>This is to:</p>"
+	      "<ul><li> tell you when updates are available.</li></ul>"
+	      "<p>No personal information will be sent, no tracking is carried out, and all requests happen in the background without interrupting your work.</p>"
+	      "<p>We recommend that you allow this. But if you do not wish to do so, please un-check the box below.<br></p>"));
+	layout->addWidget(label, 0, 0);
+
+	QCheckBox *cb = new QCheckBox(QCoreApplication::translate("NetworkPermissionTester", "Allow this"));
+	cb->setChecked(true);
+	layout->addWidget(cb, 1, 0);
+	
+	QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
+	QObject::connect(bb, SIGNAL(accepted()), &d, SLOT(accept()));
+	layout->addWidget(bb, 2, 0);
+	
+	d.exec();
+
+	bool permish = cb->isChecked();
+	settings.setValue(tag, permish);
+    }
+
+    settings.endGroup();
+
+    return permish;
+}
+
+   
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/NetworkPermissionTester.h	Wed Dec 04 18:31:39 2013 +0000
@@ -0,0 +1,27 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Tony
+    An intonation analysis and annotation tool
+    Centre for Digital Music, Queen Mary, University of London.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#ifndef NETWORK_PERMISSION_TESTER_H
+#define NETWORK_PERMISSION_TESTER_H
+
+class NetworkPermissionTester
+{
+public:
+    NetworkPermissionTester() { }
+    bool havePermission();
+};
+
+#endif
+
+
--- a/tony.qrc	Wed Dec 04 18:22:59 2013 +0000
+++ b/tony.qrc	Wed Dec 04 18:31:39 2013 +0000
@@ -64,6 +64,8 @@
     <file>icons/sharpen.png</file>
     <file>icons/help.png</file>
     <file>icons/cross.png</file>
+    <file>icons/qm-logo-larger.png</file>
+    <file>icons/qm-logo-smaller.png</file>
     <file>icons/tony-16x16.png</file>
     <file>icons/tony-22x22.png</file>
     <file>icons/tony-24x24.png</file>
--- a/tonyapp.pro	Wed Dec 04 18:22:59 2013 +0000
+++ b/tonyapp.pro	Wed Dec 04 18:31:39 2013 +0000
@@ -71,10 +71,12 @@
 RESOURCES += tony.qrc
 
 HEADERS += src/MainWindow.h \
+           src/NetworkPermissionTester.h \
            src/Analyser.h
 
 SOURCES += src/main.cpp \
            src/Analyser.cpp \
+           src/NetworkPermissionTester.cpp \
            src/MainWindow.cpp
 
 QMAKE_INFO_PLIST = deploy/osx/Info.plist