eric6/Preferences/SubstyleDefinitionDialog.py

Mon, 12 Oct 2020 18:23:44 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 12 Oct 2020 18:23:44 +0200
changeset 7780
41420f82c0ac
parent 7360
9190402e4505
child 7923
91e843545d9a
permissions
-rw-r--r--

Performed some code cleanup.

6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7263
diff changeset
3 # Copyright (c) 2019 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the sub-style definition dialog.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtCore import pyqtSlot
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from E5Gui import E5MessageBox
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from .Ui_SubstyleDefinitionDialog import Ui_SubstyleDefinitionDialog
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class SubstyleDefinitionDialog(QDialog, Ui_SubstyleDefinitionDialog):
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing the sub-style definition dialog.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 def __init__(self, lexer, style, substyle, parent=None):
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 Constructor
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param lexer reference to the lexer object
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @type PreferencesLexer
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param style style number
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @type int
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param substyle sub-style number
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @type int
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param parent reference to the parent widget
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @type QWidget
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 super(SubstyleDefinitionDialog, self).__init__(parent)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.setupUi(self)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.__lexer = lexer
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.__style = style
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.__substyle = substyle
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.header.setText(self.tr("<h3>{0} - {1}</h3>").format(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.__lexer.language(), self.__lexer.description(self.__style)))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 if self.__substyle >= 0:
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 # it's an edit operation
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.descriptionEdit.setText(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.__lexer.description(self.__style, self.__substyle))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.wordsEdit.setPlainText(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 self.__lexer.words(self.__style, self.__substyle))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 def __updateOk(self):
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 Private slot to update the state of the OK button.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 bool(self.descriptionEdit.text().strip()) and
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 bool(self.wordsEdit.toPlainText().strip())
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 )
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 @pyqtSlot(str)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 def on_descriptionEdit_textChanged(self, txt):
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 Private slot handling changes of the description.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @param txt text of the description
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @type str
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.__updateOk()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 @pyqtSlot()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 def on_wordsEdit_textChanged(self):
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 Private slot handling changes of the word list.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.__updateOk()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 @pyqtSlot()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 def on_resetButton_clicked(self):
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 Private slot to reset the dialog contents.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 ok = E5MessageBox.yesNo(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 self,
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.tr("Reset Sub-Style Data"),
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.tr("""Shall the entered sub-style data be reset?"""))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 if ok:
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 if self.__substyle >= 0:
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.descriptionEdit.setText(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.__lexer.description(self.__style, self.__substyle))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.wordsEdit.setPlainText(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__lexer.words(self.__style, self.__substyle))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 else:
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.descriptionEdit.clear()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.wordsEdit.clear()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 @pyqtSlot()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 def on_defaultButton_clicked(self):
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 Private slot to set the dialog contents to default values.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 """
7263
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
101 filled = (
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
102 bool(self.descriptionEdit.text().strip()) or
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 bool(self.wordsEdit.toPlainText().strip())
7263
c1af2e327675 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
104 )
6864
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 if filled:
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 ok = E5MessageBox.yesNo(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self,
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.tr("Set Sub-Style Data to Default"),
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 self.tr("""Shall the sub-style data be set to default"""
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 """ values?"""))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 else:
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 ok = True
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 if ok:
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 if self.__substyle >= 0:
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 self.descriptionEdit.setText(self.__lexer.defaultDescription(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 self.__style, self.__substyle))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 self.wordsEdit.setPlainText(self.__lexer.defaultWords(
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.__style, self.__substyle))
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 else:
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 self.descriptionEdit.clear()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self.wordsEdit.clear()
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 def getData(self):
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 Public method to get the entered data.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 @return tuple containing the sub-style description and words list.
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 @rtype tuple of (str, str)
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 return (
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 self.descriptionEdit.text().strip(),
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 self.wordsEdit.toPlainText().strip(),
7837ab17f079 Sub-Styles: added buttons to the Editor Highlighting Styles configuration page to add, delete, edit and copy sub-style definitions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 )

eric ide

mercurial