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:
parent
57778a74e9
commit
1b1fe40eec
@ -222,6 +222,7 @@ class CardLayout(QDialog):
|
|||||||
left = QWidget()
|
left = QWidget()
|
||||||
tform = self.tform = aqt.forms.template.Ui_Form()
|
tform = self.tform = aqt.forms.template.Ui_Form()
|
||||||
tform.setupUi(left)
|
tform.setupUi(left)
|
||||||
|
self.setup_edit_area()
|
||||||
split.addWidget(left)
|
split.addWidget(left)
|
||||||
split.setCollapsible(0, False)
|
split.setCollapsible(0, False)
|
||||||
|
|
||||||
@ -233,13 +234,13 @@ class CardLayout(QDialog):
|
|||||||
pform.preview_back.setText(tr.card_templates_back_preview())
|
pform.preview_back.setText(tr.card_templates_back_preview())
|
||||||
pform.preview_box.setTitle(tr.card_templates_preview_box())
|
pform.preview_box.setTitle(tr.card_templates_preview_box())
|
||||||
|
|
||||||
self.setup_edit_area()
|
|
||||||
self.setup_preview()
|
self.setup_preview()
|
||||||
split.addWidget(right)
|
split.addWidget(right)
|
||||||
split.setCollapsible(1, False)
|
split.setCollapsible(1, False)
|
||||||
|
|
||||||
def setup_edit_area(self) -> None:
|
def setup_edit_area(self) -> None:
|
||||||
tform = self.tform
|
tform = self.tform
|
||||||
|
editor = tform.edit_area
|
||||||
|
|
||||||
tform.front_button.setText(tr.card_templates_front_template())
|
tform.front_button.setText(tr.card_templates_front_template())
|
||||||
tform.back_button.setText(tr.card_templates_back_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())
|
tform.groupBox.setTitle(tr.card_templates_template_box())
|
||||||
|
|
||||||
cnt = self.mw.col.models.use_count(self.model)
|
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)
|
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.front_button.clicked, self.on_editor_toggled)
|
||||||
qconnect(tform.back_button.clicked, self.on_editor_toggled)
|
qconnect(tform.back_button.clicked, self.on_editor_toggled)
|
||||||
qconnect(tform.style_button.clicked, self.on_editor_toggled)
|
qconnect(tform.style_button.clicked, self.on_editor_toggled)
|
||||||
|
|
||||||
self.current_editor_index = 0
|
self.current_editor_index = 0
|
||||||
self.tform.edit_area.setAcceptRichText(False)
|
editor.setAcceptRichText(False)
|
||||||
self.tform.edit_area.setFont(QFont("Courier"))
|
editor.setFont(QFont("Courier"))
|
||||||
tab_width = self.fontMetrics().horizontalAdvance(" " * 4)
|
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 = tform.search_edit
|
||||||
widg.setPlaceholderText("Search")
|
widg.setPlaceholderText("Search")
|
||||||
|
Loading…
Reference in New Issue
Block a user