Mercurial > hg > sonic-visualiser
changeset 663:55efa5a18814
Add network permission question box on first startup
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 13:10:28 +0000 |
parents | 6f06094daba0 |
children | b4a7c98e4c83 |
files | main/MainWindow.cpp main/NetworkPermissionTester.cpp main/NetworkPermissionTester.h main/Surveyer.cpp main/Surveyer.h sv.pro |
diffstat | 6 files changed, 120 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/main/MainWindow.cpp Tue Nov 26 11:41:12 2013 +0000 +++ b/main/MainWindow.cpp Tue Nov 26 13:10:28 2013 +0000 @@ -83,6 +83,7 @@ #include "rdf/RDFExporter.h" #include "Surveyer.h" +#include "NetworkPermissionTester.h" #include "framework/VersionTester.h" // For version information @@ -251,10 +252,6 @@ IconLoader il; - QSettings settings; - settings.beginGroup("MainWindow"); - settings.endGroup(); - m_playControlsSpacer = new QFrame; layout->setSpacing(4); @@ -304,16 +301,21 @@ connect(m_midiInput, SIGNAL(eventsAvailable()), this, SLOT(midiEventsAvailable())); - - TransformFactory::getInstance()->startPopulationThread(); - - m_surveyer = new Surveyer - ("sonicvisualiser.org", "survey23-present.txt", "survey23.php"); - - m_versionTester = new VersionTester - ("sonicvisualiser.org", "latest-version.txt", SV_VERSION); - connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)), - this, SLOT(newerVersionAvailable(QString))); + + NetworkPermissionTester tester(this); + bool networkPermission = tester.havePermission(); + if (networkPermission) { + TransformFactory::getInstance()->startPopulationThread(); + m_surveyer = new Surveyer + ("sonicvisualiser.org", "survey23-present.txt", "survey23.php"); + m_versionTester = new VersionTester + ("sonicvisualiser.org", "latest-version.txt", SV_VERSION); + connect(m_versionTester, SIGNAL(newerVersionAvailable(QString)), + this, SLOT(newerVersionAvailable(QString))); + } else { + m_surveyer = 0; + m_versionTester = 0; + } } MainWindow::~MainWindow() @@ -4442,7 +4444,7 @@ 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)); + QString text(tr("<h3>Newer version available</h3><p>You are using version %1 of Sonic Visualiser, but version %2 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); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main/NetworkPermissionTester.cpp Tue Nov 26 13:10:28 2013 +0000 @@ -0,0 +1,74 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + 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(SV_VERSION); + + bool permish = false; + + if (settings.contains(tag)) { + permish = settings.value(tag, false).toBool(); + } else { + + QDialog d; + d.setWindowTitle(QCoreApplication::translate("NetworkPermissionTester", "Welcome to Sonic Visualiser")); + + QGridLayout *layout = new QGridLayout; + d.setLayout(layout); + + QLabel *label = new QLabel; + label->setWordWrap(true); + label->setText(QCoreApplication::translate("NetworkPermissionTester", "<h3>Welcome to Sonic Visualiser!</h3><p>Sonic Visualiser is a program for viewing and exploring audio data for semantic music analysis and annotation.</p><p>Developed in the Centre for Digital Music at Queen Mary, University of London, Sonic Visualiser is provided free as open source software under the GNU General Public License.</p><p><b>Before we start...</b></p><p>Sonic Visualiser needs to make occasional network requests to our servers.</p><p>This is in order to:</p><ul><li>download metadata about available and installed plugins; and</li><li>find out when a newer version of Sonic Visualiser is available.</li></ul><p>No personal or identifying information will be sent, and your use of the program will not be tracked.</p><p>We recommend that you allow this, but if you do not wish to do so, please un-check the box below.</p>")); + layout->addWidget(label, 0, 0); + + QCheckBox *cb = new QCheckBox(QCoreApplication::translate("NetworkPermissionTester", "Allow Sonic Visualiser to make these network requests")); + 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/main/NetworkPermissionTester.h Tue Nov 26 13:10:28 2013 +0000 @@ -0,0 +1,27 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Sonic Visualiser + An audio file viewer and annotation editor. + 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/main/Surveyer.cpp Tue Nov 26 11:41:12 2013 +0000 +++ b/main/Surveyer.cpp Tue Nov 26 13:10:28 2013 +0000 @@ -12,12 +12,6 @@ COPYING included with this distribution for more information. */ -/* - This is a modified version of a source file from the - Rosegarden MIDI and audio sequencer and notation editor. - This file copyright 2000-2009 Chris Cannam. -*/ - #include "Surveyer.h" #include <iostream>
--- a/main/Surveyer.h Tue Nov 26 11:41:12 2013 +0000 +++ b/main/Surveyer.h Tue Nov 26 13:10:28 2013 +0000 @@ -12,12 +12,6 @@ COPYING included with this distribution for more information. */ -/* - This is a modified version of a source file from the - Rosegarden MIDI and audio sequencer and notation editor. - This file copyright 2000-2009 Chris Cannam. -*/ - #ifndef _SURVEYER_H_ #define _SURVEYER_H_
--- a/sv.pro Tue Nov 26 11:41:12 2013 +0000 +++ b/sv.pro Tue Nov 26 13:10:28 2013 +0000 @@ -69,11 +69,13 @@ RESOURCES += sonic-visualiser.qrc HEADERS += main/MainWindow.h \ + main/NetworkPermissionTester.h \ main/Surveyer.h \ main/PreferencesDialog.h SOURCES += main/main.cpp \ main/OSCHandler.cpp \ main/MainWindow.cpp \ + main/NetworkPermissionTester.cpp \ main/Surveyer.cpp \ main/PreferencesDialog.cpp