NetworkPermissionTester.cpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version. See the file
12  COPYING included with this distribution for more information.
13 */
14 
16 
17 #include "../version.h"
18 
19 #include "base/Debug.h"
20 
21 #include <QWidget>
22 #include <QString>
23 #include <QSettings>
24 #include <QCoreApplication>
25 #include <QDialog>
26 #include <QGridLayout>
27 #include <QLabel>
28 #include <QDialogButtonBox>
29 #include <QCheckBox>
30 
31 bool
33 {
34  QSettings settings;
35  settings.beginGroup("Preferences");
36 
37  QString tag = QString("network-permission-%1").arg(SV_VERSION);
38 
39  bool permish = false;
40 
41  if (settings.contains(tag)) {
42  permish = settings.value(tag, false).toBool();
43  SVDEBUG << "NetworkPermissionTester: Asked already, result was " << permish << endl;
44  } else {
45  SVDEBUG << "NetworkPermissionTester: Asking for permission" << endl;
46 
47  QDialog d;
48  d.setWindowTitle(QCoreApplication::translate("NetworkPermissionTester", "Welcome to Sonic Visualiser"));
49 
50  QGridLayout *layout = new QGridLayout;
51  d.setLayout(layout);
52 
53  QString preamble;
54  preamble = QCoreApplication::translate
55  ("NetworkPermissionTester",
56  "<h2>Welcome to Sonic Visualiser!</h2>"
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>"
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>"
59  "<p><hr></p>"
60  "<p><b>Before we go on...</b></p>"
61  "<p>Sonic Visualiser would like permission to use the network.</p>");
62 
63  QString bullets;
64  if (m_withOSC) {
65  bullets = QCoreApplication::translate
66  ("NetworkPermissionTester",
67  "<p>This is to:</p>"
68  "<ul><li> Find information about available and installed plugins;</li>"
69  "<li> Support the use of Open Sound Control; and</li>"
70  "<li> Tell you when updates are available.</li>"
71  "</ul>");
72  } else {
73  bullets = QCoreApplication::translate
74  ("NetworkPermissionTester",
75  "<p>This is to:</p>"
76  "<ul><li> Find information about available and installed plugins; and</li>"
77  "<li> Tell you when updates are available.</li>"
78  "</ul>");
79  }
80 
81  QString postamble;
82  postamble = QCoreApplication::translate
83  ("NetworkPermissionTester",
84  "<p><b>No personal information will be sent, no tracking is carried out, and no information will be shared with anyone else.</b></p>"
85  "<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>");
86 
87  QLabel *label = new QLabel;
88  label->setWordWrap(true);
89  label->setText(preamble + bullets + postamble);
90  layout->addWidget(label, 0, 0);
91 
92  QCheckBox *cb = new QCheckBox(QCoreApplication::translate("NetworkPermissionTester", "Allow this"));
93  cb->setChecked(true);
94  layout->addWidget(cb, 1, 0);
95 
96  QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok);
97  QObject::connect(bb, SIGNAL(accepted()), &d, SLOT(accept()));
98  layout->addWidget(bb, 2, 0);
99 
100  d.exec();
101 
102  permish = cb->isChecked();
103  settings.setValue(tag, permish);
104 
105  SVDEBUG << "NetworkPermissionTester: asked, answer was " << permish << endl;
106  }
107 
108  settings.endGroup();
109 
110  return permish;
111 }
112 
113 
114