mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
Allow inclusion of external icons into aqt/forms/icons
+ Replace old tag icon with mdi tag and tag-off icon
This commit is contained in:
parent
b19e07c135
commit
3aebae9f13
5 changed files with 68 additions and 27 deletions
|
@ -678,7 +678,8 @@ class SidebarTreeView(QTreeView):
|
|||
###########################
|
||||
|
||||
def _tag_tree(self, root: SidebarItem) -> None:
|
||||
icon = ":/icons/tag.svg"
|
||||
icon = ":/icons/tag-outline.svg"
|
||||
icon_off = ":/icons/tag-off-outline.svg"
|
||||
|
||||
def render(
|
||||
root: SidebarItem, nodes: Iterable[TagTreeNode], head: str = ""
|
||||
|
@ -714,7 +715,7 @@ class SidebarTreeView(QTreeView):
|
|||
root.search_node = SearchNode(tag="_*")
|
||||
root.add_simple(
|
||||
name=tr.browsing_sidebar_untagged(),
|
||||
icon=icon,
|
||||
icon=icon_off,
|
||||
type=SidebarItemType.TAG_NONE,
|
||||
search_node=SearchNode(negated=SearchNode(tag="_*")),
|
||||
)
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
load("@rules_python//python:defs.bzl", "py_binary")
|
||||
load("compile.bzl", "compile_all")
|
||||
|
||||
py_binary(
|
||||
name = "build_ui",
|
||||
srcs = ["build_ui.py"],
|
||||
legacy_create_init = False,
|
||||
deps = ["@pyqt5//:pkg"],
|
||||
)
|
||||
|
||||
compile_all(
|
||||
srcs = glob(["*.ui"]),
|
||||
group = "forms",
|
||||
|
@ -16,6 +9,20 @@ compile_all(
|
|||
],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
name = "build_ui",
|
||||
srcs = ["build_ui.py"],
|
||||
legacy_create_init = False,
|
||||
deps = ["@pyqt5//:pkg"],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
name = "build_qrc",
|
||||
srcs = ["build_qrc.py"],
|
||||
legacy_create_init = False,
|
||||
deps = ["@pyqt5//:pkg"],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
name = "build_rcc",
|
||||
srcs = ["build_rcc.py"],
|
||||
|
@ -23,11 +30,20 @@ py_binary(
|
|||
deps = ["@pyqt5//:pkg"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "icons_qrc",
|
||||
srcs = ["//qt/aqt/forms/icons"],
|
||||
outs = ["icons.qrc"],
|
||||
cmd = "$(location build_qrc) $(location icons.qrc) $(SRCS)",
|
||||
tools = ["build_qrc"],
|
||||
visibility = ["//qt/aqt:__pkg__"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "icons",
|
||||
srcs = ["icons.qrc"] + glob(["icons/*"]),
|
||||
srcs = ["icons_qrc", "//qt/aqt/forms/icons"],
|
||||
outs = ["icons_rc.py"],
|
||||
cmd = "$(location build_rcc) $(location icons.qrc) $(location icons_rc.py)",
|
||||
cmd = "$(location build_rcc) $(location icons_qrc) $(location icons_rc.py)",
|
||||
tools = ["build_rcc"],
|
||||
visibility = ["//qt/aqt:__pkg__"],
|
||||
)
|
||||
|
|
25
qt/aqt/forms/build_qrc.py
Normal file
25
qt/aqt/forms/build_qrc.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import sys
|
||||
import os
|
||||
|
||||
qrc_file = os.path.abspath(sys.argv[1])
|
||||
icons = sys.argv[2:]
|
||||
|
||||
file_skeleton = """
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
FILES
|
||||
</qresource>
|
||||
</RCC>
|
||||
""".strip()
|
||||
|
||||
indent = " " * 8
|
||||
lines = []
|
||||
for icon in icons:
|
||||
alias = ""
|
||||
path = os.path.relpath(icon, start=os.path.dirname(qrc_file))
|
||||
alias = "" if os.path.dirname(path) == "icons" else f' alias="icons/{os.path.basename(path)}"'
|
||||
line = f"{indent}<file{alias}>{path}</file>"
|
||||
lines.append(line)
|
||||
|
||||
with open(qrc_file, "w") as file:
|
||||
file.write(file_skeleton.replace("FILES", "\n".join(lines)))
|
|
@ -1,16 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>icons/anki.png</file>
|
||||
<file>icons/tag.svg</file>
|
||||
<file>icons/deck.svg</file>
|
||||
<file>icons/notetype.svg</file>
|
||||
<file>icons/heart.svg</file>
|
||||
<file>icons/collection.svg</file>
|
||||
<file>icons/media-record.png</file>
|
||||
<file>icons/clock.svg</file>
|
||||
<file>icons/card-state.svg</file>
|
||||
<file>icons/flag.svg</file>
|
||||
<file>icons/select.svg</file>
|
||||
<file>icons/magnifying_glass.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
15
qt/aqt/forms/icons/BUILD.bazel
Normal file
15
qt/aqt/forms/icons/BUILD.bazel
Normal file
|
@ -0,0 +1,15 @@
|
|||
load("//ts:vendor.bzl", "copy_mdi_icons")
|
||||
|
||||
copy_mdi_icons(
|
||||
name = "mdi-icons",
|
||||
icons = [
|
||||
"tag-outline.svg",
|
||||
"tag-off-outline.svg",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "icons",
|
||||
srcs = ["mdi-icons"] + glob(["*.svg", "*.png"]),
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
Loading…
Reference in a new issue