Browse Source

Add license information window

Neal Wilson 9 years ago
parent
commit
b58b2a1355
4 changed files with 126 additions and 7 deletions
  1. 4
    2
      src/Typica.pro
  2. 17
    4
      src/helpmenu.w
  3. 104
    0
      src/licensewindow.w
  4. 1
    1
      src/typica.w

+ 4
- 2
src/Typica.pro View File

24
     webelement.h \
24
     webelement.h \
25
     scale.h \
25
     scale.h \
26
     draglabel.h \
26
     draglabel.h \
27
-    daterangeselector.h
27
+    daterangeselector.h \
28
+    licensewindow.h
28
 SOURCES += typica.cpp \
29
 SOURCES += typica.cpp \
29
     helpmenu.cpp \
30
     helpmenu.cpp \
30
     abouttypica.cpp \
31
     abouttypica.cpp \
33
     webelement.cpp \
34
     webelement.cpp \
34
     scale.cpp \
35
     scale.cpp \
35
     draglabel.cpp \
36
     draglabel.cpp \
36
-    daterangeselector.cpp
37
+    daterangeselector.cpp \
38
+    licensewindow.cpp
37
 
39
 
38
 RESOURCES += \
40
 RESOURCES += \
39
     resources.qrc
41
     resources.qrc

+ 17
- 4
src/helpmenu.w View File

26
 		HelpMenu();
26
 		HelpMenu();
27
 	public slots:
27
 	public slots:
28
 		void displayAboutTypica();
28
 		void displayAboutTypica();
29
+		void displayLicenseWindow();
29
 };
30
 };
30
 
31
 
31
 #endif
32
 #endif
35
 @(helpmenu.cpp@>=
36
 @(helpmenu.cpp@>=
36
 #include "helpmenu.h"
37
 #include "helpmenu.h"
37
 #include "abouttypica.h"
38
 #include "abouttypica.h"
39
+#include "licensewindow.h"
38
 
40
 
39
 @<Help menu implementation@>@;
41
 @<Help menu implementation@>@;
40
 
42
 
41
 @ The constructor sets an object name for the menu so scripts are able to look
43
 @ The constructor sets an object name for the menu so scripts are able to look
42
-up the menu and add additional items. The "About Typica" menu item also has an
43
-object name which can be used to provide custom handling if this is desired.
44
-The |triggered()| signal from that item is immediately connected to a handler
45
-for displaying an about box.
44
+up the menu and add additional items.
46
 
45
 
47
 @<Help menu implementation@>=
46
 @<Help menu implementation@>=
48
 HelpMenu::HelpMenu() : QMenu()
47
 HelpMenu::HelpMenu() : QMenu()
53
 	aboutTypicaAction->setObjectName("aboutTypicaAction");
52
 	aboutTypicaAction->setObjectName("aboutTypicaAction");
54
 	addAction(aboutTypicaAction);
53
 	addAction(aboutTypicaAction);
55
 	connect(aboutTypicaAction, SIGNAL(triggered()), this, SLOT(displayAboutTypica()));
54
 	connect(aboutTypicaAction, SIGNAL(triggered()), this, SLOT(displayAboutTypica()));
55
+	QAction *licenseAction = new QAction(tr("License Information"), this);
56
+	licenseAction->setObjectName("licenseAction");
57
+	addAction(licenseAction);
58
+	connect(licenseAction, SIGNAL(triggered()), this, SLOT(displayLicenseWindow()));
56
 }
59
 }
57
 
60
 
58
 @ When "About Typica" is selected from the menu, we display an about box. This
61
 @ When "About Typica" is selected from the menu, we display an about box. This
65
 	aboutBox->show();
68
 	aboutBox->show();
66
 }
69
 }
67
 
70
 
71
+@ Similarly, the "License Information" menu item brings up a window with
72
+appropriate information.
73
+
74
+@<Help menu implementation@>=
75
+void HelpMenu::displayLicenseWindow()
76
+{
77
+	LicenseWindow *window = new LicenseWindow;
78
+	window->show();
79
+}
80
+

+ 104
- 0
src/licensewindow.w View File

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
+

+ 1
- 1
src/typica.w View File

4612
 
4612
 
4613
 @i helpmenu.w
4613
 @i helpmenu.w
4614
 
4614
 
4615
-@i feedback.w
4615
+@i licensewindow.w
4616
 
4616
 
4617
 @ A layout can contain a number of different elements including a variety of
4617
 @ A layout can contain a number of different elements including a variety of
4618
 widget types and other layouts. This function is responsible for applying any
4618
 widget types and other layouts. This function is responsible for applying any

Loading…
Cancel
Save