Differential D3445 Diff 8365 plugins/extensions/pykrita/plugin/plugins/scripter/syntaxstylescombobox.py
Changeset View
Changeset View
Standalone View
Standalone View
plugins/extensions/pykrita/plugin/plugins/scripter/syntaxstylescombobox.py
- This file was added.
1 | # -*- coding: utf-8 -*- | ||||
---|---|---|---|---|---|
2 | | ||||
3 | from PyQt5.QtWidgets import * | ||||
4 | from scripter import syntaxstyles | ||||
5 | import importlib | ||||
6 | | ||||
7 | | ||||
8 | class SyntaxStylesComboBox(QComboBox): | ||||
9 | | ||||
10 | def __init__(self, highlight, parent=None): | ||||
11 | super(SyntaxStylesComboBox, self).__init__(parent) | ||||
12 | | ||||
13 | self.highlight = highlight | ||||
14 | self.styleClasses = [syntaxstyles.DefaultSyntaxStyle, syntaxstyles.PythonVimSyntaxStyle] | ||||
15 | | ||||
16 | for styleClass in self.styleClasses: | ||||
17 | className = styleClass.__name__ | ||||
18 | self.addItem(className) | ||||
19 | | ||||
20 | if className == type(self.highlight.getSyntaxStyle()).__name__: | ||||
21 | self.setCurrentIndex(self.findText(className)) | ||||
22 | | ||||
23 | self.currentIndexChanged.connect(self._currentIndexChanged) | ||||
24 | | ||||
25 | def _currentIndexChanged(self, index): | ||||
26 | self.highlight.setSyntaxStyle(getattr(syntaxstyles, self.itemText(index))()) | ||||
27 | self.highlight.rehighlight() |