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@663
|
19 #include <QWidget>
|
Chris@663
|
20 #include <QString>
|
Chris@663
|
21 #include <QSettings>
|
Chris@663
|
22 #include <QCoreApplication>
|
Chris@663
|
23 #include <QDialog>
|
Chris@663
|
24 #include <QGridLayout>
|
Chris@663
|
25 #include <QLabel>
|
Chris@663
|
26 #include <QDialogButtonBox>
|
Chris@663
|
27 #include <QCheckBox>
|
Chris@663
|
28
|
Chris@663
|
29 bool
|
Chris@663
|
30 NetworkPermissionTester::havePermission()
|
Chris@663
|
31 {
|
Chris@663
|
32 QSettings settings;
|
Chris@663
|
33 settings.beginGroup("Preferences");
|
Chris@663
|
34
|
Chris@663
|
35 QString tag = QString("network-permission-%1").arg(SV_VERSION);
|
Chris@663
|
36
|
Chris@663
|
37 bool permish = false;
|
Chris@663
|
38
|
Chris@663
|
39 if (settings.contains(tag)) {
|
Chris@663
|
40 permish = settings.value(tag, false).toBool();
|
Chris@663
|
41 } else {
|
Chris@663
|
42
|
Chris@663
|
43 QDialog d;
|
Chris@663
|
44 d.setWindowTitle(QCoreApplication::translate("NetworkPermissionTester", "Welcome to Sonic Visualiser"));
|
Chris@663
|
45
|
Chris@663
|
46 QGridLayout *layout = new QGridLayout;
|
Chris@663
|
47 d.setLayout(layout);
|
Chris@663
|
48
|
Chris@663
|
49 QLabel *label = new QLabel;
|
Chris@663
|
50 label->setWordWrap(true);
|
Chris@664
|
51 label->setText
|
Chris@664
|
52 (QCoreApplication::translate
|
Chris@664
|
53 ("NetworkPermissionTester",
|
Chris@664
|
54 "<h3>Welcome to Sonic Visualiser!</h3>"
|
Chris@664
|
55 "<p>Sonic Visualiser is a program for viewing and exploring audio data for semantic music analysis and annotation.</p>"
|
Chris@664
|
56 "<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>"
|
Chris@664
|
57 "<p><b>Before we start...</b></p>"
|
Chris@664
|
58 "<p>Sonic Visualiser needs to make occasional network requests to our servers.</p>"
|
Chris@664
|
59 "<p>This is in order to:</p>"
|
Chris@664
|
60 "<ul><li>download metadata about available and installed plugins; and</li>"
|
Chris@664
|
61 "<li>find out when a newer version of Sonic Visualiser is available.</li></ul>"
|
Chris@664
|
62 "<p>No personal or identifying information will be sent, and your use of the program will not be tracked.</p>"
|
Chris@664
|
63 "<p>We recommend that you allow this, but if you do not wish to do so, please un-check the box below.<br></p>"));
|
Chris@663
|
64 layout->addWidget(label, 0, 0);
|
Chris@663
|
65
|
Chris@663
|
66 QCheckBox *cb = new QCheckBox(QCoreApplication::translate("NetworkPermissionTester", "Allow Sonic Visualiser to make these network requests"));
|
Chris@663
|
67 cb->setChecked(true);
|
Chris@663
|
68 layout->addWidget(cb, 1, 0);
|
Chris@663
|
69
|
Chris@663
|
70 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
|
Chris@663
|
71 QObject::connect(bb, SIGNAL(accepted()), &d, SLOT(accept()));
|
Chris@663
|
72 layout->addWidget(bb, 2, 0);
|
Chris@663
|
73
|
Chris@663
|
74 d.exec();
|
Chris@663
|
75
|
Chris@663
|
76 bool permish = cb->isChecked();
|
Chris@663
|
77 settings.setValue(tag, permish);
|
Chris@663
|
78 }
|
Chris@663
|
79
|
Chris@663
|
80 settings.endGroup();
|
Chris@663
|
81
|
Chris@663
|
82 return permish;
|
Chris@663
|
83 }
|
Chris@663
|
84
|
Chris@663
|
85
|
Chris@663
|
86
|