mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
add night mode and mobile class toggles in card layout screen
This commit is contained in:
parent
215413ce25
commit
03a80e596a
4 changed files with 51 additions and 12 deletions
|
@ -55,7 +55,9 @@ class CardLayout(QDialog):
|
|||
self.mm = self.mw.col.models
|
||||
self.model = note.model()
|
||||
self.templates = self.model["tmpls"]
|
||||
self._want_fill_empty_on = fill_empty
|
||||
self.fill_empty_action_toggled = fill_empty
|
||||
self.night_mode_action_toggled = self.mw.pm.night_mode()
|
||||
self.mobile_class_action_toggled = False
|
||||
self.have_autoplayed = False
|
||||
self.mm._remove_from_cache(self.model["id"])
|
||||
self.mw.checkpoint(_("Card Types"))
|
||||
|
@ -288,12 +290,9 @@ class CardLayout(QDialog):
|
|||
pform.preview_front.isChecked()
|
||||
qconnect(pform.preview_front.clicked, self.on_preview_toggled)
|
||||
qconnect(pform.preview_back.clicked, self.on_preview_toggled)
|
||||
if self._want_fill_empty_on:
|
||||
pform.fill_empty.setChecked(True)
|
||||
qconnect(pform.fill_empty.toggled, self.on_preview_toggled)
|
||||
if not self.note_has_empty_field():
|
||||
pform.fill_empty.setHidden(True)
|
||||
pform.fill_empty.setText(tr(TR.CARD_TEMPLATES_FILL_EMPTY))
|
||||
pform.preview_options.setText(_("Options") + " " + downArrow())
|
||||
qconnect(pform.preview_options.clicked, self.on_preview_options)
|
||||
|
||||
jsinc = [
|
||||
"jquery.js",
|
||||
"browsersel.js",
|
||||
|
@ -317,6 +316,40 @@ class CardLayout(QDialog):
|
|||
self.cloze_numbers = []
|
||||
self.pform.cloze_number_combo.setHidden(True)
|
||||
|
||||
def on_fill_empty_action_toggled(self):
|
||||
self.fill_empty_action_toggled = not self.fill_empty_action_toggled
|
||||
self.on_preview_toggled()
|
||||
|
||||
def on_night_mode_action_toggled(self):
|
||||
self.night_mode_action_toggled = not self.night_mode_action_toggled
|
||||
self.on_preview_toggled()
|
||||
|
||||
def on_mobile_class_action_toggled(self):
|
||||
self.mobile_class_action_toggled = not self.mobile_class_action_toggled
|
||||
self.on_preview_toggled()
|
||||
|
||||
def on_preview_options(self):
|
||||
m = QMenu(self)
|
||||
|
||||
a = m.addAction(tr(TR.CARD_TEMPLATES_FILL_EMPTY))
|
||||
a.setCheckable(True)
|
||||
a.setChecked(self.fill_empty_action_toggled)
|
||||
qconnect(a.triggered, self.on_fill_empty_action_toggled)
|
||||
if not self.note_has_empty_field():
|
||||
a.setVisible(False)
|
||||
|
||||
a = m.addAction(tr(TR.CARD_TEMPLATES_INVERT_NIGHT_MODE))
|
||||
a.setCheckable(True)
|
||||
a.setChecked(self.night_mode_action_toggled)
|
||||
qconnect(a.triggered, self.on_night_mode_action_toggled)
|
||||
|
||||
a = m.addAction(tr(TR.CARD_TEMPLATES_ADD_MOBILE_CLASS))
|
||||
a.setCheckable(True)
|
||||
a.setChecked(self.mobile_class_action_toggled)
|
||||
qconnect(a.toggled, self.on_mobile_class_action_toggled)
|
||||
|
||||
m.exec_(self.pform.preview_options.mapToGlobal(QPoint(0, 0)))
|
||||
|
||||
def on_preview_toggled(self):
|
||||
self.have_autoplayed = False
|
||||
self._renderPreview()
|
||||
|
@ -423,7 +456,11 @@ class CardLayout(QDialog):
|
|||
|
||||
ti = self.maybeTextInput
|
||||
|
||||
theme_manager.set_night_mode(self.night_mode_action_toggled)
|
||||
|
||||
bodyclass = theme_manager.body_classes_for_card_ord(c.ord)
|
||||
if self.mobile_class_action_toggled:
|
||||
bodyclass += " mobile"
|
||||
|
||||
if self.pform.preview_front.isChecked():
|
||||
q = ti(self.mw.prepare_card_text_for_display(c.q()))
|
||||
|
@ -485,7 +522,7 @@ class CardLayout(QDialog):
|
|||
card,
|
||||
notetype=self.model,
|
||||
template=template,
|
||||
fill_empty=self.pform.fill_empty.isChecked(),
|
||||
fill_empty=self.fill_empty_action_toggled,
|
||||
).render()
|
||||
card.set_render_output(output)
|
||||
return card
|
||||
|
@ -749,6 +786,7 @@ Enter deck to place new %s cards in, or leave blank:"""
|
|||
except TemplateError as e:
|
||||
showWarning(str(e))
|
||||
return
|
||||
theme_manager.set_night_mode(self.mw.pm.night_mode())
|
||||
self.mw.reset()
|
||||
tooltip("Changes saved.", parent=self.parent())
|
||||
self.cleanup()
|
||||
|
@ -772,6 +810,7 @@ Enter deck to place new %s cards in, or leave blank:"""
|
|||
self.preview_web = None
|
||||
self.model = None
|
||||
self.rendered_card = None
|
||||
theme_manager.set_night_mode(self.mw.pm.night_mode())
|
||||
self.mw = None
|
||||
|
||||
def onHelp(self):
|
||||
|
|
|
@ -226,7 +226,6 @@ Not currently enabled; click the sync button in the main window to enable."""
|
|||
self.form.pasteInvert.setChecked(self.prof.get("pasteInvert", False))
|
||||
self.form.showPlayButtons.setChecked(self.prof.get("showPlayButtons", True))
|
||||
self.form.nightMode.setChecked(self.mw.pm.night_mode())
|
||||
self.form.nightMode.setChecked(self.mw.pm.night_mode())
|
||||
self.form.interrupt_audio.setChecked(self.mw.pm.interrupt_audio())
|
||||
|
||||
def updateOptions(self):
|
||||
|
|
|
@ -65,9 +65,9 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="fill_empty">
|
||||
<widget class="QPushButton" name="preview_options">
|
||||
<property name="text">
|
||||
<string notr="true">FILL_EMPTY</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -14,5 +14,6 @@ card-templates-template-box = Template
|
|||
card-templates-sample-cloze = This is a {"{{c1::"}sample{"}}"} cloze deletion.
|
||||
card-templates-fill-empty = Fill Empty Fields
|
||||
card-templates-invalid-template-number = Please correct the problems on card template { $number } first.
|
||||
|
||||
card-templates-invert-night-mode = Invert Night Mode
|
||||
card-templates-add-mobile-class = Add mobile Class
|
||||
|
||||
|
|
Loading…
Reference in a new issue