|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2015 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to show some template help. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtCore import Qt |
|
11 from PyQt5.QtWidgets import QDialog |
|
12 |
|
13 from .Ui_TemplateHelpDialog import Ui_TemplateHelpDialog |
|
14 |
|
15 |
|
16 class TemplateHelpDialog(QDialog, Ui_TemplateHelpDialog): |
|
17 """ |
|
18 Class implementing a dialog to show some template help. |
|
19 """ |
|
20 def __init__(self, parent=None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param parent reference to the parent widget |
|
25 @type QWidget |
|
26 """ |
|
27 super(TemplateHelpDialog, self).__init__(parent) |
|
28 self.setupUi(self) |
|
29 self.setWindowFlags(Qt.Window) |
|
30 |
|
31 self.helpEdit.setHtml(self.tr( |
|
32 """<p>To use variables in a template, you just have to""" |
|
33 """ enclose the variablename with $-characters. When you""" |
|
34 """ use the template, you will then be asked for a value""" |
|
35 """ for this variable.</p>""" |
|
36 """<p>Example template: This is a $VAR$</p>""" |
|
37 """<p>When you use this template you will be prompted for""" |
|
38 """ a value for the variable $VAR$. Any occurrences of $VAR$""" |
|
39 """ will then be replaced with whatever you've entered.</p>""" |
|
40 """<p>If you need a single $-character in a template, which""" |
|
41 """ is not used to enclose a variable, type $$(two dollar""" |
|
42 """ characters) instead. They will automatically be replaced""" |
|
43 """ with a single $-character when you use the template.</p>""" |
|
44 """<p>If you want a variables contents to be treated""" |
|
45 """ specially, the variablename must be followed by a ':'""" |
|
46 """ and one formatting specifier (e.g. $VAR:ml$). The""" |
|
47 """ supported specifiers are:""" |
|
48 """<table>""" |
|
49 """<tr><td>ml</td><td>Specifies a multiline formatting.""" |
|
50 """ The first line of the variable contents is prefixed with""" |
|
51 """ the string occurring before the variable on the same""" |
|
52 """ line of the template. All other lines are prefixed by""" |
|
53 """ the same amount of whitespace as the line containing""" |
|
54 """ the variable.""" |
|
55 """</td></tr>""" |
|
56 """<tr><td>rl</td><td>Specifies a repeated line formatting.""" |
|
57 """ Each line of the variable contents is prefixed with the""" |
|
58 """ string occuring before the variable on the same line of""" |
|
59 """ the template.""" |
|
60 """</td></tr>""" |
|
61 """</table></p>""" |
|
62 """<p>The following predefined variables may be used in a""" |
|
63 """ template:""" |
|
64 """<table>""" |
|
65 """<tr><td>date</td>""" |
|
66 """<td>today's date in ISO format (YYYY-MM-DD)</td></tr>""" |
|
67 """<tr><td>year</td>""" |
|
68 """<td>the current year</td></tr>""" |
|
69 """<tr><td>project_name</td>""" |
|
70 """<td>the name of the project (if any)</td></tr>""" |
|
71 """<tr><td>project_path</td>""" |
|
72 """<td>the path of the project (if any)</td></tr>""" |
|
73 """<tr><td>path_name</td>""" |
|
74 """<td>full path of the current file</td></tr>""" |
|
75 """<tr><td>dir_name</td>""" |
|
76 """<td>full path of the parent directory</td></tr>""" |
|
77 """<tr><td>file_name</td>""" |
|
78 """<td>the current file name (without directory)</td></tr>""" |
|
79 """<tr><td>base_name</td>""" |
|
80 """<td>like <i>file_name</i>, but without extension""" |
|
81 """</td></tr>""" |
|
82 """<tr><td>ext</td>""" |
|
83 """<td>the extension of the current file</td></tr>""" |
|
84 """<tr><td>cur_select</td>""" |
|
85 """<td>the currently selected text</td></tr>""" |
|
86 """<tr><td>insertion</td>""" |
|
87 """<td>Sets insertion point for cursor after template is""" |
|
88 """ inserted.</td>""" |
|
89 """</tr>""" |
|
90 """<tr><td>select_start</td>""" |
|
91 """<td>Sets span of selected text in template after template""" |
|
92 """ is inserted (used together with 'select_end').</td></tr>""" |
|
93 """<tr><td>select_end</td>""" |
|
94 """<td>Sets span of selected text in template after template""" |
|
95 """ is inserted (used together with 'select_start').""" |
|
96 """</td></tr>""" |
|
97 """<tr><td>clipboard</td>""" |
|
98 """<td>the text of the clipboard</td></tr>""" |
|
99 """</table></p>""" |
|
100 """<p>If you want to change the default delimiter to""" |
|
101 """ anything different, please use the configuration""" |
|
102 """ dialog to do so.</p>""" |
|
103 )) |