Preferences/ConfigurationPages/EditorHighlightingStylesPage.py

changeset 4698
61c0aef6a570
parent 4675
adb8882de5af
child 5389
9b1c800daff3
diff -r c2e9bf425554 -r 61c0aef6a570 Preferences/ConfigurationPages/EditorHighlightingStylesPage.py
--- a/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py	Sun Jan 24 19:28:37 2016 +0100
+++ b/Preferences/ConfigurationPages/EditorHighlightingStylesPage.py	Mon Jan 25 18:57:22 2016 +0100
@@ -9,7 +9,7 @@
 
 from __future__ import unicode_literals
 
-from PyQt5.QtCore import pyqtSlot, Qt, QFileInfo, QFile, QIODevice
+from PyQt5.QtCore import pyqtSlot, Qt, QFileInfo, QFile, QIODevice, qVersion
 from PyQt5.QtGui import QPalette, QFont
 from PyQt5.QtWidgets import QColorDialog, QFontDialog, QInputDialog, QMenu
 
@@ -20,8 +20,13 @@
 
 import Preferences
 
+try:
+    MonospacedFontsOption = QFontDialog.MonospacedFonts
+except AttributeError:
+    MonospacedFontsOption = QFontDialog.FontDialogOptions(0x10)
+NoFontsOption = QFontDialog.FontDialogOptions(0)
 
-# TODO: add a button to show only monospaced fonts
+
 class EditorHighlightingStylesPage(ConfigurationPageBase,
                                    Ui_EditorHighlightingStylesPage):
     """
@@ -42,6 +47,10 @@
         self.setupUi(self)
         self.setObjectName("EditorHighlightingStylesPage")
         
+        if qVersion() < "5.0.0":
+            self.monospacedButton.setChecked(False)
+            self.monospacedButton.hide()
+        
         self.__fontButtonMenu = QMenu()
         act = self.__fontButtonMenu.addAction(self.tr("Font"))
         act.setData(self.FONT)
@@ -265,7 +274,12 @@
             else:
                 self.sampleText.setFont(font)
         
-        font, ok = QFontDialog.getFont(self.lexer.font(self.style))
+        if self.monospacedButton.isChecked():
+            options = MonospacedFontsOption
+        else:
+            options = NoFontsOption
+        font, ok = QFontDialog.getFont(self.lexer.font(self.style), self,
+                                       "", options)
         if ok:
             setSampleFont(font, familyOnly, sizeOnly)
             if doAll:

eric ide

mercurial