Rework the Icon library to the wireframe

Section 16 of the audit page draws the three actions on the title row, a
magnifier inside the search box, caps section headings, and names its complaint
outright: "Ô icon trong lưới hiện tại không có viền/hover rõ khi rê chuột hay
khi đang chọn" — you could not tell which cell you were about to pick.

So: Thêm / Dán / Xoá move from the strip under both grids (where they read as
belonging to the custom grid alone) up beside the title; the search box gets its
magnifier; the two headings become caps through the same #navSectionHdr style
the rail uses; and #iconGrid cells take an accent border on hover and on
selection, the card language Agent and Công cụ already use.

Wording follows the drawing too: "ICON TÍCH HỢP" rather than "Icon có sẵn", and
"Tìm icon theo tên…" rather than "Tìm icon có sẵn…".

Left alone, and worth a decision: the drawing labels the buttons "+ Thêm icon"
and "Xoá", where the app says "Thêm tệp SVG" and "Xóa tùy chỉnh". The longer
labels say which file type is wanted and that only custom icons can be deleted,
so shortening them to match the drawing would cost more than it gains.

check_icons_screen covers the four points. Its first version passed a mutation
that dropped the buttons from the header layout — unparented they sit at (0,0),
which read as "the same row" — so it now requires the vertical centres to line
up AND each button to start right of the title.

20/20 checkers pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nam Pham Dinh Thanh
2026-08-18 13:10:18 +09:00
co-authored by Claude Opus 5
parent 77976405b1
commit e5bd6791e7
5 changed files with 181 additions and 26 deletions
+38 -24
View File
@@ -22,6 +22,7 @@ from .icons import icon
def _grid() -> QListWidget:
g = QListWidget()
g.setObjectName("iconGrid") # accent border on hover/selection, see theme.py
g.setViewMode(QListWidget.IconMode)
g.setResizeMode(QListWidget.Adjust)
g.setMovement(QListWidget.Static)
@@ -36,34 +37,44 @@ class IconsAdminTab(QWidget):
super().__init__()
self.ctx = ctx
root = QVBoxLayout(self)
self._hint = QLabel(); self._hint.setObjectName("hint"); self._hint.setWordWrap(True)
root.addWidget(self._hint)
# search over built-in names
self.search = QLineEdit()
self.search.textChanged.connect(self._reload_builtin)
root.addWidget(self.search)
self._builtin_lbl = QLabel()
root.addWidget(self._builtin_lbl)
self.builtin_grid = _grid()
root.addWidget(self.builtin_grid, 2)
self._custom_lbl = QLabel()
root.addWidget(self._custom_lbl)
self.custom_grid = _grid()
root.addWidget(self.custom_grid, 1)
btns = QHBoxLayout()
# Header row: the three actions sit beside the title, where the drawing
# puts them, instead of in a strip below the two grids where they read
# as belonging to the custom grid alone.
head = QHBoxLayout()
self._title = QLabel()
self._title.setObjectName("monTitle")
head.addWidget(self._title)
head.addStretch(1)
self.add_btn = QPushButton(); self.add_btn.setIcon(icon("plus"))
self.add_btn.clicked.connect(self._add_icon)
self.paste_btn = QPushButton()
self.paste_btn.clicked.connect(self._add_from_svg_text)
self.del_btn = QPushButton(); self.del_btn.setIcon(icon("trash"))
self.del_btn.clicked.connect(self._delete_icon)
btns.addWidget(self.add_btn); btns.addWidget(self.paste_btn)
btns.addWidget(self.del_btn); btns.addStretch(1)
root.addLayout(btns)
for b in (self.add_btn, self.paste_btn, self.del_btn):
head.addWidget(b)
root.addLayout(head)
self._hint = QLabel(); self._hint.setObjectName("hint"); self._hint.setWordWrap(True)
root.addWidget(self._hint)
# search over built-in names, with the magnifier the drawing asks for
self.search = QLineEdit()
self.search.addAction(icon("search"), QLineEdit.LeadingPosition)
self.search.textChanged.connect(self._reload_builtin)
root.addWidget(self.search)
self._builtin_lbl = QLabel()
self._builtin_lbl.setObjectName("navSectionHdr") # quiet caps heading
root.addWidget(self._builtin_lbl)
self.builtin_grid = _grid()
root.addWidget(self.builtin_grid, 2)
self._custom_lbl = QLabel()
self._custom_lbl.setObjectName("navSectionHdr")
root.addWidget(self._custom_lbl)
self.custom_grid = _grid()
root.addWidget(self.custom_grid, 1)
on_language_changed(self._retranslate)
self._retranslate()
@@ -131,10 +142,13 @@ class IconsAdminTab(QWidget):
self._reload_custom()
def _retranslate(self) -> None:
self._title.setText(tr("monitoring.tab_icons"))
self._hint.setText(tr("icons_admin.hint"))
self.search.setPlaceholderText(tr("icons_admin.search"))
self._builtin_lbl.setText(tr("icons_admin.builtin"))
self._custom_lbl.setText(tr("icons_admin.custom"))
# ICON TÍCH HỢP / ICON TÙY CHỈNH — caps, like every other section
# heading the audit page draws.
self._builtin_lbl.setText(tr("icons_admin.builtin").upper())
self._custom_lbl.setText(tr("icons_admin.custom").upper())
self.add_btn.setText(tr("icons_admin.add"))
self.paste_btn.setText(tr("icons_admin.paste"))
self.del_btn.setText(tr("icons_admin.delete"))