Preferences/ConfigurationPages/EditorHighlightingStylesPage.py

changeset 4698
61c0aef6a570
parent 4675
adb8882de5af
child 5389
9b1c800daff3
equal deleted inserted replaced
4697:c2e9bf425554 4698:61c0aef6a570
7 Module implementing the Editor Highlighting Styles configuration page. 7 Module implementing the Editor Highlighting Styles configuration page.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 from PyQt5.QtCore import pyqtSlot, Qt, QFileInfo, QFile, QIODevice 12 from PyQt5.QtCore import pyqtSlot, Qt, QFileInfo, QFile, QIODevice, qVersion
13 from PyQt5.QtGui import QPalette, QFont 13 from PyQt5.QtGui import QPalette, QFont
14 from PyQt5.QtWidgets import QColorDialog, QFontDialog, QInputDialog, QMenu 14 from PyQt5.QtWidgets import QColorDialog, QFontDialog, QInputDialog, QMenu
15 15
16 from .ConfigurationPageBase import ConfigurationPageBase 16 from .ConfigurationPageBase import ConfigurationPageBase
17 from .Ui_EditorHighlightingStylesPage import Ui_EditorHighlightingStylesPage 17 from .Ui_EditorHighlightingStylesPage import Ui_EditorHighlightingStylesPage
18 18
19 from E5Gui import E5MessageBox, E5FileDialog 19 from E5Gui import E5MessageBox, E5FileDialog
20 20
21 import Preferences 21 import Preferences
22 22
23 23 try:
24 # TODO: add a button to show only monospaced fonts 24 MonospacedFontsOption = QFontDialog.MonospacedFonts
25 except AttributeError:
26 MonospacedFontsOption = QFontDialog.FontDialogOptions(0x10)
27 NoFontsOption = QFontDialog.FontDialogOptions(0)
28
29
25 class EditorHighlightingStylesPage(ConfigurationPageBase, 30 class EditorHighlightingStylesPage(ConfigurationPageBase,
26 Ui_EditorHighlightingStylesPage): 31 Ui_EditorHighlightingStylesPage):
27 """ 32 """
28 Class implementing the Editor Highlighting Styles configuration page. 33 Class implementing the Editor Highlighting Styles configuration page.
29 """ 34 """
39 @param lexers reference to the lexers dictionary 44 @param lexers reference to the lexers dictionary
40 """ 45 """
41 super(EditorHighlightingStylesPage, self).__init__() 46 super(EditorHighlightingStylesPage, self).__init__()
42 self.setupUi(self) 47 self.setupUi(self)
43 self.setObjectName("EditorHighlightingStylesPage") 48 self.setObjectName("EditorHighlightingStylesPage")
49
50 if qVersion() < "5.0.0":
51 self.monospacedButton.setChecked(False)
52 self.monospacedButton.hide()
44 53
45 self.__fontButtonMenu = QMenu() 54 self.__fontButtonMenu = QMenu()
46 act = self.__fontButtonMenu.addAction(self.tr("Font")) 55 act = self.__fontButtonMenu.addAction(self.tr("Font"))
47 act.setData(self.FONT) 56 act.setData(self.FONT)
48 self.__fontButtonMenu.addSeparator() 57 self.__fontButtonMenu.addSeparator()
263 newFont.setPointSize(font.pointSize()) 272 newFont.setPointSize(font.pointSize())
264 self.sampleText.setFont(newFont) 273 self.sampleText.setFont(newFont)
265 else: 274 else:
266 self.sampleText.setFont(font) 275 self.sampleText.setFont(font)
267 276
268 font, ok = QFontDialog.getFont(self.lexer.font(self.style)) 277 if self.monospacedButton.isChecked():
278 options = MonospacedFontsOption
279 else:
280 options = NoFontsOption
281 font, ok = QFontDialog.getFont(self.lexer.font(self.style), self,
282 "", options)
269 if ok: 283 if ok:
270 setSampleFont(font, familyOnly, sizeOnly) 284 setSampleFont(font, familyOnly, sizeOnly)
271 if doAll: 285 if doAll:
272 for style in list(self.lexer.ind2style.values()): 286 for style in list(self.lexer.ind2style.values()):
273 setFont(font, style, familyOnly, sizeOnly) 287 setFont(font, style, familyOnly, sizeOnly)

eric ide

mercurial