Changeset View
Changeset View
Standalone View
Standalone View
plugins/extensions/pykrita/plugin/plugins/scripter/fontscombobox.py
- This file was added.
1 | from PyQt5.QtWidgets import * | ||||
---|---|---|---|---|---|
2 | from PyQt5.QtGui import * | ||||
3 | from PyQt5.QtCore import * | ||||
4 | | ||||
5 | class FontsComboBox(QComboBox): | ||||
6 | | ||||
7 | def __init__(self, editor, parent=None): | ||||
8 | super(FontsComboBox, self).__init__(parent) | ||||
9 | | ||||
10 | self.editor = editor | ||||
11 | | ||||
12 | _fontDataBase = QFontDatabase() | ||||
13 | | ||||
14 | self.addItems(_fontDataBase.families()) | ||||
15 | self.setCurrentIndex(self.findText(self.editor.font)) | ||||
16 | | ||||
17 | com = QCompleter() | ||||
18 | com.setCaseSensitivity(Qt.CaseInsensitive) | ||||
19 | com.setCompletionMode(QCompleter.PopupCompletion) | ||||
20 | | ||||
21 | # Style sheet to set false on combobox-popup | ||||
22 | self.setStyleSheet("QComboBox { combobox-popup: 0; }") | ||||
23 | self.setMaxVisibleItems(10) | ||||
24 | self.setCompleter(com) | ||||
25 | self.currentIndexChanged.connect(self._currentIndexChanged) | ||||
26 | | ||||
27 | def _currentIndexChanged(self, index): | ||||
28 | self.editor.font = self.itemText(index) |