更新::
This commit is contained in:
@@ -1319,9 +1319,15 @@ class ShellWindow(QMainWindow):
|
||||
search_layout = QHBoxLayout(search_host)
|
||||
search_layout.setContentsMargins(4, 0, 7, 0)
|
||||
search_layout.setSpacing(3)
|
||||
self.search_mark = QLabel(search_host)
|
||||
self.search_mark = QToolButton(search_host)
|
||||
self.search_mark.setObjectName("ShellSearchMark")
|
||||
self.search_mark.setFixedSize(20, 20)
|
||||
self.search_mark.setAutoRaise(True)
|
||||
self.search_mark.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.search_mark.setAccessibleName("搜索患者")
|
||||
self.search_mark.setToolTip("搜索患者(回车)")
|
||||
self.search_mark.setStyleSheet("background: transparent; border: 0; padding: 0;")
|
||||
self.search_mark.clicked.connect(self._run_global_search)
|
||||
self.search_mark.hide()
|
||||
search_layout.addWidget(self.search_mark)
|
||||
self.global_search = QLineEdit(search_host)
|
||||
@@ -1329,12 +1335,15 @@ class ShellWindow(QMainWindow):
|
||||
self.global_search.setSizePolicy(
|
||||
QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed
|
||||
)
|
||||
self.global_search.setPlaceholderText("搜索患者姓名、手机号、病历号")
|
||||
self.global_search.setPlaceholderText("搜索患者姓名、手机号...")
|
||||
self.global_search.setToolTip("输入患者姓名或手机号,按回车或点击放大镜搜索")
|
||||
self.global_search.setClearButtonEnabled(True)
|
||||
self._global_search_icon_action = self.global_search.addAction(
|
||||
_painted_shell_icon("search", 16),
|
||||
QLineEdit.ActionPosition.LeadingPosition,
|
||||
)
|
||||
self._global_search_icon_action.setToolTip("搜索患者(回车)")
|
||||
self._global_search_icon_action.triggered.connect(self._run_global_search)
|
||||
self.global_search.returnPressed.connect(self._run_global_search)
|
||||
search_layout.addWidget(self.global_search, 1)
|
||||
shortcut_hint = QLabel("Ctrl K", search_host)
|
||||
@@ -1614,7 +1623,7 @@ class ShellWindow(QMainWindow):
|
||||
self.search_host.layout().setSpacing(6 if active else 3)
|
||||
self.search_mark.setVisible(active)
|
||||
self._global_search_icon_action.setVisible(not active)
|
||||
self.global_search.setPlaceholderText("搜索患者姓名、手机号..." if active else "搜索患者姓名、手机号、病历号")
|
||||
self.global_search.setPlaceholderText("搜索患者姓名、手机号...")
|
||||
self.search_shortcut_hint.setText("Ctrl K")
|
||||
self.ai_top_button.setVisible(self._can_ai_assistant and not active)
|
||||
self.menu_sidebar_action.setVisible(active)
|
||||
@@ -1789,7 +1798,8 @@ class ShellWindow(QMainWindow):
|
||||
self._global_search_icon_action.setIcon(
|
||||
_painted_shell_icon("search", 20 if active else 16, reception=active)
|
||||
)
|
||||
self.search_mark.setPixmap(_painted_shell_icon("search", 20, reception=True).pixmap(20, 20))
|
||||
self.search_mark.setIcon(_painted_shell_icon("search", 20, reception=True))
|
||||
self.search_mark.setIconSize(QSize(20, 20))
|
||||
for key, button in self.nav_buttons.items():
|
||||
size = 20 if active else 18
|
||||
button.setProperty("receptionTechBlue", active)
|
||||
@@ -1819,46 +1829,20 @@ class ShellWindow(QMainWindow):
|
||||
|
||||
def _run_global_search(self) -> None:
|
||||
query = self.global_search.text().strip()
|
||||
if not query:
|
||||
self._focus_global_search()
|
||||
keys = ("patients", "consultations") if self._active_page_key == "patients" else (
|
||||
"consultations", "patients",
|
||||
)
|
||||
for key in keys:
|
||||
# Only use patient pages already registered by permission-aware navigation.
|
||||
page = self.pages.get(key)
|
||||
search = getattr(page, "search_patient", None)
|
||||
if page is None or key not in self.nav_buttons or not callable(search):
|
||||
continue
|
||||
self._navigate(
|
||||
self.stack.indexOf(page), key, on_activate=lambda search=search: search(query),
|
||||
)
|
||||
return
|
||||
page = self.stack.currentWidget()
|
||||
if page is None:
|
||||
return
|
||||
target: QLineEdit | None = None
|
||||
for attribute in (
|
||||
"patient_input",
|
||||
"keyword_edit",
|
||||
"search_edit",
|
||||
"patient_filter",
|
||||
"name_filter",
|
||||
"sn_filter",
|
||||
):
|
||||
candidate = getattr(page, attribute, None)
|
||||
if isinstance(candidate, QLineEdit) and not candidate.isHidden():
|
||||
target = candidate
|
||||
break
|
||||
if target is None:
|
||||
for candidate in page.findChildren(QLineEdit):
|
||||
placeholder = candidate.placeholderText()
|
||||
if not candidate.isHidden() and any(
|
||||
marker in placeholder
|
||||
for marker in ("患者", "姓名", "手机号", "处方")
|
||||
):
|
||||
target = candidate
|
||||
break
|
||||
if target is None:
|
||||
show_toast(self, "当前页面没有可用的快捷搜索条件。", "warning")
|
||||
return
|
||||
target.setText(query)
|
||||
search = getattr(page, "_search", None)
|
||||
if callable(search):
|
||||
search()
|
||||
else:
|
||||
refresh = getattr(page, "refresh", None)
|
||||
if callable(refresh):
|
||||
refresh()
|
||||
show_toast(self, f"正在当前页面搜索“{query}”。", "info")
|
||||
show_toast(self, "当前账号没有可用的患者搜索页面。", "warning")
|
||||
|
||||
def _open_ai_assistant(self) -> None:
|
||||
if not self._can_ai_assistant:
|
||||
@@ -2109,18 +2093,25 @@ class ShellWindow(QMainWindow):
|
||||
self._ensure_activation_refresh(page, generation)
|
||||
self._activation_page = None
|
||||
|
||||
def _navigate(self, index: int, key: str) -> None:
|
||||
def _navigate(
|
||||
self, index: int, key: str, *, on_activate: Callable[[], None] | None = None,
|
||||
) -> None:
|
||||
if index < 0 or index >= self.stack.count():
|
||||
return
|
||||
page = self.stack.widget(index)
|
||||
if page is None:
|
||||
return
|
||||
if self._active_page_key == key and self.stack.currentWidget() is page:
|
||||
if on_activate is not None:
|
||||
self._activation_refreshed = False
|
||||
on_activate()
|
||||
return
|
||||
self._activation_generation += 1
|
||||
activation_generation = self._activation_generation
|
||||
self._activation_page = page
|
||||
self._activation_refreshed = False
|
||||
if on_activate is not None:
|
||||
on_activate()
|
||||
# A stack swap is otherwise a hard cut between two frames: this is the
|
||||
# transition a doctor sees on every sidebar click all day.
|
||||
motion.switch_stack(self.stack, index)
|
||||
|
||||
Reference in New Issue
Block a user