diff --git a/qt/aqt/browser/sidebar/tree.py b/qt/aqt/browser/sidebar/tree.py index af029d439..beae6cb95 100644 --- a/qt/aqt/browser/sidebar/tree.py +++ b/qt/aqt/browser/sidebar/tree.py @@ -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="_*")), ) diff --git a/qt/aqt/forms/BUILD.bazel b/qt/aqt/forms/BUILD.bazel index 968c77693..0bdf3afbc 100644 --- a/qt/aqt/forms/BUILD.bazel +++ b/qt/aqt/forms/BUILD.bazel @@ -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__"], ) diff --git a/qt/aqt/forms/build_qrc.py b/qt/aqt/forms/build_qrc.py new file mode 100644 index 000000000..6d385b402 --- /dev/null +++ b/qt/aqt/forms/build_qrc.py @@ -0,0 +1,25 @@ +import sys +import os + +qrc_file = os.path.abspath(sys.argv[1]) +icons = sys.argv[2:] + +file_skeleton = """ + + +FILES + + +""".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}{path}" + lines.append(line) + +with open(qrc_file, "w") as file: + file.write(file_skeleton.replace("FILES", "\n".join(lines))) diff --git a/qt/aqt/forms/icons.qrc b/qt/aqt/forms/icons.qrc deleted file mode 100644 index 23dd5f5c5..000000000 --- a/qt/aqt/forms/icons.qrc +++ /dev/null @@ -1,16 +0,0 @@ - - - icons/anki.png - icons/tag.svg - icons/deck.svg - icons/notetype.svg - icons/heart.svg - icons/collection.svg - icons/media-record.png - icons/clock.svg - icons/card-state.svg - icons/flag.svg - icons/select.svg - icons/magnifying_glass.svg - - diff --git a/qt/aqt/forms/icons/BUILD.bazel b/qt/aqt/forms/icons/BUILD.bazel new file mode 100644 index 000000000..537802a5d --- /dev/null +++ b/qt/aqt/forms/icons/BUILD.bazel @@ -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"], +)