""",
+ ),
+ self._addButton(
+ None,
+ "changeCol",
+ _("Change colour (F8)"),
+ """
+
""",
+ ),
+ self._addButton("text_cloze", "cloze", _("Cloze deletion (Ctrl+Shift+C)")),
+ self._addButton(
+ "paperclip", "attach", _("Attach pictures/audio/video (F3)")
+ ),
+ self._addButton("media-record", "record", _("Record audio (F5)")),
+ self._addButton("more", "more"),
]
- # The color selection buttons do not use an icon so the HTML must be specified manually
- tip = _("Set foreground colour (F7)")
- righttopbtns.append(
- """
""".format(
- tip
- )
- )
- tip = _("Change colour (F8)")
- righttopbtns.extend(
- [
- """
""".format(
- tip
- ),
- self._addButton(
- "text_cloze", "cloze", _("Cloze deletion (Ctrl+Shift+C)")
- ),
- self._addButton(
- "paperclip", "attach", _("Attach pictures/audio/video (F3)")
- ),
- self._addButton("media-record", "record", _("Record audio (F5)")),
- self._addButton("more", "more"),
- ]
- )
+
gui_hooks.editor_did_init_buttons(righttopbtns, self)
# legacy filter
righttopbtns = runFilter("setupEditorButtons", righttopbtns, self)
+
topbuts = """
-
-
+ %(leftbts)s
%(rightbts)s
""" % dict(
- flds=_("Fields"),
- cards=_("Cards"),
+ leftbts="".join(lefttopbtns),
rightbts="".join(righttopbtns),
- fldsTitle=_("Customize Fields"),
- cardsTitle=shortcut(_("Customize Card Templates (Ctrl+L)")),
)
bgcol = self.mw.app.palette().window().color().name() # type: ignore
# then load page
@@ -218,7 +218,7 @@ class Editor:
def addButton(
self,
- icon: str,
+ icon: Optional[str],
cmd: str,
func: Callable[["Editor"], None],
tip: str = "",
@@ -227,6 +227,7 @@ class Editor:
toggleable: bool = False,
keys: str = None,
disables: bool = True,
+ rightside: bool = True,
):
"""Assign func to bridge cmd, register shortcut, return button"""
if func:
@@ -245,18 +246,20 @@ class Editor:
id=id,
toggleable=toggleable,
disables=disables,
+ rightside=rightside,
)
return btn
def _addButton(
self,
- icon: str,
+ icon: Optional[str],
cmd: str,
tip: str = "",
label: str = "",
id: Optional[str] = None,
toggleable: bool = False,
disables: bool = True,
+ rightside: bool = True,
) -> str:
if icon:
if icon.startswith("qrc:/"):
@@ -281,12 +284,15 @@ class Editor:
else:
toggleScript = ""
tip = shortcut(tip)
- theclass = "linkb"
+ if rightside:
+ class_ = "linkb"
+ else:
+ class_ = ""
if not disables:
- theclass += " perm"
+ class_ += " perm"
return """