# HG changeset patch # User Chris Cannam # Date 1385471428 0 # Node ID 55efa5a18814988541f5e02e0be50010d2a1edcd # Parent 6f06094daba0aa2dcd177e81304247abfa65e6fc Add network permission question box on first startup diff -r 6f06094daba0 -r 55efa5a18814 main/MainWindow.cpp --- 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("

Newer version available

You are using version %1 of Sonic Visualiser, but version %3 is now available.

Please see the Sonic Visualiser website for more information.

").arg(SV_VERSION).arg(version)); + QString text(tr("

Newer version available

You are using version %1 of Sonic Visualiser, but version %2 is now available.

Please see the Sonic Visualiser website for more information.

").arg(SV_VERSION).arg(version)); QMessageBox::information(this, title, text); settings.setValue(tag, false); } diff -r 6f06094daba0 -r 55efa5a18814 main/NetworkPermissionTester.cpp --- /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 +#include +#include +#include +#include +#include +#include +#include +#include + +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", "

Welcome to Sonic Visualiser!

Sonic Visualiser is a program for viewing and exploring audio data for semantic music analysis and annotation.

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.

Before we start...

Sonic Visualiser needs to make occasional network requests to our servers.

This is in order to:

  • download metadata about available and installed plugins; and
  • find out when a newer version of Sonic Visualiser is available.

No personal or identifying information will be sent, and your use of the program will not be tracked.

We recommend that you allow this, but if you do not wish to do so, please un-check the box below.

")); + 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; +} + + + diff -r 6f06094daba0 -r 55efa5a18814 main/NetworkPermissionTester.h --- /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 + + diff -r 6f06094daba0 -r 55efa5a18814 main/Surveyer.cpp --- 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 diff -r 6f06094daba0 -r 55efa5a18814 main/Surveyer.h --- 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_ diff -r 6f06094daba0 -r 55efa5a18814 sv.pro --- 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