Add an option for monospace font
offlate/window.py
30 | 30 | return self.value | |
31 | 31 | ||
32 | 32 | class ProjectView(QWidget): | |
33 | - | def __init__(self, project, showTranslated = True, showUntranslated = True, showFuzzy = True, parent = None): | |
33 | + | def __init__(self, project, showTranslated = True, showUntranslated = True, | |
34 | + | showFuzzy = True, monospace = False, parent = None): | |
34 | 35 | super(ProjectView, self).__init__(parent) | |
35 | 36 | self.project = project | |
36 | 37 | self.content = self.project.content() | |
… | |||
38 | 39 | self.showTranslated = showTranslated | |
39 | 40 | self.showUntranslated = showUntranslated | |
40 | 41 | self.showFuzzy = showFuzzy | |
42 | + | self.monospace = monospace | |
41 | 43 | self.initUI() | |
42 | 44 | ||
43 | 45 | def updateContent(self): | |
… | |||
100 | 102 | self.msgid.deleteLater() | |
101 | 103 | self.msgstr.deleteLater() | |
102 | 104 | ||
105 | + | font = "monospace" if self.monospace else "sans-serif" | |
106 | + | ||
103 | 107 | if len(data.msgstrs) > 1: | |
104 | 108 | self.msgid = QTabWidget(); | |
105 | 109 | self.msgstr = QTabWidget(); | |
106 | 110 | singular = QTextEdit() | |
111 | + | singular.setFont(QFont(font)) | |
107 | 112 | singular.setReadOnly(True) | |
108 | 113 | singular.setText(data.msgids[0]) | |
109 | 114 | plural = QTextEdit() | |
115 | + | plural.setFont(QFont(font)) | |
110 | 116 | plural.setReadOnly(True) | |
111 | 117 | plural.setText(data.msgids[1]) | |
112 | 118 | self.msgid.addTab(singular, self.tr("Singular")) | |
… | |||
114 | 120 | i = 0 | |
115 | 121 | for msgstr in data.msgstrs: | |
116 | 122 | form = SpellCheckEdit(self.project.lang) | |
123 | + | form.setFont(QFont(font)) | |
117 | 124 | form.setText(msgstr) | |
118 | 125 | form.textChanged.connect(self.modify) | |
119 | 126 | self.msgstr.addTab(form, str(i)) | |
120 | 127 | i=i+1 | |
121 | 128 | else: | |
122 | 129 | self.msgid = QTextEdit() | |
130 | + | self.msgid.setFont(QFont(font)) | |
123 | 131 | self.msgid.setReadOnly(True) | |
124 | - | self.msgstr = SpellCheckEdit(self.project.lang) | |
125 | 132 | self.msgid.setText(data.msgids[0]) | |
133 | + | self.msgstr = SpellCheckEdit(self.project.lang) | |
134 | + | self.msgstr.setFont(QFont(font)) | |
126 | 135 | self.msgstr.setText(data.msgstrs[0]) | |
127 | 136 | self.msgstr.textChanged.connect(self.modify) | |
128 | 137 | self.hbox.addWidget(self.msgid) | |
… | |||
165 | 174 | self.showFuzzy = showFuzzy | |
166 | 175 | self.updateContent() | |
167 | 176 | ||
177 | + | def setFont(self, monospace): | |
178 | + | self.monospace = monospace | |
179 | + | current = self.treeWidget.currentItem() | |
180 | + | self.selectItem(current, current) | |
181 | + | ||
168 | 182 | class NewWindow(QDialog): | |
169 | 183 | def __init__(self, manager, parent = None): | |
170 | 184 | super().__init__(parent) | |
… | |||
414 | 428 | ||
415 | 429 | def open(self, name): | |
416 | 430 | project = self.manager.getProject(name) | |
417 | - | self.tabs.addTab(ProjectView(project), name) | |
431 | + | self.tabs.addTab(ProjectView(project, | |
432 | + | showTranslated = self.showTranslatedAct.isChecked(), | |
433 | + | showUntranslated = self.showUntranslatedAct.isChecked(), | |
434 | + | showFuzzy = self.showFuzzyAct.isChecked(), | |
435 | + | monospace = self.monospaceAct.isChecked()), name) | |
418 | 436 | ||
419 | 437 | def save(self): | |
420 | 438 | self.tabs.currentWidget().save() | |
… | |||
450 | 468 | self.showUntranslatedAct.isChecked(), | |
451 | 469 | self.showFuzzyAct.isChecked()) | |
452 | 470 | ||
471 | + | def setFont(self): | |
472 | + | for i in range(0, self.tabs.count()): | |
473 | + | self.tabs.widget(i).setFont(self.monospaceAct.isChecked()) | |
474 | + | ||
453 | 475 | def initUI(self): | |
454 | 476 | # Build menu | |
455 | 477 | exitAct = QAction(QIcon('exit.png'), self.tr('Exit'), self) | |
… | |||
495 | 517 | self.showUntranslatedAct = QAction(self.tr('Show Empty Translation'), self, checkable=True) | |
496 | 518 | self.showUntranslatedAct.setChecked(True) | |
497 | 519 | self.showUntranslatedAct.triggered.connect(self.filter) | |
520 | + | self.monospaceAct = QAction(self.tr('Use a monospace font'), self, checkable=True) | |
521 | + | self.monospaceAct.setChecked(False) | |
522 | + | self.monospaceAct.triggered.connect(self.setFont) | |
498 | 523 | ||
499 | 524 | self.statusBar() | |
500 | 525 | ||
… | |||
522 | 547 | viewMenu.addAction(self.showTranslatedAct) | |
523 | 548 | viewMenu.addAction(self.showUntranslatedAct) | |
524 | 549 | viewMenu.addAction(self.showFuzzyAct) | |
550 | + | viewMenu.addSeparator() | |
551 | + | viewMenu.addAction(self.monospaceAct) | |
525 | 552 | ||
526 | 553 | self.tabs = ProjectTab() | |
527 | 554 |
setup.py
2 | 2 | ||
3 | 3 | setup ( | |
4 | 4 | name="offlate", | |
5 | - | version="0.1", | |
5 | + | version="0.1.1.dev", | |
6 | 6 | packages=find_packages(exclude=['.guix-profile*']), | |
7 | 7 | python_requires = '>=3', | |
8 | 8 | install_requires=['polib', 'ruamel.yaml', 'python-dateutil'], |