def setup_edit_area(self) -> None: tform = self.tform tform.front_button.setText(tr.card_templates_front_template()) tform.back_button.setText(tr.card_templates_back_template()) tform.style_button.setText(tr.card_templates_template_styling()) tform.groupBox.setTitle(tr.card_templates_template_box()) cnt = self.mw.col.models.useCount(self.model) self.tform.changes_affect_label.setText( self.col.tr.card_templates_changes_will_affect_notes(count=cnt)) qconnect(tform.edit_area.textChanged, self.write_edits_to_template_and_redraw) qconnect(tform.front_button.clicked, self.on_editor_toggled) qconnect(tform.back_button.clicked, self.on_editor_toggled) qconnect(tform.style_button.clicked, self.on_editor_toggled) self.current_editor_index = 0 self.tform.edit_area.setAcceptRichText(False) self.tform.edit_area.setFont(QFont("Courier")) if qtminor < 10: self.tform.edit_area.setTabStopWidth(30) else: tab_width = self.fontMetrics().width(" " * 4) self.tform.edit_area.setTabStopDistance(tab_width) widg = tform.search_edit widg.setPlaceholderText("Search") qconnect(widg.textChanged, self.on_search_changed) qconnect(widg.returnPressed, self.on_search_next)
def setup_edit_area(self) -> None: tform = self.tform editor = tform.edit_area tform.front_button.setText(tr.card_templates_front_template()) tform.back_button.setText(tr.card_templates_back_template()) tform.style_button.setText(tr.card_templates_template_styling()) tform.groupBox.setTitle(tr.card_templates_template_box()) cnt = self.mw.col.models.use_count(self.model) tform.changes_affect_label.setText( self.col.tr.card_templates_changes_will_affect_notes(count=cnt)) qconnect(editor.textChanged, self.write_edits_to_template_and_redraw) qconnect(tform.front_button.clicked, self.on_editor_toggled) qconnect(tform.back_button.clicked, self.on_editor_toggled) qconnect(tform.style_button.clicked, self.on_editor_toggled) self.current_editor_index = 0 editor.setAcceptRichText(False) editor.setFont(QFont("Courier")) tab_width = self.fontMetrics().horizontalAdvance(" " * 4) editor.setTabStopDistance(tab_width) palette = editor.palette() palette.setColor( QPalette.ColorGroup.Inactive, QPalette.ColorRole.Highlight, QColor("#4169e1" if theme_manager.night_mode else "#FFFF80"), ) palette.setColor( QPalette.ColorGroup.Inactive, QPalette.ColorRole.HighlightedText, QColor("#ffffff" if theme_manager.night_mode else "#000000"), ) editor.setPalette(palette) widg = tform.search_edit widg.setPlaceholderText("Search") qconnect(widg.textChanged, self.on_search_changed) qconnect(widg.returnPressed, self.on_search_next)