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