eric6/Templates/TemplatePropertiesDialog.py

Mon, 12 Oct 2020 19:28:42 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 12 Oct 2020 19:28:42 +0200
changeset 7781
607a6098cb44
parent 7775
4a1db75550bd
child 7923
91e843545d9a
permissions
-rw-r--r--

Performed some more code cleanup.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
3 # Copyright (c) 2005 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the templates properties dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
10 from PyQt5.QtCore import pyqtSlot, Qt, QRegularExpression
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
11 from PyQt5.QtGui import QRegularExpressionValidator
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
12 from PyQt5.QtWidgets import QDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
14 from .Ui_TemplatePropertiesDialog import Ui_TemplatePropertiesDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 108
diff changeset
16 from E5Gui import E5MessageBox
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
3492
ae74a7201759 Added a configurable template code editor font.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
18 import Preferences
ae74a7201759 Added a configurable template code editor font.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
19
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
20
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 class TemplatePropertiesDialog(QDialog, Ui_TemplatePropertiesDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Class implementing the templates properties dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
25 def __init__(self, parent, groupMode=False, itm=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param parent the parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param groupMode flag indicating group mode (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param itm item (TemplateEntry or TemplateGroup) to
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 read the data from
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
34 super(TemplatePropertiesDialog, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
3492
ae74a7201759 Added a configurable template code editor font.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
37 self.templateEdit.setFont(Preferences.getTemplates("EditorFont"))
ae74a7201759 Added a configurable template code editor font.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
38
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 if not groupMode:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
40 self.nameEdit.setWhatsThis(self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """<b>Template name<b><p>Enter the name of the template."""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """ Templates may be autocompleted upon this name."""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """ In order to support autocompletion. the template name"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """ must only consist of letters (a-z and A-Z),"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """ digits (0-9) and underscores (_).</p>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 ))
7775
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
47 self.__nameValidator = QRegularExpressionValidator(
4a1db75550bd Changed code to not use deprecated 'QRegExp' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
48 QRegularExpression("[a-zA-Z0-9_]+"), self.nameEdit)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.nameEdit.setValidator(self.__nameValidator)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
51 import QScintilla.Lexers
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
52 self.languages = [("All", self.tr("All"))]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 supportedLanguages = QScintilla.Lexers.getSupportedLanguages()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 languages = sorted(supportedLanguages.keys())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 for language in languages:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.languages.append((language, supportedLanguages[language][0]))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.groupMode = groupMode
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 if groupMode:
5427
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
60 self.groupLabel.setText(self.tr("Language:"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 for lang, langDisp in self.languages:
5427
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
62 self.groupCombo.addItem(
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
63 QScintilla.Lexers.getLanguageIcon(lang, False),
614e88cfbd84 Added some eye candy.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
64 langDisp)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.templateLabel.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.templateEdit.setEnabled(False)
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
67 self.templateEdit.setPlainText(self.tr("GROUP"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.helpButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.descriptionLabel.hide()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.descriptionEdit.hide()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 groups = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 for group in parent.getGroupNames():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 groups.append(group)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.groupCombo.addItems(groups)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 if itm is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.nameEdit.setText(itm.getName())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 if groupMode:
5148
1a879f9af1c0 Fixed some code style issue detected by the new pycodestyle checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
80 language = itm.getLanguage()
1a879f9af1c0 Fixed some code style issue detected by the new pycodestyle checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
81 for lang, langDisp in self.languages:
1a879f9af1c0 Fixed some code style issue detected by the new pycodestyle checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
82 if language == lang:
1a879f9af1c0 Fixed some code style issue detected by the new pycodestyle checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
83 self.setSelectedGroup(langDisp)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.setSelectedGroup(itm.getGroupName())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.templateEdit.setPlainText(itm.getTemplateText())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.descriptionEdit.setText(itm.getDescription())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.nameEdit.selectAll()
4481
456c58fc64b0 Added a specialized dialog to show template help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
91
456c58fc64b0 Added a specialized dialog to show template help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
92 self.__helpDialog = None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 def keyPressEvent(self, ev):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3515
diff changeset
96 Protected method to handle the user pressing the escape key.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 @param ev key event (QKeyEvent)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 if ev.key() == Qt.Key_Escape:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2997
diff changeset
101 res = E5MessageBox.yesNo(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2997
diff changeset
102 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
103 self.tr("Close dialog"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
104 self.tr("""Do you really want to close the dialog?"""))
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 538
diff changeset
105 if not res:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.reject()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 def on_helpButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3515
diff changeset
111 Private slot to show some help.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 """
4481
456c58fc64b0 Added a specialized dialog to show template help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
113 if self.__helpDialog is None:
5769
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
114 from E5Gui.E5SimpleHelpDialog import E5SimpleHelpDialog
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
115 self.__helpDialog = E5SimpleHelpDialog(
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
116 title=self.tr("Template Help"),
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
117 label=self.tr("<b>Template Help</b>"),
5794
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
118 helpStr=self.tr(
5769
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
119 """<p>To use variables in a template, you just have to"""
5792
519a193a19d7 Fixed some typos in the templates help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5769
diff changeset
120 """ enclose the variable name with $-characters. When"""
519a193a19d7 Fixed some typos in the templates help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5769
diff changeset
121 """ you use the template, you will then be asked for a"""
519a193a19d7 Fixed some typos in the templates help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5769
diff changeset
122 """ value for this variable.</p>"""
5769
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
123 """<p>Example template: This is a $VAR$</p>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
124 """<p>When you use this template you will be prompted"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
125 """ for a value for the variable $VAR$. Any occurrences"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
126 """ of $VAR$ will then be replaced with whatever you've"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
127 """ entered.</p>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
128 """<p>If you need a single $-character in a template,"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
129 """ which is not used to enclose a variable, type"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
130 """ $$(two dollar characters) instead. They will"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
131 """ automatically be replaced with a single $-character"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
132 """ when you use the template.</p>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
133 """<p>If you want a variables contents to be treated"""
5794
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
134 """ specially, the variable name must be followed by a"""
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
135 """ ':' and one formatting specifier (e.g. $VAR:ml$)."""
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
136 """ The supported specifiers are:"""
5769
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
137 """<table>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
138 """<tr><td>ml</td><td>Specifies a multiline formatting."""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
139 """ The first line of the variable contents is prefixed"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
140 """ with the string occurring before the variable on"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
141 """ the same line of the template. All other lines are"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
142 """ prefixed by the same amount of whitespace as the"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
143 """ line containing the variable."""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
144 """</td></tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
145 """<tr><td>rl</td><td>Specifies a repeated line"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
146 """ formatting. Each line of the variable contents is"""
5792
519a193a19d7 Fixed some typos in the templates help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5769
diff changeset
147 """ prefixed with the string occurring before the"""
5769
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
148 """ variable on the same line of the template."""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
149 """</td></tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
150 """</table></p>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
151 """<p>The following predefined variables may be used"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
152 """ in a template:"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
153 """<table>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
154 """<tr><td>date</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
155 """<td>today's date in ISO format (YYYY-MM-DD)</td></tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
156 """<tr><td>year</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
157 """<td>the current year</td></tr>"""
5794
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
158 """<tr><td>time</td>"""
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
159 """<td>current time in ISO format (hh:mm:ss)</td></tr>"""
5769
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
160 """<tr><td>project_name</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
161 """<td>the name of the project (if any)</td></tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
162 """<tr><td>project_path</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
163 """<td>the path of the project (if any)</td></tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
164 """<tr><td>path_name</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
165 """<td>full path of the current file</td></tr>"""
5794
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
166 """<tr><td>path_name_rel</td>"""
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
167 """<td>project relative path of the current file</td>"""
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
168 """</tr>"""
5769
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
169 """<tr><td>dir_name</td>"""
5794
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
170 """<td>full path of the current file's directory</td>"""
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
171 """</tr>"""
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
172 """<tr><td>dir_name_rel</td>"""
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
173 """<td>project relative path of the current file's"""
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
174 """ directory</td></tr>"""
5769
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
175 """<tr><td>file_name</td>"""
5794
f8cf9bcaa1fa Added some new predefined template variables (time, path_name_rel, dir_name_rel).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5792
diff changeset
176 """<td>the current file's name (without directory)"""
5769
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
177 """</td></tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
178 """<tr><td>base_name</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
179 """<td>like <i>file_name</i>, but without extension"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
180 """</td></tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
181 """<tr><td>ext</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
182 """<td>the extension of the current file</td></tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
183 """<tr><td>cur_select</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
184 """<td>the currently selected text</td></tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
185 """<tr><td>insertion</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
186 """<td>Sets insertion point for cursor after template is"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
187 """ inserted.</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
188 """</tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
189 """<tr><td>select_start</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
190 """<td>Sets span of selected text in template after"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
191 """ template is inserted (used together with"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
192 """ 'select_end').</td></tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
193 """<tr><td>select_end</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
194 """<td>Sets span of selected text in template after"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
195 """ template is inserted (used together with"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
196 """ 'select_start')."""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
197 """</td></tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
198 """<tr><td>clipboard</td>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
199 """<td>the text of the clipboard</td></tr>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
200 """</table></p>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
201 """<p>If you want to change the default delimiter to"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
202 """ anything different, please use the configuration"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
203 """ dialog to do so.</p>"""
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
204 ),
944c04cec861 Added the capability to send these emails via Google Mail using OAuth2 authentication.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5427
diff changeset
205 parent=self)
4481
456c58fc64b0 Added a specialized dialog to show template help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
206 self.__helpDialog.show()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 def setSelectedGroup(self, name):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 Public method to select a group.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 @param name name of the group to be selected (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 index = self.groupCombo.findText(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.groupCombo.setCurrentIndex(index)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 def getData(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 Public method to get the data entered into the dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220
2997
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
221 @return a tuple of two strings (name, language), if the dialog is in
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
222 group mode, and a tuple of four strings (name, description, group
7f0ef975da9e Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
223 name, template) otherwise.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 if self.groupMode:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 return (self.nameEdit.text(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 self.languages[self.groupCombo.currentIndex()][0]
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
228 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 return (self.nameEdit.text(),
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
231 self.descriptionEdit.text(),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 self.groupCombo.currentText(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 self.templateEdit.toPlainText()
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
234 )

eric ide

mercurial