annotate main/NetworkPermissionTester.cpp @ 2191:8ce96d97de1a bqaudiostream

Read metadata from files in CoreAudio reader
author Chris Cannam
date Tue, 22 Jan 2019 11:45:40 +0000
parents 893f556cd5c9
children 2de306979a2a
rev   line source
Chris@663 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@663 2
Chris@663 3 /*
Chris@663 4 Sonic Visualiser
Chris@663 5 An audio file viewer and annotation editor.
Chris@663 6 Centre for Digital Music, Queen Mary, University of London.
Chris@663 7
Chris@663 8 This program is free software; you can redistribute it and/or
Chris@663 9 modify it under the terms of the GNU General Public License as
Chris@663 10 published by the Free Software Foundation; either version 2 of the
Chris@663 11 License, or (at your option) any later version. See the file
Chris@663 12 COPYING included with this distribution for more information.
Chris@663 13 */
Chris@663 14
Chris@663 15 #include "NetworkPermissionTester.h"
Chris@663 16
Chris@663 17 #include "../version.h"
Chris@663 18
Chris@1639 19 #include "base/Debug.h"
Chris@1639 20
Chris@663 21 #include <QWidget>
Chris@663 22 #include <QString>
Chris@663 23 #include <QSettings>
Chris@663 24 #include <QCoreApplication>
Chris@663 25 #include <QDialog>
Chris@663 26 #include <QGridLayout>
Chris@663 27 #include <QLabel>
Chris@663 28 #include <QDialogButtonBox>
Chris@663 29 #include <QCheckBox>
Chris@663 30
Chris@663 31 bool
Chris@663 32 NetworkPermissionTester::havePermission()
Chris@663 33 {
Chris@663 34 QSettings settings;
Chris@663 35 settings.beginGroup("Preferences");
Chris@663 36
Chris@663 37 QString tag = QString("network-permission-%1").arg(SV_VERSION);
Chris@663 38
Chris@663 39 bool permish = false;
Chris@663 40
Chris@663 41 if (settings.contains(tag)) {
Chris@1639 42 permish = settings.value(tag, false).toBool();
Chris@1639 43 SVDEBUG << "NetworkPermissionTester: Asked already, result was " << permish << endl;
Chris@663 44 } else {
Chris@1639 45 SVDEBUG << "NetworkPermissionTester: Asking for permission" << endl;
Chris@663 46
Chris@1639 47 QDialog d;
Chris@1770 48 d.setWindowTitle(QCoreApplication::translate("NetworkPermissionTester", "Welcome to Sonic Visualiser"));
Chris@663 49
Chris@1770 50 QGridLayout *layout = new QGridLayout;
Chris@1770 51 d.setLayout(layout);
Chris@663 52
Chris@1613 53 QString preamble;
Chris@1613 54 preamble = QCoreApplication::translate
Chris@1613 55 ("NetworkPermissionTester",
Chris@1613 56 "<h2>Welcome to Sonic Visualiser!</h2>"
Chris@1613 57 "<p><img src=\":icons/qm-logo-smaller.png\" style=\"float:right\">Sonic Visualiser is a program for viewing and exploring audio data for semantic music analysis and annotation.</p>"
Chris@1613 58 "<p>Developed in the Centre for Digital Music at Queen Mary University of London, Sonic Visualiser is open source software under the GNU General Public License.</p>"
Chris@1613 59 "<p><hr></p>"
Chris@1613 60 "<p><b>Before we go on...</b></p>"
Chris@1613 61 "<p>Sonic Visualiser would like permission to use the network.</p>");
Chris@1613 62
Chris@1613 63 QString bullets;
Chris@1613 64 if (m_withOSC) {
Chris@1613 65 bullets = QCoreApplication::translate
Chris@1613 66 ("NetworkPermissionTester",
Chris@1613 67 "<p>This is to:</p>"
Chris@1613 68 "<ul><li> Find information about available and installed plugins;</li>"
Chris@1613 69 "<li> Support the use of Open Sound Control; and</li>"
Chris@1613 70 "<li> Tell you when updates are available.</li>"
Chris@1613 71 "</ul>");
Chris@1613 72 } else {
Chris@1613 73 bullets = QCoreApplication::translate
Chris@1613 74 ("NetworkPermissionTester",
Chris@1613 75 "<p>This is to:</p>"
Chris@1613 76 "<ul><li> Find information about available and installed plugins; and</li>"
Chris@1613 77 "<li> Tell you when updates are available.</li>"
Chris@1613 78 "</ul>");
Chris@1613 79 }
Chris@1613 80
Chris@1613 81 QString postamble;
Chris@1613 82 postamble = QCoreApplication::translate
Chris@1613 83 ("NetworkPermissionTester",
Chris@1613 84 "<p><b>No personal information will be sent, no tracking is carried out, and no individual information will be shared with anyone else.</b> We will however make aggregate counts of distinct requests for usage reporting.</p>"
Chris@1613 85 "<p>We recommend that you allow this, because it makes Sonic Visualiser more useful to you and supports the public funding of this work. But if you do not wish to allow it, please un-check the box below.<br></p>");
Chris@1613 86
Chris@1770 87 QLabel *label = new QLabel;
Chris@1770 88 label->setWordWrap(true);
Chris@1770 89 label->setText(preamble + bullets + postamble);
Chris@1770 90 layout->addWidget(label, 0, 0);
Chris@663 91
Chris@1770 92 QCheckBox *cb = new QCheckBox(QCoreApplication::translate("NetworkPermissionTester", "Allow this"));
Chris@1770 93 cb->setChecked(true);
Chris@1770 94 layout->addWidget(cb, 1, 0);
Chris@1770 95
Chris@1770 96 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
Chris@1770 97 QObject::connect(bb, SIGNAL(accepted()), &d, SLOT(accept()));
Chris@1770 98 layout->addWidget(bb, 2, 0);
Chris@1770 99
Chris@1770 100 d.exec();
Chris@663 101
Chris@681 102 permish = cb->isChecked();
Chris@1770 103 settings.setValue(tag, permish);
Chris@1639 104
Chris@1639 105 SVDEBUG << "NetworkPermissionTester: asked, answer was " << permish << endl;
Chris@663 106 }
Chris@663 107
Chris@663 108 settings.endGroup();
Chris@663 109
Chris@663 110 return permish;
Chris@663 111 }
Chris@663 112
Chris@663 113
Chris@663 114