Skip to content

Commit

Permalink
[2.1] Field names Addition (#12)
Browse files Browse the repository at this point in the history
* Add more options to web filters

* Add full immersion kit option compatibility
Added minimal and maximal length for sentences

* Update webcard contents
- Updated field names to match standard sub2srs format
- Remove Audio and image caption
- Add tags to view

* Add page system to card view
- Add buttons
- Change behaviour of note count

* Revert layout renaming

* Fix local search issue
- map needed as list for indexing
- setting the page buttons and page was not yet done

* Add page buttons to window reset

* Add more options to web filters

* format code

remove unused methods

* change if logic

* add missing field

* restore original field names

* extract function

* rework tag previews

* update ajt common

* control field mapping in config

* add widgets for setting up remote field names

* rename sent to sentence

* Add presets to name settings

* Fit field names

* Rename fields to sentence

* update ajt common

* discard unrelated changes

* format code

* refactor

---------

Co-authored-by: FileX <filex.stuff@proton.me>
Co-authored-by: Ren Tatsumoto <tatsu@autistici.org>
  • Loading branch information
3 people committed May 25, 2024
1 parent 1b43158 commit 389dd28
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion settings_dialog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright: Ajatt-Tools and contributors; https://github.com/Ajatt-Tools
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import functools

from aqt.qt import *
from aqt.utils import restoreGeom, saveGeom, disable_help_button, showText, openFolder
Expand Down Expand Up @@ -111,9 +112,49 @@ def _make_web_tab(self) -> QWidget:
length_layout.addWidget(self.sentence_max_length)
length_layout.setAlignment(Qt.AlignmentFlag.AlignRight)
layout.addRow("Sentence Length", length_layout)
layout.addRow(self._make_field_names_group())
return widget

def _make_field_names_group(self) -> QGroupBox:
def presets() -> dict[str, dict[str, str]]:
return {
"AJATT preset": {
"sentence_kanji": "SentKanji",
"sentence_furigana": "SentFurigana",
"sentence_eng": "SentEng",
"sentence_audio": "SentAudio",
"image": "Image",
"notes": "Notes",
},
"Standard subs2srs preset": {
"sentence_kanji": "Expression",
"sentence_furigana": "Reading",
"sentence_eng": "English",
"sentence_audio": "Audio",
"image": "Image",
"notes": "ID",
},
}

group = QGroupBox("Field names")
group.setCheckable(False)
group.setLayout(layout := QFormLayout())

for field_key, edit_widget in self._remote_fields.items():
layout.addRow(ui_translate(field_key).title(), edit_widget)
return widget

presets_layout = QHBoxLayout()
for preset_name, preset_opts in presets().items():
activate_btn = QPushButton(preset_name)
presets_layout.addWidget(activate_btn)
qconnect(activate_btn.clicked, functools.partial(self.set_preset, preset_opts))
layout.addRow(presets_layout)

return group

def set_preset(self, name_dict: dict[str, str]) -> None:
for field_key, edit_widget in self._remote_fields.items():
edit_widget.setCurrentText(name_dict[field_key])

def _make_hl_tab(self) -> QWidget:
widget = QWidget()
Expand Down

0 comments on commit 389dd28

Please sign in to comment.