Preferences/ConfigurationPages/EditorHighlightingStylesPage.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3190
a9a94491c4fd
child 3656
441956d8fce5
child 3961
1e8abbfe11c7
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
40 super(EditorHighlightingStylesPage, self).__init__() 40 super(EditorHighlightingStylesPage, self).__init__()
41 self.setupUi(self) 41 self.setupUi(self)
42 self.setObjectName("EditorHighlightingStylesPage") 42 self.setObjectName("EditorHighlightingStylesPage")
43 43
44 self.__fontButtonMenu = QMenu() 44 self.__fontButtonMenu = QMenu()
45 act = self.__fontButtonMenu.addAction(self.trUtf8("Font")) 45 act = self.__fontButtonMenu.addAction(self.tr("Font"))
46 act.setData(self.FONT) 46 act.setData(self.FONT)
47 self.__fontButtonMenu.addSeparator() 47 self.__fontButtonMenu.addSeparator()
48 act = self.__fontButtonMenu.addAction( 48 act = self.__fontButtonMenu.addAction(
49 self.trUtf8("Family and Size only")) 49 self.tr("Family and Size only"))
50 act.setData(self.FAMILYANDSIZE) 50 act.setData(self.FAMILYANDSIZE)
51 act = self.__fontButtonMenu.addAction(self.trUtf8("Family only")) 51 act = self.__fontButtonMenu.addAction(self.tr("Family only"))
52 act.setData(self.FAMILYONLY) 52 act.setData(self.FAMILYONLY)
53 act = self.__fontButtonMenu.addAction(self.trUtf8("Size only")) 53 act = self.__fontButtonMenu.addAction(self.tr("Size only"))
54 act.setData(self.SIZEONLY) 54 act.setData(self.SIZEONLY)
55 self.__fontButtonMenu.triggered.connect(self.__fontButtonMenuTriggered) 55 self.__fontButtonMenu.triggered.connect(self.__fontButtonMenuTriggered)
56 self.fontButton.setMenu(self.__fontButtonMenu) 56 self.fontButton.setMenu(self.__fontButtonMenu)
57 57
58 self.__allFontsButtonMenu = QMenu() 58 self.__allFontsButtonMenu = QMenu()
59 act = self.__allFontsButtonMenu.addAction(self.trUtf8("Font")) 59 act = self.__allFontsButtonMenu.addAction(self.tr("Font"))
60 act.setData(self.FONT) 60 act.setData(self.FONT)
61 self.__allFontsButtonMenu.addSeparator() 61 self.__allFontsButtonMenu.addSeparator()
62 act = self.__allFontsButtonMenu.addAction( 62 act = self.__allFontsButtonMenu.addAction(
63 self.trUtf8("Family and Size only")) 63 self.tr("Family and Size only"))
64 act.setData(self.FAMILYANDSIZE) 64 act.setData(self.FAMILYANDSIZE)
65 act = self.__allFontsButtonMenu.addAction(self.trUtf8("Family only")) 65 act = self.__allFontsButtonMenu.addAction(self.tr("Family only"))
66 act.setData(self.FAMILYONLY) 66 act.setData(self.FAMILYONLY)
67 act = self.__allFontsButtonMenu.addAction(self.trUtf8("Size only")) 67 act = self.__allFontsButtonMenu.addAction(self.tr("Size only"))
68 act.setData(self.SIZEONLY) 68 act.setData(self.SIZEONLY)
69 self.__allFontsButtonMenu.triggered.connect( 69 self.__allFontsButtonMenu.triggered.connect(
70 self.__allFontsButtonMenuTriggered) 70 self.__allFontsButtonMenuTriggered)
71 self.allFontsButton.setMenu(self.__allFontsButtonMenu) 71 self.allFontsButton.setMenu(self.__allFontsButtonMenu)
72 72
324 def on_allEolFillButton_clicked(self): 324 def on_allEolFillButton_clicked(self):
325 """ 325 """
326 Private method used to set the eolfill for all styles of a selected 326 Private method used to set the eolfill for all styles of a selected
327 lexer. 327 lexer.
328 """ 328 """
329 on = self.trUtf8("Enabled") 329 on = self.tr("Enabled")
330 off = self.trUtf8("Disabled") 330 off = self.tr("Disabled")
331 selection, ok = QInputDialog.getItem( 331 selection, ok = QInputDialog.getItem(
332 self, 332 self,
333 self.trUtf8("Fill to end of line"), 333 self.tr("Fill to end of line"),
334 self.trUtf8("Select fill to end of line for all styles"), 334 self.tr("Select fill to end of line for all styles"),
335 [on, off], 335 [on, off],
336 0, False) 336 0, False)
337 if ok: 337 if ok:
338 enabled = selection == on 338 enabled = selection == on
339 self.eolfillCheckBox.setChecked(enabled) 339 self.eolfillCheckBox.setChecked(enabled)
413 413
414 @param lexers list of lexer objects for which to export the styles 414 @param lexers list of lexer objects for which to export the styles
415 """ 415 """
416 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( 416 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
417 self, 417 self,
418 self.trUtf8("Export Highlighting Styles"), 418 self.tr("Export Highlighting Styles"),
419 "", 419 "",
420 self.trUtf8("Highlighting styles file (*.e4h)"), 420 self.tr("Highlighting styles file (*.e4h)"),
421 "", 421 "",
422 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) 422 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
423 423
424 if not fn: 424 if not fn:
425 return 425 return
436 HighlightingStylesWriter(f, lexers).writeXML() 436 HighlightingStylesWriter(f, lexers).writeXML()
437 f.close() 437 f.close()
438 else: 438 else:
439 E5MessageBox.critical( 439 E5MessageBox.critical(
440 self, 440 self,
441 self.trUtf8("Export Highlighting Styles"), 441 self.tr("Export Highlighting Styles"),
442 self.trUtf8( 442 self.tr(
443 """<p>The highlighting styles could not be exported""" 443 """<p>The highlighting styles could not be exported"""
444 """ to file <b>{0}</b>.</p><p>Reason: {1}</p>""") 444 """ to file <b>{0}</b>.</p><p>Reason: {1}</p>""")
445 .format(fn, f.errorString()) 445 .format(fn, f.errorString())
446 ) 446 )
447 447
452 @param lexers dictionary of lexer objects for which to import the 452 @param lexers dictionary of lexer objects for which to import the
453 styles 453 styles
454 """ 454 """
455 fn = E5FileDialog.getOpenFileName( 455 fn = E5FileDialog.getOpenFileName(
456 self, 456 self,
457 self.trUtf8("Import Highlighting Styles"), 457 self.tr("Import Highlighting Styles"),
458 "", 458 "",
459 self.trUtf8("Highlighting styles file (*.e4h)")) 459 self.tr("Highlighting styles file (*.e4h)"))
460 460
461 if not fn: 461 if not fn:
462 return 462 return
463 463
464 f = QFile(fn) 464 f = QFile(fn)
468 reader.readXML() 468 reader.readXML()
469 f.close() 469 f.close()
470 else: 470 else:
471 E5MessageBox.critical( 471 E5MessageBox.critical(
472 self, 472 self,
473 self.trUtf8("Import Highlighting Styles"), 473 self.tr("Import Highlighting Styles"),
474 self.trUtf8( 474 self.tr(
475 """<p>The highlighting styles could not be read""" 475 """<p>The highlighting styles could not be read"""
476 """ from file <b>{0}</b>.</p><p>Reason: {1}</p>""") 476 """ from file <b>{0}</b>.</p><p>Reason: {1}</p>""")
477 .format(fn, f.errorString()) 477 .format(fn, f.errorString())
478 ) 478 )
479 return 479 return

eric ide

mercurial