15 |
15 |
16 class FormSelectionDialog(QDialog, Ui_FormSelectionDialog): |
16 class FormSelectionDialog(QDialog, Ui_FormSelectionDialog): |
17 """ |
17 """ |
18 Class implementing a dialog to select the template type. |
18 Class implementing a dialog to select the template type. |
19 """ |
19 """ |
|
20 |
20 def __init__(self, parent=None): |
21 def __init__(self, parent=None): |
21 """ |
22 """ |
22 Constructor |
23 Constructor |
23 |
24 |
24 @param parent reference to the parent widget |
25 @param parent reference to the parent widget |
25 @type QWidget |
26 @type QWidget |
26 """ |
27 """ |
27 super().__init__(parent) |
28 super().__init__(parent) |
28 self.setupUi(self) |
29 self.setupUi(self) |
29 |
30 |
30 self.__templates = { |
31 self.__templates = { |
31 "html5": [ |
32 "html5": [ |
32 self.tr("Standard HTML 5 template"), |
33 self.tr("Standard HTML 5 template"), |
33 '''<!DOCTYPE html>\n''' |
34 """<!DOCTYPE html>\n""" |
34 ''' <head>\n''' |
35 """ <head>\n""" |
35 ''' <title></title>\n''' |
36 """ <title></title>\n""" |
36 ''' <style>\n''' |
37 """ <style>\n""" |
37 ''' </style>\n''' |
38 """ </style>\n""" |
38 ''' </head>\n''' |
39 """ </head>\n""" |
39 '''\n''' |
40 """\n""" |
40 ''' <body>\n''' |
41 """ <body>\n""" |
41 ''' </body>\n''' |
42 """ </body>\n""" |
42 '''</html>\n''' |
43 """</html>\n""", |
43 ], |
44 ], |
44 "simple": [ |
45 "simple": [ |
45 self.tr("Standard HTML template"), |
46 self.tr("Standard HTML template"), |
46 '''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"\n''' |
47 """<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"\n""" |
47 ''' "http://www.w3.org/TR/html4/strict.dtd">\n''' |
48 """ "http://www.w3.org/TR/html4/strict.dtd">\n""" |
48 ''' <head>\n''' |
49 """ <head>\n""" |
49 ''' <title></title>\n''' |
50 """ <title></title>\n""" |
50 ''' <style>\n''' |
51 """ <style>\n""" |
51 ''' </style>\n''' |
52 """ </style>\n""" |
52 ''' </head>\n''' |
53 """ </head>\n""" |
53 '''\n''' |
54 """\n""" |
54 ''' <body>\n''' |
55 """ <body>\n""" |
55 ''' </body>\n''' |
56 """ </body>\n""" |
56 '''</html>\n''' |
57 """</html>\n""", |
57 ], |
58 ], |
58 "complex": [ |
59 "complex": [ |
59 self.tr("Chameleon template"), |
60 self.tr("Chameleon template"), |
60 '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0''' |
61 """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0""" |
61 ''' Strict//EN"\n''' |
62 """ Strict//EN"\n""" |
62 ''' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n''' |
63 """ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n""" |
63 '''<html xmlns="http://www.w3.org/1999/xhtml"''' |
64 '''<html xmlns="http://www.w3.org/1999/xhtml"''' |
64 ''' xml:lang="en"\n''' |
65 """ xml:lang="en"\n""" |
65 ''' xmlns:tal="http://xml.zope.org/namespaces/tal">\n''' |
66 """ xmlns:tal="http://xml.zope.org/namespaces/tal">\n""" |
66 ''' xmlns:metal="http://xml.zope.org/namespaces/''' |
67 """ xmlns:metal="http://xml.zope.org/namespaces/""" |
67 '''metal">\n''' |
68 """metal">\n""" |
68 '''<head>\n''' |
69 """<head>\n""" |
69 ''' <title>The Pyramid Web Application Development''' |
70 """ <title>The Pyramid Web Application Development""" |
70 ''' Framework</title>\n''' |
71 """ Framework</title>\n""" |
71 ''' <meta http-equiv="Content-Type"\n''' |
72 """ <meta http-equiv="Content-Type"\n""" |
72 ''' content="text/html;charset=UTF-8"/>\n''' |
73 """ content="text/html;charset=UTF-8"/>\n""" |
73 ''' <meta name="keywords" content="python web application"''' |
74 ''' <meta name="keywords" content="python web application"''' |
74 ''' />\n''' |
75 """ />\n""" |
75 ''' <meta name="description" content="pyramid web''' |
76 """ <meta name="description" content="pyramid web""" |
76 ''' application" />\n''' |
77 """ application" />\n""" |
77 ''' <link rel="shortcut icon"\n''' |
78 """ <link rel="shortcut icon"\n""" |
78 ''' href="${request.static_url('site:static/''' |
79 """ href="${request.static_url('site:static/""" |
79 '''favicon.ico')}" />\n''' |
80 """favicon.ico')}" />\n""" |
80 ''' <link rel="stylesheet"\n''' |
81 """ <link rel="stylesheet"\n""" |
81 ''' href="${request.static_url('site:static/''' |
82 """ href="${request.static_url('site:static/""" |
82 '''pylons.css')}"\n''' |
83 """pylons.css')}"\n""" |
83 ''' type="text/css" media="screen" charset="utf-8" />\n''' |
84 """ type="text/css" media="screen" charset="utf-8" />\n""" |
84 ''' <link rel="stylesheet"\n''' |
85 """ <link rel="stylesheet"\n""" |
85 ''' href="http://static.pylonsproject.org/fonts/nobile/''' |
86 """ href="http://static.pylonsproject.org/fonts/nobile/""" |
86 '''stylesheet.css"\n''' |
87 """stylesheet.css"\n""" |
87 ''' media="screen" />\n''' |
88 """ media="screen" />\n""" |
88 ''' <link rel="stylesheet"\n''' |
89 """ <link rel="stylesheet"\n""" |
89 ''' href="http://static.pylonsproject.org/fonts/neuton/''' |
90 """ href="http://static.pylonsproject.org/fonts/neuton/""" |
90 '''stylesheet.css"\n''' |
91 """stylesheet.css"\n""" |
91 ''' media="screen" />\n''' |
92 """ media="screen" />\n""" |
92 ''' <!--[if lte IE 6]>\n''' |
93 """ <!--[if lte IE 6]>\n""" |
93 ''' <link rel="stylesheet"\n''' |
94 """ <link rel="stylesheet"\n""" |
94 ''' href="${request.static_url('site:static/ie6.css')}"\n''' |
95 """ href="${request.static_url('site:static/ie6.css')}"\n""" |
95 ''' type="text/css" media="screen" charset="utf-8" />\n''' |
96 """ type="text/css" media="screen" charset="utf-8" />\n""" |
96 ''' <![endif]-->\n''' |
97 """ <![endif]-->\n""" |
97 '''</head>\n''' |
98 """</head>\n""" |
98 '''<body>\n''' |
99 """<body>\n""" |
99 ''' <div id="wrap">\n''' |
100 """ <div id="wrap">\n""" |
100 ''' <div id="top">\n''' |
101 """ <div id="top">\n""" |
101 ''' </div>\n''' |
102 """ </div>\n""" |
102 ''' <div id="middle">\n''' |
103 """ <div id="middle">\n""" |
103 ''' </div>\n''' |
104 """ </div>\n""" |
104 ''' <div id="bottom">\n''' |
105 """ <div id="bottom">\n""" |
105 ''' </div>\n''' |
106 """ </div>\n""" |
106 ''' </div>\n''' |
107 """ </div>\n""" |
107 ''' <div id="footer">\n''' |
108 """ <div id="footer">\n""" |
108 ''' <div class="footer">© Copyright 2012, Somebody.''' |
109 """ <div class="footer">© Copyright 2012, Somebody.""" |
109 '''</div>\n''' |
110 """</div>\n""" |
110 ''' </div>\n''' |
111 """ </div>\n""" |
111 '''</body>\n''' |
112 """</body>\n""" |
112 '''</html>\n''' |
113 """</html>\n""", |
113 ], |
114 ], |
114 "sections": [ |
115 "sections": [ |
115 self.tr("Mako template with sections"), |
116 self.tr("Mako template with sections"), |
116 '''## -*- coding: utf-8 -*-\n''' |
117 """## -*- coding: utf-8 -*-\n""" |
117 '''\n''' |
118 """\n""" |
118 '''<!DOCTYPE html>\n''' |
119 """<!DOCTYPE html>\n""" |
119 '''<html>\n''' |
120 """<html>\n""" |
120 '''<head>\n''' |
121 """<head>\n""" |
121 ''' <title>${self.title()}</title>\n''' |
122 """ <title>${self.title()}</title>\n""" |
122 ''' ${self.head()}\n''' |
123 """ ${self.head()}\n""" |
123 '''</head>\n''' |
124 """</head>\n""" |
124 '''<body>\n''' |
125 """<body>\n""" |
125 ''' ${self.header()}\n''' |
126 """ ${self.header()}\n""" |
126 ''' ${self.tabs()}\n''' |
127 """ ${self.tabs()}\n""" |
127 ''' ${self.menu()}\n''' |
128 """ ${self.menu()}\n""" |
128 ''' ${self.heading()}\n''' |
129 """ ${self.heading()}\n""" |
129 ''' ${self.breadcrumbs()}\n''' |
130 """ ${self.breadcrumbs()}\n""" |
130 ''' ${next.body()}\n''' |
131 """ ${next.body()}\n""" |
131 ''' ${self.footer()}\n''' |
132 """ ${self.footer()}\n""" |
132 '''</body>\n''' |
133 """</body>\n""" |
133 '''</html>\n''' |
134 """</html>\n""" |
134 '''\n''' |
135 """\n""" |
135 '''<%def name="title()">SimpleSite</%def>\n''' |
136 """<%def name="title()">SimpleSite</%def>\n""" |
136 '''<%def name="head()"></%def>\n''' |
137 """<%def name="head()"></%def>\n""" |
137 '''<%def name="header()"><a name="top"></a></%def>\n''' |
138 """<%def name="header()"><a name="top"></a></%def>\n""" |
138 '''<%def name="tabs()"></%def>\n''' |
139 """<%def name="tabs()"></%def>\n""" |
139 '''<%def name="menu()"></%def>\n''' |
140 """<%def name="menu()"></%def>\n""" |
140 '''<%def name="heading()"><h1>${c.heading or 'No Title'}''' |
141 """<%def name="heading()"><h1>${c.heading or 'No Title'}""" |
141 '''</h1></%def>\n''' |
142 """</h1></%def>\n""" |
142 '''<%def name="breadcrumbs()"></%def>\n''' |
143 """<%def name="breadcrumbs()"></%def>\n""" |
143 '''<%def name="footer()"><p><a href="#top">Top ^</a></p>''' |
144 """<%def name="footer()"><p><a href="#top">Top ^</a></p>""" |
144 '''</%def>\n''' |
145 """</%def>\n""", |
145 ], |
146 ], |
146 } |
147 } |
147 |
148 |
148 self.__okButton = self.buttonBox.button( |
149 self.__okButton = self.buttonBox.button(QDialogButtonBox.StandardButton.Ok) |
149 QDialogButtonBox.StandardButton.Ok) |
|
150 self.__okButton.setEnabled(False) |
150 self.__okButton.setEnabled(False) |
151 |
151 |
152 templates = {} |
152 templates = {} |
153 for templateType in self.__templates: |
153 for templateType in self.__templates: |
154 templates[self.__templates[templateType][0]] = templateType |
154 templates[self.__templates[templateType][0]] = templateType |
155 |
155 |
156 self.typeCombo.addItem("") |
156 self.typeCombo.addItem("") |
157 for templateString, templateType in sorted(templates.items()): |
157 for templateString, templateType in sorted(templates.items()): |
158 self.typeCombo.addItem(templateString, templateType) |
158 self.typeCombo.addItem(templateString, templateType) |
159 self.typeCombo.setCurrentIndex(0) |
159 self.typeCombo.setCurrentIndex(0) |
160 |
160 |
161 @pyqtSlot(int) |
161 @pyqtSlot(int) |
162 def on_typeCombo_currentIndexChanged(self, index): |
162 def on_typeCombo_currentIndexChanged(self, index): |
163 """ |
163 """ |
164 Private slot to act upon a change of the selected template type. |
164 Private slot to act upon a change of the selected template type. |
165 |
165 |
166 @param index selected index |
166 @param index selected index |
167 @type int |
167 @type int |
168 """ |
168 """ |
169 templateType = self.typeCombo.itemData(index) |
169 templateType = self.typeCombo.itemData(index) |
170 if templateType: |
170 if templateType: |