更新bug
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlite3
|
||||
from collections.abc import Mapping, Sequence
|
||||
from dataclasses import dataclass
|
||||
from functools import wraps
|
||||
@@ -22,6 +23,7 @@ from PySide6.QtGui import (
|
||||
QShortcut,
|
||||
)
|
||||
from PySide6.QtWidgets import (
|
||||
QApplication,
|
||||
QButtonGroup,
|
||||
QFrame,
|
||||
QHBoxLayout,
|
||||
@@ -38,6 +40,7 @@ from PySide6.QtWidgets import (
|
||||
QWidget,
|
||||
)
|
||||
|
||||
from .dialogs.local_audio_queue import LocalAudioQueueDialog
|
||||
from .pages import (
|
||||
AppointmentsPage,
|
||||
ConsultationsPage,
|
||||
@@ -61,6 +64,25 @@ _SHELL_TOPBAR_HEIGHT = 62
|
||||
_SHELL_TABS_HEIGHT = 0
|
||||
_SHELL_OUTER_GUTTER = 13
|
||||
_SHELL_PANEL_GAP = 0
|
||||
_SHELL_DESIGN_SIZE = QSize(1710, 920)
|
||||
_SHELL_MINIMUM_SIZE = QSize(1024, 640)
|
||||
|
||||
|
||||
def _bounded_initial_window_size(available_size: QSize | None) -> QSize:
|
||||
"""Fit the design viewport inside the screen's logical available geometry."""
|
||||
|
||||
if available_size is None or not available_size.isValid():
|
||||
return QSize(_SHELL_DESIGN_SIZE.width(), _SHELL_DESIGN_SIZE.height())
|
||||
return QSize(
|
||||
max(
|
||||
_SHELL_MINIMUM_SIZE.width(),
|
||||
min(_SHELL_DESIGN_SIZE.width(), available_size.width()),
|
||||
),
|
||||
max(
|
||||
_SHELL_MINIMUM_SIZE.height(),
|
||||
min(_SHELL_DESIGN_SIZE.height(), available_size.height()),
|
||||
),
|
||||
)
|
||||
|
||||
# The references place the workspace at page-specific global x anchors while
|
||||
# keeping a 13 px outer gutter. These are the actual rail widths inside that
|
||||
@@ -660,24 +682,29 @@ class _PaintedIconButton(QToolButton):
|
||||
self.setFixedSize(size, size)
|
||||
self.setIcon(_painted_shell_icon(kind, icon_size))
|
||||
self.setIconSize(QSize(icon_size, icon_size))
|
||||
content_size = max(0, size - 2)
|
||||
self.setStyleSheet(
|
||||
"""
|
||||
QToolButton#ShellPaintedIconButton {
|
||||
f"""
|
||||
QToolButton#ShellPaintedIconButton {{
|
||||
min-width: {content_size}px;
|
||||
max-width: {content_size}px;
|
||||
min-height: {content_size}px;
|
||||
max-height: {content_size}px;
|
||||
background: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 9px;
|
||||
}
|
||||
QToolButton#ShellPaintedIconButton:hover {
|
||||
}}
|
||||
QToolButton#ShellPaintedIconButton:hover {{
|
||||
background: #F0F3FC;
|
||||
border-color: #E2E7F4;
|
||||
}
|
||||
QToolButton#ShellPaintedIconButton:pressed { background: #EEF1FF; }
|
||||
QToolButton#ShellPaintedIconButton:focus { border-color: #8D9BFF; }
|
||||
QToolButton#ShellPaintedIconButton[windowControl="close"]:hover {
|
||||
}}
|
||||
QToolButton#ShellPaintedIconButton:pressed {{ background: #EEF1FF; }}
|
||||
QToolButton#ShellPaintedIconButton:focus {{ border-color: #8D9BFF; }}
|
||||
QToolButton#ShellPaintedIconButton[windowControl="close"]:hover {{
|
||||
background: #FFF0F2;
|
||||
border-color: #F4C4CC;
|
||||
}
|
||||
QToolButton#ShellPaintedIconButton::menu-indicator { image: none; width: 0; }
|
||||
}}
|
||||
QToolButton#ShellPaintedIconButton::menu-indicator {{ image: none; width: 0; }}
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -868,9 +895,12 @@ class ShellWindow(QMainWindow):
|
||||
self._activation_page: QWidget | None = None
|
||||
self._activation_generation = 0
|
||||
self._activation_refreshed = False
|
||||
self._local_audio_settings_dialog: LocalAudioQueueDialog | None = None
|
||||
|
||||
self.setMinimumSize(1024, 640)
|
||||
self.resize(1710, 920)
|
||||
self.setMinimumSize(_SHELL_MINIMUM_SIZE)
|
||||
screen = self.screen() or QApplication.primaryScreen()
|
||||
available_size = screen.availableGeometry().size() if screen is not None else None
|
||||
self.resize(_bounded_initial_window_size(available_size))
|
||||
|
||||
canvas = _ShellCanvas(self)
|
||||
canvas.setObjectName("AppCanvas")
|
||||
@@ -1002,7 +1032,20 @@ class ShellWindow(QMainWindow):
|
||||
font-weight: 700;
|
||||
}
|
||||
QPushButton#ShellAssistantButton:hover { background-color: #4658E8; }
|
||||
QLabel#ShellModelLabel { color: #8A95AF; font-size: 10px; }
|
||||
QPushButton#ShellSettingsButton {
|
||||
min-height: 42px;
|
||||
color: #6E7C9F;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
background-color: transparent;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 10px;
|
||||
}
|
||||
QPushButton#ShellSettingsButton:hover {
|
||||
color: #5265F6;
|
||||
background-color: #EEF1FF;
|
||||
}
|
||||
QPushButton#ShellSettingsButton:focus { border-color: #8D9BFF; }
|
||||
"""
|
||||
)
|
||||
layout = QVBoxLayout(sidebar)
|
||||
@@ -1074,11 +1117,17 @@ class ShellWindow(QMainWindow):
|
||||
outer_assistant.addWidget(self.assistant_card)
|
||||
layout.addLayout(outer_assistant)
|
||||
|
||||
self.model_label = QLabel("模型:GPT-4o 医疗版 ›", sidebar)
|
||||
self.model_label.setObjectName("ShellModelLabel")
|
||||
self.model_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.model_label.setFixedHeight(76)
|
||||
layout.addWidget(self.model_label)
|
||||
self.upload_settings_button = QPushButton("设置 ›", sidebar)
|
||||
self.upload_settings_button.setObjectName("ShellSettingsButton")
|
||||
self.upload_settings_button.setAccessibleName("本机录音上传设置")
|
||||
self.upload_settings_button.setToolTip("查看本机录音上传记录")
|
||||
self.upload_settings_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.upload_settings_button.setFixedHeight(76)
|
||||
self.upload_settings_button.clicked.connect(self._open_local_audio_settings)
|
||||
# Keep the former attribute as a compatibility alias for integrations
|
||||
# that inspect the bottom sidebar control.
|
||||
self.model_label = self.upload_settings_button
|
||||
layout.addWidget(self.upload_settings_button)
|
||||
return sidebar
|
||||
|
||||
def _build_topbar(self) -> QWidget:
|
||||
@@ -1095,10 +1144,6 @@ class ShellWindow(QMainWindow):
|
||||
border-top-right-radius: 16px;
|
||||
}
|
||||
QFrame#ShellGlobalSearch {
|
||||
min-width: 265px;
|
||||
max-width: 265px;
|
||||
min-height: 36px;
|
||||
max-height: 36px;
|
||||
background-color: #F8FAFF;
|
||||
border: 1px solid #E2E7F4;
|
||||
border-radius: 10px;
|
||||
@@ -1112,6 +1157,23 @@ class ShellWindow(QMainWindow):
|
||||
border: 0;
|
||||
border-radius: 9px;
|
||||
}
|
||||
QLineEdit#ShellGlobalSearchInput QToolButton {
|
||||
min-width: 22px;
|
||||
max-width: 22px;
|
||||
min-height: 18px;
|
||||
max-height: 18px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
QLineEdit#ShellGlobalSearchInput QToolButton:hover,
|
||||
QLineEdit#ShellGlobalSearchInput QToolButton:pressed,
|
||||
QLineEdit#ShellGlobalSearchInput QToolButton:focus {
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
}
|
||||
QLabel#ShellShortcutHint {
|
||||
color: #8A95AF;
|
||||
background-color: #F0F3FC;
|
||||
@@ -1207,7 +1269,9 @@ class ShellWindow(QMainWindow):
|
||||
search_layout.addWidget(self.global_search, 1)
|
||||
shortcut_hint = QLabel("Ctrl K", search_host)
|
||||
shortcut_hint.setObjectName("ShellShortcutHint")
|
||||
search_layout.addWidget(shortcut_hint)
|
||||
shortcut_hint.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
shortcut_hint.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
|
||||
search_layout.addWidget(shortcut_hint, 0, Qt.AlignmentFlag.AlignVCenter)
|
||||
layout.addWidget(search_host)
|
||||
|
||||
self.context_label = QLabel("工作台", topbar)
|
||||
@@ -1393,7 +1457,7 @@ class ShellWindow(QMainWindow):
|
||||
)
|
||||
self.brand_copy.setVisible(not self._sidebar_collapsed)
|
||||
self.assistant_card.setVisible(not self._sidebar_collapsed)
|
||||
self.model_label.setVisible(not self._sidebar_collapsed)
|
||||
self.upload_settings_button.setVisible(not self._sidebar_collapsed)
|
||||
margins = (7, 14, 7, 0) if self._sidebar_collapsed else (12, 19, 12, 0)
|
||||
self.nav_layout.setContentsMargins(*margins)
|
||||
self.fold_button.kind = "expand" if self._sidebar_collapsed else "fold"
|
||||
@@ -1486,6 +1550,26 @@ class ShellWindow(QMainWindow):
|
||||
3600,
|
||||
)
|
||||
|
||||
def _open_local_audio_settings(self) -> None:
|
||||
current = self._local_audio_settings_dialog
|
||||
if current is not None and current.isVisible():
|
||||
current.raise_()
|
||||
current.activateWindow()
|
||||
return
|
||||
try:
|
||||
dialog = LocalAudioQueueDialog(self.repository, None, self)
|
||||
except (OSError, RuntimeError, ValueError, sqlite3.Error) as error:
|
||||
show_toast(self, f"无法打开本机录音上传设置:{error}", "error")
|
||||
return
|
||||
self._local_audio_settings_dialog = dialog
|
||||
|
||||
def clear_dialog(_result: int) -> None:
|
||||
if self._local_audio_settings_dialog is dialog:
|
||||
self._local_audio_settings_dialog = None
|
||||
|
||||
dialog.finished.connect(clear_dialog)
|
||||
dialog.open()
|
||||
|
||||
def _tab_index_for_key(self, key: str) -> int:
|
||||
for index in range(self.tab_bar.count()):
|
||||
if self.tab_bar.tabData(index) == key:
|
||||
|
||||
Reference in New Issue
Block a user