Mercurial > hg > tony
comparison src/NetworkPermissionTester.cpp @ 95:a67f0e5ec654
Add initial dialog / network permission tester; lower default zoom level
author | Chris Cannam |
---|---|
date | Wed, 04 Dec 2013 18:31:39 +0000 |
parents | |
children | 4d9ce1ed2ac0 |
comparison
equal
deleted
inserted
replaced
94:ab624c319eb7 | 95:a67f0e5ec654 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Tony | |
5 An intonation analysis and annotation tool | |
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(TONY_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 | |
45 ("NetworkPermissionTester", | |
46 "Tony: a tool for melody annotation")); | |
47 | |
48 QGridLayout *layout = new QGridLayout; | |
49 d.setLayout(layout); | |
50 | |
51 QLabel *label = new QLabel; | |
52 label->setWordWrap(true); | |
53 label->setText | |
54 (QCoreApplication::translate | |
55 ("NetworkPermissionTester", | |
56 "<h2>Tony: a tool for melody annotation</h2>" | |
57 "<p><img src=\":icons/qm-logo-smaller.png\" style=\"float:right\">Tony is a program for computer-aided melody annotation.<br>This is a very preliminary release, with many unfinished and provisional features.</p>" | |
58 "<p>Developed in the Centre for Digital Music at Queen Mary, University of London, Tony is provided free as 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>Tony needs to make occasional network requests to our servers.</p>" | |
62 "<p>This is to:</p>" | |
63 "<ul><li> tell you when updates are available.</li></ul>" | |
64 "<p>No personal information will be sent, no tracking is carried out, and all requests happen in the background without interrupting your work.</p>" | |
65 "<p>We recommend that you allow this. But if you do not wish to do so, please un-check the box below.<br></p>")); | |
66 layout->addWidget(label, 0, 0); | |
67 | |
68 QCheckBox *cb = new QCheckBox(QCoreApplication::translate("NetworkPermissionTester", "Allow this")); | |
69 cb->setChecked(true); | |
70 layout->addWidget(cb, 1, 0); | |
71 | |
72 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok); | |
73 QObject::connect(bb, SIGNAL(accepted()), &d, SLOT(accept())); | |
74 layout->addWidget(bb, 2, 0); | |
75 | |
76 d.exec(); | |
77 | |
78 bool permish = cb->isChecked(); | |
79 settings.setValue(tag, permish); | |
80 } | |
81 | |
82 settings.endGroup(); | |
83 | |
84 return permish; | |
85 } | |
86 | |
87 | |
88 |