Sat, 28 Sep 2019 18:44:48 +0200
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
7278
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | """ |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | Module implementing a dialog to set the tab and indentation width override for |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | a language. |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | from PyQt5.QtCore import pyqtSlot |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | from .Ui_EditorLanguageTabIndentOverrideDialog import ( |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | Ui_EditorLanguageTabIndentOverrideDialog |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | ) |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | class EditorLanguageTabIndentOverrideDialog( |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | QDialog, Ui_EditorLanguageTabIndentOverrideDialog): |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | """ |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | Class implementing a dialog to set the tab and indentation width override |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | for a language. |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | """ |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | def __init__(self, *, editMode=False, languages=None, tabWidth=0, |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | indentWidth=0, parent=None): |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | Constructor |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | @param editMode flag indicating the edit mode (Note: in edit mode |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | the language is fixed) |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | @type bool |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | @param languages list of available languages |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | @type list of str |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | @param tabWidth tab width to be set |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | @type int |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | @param indentWidth indentation width to be set |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | @type int |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | @param parent reference to the parent widget |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | @type QWidget |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | """ |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | super(EditorLanguageTabIndentOverrideDialog, self).__init__(parent) |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | self.setupUi(self) |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | if editMode: |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | self.languageComboBox.addItems(languages) |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | else: |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | self.languageComboBox.addItems([""] + sorted(languages)) |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | self.tabWidthSpinBox.setValue(tabWidth) |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | self.indentWidthSpinBox.setValue(indentWidth) |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | def getData(self): |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | """ |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | Public method to get the entered data. |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | @return tuple containing the language, the tab width and the |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | indentation width |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | @rtype tuple of (str, int, int) |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | """ |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | return ( |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | self.languageComboBox.currentText(), |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | self.tabWidthSpinBox.value(), |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | self.indentWidthSpinBox.value(), |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | ) |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | @pyqtSlot(str) |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | def on_languageComboBox_currentIndexChanged(self, lang): |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | """ |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | Private slot to handle the selection of a language. |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | @param lang selected language |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | @type str |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | """ |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( |
1820a0344b62
Editor: added configuration option to set the tab and indentation width for each languages separately (as an override to the global ones).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | bool(lang)) |