|
@@ -0,0 +1,104 @@
|
|
1
|
+@* Presenting License Information.
|
|
2
|
+
|
|
3
|
+\noindent Typica has its own copyright and license information, but it also
|
|
4
|
+relies on other projects which have their own copyright and license information
|
|
5
|
+which must be preserved, but it is better to present this information in a way
|
|
6
|
+that someone interested can quickly examine the license of any particular work.
|
|
7
|
+
|
|
8
|
+I would like to present this as a two panel window where the left side contains a
|
|
9
|
+list of the various projects and the right side contains a web view. Clicking
|
|
10
|
+an item in the list on the left should bring up the appropriate license
|
|
11
|
+document on the right.
|
|
12
|
+
|
|
13
|
+@(licensewindow.h@>=
|
|
14
|
+#include <QMainWindow>
|
|
15
|
+#include <QListWidgetItem>
|
|
16
|
+#include <QWebView>
|
|
17
|
+
|
|
18
|
+#ifndef TypicaLicenseHeader
|
|
19
|
+#define TypicaLicenseHeader
|
|
20
|
+
|
|
21
|
+class LicenseWindow : public QMainWindow@/
|
|
22
|
+{
|
|
23
|
+ @[Q_OBJECT@]@;
|
|
24
|
+ public:@/
|
|
25
|
+ LicenseWindow();
|
|
26
|
+ @[private slots@]:@/
|
|
27
|
+ void setWebView(QListWidgetItem *current, QListWidgetItem *);
|
|
28
|
+ private:@/
|
|
29
|
+ QWebView *view;
|
|
30
|
+};
|
|
31
|
+
|
|
32
|
+#endif
|
|
33
|
+
|
|
34
|
+@ Implementation is in a separate file.
|
|
35
|
+
|
|
36
|
+@(licensewindow.cpp@>=
|
|
37
|
+@<License window headers@>@;
|
|
38
|
+@<License window implementation@>@;
|
|
39
|
+
|
|
40
|
+@ The constructor is responsible for setting up the structure of the window and
|
|
41
|
+setting its initial content.
|
|
42
|
+
|
|
43
|
+@<License window implementation@>=
|
|
44
|
+LicenseWindow::LicenseWindow()
|
|
45
|
+ : QMainWindow(NULL), view(new QWebView)
|
|
46
|
+{
|
|
47
|
+ QSplitter *split = new QSplitter;
|
|
48
|
+ QListWidget *projects = new QListWidget;
|
|
49
|
+
|
|
50
|
+ @<Add items to license list@>@;
|
|
51
|
+ connect(projects, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
|
|
52
|
+ this, SLOT(setWebView(QListWidgetItem*, QListWidgetItem*)));
|
|
53
|
+
|
|
54
|
+ split->addWidget(projects);
|
|
55
|
+ split->addWidget(view);
|
|
56
|
+ setCentralWidget(split);
|
|
57
|
+}
|
|
58
|
+
|
|
59
|
+@ Each item in the |projects| list contains a |QUrl| pointing to an HTML
|
|
60
|
+document in the resources compiled in with \pn{}. When an item in the list is
|
|
61
|
+selected, the appropriate document is loaded in the web view. The previously
|
|
62
|
+selected item is unused.
|
|
63
|
+
|
|
64
|
+@<License window implementation@>=
|
|
65
|
+void LicenseWindow::setWebView(QListWidgetItem *current, QListWidgetItem *)
|
|
66
|
+{
|
|
67
|
+ view->load(current->data(Qt::UserRole).toUrl());
|
|
68
|
+}
|
|
69
|
+
|
|
70
|
+@ Each item in the list provides the name of the project to display in the list
|
|
71
|
+and the location of the relevant license. This section must be updated any time
|
|
72
|
+the external projects used changes. At present only projects which are used
|
|
73
|
+directly by \pn{} are included here but it would not be a bad idea to audit
|
|
74
|
+projects that are used indirectly and include these as well. The item with
|
|
75
|
+the license for \pn{} is the initial selection and the web view is set
|
|
76
|
+appropriately here as the |currentItemChanged| signal is not connected until
|
|
77
|
+after this code executes.
|
|
78
|
+
|
|
79
|
+@<Add items to license list@>=
|
|
80
|
+QListWidgetItem *item = new QListWidgetItem("Typica", projects);
|
|
81
|
+item->setData(Qt::UserRole, QVariant(QUrl("qrc:/resources/html/licenses/typica.html")));
|
|
82
|
+projects->setCurrentItem(item);
|
|
83
|
+setWebView(item, NULL);
|
|
84
|
+item = new QListWidgetItem("d3.js", projects);
|
|
85
|
+item->setData(Qt::UserRole, QVariant(QUrl("qrc:/resources/html/licenses/d3.html")));
|
|
86
|
+item = new QListWidgetItem("Entypo", projects);
|
|
87
|
+item->setData(Qt::UserRole, QVariant(QUrl("qrc:/resources/html/licenses/entypo.html")));
|
|
88
|
+item = new QListWidgetItem("Tango Desktop Project", projects);
|
|
89
|
+item->setData(Qt::UserRole, QVariant(QUrl("qrc:/resources/html/licenses/tango.html")));
|
|
90
|
+item = new QListWidgetItem("QextSerialPort", projects);
|
|
91
|
+item->setData(Qt::UserRole, QVariant(QUrl("qrc:/resources/html/licenses/qextserialport.html")));
|
|
92
|
+item = new QListWidgetItem("Qt", projects);
|
|
93
|
+item->setData(Qt::UserRole, QVariant(QUrl("qrc:/resources/html/licenses/qt.html")));
|
|
94
|
+
|
|
95
|
+@ Several headers are required.
|
|
96
|
+
|
|
97
|
+@<License window headers@>=
|
|
98
|
+#include "licensewindow.h"
|
|
99
|
+
|
|
100
|
+#include <QSplitter>
|
|
101
|
+#include <QListWidget>
|
|
102
|
+#include <QVariant>
|
|
103
|
+#include <QUrl>
|
|
104
|
+
|