eric6/Preferences/SubstyleDefinitionDialog.py

Sun, 01 Sep 2019 19:40:53 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 01 Sep 2019 19:40:53 +0200
branch
without_py2_and_pyqt4
changeset 7198
684261ef2165
parent 6942
2602857055c5
child 7229
53054eb5b15a
permissions
-rw-r--r--

Removed the Qt4 runtime stuff.

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
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
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de>
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 __future__ import unicode_literals
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
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 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
13 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
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 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
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 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
18
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 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
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 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
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 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
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 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
27
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 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
29 @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
30 @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
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 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
33 @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
34 @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
35 @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
36 """
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 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
38 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
39
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.__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
41 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
42 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
43
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 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
45 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
46 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
47 # 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
48 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
49 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
50 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
51 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
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 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
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 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
56 """
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 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
58 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
59 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
60 )
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
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 @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
63 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
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 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
66
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 @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
68 @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
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 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
71
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 @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
73 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
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 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
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 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
78
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 @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
80 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
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 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
83 """
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 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
85 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
86 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
87 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
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97
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 @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
99 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
100 """
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
101 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
102 """
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 filled = bool(self.descriptionEdit.text().strip()) or \
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
104 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
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