1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
/* -*- 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 "base/Debug.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();
SVDEBUG << "NetworkPermissionTester: Asked already, result was " << permish << endl;
} else {
SVDEBUG << "NetworkPermissionTester: Asking for permission" << endl;
QDialog d;
d.setWindowTitle(QCoreApplication::translate("NetworkPermissionTester", "Welcome to Sonic Visualiser"));
QGridLayout *layout = new QGridLayout;
d.setLayout(layout);
QString preamble;
preamble = QCoreApplication::translate
("NetworkPermissionTester",
"<h2>Welcome to Sonic Visualiser!</h2>"
"<p>Sonic Visualiser is a program for viewing and exploring audio data for semantic music analysis and annotation.</p>"
"<p>Sonic Visualiser is open source software under the GNU General Public License.</p>"
"<p><hr></p>"
"<p><b>Before we go on...</b></p>"
"<p>Sonic Visualiser would like permission to use the network.</p>");
QString bullets;
if (m_withOSC) {
bullets = QCoreApplication::translate
("NetworkPermissionTester",
"<p>This is to:</p>"
"<ul><li> Find information about available and installed plugins;</li>"
"<li> Support the use of Open Sound Control; and</li>"
"<li> Tell you when updates are available.</li>"
"</ul>");
} else {
bullets = QCoreApplication::translate
("NetworkPermissionTester",
"<p>This is to:</p>"
"<ul><li> Find information about available and installed plugins; and</li>"
"<li> Tell you when updates are available.</li>"
"</ul>");
}
QString postamble;
postamble = QCoreApplication::translate
("NetworkPermissionTester",
"<p><b>No personal information will be sent, no tracking is carried out, and no information will be shared with anyone else.</b></p>"
"<p>We recommend that you allow this, because it makes Sonic Visualiser more useful to you. But if you do not wish to allow it, please un-check the box below.<br></p>");
QLabel *label = new QLabel;
label->setWordWrap(true);
label->setText(preamble + bullets + postamble);
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();
permish = cb->isChecked();
settings.setValue(tag, permish);
SVDEBUG << "NetworkPermissionTester: asked, answer was " << permish << endl;
}
settings.endGroup();
return permish;
}
|