Tweak search highlight color in the templates screen (#1625)

* Tweak search highlight color in the templates screen

* Minor refactoring

* Also set foreground color

https://github.com/ankitects/anki/pull/1625#issuecomment-1020697992
This commit is contained in:
Abdo 2022-01-27 02:40:33 +03:00 committed by GitHub
parent 57778a74e9
commit 1b1fe40eec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -222,6 +222,7 @@ class CardLayout(QDialog):
left = QWidget()
tform = self.tform = aqt.forms.template.Ui_Form()
tform.setupUi(left)
self.setup_edit_area()
split.addWidget(left)
split.setCollapsible(0, False)
@ -233,13 +234,13 @@ class CardLayout(QDialog):
pform.preview_back.setText(tr.card_templates_back_preview())
pform.preview_box.setTitle(tr.card_templates_preview_box())
self.setup_edit_area()
self.setup_preview()
split.addWidget(right)
split.setCollapsible(1, False)
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())
@ -247,20 +248,33 @@ class CardLayout(QDialog):
tform.groupBox.setTitle(tr.card_templates_template_box())
cnt = self.mw.col.models.use_count(self.model)
self.tform.changes_affect_label.setText(
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(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
self.tform.edit_area.setAcceptRichText(False)
self.tform.edit_area.setFont(QFont("Courier"))
editor.setAcceptRichText(False)
editor.setFont(QFont("Courier"))
tab_width = self.fontMetrics().horizontalAdvance(" " * 4)
self.tform.edit_area.setTabStopDistance(tab_width)
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")