feat(ui): refine acrylic task center workspace
No files matched your search
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M10 16V4M5.5 8.5 10 4l4.5 4.5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 215 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M5 3.5h10a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H9l-4.5 3v-3a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2Z"/><path d="M6.5 7.5h7m-7 3h4"/></g></svg>
|
||||
|
After Width: | Height: | Size: 298 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="7.25"/><path d="m6.5 10 2.5 2.5 4.5-5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 241 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="m4.5 10 3.5 3.5 7.5-8"/></g></svg>
|
||||
|
After Width: | Height: | Size: 207 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="m8 5 5 5-5 5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 198 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="5" width="10" height="10" rx="2"/><path d="M8 2v3m4-3v3m-4 10v3m4-3v3M2 8h3m-3 4h3m10-4h3m-3 4h3M8 8h4v4H8Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 299 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="7.25"/><path d="M10 5.5v5l3 1.5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 235 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="m5 5 10 10M15 5 5 15"/></g></svg>
|
||||
|
After Width: | Height: | Size: 206 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="2.5" y="3.5" width="15" height="13" rx="2"/><path d="M7.5 3.5v13m5-13v13"/></g></svg>
|
||||
|
After Width: | Height: | Size: 258 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="7" y="7" width="10" height="10" rx="2"/><path d="M12.5 4V3H3v9.5h1"/></g></svg>
|
||||
|
After Width: | Height: | Size: 252 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M10 2.5v10m-3.5-3.5 3.5 3.5 3.5-3.5M3.5 13v4h13v-4"/></g></svg>
|
||||
|
After Width: | Height: | Size: 236 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M2.5 6a2 2 0 0 1 2-2h4l2 2h5a2 2 0 0 1 2 2v6.5a2 2 0 0 1-2 2h-11a2 2 0 0 1-2-2Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 265 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="5" height="5" rx="1"/><rect x="12" y="3" width="5" height="5" rx="1"/><rect x="3" y="12" width="5" height="5" rx="1"/><rect x="12" y="12" width="5" height="5" rx="1"/></g></svg>
|
||||
|
After Width: | Height: | Size: 366 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="7.25"/><path d="M10 9v5m0-8h.01"/></g></svg>
|
||||
|
After Width: | Height: | Size: 235 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M6 2.5h6l4 4v11H4v-15h2Zm6 0v4h4M7 10h6m-6 3.5h6"/></g></svg>
|
||||
|
After Width: | Height: | Size: 234 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="4" cy="10" r=".9" fill="currentColor" stroke="none"/><circle cx="10" cy="10" r=".9" fill="currentColor" stroke="none"/><circle cx="16" cy="10" r=".9" fill="currentColor" stroke="none"/></g></svg>
|
||||
|
After Width: | Height: | Size: 371 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M7 4v12m6-12v12" stroke-width="2.5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 220 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="m7 3.5 9 6.5-9 6.5Z" fill="currentColor" stroke="none"/></g></svg>
|
||||
|
After Width: | Height: | Size: 239 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M10 4v12M4 10h12"/></g></svg>
|
||||
|
After Width: | Height: | Size: 202 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="2.5" width="12" height="15" rx="2"/><path d="M7 6h6M7 10h3m0 0v4m0-4h3m-6 4h6"/></g></svg>
|
||||
|
After Width: | Height: | Size: 269 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M16.5 7A7 7 0 1 0 17 12M16.5 3v4h-4"/></g></svg>
|
||||
|
After Width: | Height: | Size: 221 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M7 5h10M7 10h10M7 15h10"/><circle cx="3.5" cy="5" r=".6"/><circle cx="3.5" cy="10" r=".6"/><circle cx="3.5" cy="15" r=".6"/></g></svg>
|
||||
|
After Width: | Height: | Size: 307 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3h12l2 2v12H3ZM6 3v5h7V3M6 17v-5h8v5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 225 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M7 3H3v4m10-4h4v4M3 13v4h4m10-4v4h-4M6 10h8m-6-3v6m4-6v6"/></g></svg>
|
||||
|
After Width: | Height: | Size: 242 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="8.5" cy="8.5" r="5.5"/><path d="m12.5 12.5 4.5 4.5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 239 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="2.5" y="3.5" width="15" height="13" rx="2"/><path d="M7 3.5v13M4.5 7h.1m-.1 3h.1"/></g></svg>
|
||||
|
After Width: | Height: | Size: 266 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M3 5h3m4 0h7M3 10h8m4 0h2M3 15h2m4 0h8"/><circle cx="8" cy="5" r="2"/><circle cx="13" cy="10" r="2"/><circle cx="7" cy="15" r="2"/></g></svg>
|
||||
|
After Width: | Height: | Size: 314 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M6 4v12m-3-3 3 3 3-3M13 5h4m-4 5h3m-3 5h2"/></g></svg>
|
||||
|
After Width: | Height: | Size: 227 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="2.5" y="3.5" width="15" height="13" rx="2"/><path d="M2.5 8h15M8 8v8.5m4-8.5v8.5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 266 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M3.5 5.5h13M7 5V3h6v2M5 5.5l.8 11h8.4l.8-11M8 8.5v5m4-5v5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 243 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M10 12.5v-10M6.5 6 10 2.5 13.5 6M3.5 13v4h13v-4"/></g></svg>
|
||||
|
After Width: | Height: | Size: 233 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="m10 2.5 8 14H2Zm0 5v4.5m0 2.5h.01"/></g></svg>
|
||||
|
After Width: | Height: | Size: 219 B |
@@ -0,0 +1,32 @@
|
||||
"""Menu presentation for existing buttons, preserving their live business gates."""
|
||||
from PySide6.QtWidgets import QMenu,QWidget
|
||||
|
||||
|
||||
class CommandMenu(QMenu):
|
||||
def __init__(self,parent=None):
|
||||
super().__init__(parent)
|
||||
self.storage=QWidget(parent)
|
||||
self.storage.setObjectName('menuCommandStorage')
|
||||
self.storage.hide()
|
||||
self._commands=[]
|
||||
self.aboutToShow.connect(self.sync)
|
||||
|
||||
def add_button(self,button):
|
||||
button.setParent(self.storage)
|
||||
# Only the parent is hidden. Explicit visibility remains the state gate.
|
||||
button.show()
|
||||
action=self.addAction(button.text())
|
||||
def invoke():
|
||||
if button.isEnabled() and not button.isHidden():
|
||||
button.click()
|
||||
action.triggered.connect(invoke)
|
||||
self._commands.append((action,button))
|
||||
return action
|
||||
|
||||
def sync(self):
|
||||
for action,button in self._commands:
|
||||
action.setText(button.text())
|
||||
action.setIcon(button.icon())
|
||||
action.setEnabled(button.isEnabled())
|
||||
action.setVisible(not button.isHidden())
|
||||
action.setToolTip(button.toolTip())
|
||||
@@ -0,0 +1,64 @@
|
||||
"""Original SVG icons rendered in consistent normal, disabled and primary colors."""
|
||||
from functools import lru_cache
|
||||
from pathlib import Path
|
||||
|
||||
from PySide6.QtCore import QByteArray, QRectF, Qt,QSize
|
||||
from PySide6.QtGui import QIcon, QPainter, QPixmap
|
||||
from PySide6.QtSvg import QSvgRenderer
|
||||
from PySide6.QtWidgets import QAbstractButton, QLineEdit, QToolButton
|
||||
|
||||
ASSETS = Path(__file__).resolve().parents[1] / 'assets'
|
||||
|
||||
|
||||
@lru_cache(maxsize=128)
|
||||
def icon(name: str, primary: bool = False) -> QIcon:
|
||||
source = (ASSETS / f'ui-{name}.svg').read_text(encoding='utf-8')
|
||||
result = QIcon()
|
||||
for mode, color in ((QIcon.Mode.Normal, '#ffffff' if primary else '#61758e'),
|
||||
(QIcon.Mode.Disabled, '#a7b0bd')):
|
||||
renderer = QSvgRenderer(QByteArray(source.replace('currentColor', color).encode()))
|
||||
for size in (16, 20, 24, 32, 40, 48):
|
||||
pixmap = QPixmap(size, size)
|
||||
pixmap.fill(Qt.GlobalColor.transparent)
|
||||
painter = QPainter(pixmap)
|
||||
renderer.render(painter, QRectF(0, 0, size, size))
|
||||
painter.end()
|
||||
result.addPixmap(pixmap, mode)
|
||||
return result
|
||||
|
||||
|
||||
BUTTON_ICONS = {
|
||||
'task_center_navigation': 'grid', 'dsh_navigation': 'chat',
|
||||
'newTaskButton': 'plus', 'editTaskButton': 'sliders', 'deleteTaskButton': 'trash',
|
||||
'restoreTaskButton': 'refresh', 'taskRecycleBin': 'trash',
|
||||
'moveTaskUp': 'arrow-up', 'moveTaskDown': 'sort', 'executeProjectTasks': 'play',
|
||||
'addMappingButton': 'plus', 'editMappingButton': 'sliders', 'deleteMappingButton': 'trash',
|
||||
'collectTargetInventory': 'scan', 'saveTargetPlan': 'save',
|
||||
'exportBomTemplate': 'download', 'importBomPlan': 'upload',
|
||||
'importTargetPlan': 'upload', 'exportTargetPlan': 'download',
|
||||
'quickRunButton': 'play', 'stopQueueButton': 'pause', 'forceStopButton': 'warning',
|
||||
'retryTaskItems': 'refresh', 'recoverQuickRunButton': 'refresh',
|
||||
'cleanupBatchResources': 'refresh', 'exportDiagnosticBundle': 'download',
|
||||
'startNewRoundButton': 'plus', 'roundHistoryButton': 'folder',
|
||||
'toggleLogButton': 'log', 'resetLayoutButton': 'columns', 'refreshBoundProject': 'refresh',
|
||||
'findTargets': 'search', 'cancelInventoryOperation': 'close',
|
||||
}
|
||||
|
||||
|
||||
def apply_icons(window):
|
||||
for button in window.findChildren(QAbstractButton):
|
||||
name = BUTTON_ICONS.get(button.objectName())
|
||||
if name:
|
||||
button.setIconSize(QSize(16,16))
|
||||
button.setIcon(icon(name, primary=button.objectName() in {
|
||||
'quickRunButton','recoverQuickRunButton','retryTaskItems','startNewRoundButton','stopQueueButton'}))
|
||||
if isinstance(button, QToolButton):
|
||||
if button.defaultAction() is not None:
|
||||
button.defaultAction().setIcon(icon(name))
|
||||
button.setToolTip(button.text())
|
||||
if button.objectName() == 'toggleLogButton':
|
||||
button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||
for name in ('taskSearch', 'findTargetText'):
|
||||
edit = window.findChild(QLineEdit, name)
|
||||
if edit:
|
||||
edit.addAction(icon('search'), QLineEdit.ActionPosition.LeadingPosition)
|
||||
@@ -19,6 +19,8 @@ from .project_plan import DirectoryTaskDialog, ProjectPlanPanel
|
||||
from .project_summary import ProjectSummary
|
||||
from .run_panel import RunPanel
|
||||
from .styles import APP_STYLESHEET
|
||||
from .material import AcrylicController, MaterialMainWindow
|
||||
from .icons import apply_icons, icon
|
||||
from .task_list import TaskList
|
||||
from .workers import ServiceWorker
|
||||
from .queries import LatestQuery
|
||||
@@ -29,9 +31,10 @@ from ...dsh.service_adapter import DshServiceAdapter
|
||||
from ...dsh.snapshot import TaskSnapshot
|
||||
from ...dsh.supervisor import DshSupervisor
|
||||
|
||||
class TrialTaskCenterWindow(QMainWindow):
|
||||
class TrialTaskCenterWindow(MaterialMainWindow):
|
||||
def __init__(self, service, directory_picker=None, quick_run_confirmer=None, close_plan_confirmer=None):
|
||||
super().__init__()
|
||||
self._material = AcrylicController(self)
|
||||
self.service = service
|
||||
self._dsh = DshSupervisor(DshServiceAdapter(service).execute)
|
||||
self._dsh_view = None
|
||||
@@ -51,6 +54,9 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
navigation_layout = QHBoxLayout(navigation)
|
||||
navigation_layout.setContentsMargins(12, 6, 12, 6)
|
||||
navigation_layout.setSpacing(8)
|
||||
brand = QLabel('DxPartReplace', objectName='applicationBrand')
|
||||
navigation_layout.addWidget(brand)
|
||||
navigation_layout.addSpacing(24)
|
||||
for name, action in (('task_center_navigation', self.task_center_action), ('dsh_navigation', self.dsh_action)):
|
||||
action.setCheckable(True)
|
||||
self._navigation_actions.addAction(action)
|
||||
@@ -58,10 +64,18 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
button = QToolButton(navigation)
|
||||
button.setObjectName(name)
|
||||
button.setDefaultAction(action)
|
||||
button.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
|
||||
navigation_layout.addWidget(button, 1)
|
||||
button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||
button.setSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
|
||||
navigation_layout.addWidget(button)
|
||||
setattr(self, name, button)
|
||||
self.task_center_action.setChecked(True)
|
||||
navigation_layout.addStretch()
|
||||
self.reduced_transparency_button = QToolButton(objectName='reduceTransparency')
|
||||
self.reduced_transparency_button.setText('减少透明度')
|
||||
self.reduced_transparency_button.setCheckable(True)
|
||||
self.reduced_transparency_button.setIcon(icon('sliders'))
|
||||
self.reduced_transparency_button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||
navigation_layout.addWidget(self.reduced_transparency_button)
|
||||
self.setMenuWidget(navigation)
|
||||
self._close_plan_confirmer = close_plan_confirmer or self._confirm_close_plans
|
||||
self._close_pending = False
|
||||
@@ -139,6 +153,11 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
self.archive_on_close_check.setToolTip('默认关闭。仅归档安全任务,保留计划、日志和文件;待核验或资源未释放的任务保留在当前列表。')
|
||||
self._build_layout()
|
||||
self._layout_settings = QSettings(str(service.layout_settings_path), QSettings.Format.IniFormat)
|
||||
self.reduced_transparency_button.setChecked(self._layout_settings.value(
|
||||
'appearance/reduced_transparency', False, type=bool))
|
||||
self._material.set_reduced_transparency(self.reduced_transparency_button.isChecked())
|
||||
self.reduced_transparency_button.toggled.connect(self._set_reduced_transparency)
|
||||
apply_icons(self)
|
||||
self.archive_on_close_check.setChecked(self._layout_settings.value(
|
||||
'tasks/archive_on_close', False, type=bool))
|
||||
self.archive_on_close_check.toggled.connect(self._set_archive_on_close)
|
||||
@@ -163,12 +182,13 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
return self._context_phase is ContextReadPhase.LOADING
|
||||
|
||||
def _build_layout(self):
|
||||
rule_page = QWidget()
|
||||
rule_page = QWidget(objectName='rulePage')
|
||||
rules_layout = QVBoxLayout(rule_page)
|
||||
rules_layout.setContentsMargins(0, 0, 0, 0)
|
||||
rules_help = QLabel('规则提供采集条件和位号默认值;位号计划模式实际执行已保存的每行计划。'
|
||||
'修改默认值仅更新仍等于旧默认值的字段,保留手动覆盖和替换勾选。')
|
||||
rules_help.setWordWrap(True)
|
||||
rules_help.setObjectName('ruleHelp')
|
||||
rules_layout.addWidget(rules_help)
|
||||
rules_layout.addWidget(self.mapping_table, 1)
|
||||
commands = QHBoxLayout()
|
||||
@@ -180,29 +200,45 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
self.mapping_tabs = QTabWidget(objectName='batchPlanTabs')
|
||||
self.mapping_tabs.addTab(rule_page, '本批料号规则')
|
||||
self.mapping_tabs.addTab(self.plan_panel, '本批位号计划')
|
||||
self.mapping_tabs.setCurrentIndex(1)
|
||||
self.detail_splitter = QSplitter(Qt.Orientation.Vertical)
|
||||
self.detail_splitter.setChildrenCollapsible(False)
|
||||
self.detail_splitter.addWidget(self.mapping_tabs)
|
||||
execution_area = QWidget()
|
||||
execution_area = QWidget(objectName='executionSurface')
|
||||
execution_layout = QVBoxLayout(execution_area)
|
||||
execution_layout.setContentsMargins(0, 0, 0, 0)
|
||||
execution_layout.addWidget(self.project_summary)
|
||||
execution_layout.addWidget(self.run_panel)
|
||||
self.detail_splitter.addWidget(execution_area)
|
||||
self.detail_splitter.setStretchFactor(0, 5)
|
||||
self.detail_splitter.setStretchFactor(1, 1)
|
||||
details = QWidget()
|
||||
details = QWidget(objectName='workspace')
|
||||
details_layout = QVBoxLayout(details)
|
||||
details_layout.setContentsMargins(0, 0, 0, 0)
|
||||
details_layout.addWidget(self.run_panel.copy_value_check)
|
||||
details_layout.addWidget(self.archive_on_close_check)
|
||||
details_layout.setContentsMargins(16, 14, 16, 10)
|
||||
details_layout.setSpacing(12)
|
||||
details_layout.addWidget(self.project_summary)
|
||||
self.project_options_button = QToolButton(objectName='projectOptionsToggle')
|
||||
self.project_options_button.setText('工程设置')
|
||||
self.project_options_button.setToolTip('Value 策略与关闭归档选项')
|
||||
self.project_options_button.setProperty('appearance','quiet')
|
||||
self.project_options_button.setIcon(icon('sliders'))
|
||||
self.project_options_button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||
self.project_options_button.setCheckable(True)
|
||||
self.project_summary.heading_layout.insertWidget(1, self.project_options_button)
|
||||
options = QWidget(objectName='projectOptions')
|
||||
options_layout = QVBoxLayout(options)
|
||||
options_layout.setContentsMargins(8, 4, 8, 4)
|
||||
options_layout.addWidget(self.run_panel.copy_value_check)
|
||||
options_layout.addWidget(self.archive_on_close_check)
|
||||
options.hide()
|
||||
self.project_options_button.toggled.connect(options.setVisible)
|
||||
details_layout.addWidget(options)
|
||||
details_layout.addWidget(self.detail_splitter, 1)
|
||||
self.workspace_splitter = QSplitter(Qt.Orientation.Horizontal)
|
||||
self.workspace_splitter.setChildrenCollapsible(False)
|
||||
self.workspace_splitter.addWidget(self.task_list)
|
||||
self.workspace_splitter.addWidget(details)
|
||||
self.workspace_splitter.setStretchFactor(1, 1)
|
||||
container = QWidget()
|
||||
container = QWidget(objectName='taskCenterSurface')
|
||||
layout = QHBoxLayout(container)
|
||||
layout.setContentsMargins(8, 8, 8, 8)
|
||||
layout.addWidget(self.workspace_splitter)
|
||||
@@ -219,7 +255,7 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
|
||||
def _reset_layout(self):
|
||||
self.workspace_splitter.setSizes((240, 1040))
|
||||
self.detail_splitter.setSizes((590, 170))
|
||||
self.detail_splitter.setSizes((650, 110))
|
||||
self.run_panel.toggle_log_button.setChecked(False)
|
||||
|
||||
def _confirm_close_plans(self):
|
||||
@@ -237,6 +273,11 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
self._layout_settings.setValue('tasks/archive_on_close', bool(enabled))
|
||||
self._layout_settings.sync()
|
||||
|
||||
def _set_reduced_transparency(self, enabled):
|
||||
self._layout_settings.setValue('appearance/reduced_transparency', bool(enabled))
|
||||
self._layout_settings.sync()
|
||||
self._material.set_reduced_transparency(enabled)
|
||||
|
||||
def _session_archived(self, report):
|
||||
self._close_archived = True
|
||||
self._close_pending = True
|
||||
@@ -375,7 +416,8 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
resources_pending = bool(self.service.pending_batch_resources())
|
||||
self.run_panel.cleanup_resources_button.setVisible(resources_pending)
|
||||
self.run_panel.cleanup_resources_button.setEnabled(resources_pending and not busy)
|
||||
state = execution_state(self._context, busy=busy, dirty=self.plan_panel.table.dirty)
|
||||
state = execution_state(self._context, busy=busy,
|
||||
dirty=self.plan_panel.table.dirty or self.plan_panel.table.has_pending_editor())
|
||||
group_unsaved = self._group_has_unsaved_plans() if state.editable or state.new_round else False
|
||||
context = self._context
|
||||
self.run_panel.quick_run_button.setText(state.execute_text)
|
||||
@@ -394,6 +436,9 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
self.run_panel.force_stop_button.setVisible(self._batch_stop is not None)
|
||||
self.run_panel.force_stop_button.setEnabled(bool(self._batch_stop and
|
||||
not self._batch_stop.force_event.is_set()))
|
||||
self.run_panel.quick_run_button.setVisible(self._batch_stop is None
|
||||
and not bool(context and (context.interrupted or context.phase=='retry'
|
||||
or context.task.status is TaskStatus.COMPLETED)))
|
||||
self.run_panel.diagnostics_button.setEnabled(self._diagnostic_worker is None)
|
||||
self.run_panel.copy_value_check.setEnabled(state.editable)
|
||||
rule_editable = state.editable and not group_unsaved
|
||||
@@ -968,7 +1013,8 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
|
||||
def _run_async(self, operation, callback, button=None, *, expected_task_id=None,
|
||||
retain_result=False, operation_area='', **_unused):
|
||||
if self._workers or self._closed or (self._dsh_task_creation is not None and self._dsh_task_creation.dialog is not None):
|
||||
if (self._workers or self._closed or (self._dsh_task_creation is not None and self._dsh_task_creation.dialog is not None)
|
||||
):
|
||||
return
|
||||
worker = ServiceWorker(operation)
|
||||
self._workers.add(worker)
|
||||
|
||||
@@ -84,13 +84,24 @@ class MappingTable(QTableView):
|
||||
self.setAlternatingRowColors(True)
|
||||
self._model = RuleTableModel(self)
|
||||
self.setModel(self._model)
|
||||
self.setHorizontalScrollMode(QAbstractItemView.ScrollMode.ScrollPerPixel)
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
|
||||
if on_enabled_changed is not None:
|
||||
self._model.enabled_requested.connect(on_enabled_changed)
|
||||
header = self.horizontalHeader()
|
||||
header.setSectionsMovable(True)
|
||||
header.setSectionsClickable(True)
|
||||
header.setHighlightSections(True)
|
||||
header.setStretchLastSection(False)
|
||||
header.setMinimumSectionSize(48)
|
||||
header.setDefaultAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
|
||||
for section, width in ((0, 220), (1, 220), (2, 180), (3, 80), (4, 70), (5, 65), (6, 210)):
|
||||
header.setSectionResizeMode(section, QHeaderView.ResizeMode.Interactive)
|
||||
header.resizeSection(section, width)
|
||||
header.setStretchLastSection(True)
|
||||
# Keep the last section interactive so the horizontal scrollbar and
|
||||
# header/body coordinate stay predictable in narrow workspaces.
|
||||
header.setStretchLastSection(False)
|
||||
|
||||
def set_rules_editable(self, editable: bool):
|
||||
if self._model.editable != editable:
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
"""Owned-window Acrylic composition with an opaque, accessible fallback.
|
||||
|
||||
The data views never use window opacity or background screenshots. Windows
|
||||
composes the live backdrop. Non-Windows/offscreen rendering stays solid.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import ctypes
|
||||
from ctypes import wintypes
|
||||
import sys
|
||||
|
||||
from PySide6.QtCore import QEvent, QObject, QTimer, Qt
|
||||
from PySide6.QtGui import QColor, QGuiApplication, QPainter
|
||||
from PySide6.QtWidgets import QMainWindow
|
||||
|
||||
|
||||
class MaterialMainWindow(QMainWindow):
|
||||
"""An alpha-capable HWND needs explicit opaque painting when Acrylic is off."""
|
||||
def paintEvent(self, event):
|
||||
if not self.property('acrylicEnabled'):
|
||||
painter = QPainter(self)
|
||||
painter.fillRect(event.rect(), QColor('#edf1f5'))
|
||||
painter.end()
|
||||
super().paintEvent(event)
|
||||
|
||||
|
||||
class WindowsAcrylic:
|
||||
def __init__(self):
|
||||
self._user = None
|
||||
if sys.platform == 'win32':
|
||||
self._user = ctypes.WinDLL('user32', use_last_error=True)
|
||||
|
||||
def available(self) -> bool:
|
||||
if self._user is None or QGuiApplication.platformName() != 'windows':
|
||||
return False
|
||||
if sys.getwindowsversion().build < 17763:
|
||||
return False
|
||||
try:
|
||||
import winreg
|
||||
class HighContrast(ctypes.Structure):
|
||||
_fields_ = [('size', wintypes.UINT), ('flags', wintypes.DWORD),
|
||||
('scheme', wintypes.LPWSTR)]
|
||||
contrast = HighContrast()
|
||||
contrast.size = ctypes.sizeof(contrast)
|
||||
if not self._user.SystemParametersInfoW(0x0042, contrast.size,
|
||||
ctypes.byref(contrast), 0):
|
||||
return False
|
||||
if contrast.flags & 1 or self._user.GetSystemMetrics(0x1000):
|
||||
return False
|
||||
try:
|
||||
with winreg.OpenKey(winreg.HKEY_CURRENT_USER,
|
||||
r'Software\Microsoft\Windows\CurrentVersion\Themes\Personalize') as key:
|
||||
enabled = winreg.QueryValueEx(key, 'EnableTransparency')[0]
|
||||
return bool(enabled)
|
||||
except FileNotFoundError:
|
||||
return True
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
def _configure(self, hwnd: int, state: int) -> bool:
|
||||
if self._user is None:
|
||||
return False
|
||||
class AccentPolicy(ctypes.Structure):
|
||||
_fields_ = [('state', ctypes.c_int), ('flags', ctypes.c_int),
|
||||
('color', ctypes.c_uint32), ('animation', ctypes.c_int)]
|
||||
class CompositionData(ctypes.Structure):
|
||||
_fields_ = [('attribute', ctypes.c_int), ('data', ctypes.c_void_p),
|
||||
('size', ctypes.c_size_t)]
|
||||
# WCA_ACCENT_POLICY, ACCENT_ENABLE_ACRYLICBLURBEHIND. Color is AABBGGRR.
|
||||
policy = AccentPolicy(state, 0, 0x30F4F4F4, 0)
|
||||
data = CompositionData(19, ctypes.cast(ctypes.pointer(policy), ctypes.c_void_p),
|
||||
ctypes.sizeof(policy))
|
||||
configure = self._user.SetWindowCompositionAttribute
|
||||
configure.argtypes = [wintypes.HWND, ctypes.POINTER(CompositionData)]
|
||||
configure.restype = wintypes.BOOL
|
||||
return bool(configure(hwnd, ctypes.byref(data)))
|
||||
|
||||
def enable(self, hwnd: int) -> bool:
|
||||
return self._configure(hwnd, 4)
|
||||
|
||||
def disable(self, hwnd: int) -> None:
|
||||
self._configure(hwnd, 0)
|
||||
|
||||
|
||||
class AcrylicController(QObject):
|
||||
"""Only owns the composition state of its parent window, never system settings."""
|
||||
def __init__(self, window, *, backend=None):
|
||||
super().__init__(window)
|
||||
self.window = window
|
||||
self.backend = backend if backend is not None else WindowsAcrylic()
|
||||
self.reduced = False
|
||||
self._enabled = False
|
||||
self._handle = None
|
||||
self._signature = None
|
||||
window.setProperty('acrylicEnabled', False)
|
||||
# Set up an alpha surface before creating HWND; keep the native frame.
|
||||
if QGuiApplication.platformName() == 'windows':
|
||||
window.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
window.installEventFilter(self)
|
||||
self._timer = QTimer(self)
|
||||
self._timer.setInterval(2000)
|
||||
self._timer.timeout.connect(self._poll)
|
||||
self._timer.start()
|
||||
|
||||
def _poll(self):
|
||||
if self.window.isVisible():
|
||||
self.refresh()
|
||||
|
||||
def set_reduced_transparency(self, reduced: bool):
|
||||
self.reduced = bool(reduced)
|
||||
self.refresh()
|
||||
|
||||
def _surface(self, enabled, *, repaint=True):
|
||||
self._enabled = bool(enabled)
|
||||
self.window.setProperty('acrylicEnabled', bool(enabled))
|
||||
# Dynamic ancestor selectors affect chrome children as well as the root.
|
||||
self.window.setStyleSheet(self.window.styleSheet())
|
||||
if repaint:
|
||||
self.window.update()
|
||||
|
||||
def refresh(self):
|
||||
try:
|
||||
allowed = not self.reduced and self.backend.available()
|
||||
except (OSError, AttributeError):
|
||||
allowed = False
|
||||
handle = int(self.window.winId()) if allowed else self._handle
|
||||
signature = (handle, allowed)
|
||||
if signature == self._signature:
|
||||
return
|
||||
self._signature = signature
|
||||
# Native composition changes can briefly expose the intermediate Qt
|
||||
# surface. Batch the property/style update and Windows API call while
|
||||
# painting is paused, then present the final surface in one repaint.
|
||||
updates_enabled = self.window.updatesEnabled()
|
||||
self.window.setUpdatesEnabled(False)
|
||||
try:
|
||||
if self._enabled:
|
||||
# Paint opaque before removing native blur; avoids an unreadable alpha surface.
|
||||
self._surface(False, repaint=False)
|
||||
try:
|
||||
self.backend.disable(self._handle)
|
||||
except (OSError, AttributeError):
|
||||
pass
|
||||
self._handle = handle
|
||||
if not allowed:
|
||||
return
|
||||
try:
|
||||
enabled = self.backend.enable(handle)
|
||||
except (OSError, AttributeError):
|
||||
enabled = False
|
||||
self._surface(enabled, repaint=False)
|
||||
if not enabled:
|
||||
try:
|
||||
self.backend.disable(handle)
|
||||
except (OSError, AttributeError):
|
||||
pass
|
||||
finally:
|
||||
self.window.setUpdatesEnabled(updates_enabled)
|
||||
if updates_enabled:
|
||||
self.window.update()
|
||||
|
||||
def eventFilter(self, watched, event):
|
||||
if event.type() in (QEvent.Type.Show, QEvent.Type.WinIdChange,
|
||||
QEvent.Type.WindowActivate):
|
||||
QTimer.singleShot(0, self.refresh)
|
||||
return super().eventFilter(watched, event)
|
||||
@@ -6,6 +6,7 @@ from threading import Event
|
||||
from time import monotonic
|
||||
|
||||
from PySide6.QtCore import Qt, QThreadPool, QObject, Signal, QSignalBlocker
|
||||
from PySide6.QtGui import QAction,QKeySequence
|
||||
from PySide6.QtWidgets import (QDialog, QDialogButtonBox, QFileDialog, QHBoxLayout, QLabel,
|
||||
QLineEdit, QListWidget, QListWidgetItem, QMessageBox, QPushButton,
|
||||
QVBoxLayout, QWidget, QToolButton, QMenu)
|
||||
@@ -14,6 +15,8 @@ from .detail_windows import BomReportDialog
|
||||
from .target_table import TargetTable
|
||||
from .workers import ServiceWorker
|
||||
from .operation_state import OperationPhase
|
||||
from .command_menu import CommandMenu
|
||||
from .icons import icon
|
||||
from ..bom_import_state import BomImportMachine, BomImportPhase, BomImportState
|
||||
|
||||
|
||||
@@ -169,6 +172,8 @@ class DirectoryTaskDialog(QDialog):
|
||||
class ProjectPlanPanel(QWidget):
|
||||
def __init__(self, window):
|
||||
super().__init__()
|
||||
self.setObjectName('projectPlanPanel')
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground,True)
|
||||
self.window = window
|
||||
self.task_id = None
|
||||
self._drafts = {}
|
||||
@@ -183,7 +188,7 @@ class ProjectPlanPanel(QWidget):
|
||||
self.stop_button.hide()
|
||||
self.stop_button.clicked.connect(self.cancel_operation)
|
||||
self.table = TargetTable(self)
|
||||
self.collect_button = QPushButton('采集所有匹配位号', objectName='collectTargetInventory')
|
||||
self.collect_button = QPushButton('采集位号', objectName='collectTargetInventory')
|
||||
self.save_button = QPushButton('保存位号计划', objectName='saveTargetPlan')
|
||||
self.import_button = QPushButton('导入位号计划', objectName='importTargetPlan')
|
||||
self.export_button = QPushButton('导出位号计划', objectName='exportTargetPlan')
|
||||
@@ -196,12 +201,17 @@ class ProjectPlanPanel(QWidget):
|
||||
self.bulk_part.setPlaceholderText('对选中行批量填写新料号')
|
||||
self.bulk_apply = QPushButton('填入选中行')
|
||||
self.find_text = QLineEdit(objectName='findTargetText')
|
||||
self.find_text.setPlaceholderText('查找位号 / UID / 料号 / 图页 / Value')
|
||||
self.find_text.setPlaceholderText('搜索位号、料号或图页')
|
||||
self.find_text.setToolTip('支持位号、UID、料号、图页和 Value。过滤不改变真实执行范围。')
|
||||
self.find_text.setClearButtonEnabled(True)
|
||||
self.find_text.setMinimumWidth(140)
|
||||
self.find_text.setMaximumWidth(340)
|
||||
self.find_button = QPushButton('查找', objectName='findTargets')
|
||||
self.find_next_button = QPushButton('下一条')
|
||||
self.clear_find_button = QPushButton('清空查找')
|
||||
self.find_result = QLabel()
|
||||
self.summary = QLabel('先添加旧、新料号规则,再采集位号;可直接在这里编辑,也可选用 Excel。')
|
||||
self.summary.setObjectName('planSummary')
|
||||
self.summary.setWordWrap(True)
|
||||
self.report_text = ''
|
||||
self.report_dialog = None
|
||||
@@ -210,37 +220,48 @@ class ProjectPlanPanel(QWidget):
|
||||
self.report_toggle.hide()
|
||||
self.report_toggle.toggled.connect(self._toggle_report)
|
||||
self.last_bom_report = None
|
||||
actions = QHBoxLayout()
|
||||
for button in (self.collect_button, self.save_button, self.import_bom_button, self.export_bom_button):
|
||||
toolbar=QWidget(objectName='planToolbar')
|
||||
actions=QHBoxLayout(toolbar)
|
||||
actions.setContentsMargins(0,3,0,3);actions.setSpacing(8)
|
||||
actions.addWidget(self.find_text,1)
|
||||
actions.addStretch()
|
||||
for button in (self.export_bom_button,self.import_bom_button,self.collect_button):
|
||||
actions.addWidget(button)
|
||||
excel_menu = QMenu(self)
|
||||
for button in (self.import_button, self.export_button):
|
||||
button.setParent(self)
|
||||
button.hide()
|
||||
action = excel_menu.addAction(button.text(), button.click)
|
||||
excel_menu.aboutToShow.connect(lambda a=action, b=button: a.setEnabled(b.isEnabled()))
|
||||
self.excel_button = QToolButton()
|
||||
self.excel_button.setText('位号 Excel')
|
||||
self.excel_button.setMenu(excel_menu)
|
||||
self.export_bom_button.setProperty('appearance','quiet')
|
||||
self.more_menu=CommandMenu(self)
|
||||
for button in (self.import_button,self.export_button):self.more_menu.add_button(button)
|
||||
self.more_menu.addSeparator()
|
||||
for button in (self.find_button,self.find_next_button,self.clear_find_button):self.more_menu.add_button(button)
|
||||
self.excel_button = QToolButton(objectName='planMoreMenu')
|
||||
self.excel_button.setText('更多工具')
|
||||
self.excel_button.setToolTip('位号计划导入导出与搜索工具')
|
||||
self.excel_button.setIcon(icon('more'))
|
||||
self.excel_button.setProperty('appearance','quiet')
|
||||
self.excel_button.setMenu(self.more_menu)
|
||||
self.excel_button.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||
actions.addWidget(self.excel_button)
|
||||
actions.addWidget(self.stop_button)
|
||||
actions.addStretch()
|
||||
selection = QHBoxLayout()
|
||||
selection.setSpacing(7)
|
||||
for button in (self.select_all,self.select_none,self.bulk_apply):button.setProperty('appearance','quiet')
|
||||
selection.addWidget(self.select_all)
|
||||
selection.addWidget(self.select_none)
|
||||
selection.addWidget(self.bulk_part, 1)
|
||||
selection.addWidget(self.bulk_apply)
|
||||
self.save_state=QLabel(objectName='planSaveState')
|
||||
selection.addWidget(self.save_state)
|
||||
selection.addWidget(self.save_button)
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.addLayout(actions)
|
||||
layout.addWidget(self.summary)
|
||||
layout.setContentsMargins(0,4,0,0)
|
||||
layout.setSpacing(9)
|
||||
layout.addWidget(toolbar)
|
||||
summary_row=QHBoxLayout()
|
||||
summary_row.addWidget(self.summary,1)
|
||||
summary_row.addWidget(self.find_result)
|
||||
self.find_result.setObjectName('planFindResult')
|
||||
self.find_result.hide()
|
||||
layout.addLayout(summary_row)
|
||||
layout.addWidget(self.report_toggle)
|
||||
search = QHBoxLayout()
|
||||
for widget in (self.find_text, self.find_button, self.find_next_button,
|
||||
self.clear_find_button, self.find_result):
|
||||
search.addWidget(widget)
|
||||
layout.addLayout(search)
|
||||
layout.addWidget(self.table, 1)
|
||||
layout.addLayout(selection)
|
||||
self.collect_button.clicked.connect(self.collect)
|
||||
@@ -255,8 +276,24 @@ class ProjectPlanPanel(QWidget):
|
||||
self.table.changed.connect(self._changed)
|
||||
self.find_button.clicked.connect(self.find)
|
||||
self.find_text.returnPressed.connect(self.find)
|
||||
self.find_text.textEdited.connect(self.find)
|
||||
self.next_match_action=self.find_text.addAction(icon('chevron'),QLineEdit.ActionPosition.TrailingPosition)
|
||||
self.next_match_action.setToolTip('下一条匹配位号 · F3')
|
||||
self.next_match_action.triggered.connect(self.table.find_next)
|
||||
self.find_next_button.clicked.connect(self.table.find_next)
|
||||
self.clear_find_button.clicked.connect(self.clear_find)
|
||||
self.bulk_part.textChanged.connect(self._edit_feedback)
|
||||
self.table.selectionModel().selectionChanged.connect(self._edit_feedback)
|
||||
self.table.editor_activity.connect(self._editor_feedback)
|
||||
def shortcut(key,callback):
|
||||
action=QAction(self);action.setShortcut(QKeySequence(key))
|
||||
action.setShortcutContext(Qt.ShortcutContext.WidgetWithChildrenShortcut)
|
||||
action.triggered.connect(callback);self.addAction(action);return action
|
||||
self.find_shortcut=shortcut('Ctrl+F',self._focus_find)
|
||||
self.save_shortcut=shortcut('Ctrl+S',self._save_from_shortcut)
|
||||
self.next_shortcut=shortcut('F3',lambda:self.table.find_next()if self.next_match_action.isEnabled()else None)
|
||||
self.save_button.setToolTip('保存当前作用范围的位号计划 · Ctrl+S')
|
||||
self._edit_feedback()
|
||||
|
||||
def bind_task(self, task_id, rows=None):
|
||||
self._restore_bom_report(self._report_scope(task_id))
|
||||
@@ -278,10 +315,10 @@ class ProjectPlanPanel(QWidget):
|
||||
|
||||
def find(self):
|
||||
count = self.table.set_find_text(self.find_text.text())
|
||||
self.find_result.setText(f'{count} 条匹配')
|
||||
self.select_all.setText('替换可见行' if self.find_text.text().strip() else '替换当前工程')
|
||||
self.select_none.setText('保留可见行' if self.find_text.text().strip() else '保留当前工程')
|
||||
self.table.find_next()
|
||||
self._edit_feedback()
|
||||
|
||||
def clear_find(self):
|
||||
self.find_text.clear()
|
||||
@@ -289,16 +326,56 @@ class ProjectPlanPanel(QWidget):
|
||||
self.find_result.clear()
|
||||
self.select_all.setText('替换当前工程')
|
||||
self.select_none.setText('保留当前工程')
|
||||
self._edit_feedback()
|
||||
|
||||
def _focus_find(self):
|
||||
self.find_text.setFocus()
|
||||
self.find_text.selectAll()
|
||||
|
||||
def _editor_feedback(self):
|
||||
self._edit_feedback()
|
||||
if not getattr(self.window,'_closed',False):self.window._update_gates()
|
||||
|
||||
def _save_from_shortcut(self):
|
||||
if not self._editable or not self.task_id:return
|
||||
# Leaving the delegate editor commits its text before the save snapshot.
|
||||
self.table.setFocus(Qt.FocusReason.ShortcutFocusReason)
|
||||
self._edit_feedback()
|
||||
if self.save_button.isEnabled():self.save_button.click()
|
||||
|
||||
def _edit_feedback(self,*_):
|
||||
count=self.table.plan_model.rowCount()
|
||||
pending=bool(self.table.dirty or self._active_bom_batch() or self.table.has_pending_editor())
|
||||
self.save_state.setText('未保存'if pending else '已保存')
|
||||
self.save_state.setVisible(bool(count or pending))
|
||||
tone='pending'if pending else 'saved'
|
||||
if self.save_state.property('tone')!=tone:
|
||||
self.save_state.setProperty('tone',tone)
|
||||
self.save_state.style().unpolish(self.save_state)
|
||||
self.save_state.style().polish(self.save_state)
|
||||
self.save_button.setEnabled(self._editable and bool(self.task_id) and pending)
|
||||
selected=len(self.table.selectionModel().selectedRows())
|
||||
self.bulk_apply.setText(f'填入 {selected} 行'if selected else'填入选中行')
|
||||
self.bulk_apply.setToolTip('先选中表格行,再输入新料号;行选中与替换勾选是两种操作。')
|
||||
self.bulk_apply.setEnabled(self._editable and bool(self.task_id) and selected>0 and bool(self.bulk_part.text().strip()))
|
||||
query=bool(self.find_text.text().strip())
|
||||
visible=self.table.rowCount()
|
||||
self.find_result.setVisible(query)
|
||||
self.find_result.setText(f'匹配 {visible} / {count}'if visible else'没有匹配结果')
|
||||
self.next_match_action.setVisible(query)
|
||||
self.next_match_action.setEnabled(query and visible>0)
|
||||
self.find_next_button.setEnabled(query and visible>0)
|
||||
|
||||
def has_unsaved_plan(self, task_ids):
|
||||
return any(task_id in self._drafts or
|
||||
(task_id == self.task_id and self.table.dirty) for task_id in task_ids)
|
||||
(task_id == self.task_id and (self.table.dirty or self.table.has_pending_editor())) for task_id in task_ids)
|
||||
|
||||
def has_unsaved_plans(self):
|
||||
return bool(self._drafts or self._bom_batches or self._orphaned_bom_batches or self.table.dirty)
|
||||
return bool(self._drafts or self._bom_batches or self._orphaned_bom_batches or self.table.dirty or self.table.has_pending_editor())
|
||||
|
||||
def prepare_save_all(self):
|
||||
# Snapshot widgets only on the GUI thread; the returned operation uses plain data.
|
||||
if self.table.has_pending_editor():self.table.setFocus(Qt.FocusReason.ShortcutFocusReason)
|
||||
drafts = dict(self._drafts)
|
||||
if self.task_id and self.table.dirty:
|
||||
drafts[self.task_id] = self.table.rows()
|
||||
@@ -339,6 +416,7 @@ class ProjectPlanPanel(QWidget):
|
||||
self.table.populate(())
|
||||
|
||||
def discard_all(self):
|
||||
self.table.cancel_editor()
|
||||
self._drafts.clear()
|
||||
self._bom_batches.clear()
|
||||
self._orphaned_bom_batches.clear()
|
||||
@@ -445,6 +523,7 @@ class ProjectPlanPanel(QWidget):
|
||||
self._summary()
|
||||
|
||||
def _summary(self):
|
||||
self._edit_feedback()
|
||||
count = self.table.plan_model.rowCount()
|
||||
batch = self._active_bom_batch()
|
||||
self.save_button.setText('保存本批位号计划' if batch else '保存位号计划')
|
||||
@@ -488,6 +567,7 @@ class ProjectPlanPanel(QWidget):
|
||||
self.export_button.setEnabled(self._editable and bool(self.task_id)
|
||||
and bool(self.table.plan_model.rowCount()) and not self.table.dirty)
|
||||
self.export_bom_button.setEnabled(not busy)
|
||||
self._edit_feedback()
|
||||
|
||||
def _dispatch(self, operation, callback, button, *, retain_result=False):
|
||||
self.window._run_async(operation, callback, button, expected_task_id=self.task_id,
|
||||
|
||||
@@ -5,8 +5,9 @@ from PySide6.QtWidgets import QApplication, QHBoxLayout, QLabel, QPushButton, QT
|
||||
|
||||
class ProjectPathLabel(QLabel):
|
||||
"""One line of context; the full path remains selectable and copyable."""
|
||||
def __init__(self):
|
||||
super().__init__(objectName='boundProjectPath')
|
||||
def __init__(self,object_name='boundProjectPath',elide=Qt.TextElideMode.ElideMiddle):
|
||||
super().__init__(objectName=object_name)
|
||||
self._elide_mode=elide
|
||||
self.full_path = ''
|
||||
self.setSizePolicy(QSizePolicy.Policy.Ignored, QSizePolicy.Policy.Fixed)
|
||||
self.setTextInteractionFlags(Qt.TextInteractionFlag.TextSelectableByMouse)
|
||||
@@ -27,23 +28,43 @@ class ProjectPathLabel(QLabel):
|
||||
self._elide()
|
||||
|
||||
def _elide(self):
|
||||
super().setText(self.fontMetrics().elidedText(self.full_path, Qt.TextElideMode.ElideMiddle, max(0, self.width())))
|
||||
super().setText(self.fontMetrics().elidedText(self.full_path, self._elide_mode, max(0, self.width())))
|
||||
|
||||
|
||||
class ProjectSummary(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.name = QLabel('未选择任务')
|
||||
self.setObjectName('projectSummary')
|
||||
self.name = ProjectPathLabel('projectTitle',Qt.TextElideMode.ElideRight)
|
||||
self.name.setText('未选择任务')
|
||||
self.name.setMinimumHeight(34)
|
||||
self.path = ProjectPathLabel()
|
||||
self.copy_path = QToolButton()
|
||||
self.copy_path.setText('复制路径')
|
||||
from .icons import icon
|
||||
self.copy_path.setIcon(icon('copy'))
|
||||
self.copy_path.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly)
|
||||
self.copy_path.setToolTip('复制完整工程路径')
|
||||
self.copy_path.setProperty('appearance','quiet')
|
||||
self.copy_path.clicked.connect(lambda: QApplication.clipboard().setText(self.path.full_path))
|
||||
self.state = QLabel()
|
||||
self.state.setWordWrap(True)
|
||||
self.state = QLabel(objectName='projectState')
|
||||
self.state.setWordWrap(False)
|
||||
self.state.setMinimumWidth(130)
|
||||
self.state.setMaximumWidth(310)
|
||||
self.state.setAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignmentFlag.AlignVCenter)
|
||||
self.refresh_button = QPushButton('重新读取工程', objectName='refreshBoundProject')
|
||||
from .command_menu import CommandMenu
|
||||
self.more_menu=CommandMenu(self)
|
||||
self.more_menu.add_button(self.refresh_button)
|
||||
more=QToolButton(objectName='projectMoreMenu')
|
||||
more.setText('工程操作');more.setToolTip('重新读取工程')
|
||||
more.setIcon(icon('more'));more.setProperty('appearance','quiet')
|
||||
more.setMenu(self.more_menu);more.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||
heading = QHBoxLayout()
|
||||
self.heading_layout = heading
|
||||
heading.addWidget(self.name, 1)
|
||||
heading.addWidget(self.refresh_button)
|
||||
heading.addWidget(self.state)
|
||||
heading.addWidget(more)
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.addLayout(heading)
|
||||
@@ -51,13 +72,13 @@ class ProjectSummary(QWidget):
|
||||
path_row.addWidget(self.path, 1)
|
||||
path_row.addWidget(self.copy_path)
|
||||
layout.addLayout(path_row)
|
||||
layout.addWidget(self.state)
|
||||
|
||||
def populate(self, context):
|
||||
if context is None:
|
||||
self.name.setText('未选择任务')
|
||||
self.path.clear()
|
||||
self.state.setText('点击新建,在弹窗中读取并选择工程。')
|
||||
self.state.setToolTip(self.state.text())
|
||||
return
|
||||
project = context.project
|
||||
self.name.setText(project.display_name if project else context.task.name)
|
||||
@@ -72,4 +93,5 @@ class ProjectSummary(QWidget):
|
||||
progress = context.progress
|
||||
result = (f' · 已保存 {progress.saved_items} / 失败 {progress.failed_items} / 未命中 {progress.no_match_items}'
|
||||
if progress.completed_items else '')
|
||||
self.state.setText(f'当前工程 · {labels.get(context.task.status.value, context.task.status.value)}{result}')
|
||||
self.state.setText(f'{labels.get(context.task.status.value, context.task.status.value)}{result}')
|
||||
self.state.setToolTip(self.state.text())
|
||||
@@ -1,9 +1,11 @@
|
||||
"""Explicit single-task execution, recovery and safe pause controls."""
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtCore import Signal,Qt
|
||||
from PySide6.QtWidgets import (QCheckBox, QHBoxLayout, QLabel, QProgressBar,
|
||||
QPushButton, QToolButton, QVBoxLayout, QWidget)
|
||||
|
||||
from .detail_windows import TaskLogDialog
|
||||
from .command_menu import CommandMenu
|
||||
from .icons import icon
|
||||
|
||||
|
||||
class RunPanel(QWidget):
|
||||
@@ -11,6 +13,8 @@ class RunPanel(QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.setObjectName('runPanel')
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground,True)
|
||||
self.queue_summary = QLabel('未选择任务', objectName='queueSummary')
|
||||
self.execution_status = QLabel('空闲', objectName='executionStatus')
|
||||
self.execution_status.setWordWrap(True)
|
||||
@@ -42,18 +46,33 @@ class RunPanel(QWidget):
|
||||
self.reset_layout_button.setText('重置布局')
|
||||
self.log_dialog = None
|
||||
self.toggle_log_button.toggled.connect(self._toggle_log)
|
||||
buttons = QHBoxLayout()
|
||||
for button in (self.quick_run_button, self.retry_button, self.recover_button, self.cleanup_resources_button, self.diagnostics_button,
|
||||
self.new_round_button, self.history_button, self.stop_queue_button, self.force_stop_button):
|
||||
self.more_menu=CommandMenu(self)
|
||||
for button in (self.diagnostics_button,self.cleanup_resources_button,self.history_button,self.reset_layout_button):
|
||||
self.more_menu.add_button(button)
|
||||
self.more_menu.addSeparator()
|
||||
self.more_menu.add_button(self.force_stop_button)
|
||||
self.more_button=QToolButton(objectName='executionMoreMenu')
|
||||
self.more_button.setText('更多操作')
|
||||
self.more_button.setToolTip('诊断、轮次证据、布局与异常操作')
|
||||
self.more_button.setIcon(icon('more'))
|
||||
self.more_button.setMenu(self.more_menu)
|
||||
self.more_button.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||
self.more_button.setProperty('appearance','quiet')
|
||||
self.toggle_log_button.setProperty('appearance','quiet')
|
||||
heading=QHBoxLayout()
|
||||
heading.addWidget(self.queue_summary,1)
|
||||
heading.addWidget(self.toggle_log_button)
|
||||
heading.addWidget(self.more_button)
|
||||
buttons=QHBoxLayout()
|
||||
buttons.addWidget(self.operator_band,1)
|
||||
for button in (self.retry_button,self.recover_button,self.new_round_button,self.stop_queue_button,self.quick_run_button):
|
||||
buttons.addWidget(button)
|
||||
buttons.addStretch()
|
||||
buttons.addWidget(self.toggle_log_button)
|
||||
buttons.addWidget(self.reset_layout_button)
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
for widget in (self.queue_summary, self.execution_status, self.busy_indicator,
|
||||
self.operator_band):
|
||||
layout.addWidget(widget)
|
||||
layout.setContentsMargins(12,8,12,9)
|
||||
layout.setSpacing(5)
|
||||
layout.addLayout(heading)
|
||||
layout.addWidget(self.execution_status)
|
||||
layout.addWidget(self.busy_indicator)
|
||||
layout.addLayout(buttons)
|
||||
|
||||
def _toggle_log(self, visible):
|
||||
|
||||
@@ -1,44 +1,111 @@
|
||||
"""Restrained, work-focused styling for the trial task center."""
|
||||
"""Frosted window chrome and opaque, readable engineering data surfaces."""
|
||||
|
||||
APP_STYLESHEET = """
|
||||
QWidget { background: #f4f6f8; color: #17212b; font-size: 13px; }
|
||||
QWidget { background: transparent; color: #344359; font-family: "Segoe UI", "Microsoft YaHei UI"; font-size: 13px; }
|
||||
QMainWindow { background: #edf1f5; }
|
||||
QMainWindow[acrylicEnabled="true"] { background: transparent; }
|
||||
QDialog, QMessageBox, QMenu { background: #f8fafc; }
|
||||
QToolTip { background: #ffffff; color: #344359; border: 1px solid #ccd6e2; padding: 5px; }
|
||||
QLabel#taskSectionTitle { color: #5d6873; font-size: 12px; font-weight: 600; padding: 2px 4px; }
|
||||
QWidget#taskNavigation, QWidget#workspace, QTextEdit { background: #ffffff; border: 1px solid #cbd5df; }
|
||||
QPushButton, QComboBox, QLineEdit, QTableView { border: 1px solid #aebdca; border-radius: 6px; background: #ffffff; }
|
||||
QPushButton { min-height: 30px; padding: 2px 9px; }
|
||||
QPushButton:hover { background: #edf4fa; }
|
||||
QWidget#taskNavigation { background: #e9eef4; border: 1px solid #dbe3ed; border-radius: 10px; }
|
||||
QMainWindow[acrylicEnabled="true"] QWidget#taskNavigation { background: rgba(255,255,255,26); border: 1px solid rgba(255,255,255,165); }
|
||||
QWidget#workspace { background: #f1f5f9; border: 1px solid #dce5ef; border-radius: 14px; }
|
||||
QMainWindow[acrylicEnabled="true"] QWidget#workspace { background: rgba(255,255,255,42); border: 1px solid rgba(255,255,255,145); }
|
||||
QWidget#executionSurface { background: transparent; border: none; }
|
||||
QWidget#runPanel { background: #f8fafc; border: 1px solid #dde6f0; border-radius: 12px; }
|
||||
QMainWindow[acrylicEnabled="true"] QWidget#runPanel { background: rgba(255,255,255,65); border: 1px solid rgba(255,255,255,185); }
|
||||
QWidget#projectOptions { background: #f2f5f9; border: 1px solid #e3e9f0; border-radius: 7px; }
|
||||
QLabel#projectTitle { font-size: 23px; font-weight: 600; color: #344b67; padding: 3px 0; }
|
||||
QLabel#applicationBrand { font-size: 15px; font-weight: 600; color: #455b77; padding: 0 8px; }
|
||||
QLabel#boundProjectPath { font-family: Consolas; font-size: 12px; color: #71839b; }
|
||||
QLabel#projectState { font-size: 12px; color: #6d829c; padding: 0 2px; }
|
||||
QLabel#ruleHelp { color: #71839b; font-size: 12px; padding: 2px 2px 4px; }
|
||||
QPushButton, QComboBox, QLineEdit, QTableView { border: 1px solid #d1dce9; border-radius: 7px; background: #ffffff; }
|
||||
QPushButton { min-height: 28px; padding: 3px 11px; }
|
||||
QPushButton:hover { background: #edf3fa; border-color: #aebfd4; }
|
||||
QPushButton:disabled { color: #81909c; background: #e8edf1; }
|
||||
QPushButton#quickRunButton { background: #1769aa; color: white; border-color: #1769aa; font-weight: 600; }
|
||||
QPushButton#quickRunButton:hover { background: #12588f; }
|
||||
QPushButton#quickRunButton, QPushButton#recoverQuickRunButton, QPushButton#retryTaskItems, QPushButton#startNewRoundButton, QPushButton#stopQueueButton { background: #4e6783; color: white; border-color: #4e6783; font-weight: 600; padding: 5px 16px; border-radius: 8px; }
|
||||
QPushButton#quickRunButton:hover, QPushButton#recoverQuickRunButton:hover, QPushButton#retryTaskItems:hover, QPushButton#startNewRoundButton:hover, QPushButton#stopQueueButton:hover { background: #3d5570; }
|
||||
QPushButton#quickRunButton:disabled { background: #d9e2e9; color: #667784; border-color: #cbd5df; }
|
||||
QPushButton#deleteTaskButton, QPushButton#deleteMappingButton { color: #9f2018; border-color: #d5a29d; }
|
||||
QPushButton#deleteTaskButton:hover, QPushButton#deleteMappingButton:hover { background: #fff0ee; }
|
||||
QPushButton#deleteTaskButton:disabled, QPushButton#deleteMappingButton:disabled { color: #81909c; border-color: #cbd5df; background: #e8edf1; }
|
||||
QLineEdit, QComboBox { min-height: 28px; padding: 0 6px; }
|
||||
QTableView { gridline-color: #e4e9ee; selection-background-color: #e0edfa; selection-color: #17212b; alternate-background-color: #f8fafc; }
|
||||
QHeaderView::section { background: #e8edf1; border: 0; border-bottom: 1px solid #cbd5df; padding: 5px; font-weight: 600; }
|
||||
QListWidget { background: #ffffff; border: 1px solid #cbd5df; }
|
||||
QTableView { background: #ffffff; gridline-color: #edf1f6; selection-background-color: #e7f0fc; selection-color: #304864; alternate-background-color: #fafcff; font-family: Consolas, "Microsoft YaHei UI"; }
|
||||
QTableView::item { padding: 4px; }
|
||||
QHeaderView { background: #f1f5fa; border: 0; }
|
||||
QHeaderView::section { background: #f1f5fa; color: #61758f; border: 0; border-right: 1px solid #e2e9f1; border-bottom: 1px solid #d6e0eb; padding: 7px 9px; font-weight: 600; }
|
||||
QHeaderView::section:hover { background: #eaf1f8; color: #456587; }
|
||||
QHeaderView::section:pressed, QHeaderView::section:checked { background: #dde9f5; color: #355a80; }
|
||||
QMainWindow[acrylicEnabled="true"] QHeaderView { background: rgba(245,249,253,235); }
|
||||
QMainWindow[acrylicEnabled="true"] QHeaderView::section { background: rgba(245,249,253,235); border-right-color: rgba(211,224,238,220); border-bottom-color: rgba(202,216,232,235); }
|
||||
QMainWindow[acrylicEnabled="true"] QHeaderView::section:hover { background: rgba(232,242,251,245); }
|
||||
QMainWindow[acrylicEnabled="true"] QHeaderView::section:pressed, QMainWindow[acrylicEnabled="true"] QHeaderView::section:checked { background: rgba(216,232,247,250); }
|
||||
QListWidget { background: transparent; border: none; outline: none; }
|
||||
QListWidget::item { padding: 8px 10px; border-radius: 6px; margin: 2px 0; }
|
||||
QListWidget::item:selected { background: #e0edfa; color: #17212b; border: 1px solid #b4cce6; }
|
||||
QListWidget::item:selected { background: #ffffff; color: #385a82; border: 1px solid #d9e4f2; }
|
||||
QMainWindow[acrylicEnabled="true"] QListWidget::item:selected { background: rgba(255,255,255,120); border: 1px solid rgba(255,255,255,210); }
|
||||
QListWidget::item:hover:!selected { background: #f1f5f9; }
|
||||
QLabel#operatorBand { background: #fff8d9; border: 1px solid #dfbf4b; padding: 7px; color: #5a4600; }
|
||||
QLabel#operatorBand { background: transparent; border: none; padding: 4px 0; color: #6c809a; font-size: 12px; }
|
||||
QLabel#operatorBand[state="success"] { background: #edf8f1; border-color: #71a982; color: #245b35; }
|
||||
QLabel#operatorBand[state="error"] { background: #fff0ee; border-color: #d58b84; color: #84251e; }
|
||||
QLabel#operatorBand[state="busy"] { background: #edf4fa; border-color: #83abc9; color: #234f70; }
|
||||
QLabel#operatorBand[state="info"] { background: #edf4fa; border-color: #83abc9; color: #234f70; }
|
||||
QLabel#operatorBand[state="warning"] { background: #fff8d9; border-color: #dfbf4b; color: #5a4600; }
|
||||
QLabel#queueSummary { color: #263b49; font-weight: 600; }
|
||||
QLabel#executionStatus { color: #49616f; }
|
||||
QLabel#queueSummary { color: #73869e; font-size: 11px; font-weight: 500; }
|
||||
QLabel#executionStatus { color: #536d8c; font-size: 12px; }
|
||||
QProgressBar#quickRunBusyIndicator { border: 0; background: #dbe4ea; }
|
||||
QProgressBar#quickRunBusyIndicator::chunk { background: #1769aa; }
|
||||
QSplitter::handle { background: #bccbd8; border: 1px solid #e7edf2; }
|
||||
QSplitter::handle { background: transparent; }
|
||||
QSplitter::handle:hover { background: #83abc9; }
|
||||
QToolButton { background: #ffffff; border: 1px solid #aebdca; border-radius: 4px; padding: 4px 7px; }
|
||||
QToolButton { background: rgba(255,255,255,155); border: 1px solid #d4dfec; border-radius: 7px; padding: 4px 7px; }
|
||||
QToolButton:hover { background: #edf4fa; }
|
||||
QWidget#toolNavigation { background: #ffffff; border-bottom: 1px solid #e1e5ea; }
|
||||
QWidget#toolNavigation QToolButton { min-height: 32px; border: 0; border-radius: 7px; padding: 2px 18px; color: #637083; }
|
||||
QWidget#toolNavigation QToolButton:checked { background: #edf3ff; color: #2864d7; font-weight: 600; }
|
||||
QWidget#toolNavigation { background: #eaf0f6; border-bottom: 1px solid #d9e3ee; }
|
||||
QMainWindow[acrylicEnabled="true"] QWidget#toolNavigation { background: rgba(255,255,255,30); border-bottom: 1px solid rgba(255,255,255,150); }
|
||||
QWidget#toolNavigation QToolButton { min-height: 32px; border: 1px solid transparent; border-radius: 8px; padding: 2px 14px; color: #657b97; }
|
||||
QWidget#toolNavigation QToolButton:checked { background: rgba(255,255,255,180); border-color: rgba(255,255,255,230); color: #3f6087; font-weight: 600; }
|
||||
QWidget#toolNavigation QToolButton:hover { background: #f0f4fa; }
|
||||
QLabel#statusLabel { color: #49616f; }
|
||||
QTextEdit { padding: 5px; font-family: Consolas, "Courier New", monospace; }
|
||||
QTextEdit, QPlainTextEdit { background: #ffffff; border: 1px solid #dce5ef; border-radius: 6px; }
|
||||
QTabWidget::pane { border: none; background: transparent; padding: 0; }
|
||||
QTabBar::tab { background: transparent; color: #7d8fa7; padding: 9px 15px; border-bottom: 2px solid transparent; }
|
||||
QTabBar::tab:selected { color: #466c98; border-bottom-color: #86a4c7; }
|
||||
QMenu::item { padding: 7px 20px; }
|
||||
QMenu::item:selected { background: #e9f1fb; }
|
||||
QScrollBar:vertical { background: #f8fafd; width: 12px; }
|
||||
QScrollBar::handle:vertical { background: #ccd7e5; min-height: 25px; border-radius: 5px; }
|
||||
QScrollBar:horizontal { background: #f6f8fb; height: 10px; border: none; margin: 0; }
|
||||
QScrollBar::handle:horizontal { background: #c9d6e7; min-width: 28px; border-radius: 4px; }
|
||||
QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal { width: 0; height: 0; border: none; }
|
||||
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal { background: transparent; }
|
||||
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { width: 0; height: 0; border: none; }
|
||||
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { background: transparent; }
|
||||
QTableCornerButton::section { background: #f1f5fa; border: none; }
|
||||
QPushButton[appearance="quiet"], QToolButton[appearance="quiet"] { background: transparent; border: 1px solid transparent; color: #6a809d; padding: 3px 6px; }
|
||||
QPushButton[appearance="quiet"]:hover, QToolButton[appearance="quiet"]:hover { background: rgba(255,255,255,115); border-color: rgba(255,255,255,180); }
|
||||
QPushButton[appearance="quiet"]:disabled { background: transparent; color: #a1adbc; }
|
||||
QToolButton::menu-indicator { width: 0; height: 0; }
|
||||
QPushButton[appearance="batch"] { background: rgba(255,255,255,120); border: 1px solid rgba(255,255,255,190); border-radius: 9px; color: #617c9e; min-height: 30px; }
|
||||
QPushButton[appearance="batch"]:disabled { background: rgba(255,255,255,40); border-color: rgba(255,255,255,100); color: #9aabba; }
|
||||
QLabel#taskCount, QLabel#planSummary { color: #7e91aa; font-size: 11px; }
|
||||
QLabel#planFindResult { color: #657f9f; font-size: 11px; padding: 0 4px; }
|
||||
QLabel#planSaveState { color: #81968d; font-size: 11px; padding: 3px 5px; }
|
||||
QLabel#planSaveState[tone="pending"] { color: #9c7a43; background: rgba(255,247,226,170); border-radius: 5px; }
|
||||
QLabel#tableEmptyState { color: #8a9cb2; font-family: "Segoe UI", "Microsoft YaHei UI"; font-size: 12px; background: #ffffff; padding: 12px; }
|
||||
QWidget#planToolbar { background: transparent; border: none; }
|
||||
QLineEdit#findTargetText, QLineEdit#taskSearch { background: rgba(255,255,255,125); border: 1px solid rgba(255,255,255,190); border-radius: 8px; padding: 0 8px; }
|
||||
QPushButton#saveTargetPlan { color: #56759b; background: rgba(255,255,255,160); border: 1px solid #cfdaea; font-weight: 600; }
|
||||
QPushButton#saveTargetPlan:disabled { color: #7f8e9f; border-color: #d2dce7; background: rgba(242,246,250,220); }
|
||||
QListWidget::item { margin: 3px 0; border-radius: 10px; padding: 0; }
|
||||
QMainWindow[acrylicEnabled="true"] QListWidget::item:selected { background: rgba(255,255,255,100); border: 1px solid rgba(255,255,255,210); }
|
||||
QLineEdit:focus, QComboBox:focus { border: 1px solid #8da8ca; background: rgba(255,255,255,225); selection-background-color: #dce9f8; selection-color: #355576; }
|
||||
QLineEdit#findTargetText:focus, QLineEdit#taskSearch:focus { border-color: #93acca; background: rgba(255,255,255,210); }
|
||||
QPushButton:focus, QToolButton:focus { border: 1px solid #8da8ca; }
|
||||
QPushButton:pressed, QToolButton:pressed { background: #dde7f3; }
|
||||
QPushButton#quickRunButton:pressed, QPushButton#recoverQuickRunButton:pressed, QPushButton#retryTaskItems:pressed, QPushButton#startNewRoundButton:pressed, QPushButton#stopQueueButton:pressed { background: #334b66; }
|
||||
QTableView { outline: none; }
|
||||
QTableView::item:selected { background: #e6eef8; color: #294969; }
|
||||
QTableView::item:focus { border: 1px solid #9bb3d0; }
|
||||
QToolButton[appearance="quiet"]:checked { background: rgba(255,255,255,155); border-color: rgba(255,255,255,220); color: #3f638e; }
|
||||
"""
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Model-based editable target plan; filtering never changes saved identities."""
|
||||
from dataclasses import replace
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, QSortFilterProxyModel, Qt, Signal
|
||||
from PySide6.QtWidgets import QAbstractItemView, QHeaderView, QTableView
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, QSortFilterProxyModel, Qt, Signal,QPersistentModelIndex
|
||||
from PySide6.QtWidgets import QAbstractItemView, QHeaderView, QTableView,QLabel,QStyledItemDelegate,QLineEdit,QAbstractItemDelegate
|
||||
|
||||
HEADERS = ('替换', '原理图', '图页', '位号', '旧料号', '原 Value', '新料号', '自定义 Value', '自定义内容', '同步 NC')
|
||||
CHECK_FIELDS = {0: 'enabled', 7: 'custom_value_enabled', 9: 'sync_nc'}
|
||||
@@ -33,6 +33,12 @@ class TargetPlanModel(QAbstractTableModel):
|
||||
def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole):
|
||||
if role == Qt.ItemDataRole.DisplayRole:
|
||||
return HEADERS[section] if orientation == Qt.Orientation.Horizontal else section + 1
|
||||
if role == Qt.ItemDataRole.ToolTipRole and orientation==Qt.Orientation.Horizontal:
|
||||
return ('勾选的位号会纳入已保存的替换计划;行选中用于批量编辑。',
|
||||
'原理图名称,只读。','图页编号,只读。','器件位号,只读;完整 UID 在单元格提示中。',
|
||||
'当前工程的原料号,只读。','原始 Value,只读。','可编辑的新料号;修改后需要保存计划。',
|
||||
'启用本行自定义 Value,优先于工程级 Value 策略。',
|
||||
'本行自定义 Value 内容。','按本行配置是否同步 NC。')[section]
|
||||
def data(self, index, role=Qt.ItemDataRole.DisplayRole):
|
||||
if not index.isValid():
|
||||
return None
|
||||
@@ -45,7 +51,10 @@ class TargetPlanModel(QAbstractTableModel):
|
||||
return ('', t.schematic_name, t.sheet_number, t.refdes, t.old_part_number,
|
||||
t.old_value, row.new_part_number, '', row.custom_value, '')[col]
|
||||
if role == Qt.ItemDataRole.ToolTipRole:
|
||||
return f'{t.project_path}\n{t.schematic_name}:{t.sheet_number} | {t.refdes} | UID {t.uid}'
|
||||
content=self.data(index,Qt.ItemDataRole.DisplayRole)
|
||||
if col in CHECK_FIELDS:content='开启'if getattr(row,CHECK_FIELDS[col])else'关闭'
|
||||
return (f'{HEADERS[col]}:{content or "未设置"}\n'
|
||||
f'{t.schematic_name}:{t.sheet_number} | {t.refdes} | UID {t.uid}\n{t.project_path}')
|
||||
def flags(self, index):
|
||||
if not index.isValid():
|
||||
return Qt.ItemFlag.NoItemFlags
|
||||
@@ -108,11 +117,32 @@ class TargetFilter(QSortFilterProxyModel):
|
||||
def filterAcceptsRow(self, row, parent):
|
||||
return not self.query or self.query in self.sourceModel().search_text[row]
|
||||
|
||||
|
||||
class PlanEditorDelegate(QStyledItemDelegate):
|
||||
"""Expose uncommitted editor text without changing Escape/cancel semantics."""
|
||||
def createEditor(self,parent,option,index):
|
||||
editor=super().createEditor(parent,option,index)
|
||||
if isinstance(editor,QLineEdit):
|
||||
view=self.parent()
|
||||
view._active_editor=(editor,QPersistentModelIndex(index))
|
||||
editor.textChanged.connect(lambda _:view.editor_activity.emit())
|
||||
return editor
|
||||
|
||||
def destroyEditor(self,editor,index):
|
||||
view=self.parent()
|
||||
if view._active_editor and view._active_editor[0]is editor:
|
||||
view._active_editor=None
|
||||
view.editor_activity.emit()
|
||||
super().destroyEditor(editor,index)
|
||||
|
||||
class TargetTable(QTableView):
|
||||
changed = Signal()
|
||||
editor_activity=Signal()
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setObjectName('targetPlanTable')
|
||||
self._active_editor=None
|
||||
self.setItemDelegate(PlanEditorDelegate(self))
|
||||
self.plan_model = TargetPlanModel(self)
|
||||
self.proxy = TargetFilter(self)
|
||||
self.proxy.setSourceModel(self.plan_model)
|
||||
@@ -120,16 +150,34 @@ class TargetTable(QTableView):
|
||||
self.setSortingEnabled(True)
|
||||
self.sortByColumn(-1, Qt.SortOrder.AscendingOrder)
|
||||
self.setAlternatingRowColors(True)
|
||||
self.setShowGrid(False)
|
||||
self.verticalHeader().setDefaultSectionSize(34)
|
||||
self.setMinimumHeight(160)
|
||||
self.setEditTriggers(QAbstractItemView.EditTrigger.DoubleClicked | QAbstractItemView.EditTrigger.EditKeyPressed)
|
||||
self.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
|
||||
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
|
||||
self.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Interactive)
|
||||
self.setHorizontalScrollMode(QAbstractItemView.ScrollMode.ScrollPerPixel)
|
||||
self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
|
||||
self.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded)
|
||||
header = self.horizontalHeader()
|
||||
# Keep the header and body in one scrollable coordinate system. The
|
||||
# stored header state also preserves a user's column widths/order.
|
||||
header.setSectionResizeMode(QHeaderView.ResizeMode.Interactive)
|
||||
header.setSectionsMovable(True)
|
||||
header.setSectionsClickable(True)
|
||||
header.setHighlightSections(True)
|
||||
header.setStretchLastSection(False)
|
||||
header.setMinimumSectionSize(48)
|
||||
header.setDefaultAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
|
||||
for col, width in enumerate((55, 90, 50, 70, 145, 115, 145, 90, 125, 75)):
|
||||
self.setColumnWidth(col, width)
|
||||
self.dirty = False
|
||||
self._next_match = -1
|
||||
self.plan_model.changed.connect(self._changed)
|
||||
self.empty_hint=QLabel(self.viewport(),objectName='tableEmptyState')
|
||||
self.empty_hint.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.empty_hint.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents)
|
||||
self._update_empty_hint()
|
||||
def _changed(self):
|
||||
self.dirty = True
|
||||
self.changed.emit()
|
||||
@@ -137,8 +185,16 @@ class TargetTable(QTableView):
|
||||
self.plan_model.populate(rows)
|
||||
self._next_match = -1
|
||||
self.dirty = False
|
||||
self._update_empty_hint()
|
||||
def rows(self):
|
||||
return tuple(self.plan_model.rows)
|
||||
def has_pending_editor(self):
|
||||
if not self._active_editor:return False
|
||||
editor,index=self._active_editor
|
||||
return index.isValid()and editor.isVisible()and editor.text()!=str(index.data(Qt.ItemDataRole.EditRole)or'')
|
||||
def cancel_editor(self):
|
||||
if self._active_editor:
|
||||
self.itemDelegate().closeEditor.emit(self._active_editor[0],QAbstractItemDelegate.EndEditHint.RevertModelCache)
|
||||
def rowCount(self):
|
||||
return self.proxy.rowCount()
|
||||
|
||||
@@ -156,7 +212,18 @@ class TargetTable(QTableView):
|
||||
else:
|
||||
self.proxy.invalidateFilter()
|
||||
self._next_match = -1
|
||||
self._update_empty_hint()
|
||||
return self.rowCount()
|
||||
|
||||
def _update_empty_hint(self):
|
||||
self.empty_hint.setText('没有匹配的位号\n换个关键词,或清空搜索。'if self.proxy.query else
|
||||
'暂无位号计划\n导入 BOM,或添加规则后采集位号。')
|
||||
self.empty_hint.setGeometry(self.viewport().rect())
|
||||
self.empty_hint.setVisible(self.rowCount()==0)
|
||||
|
||||
def resizeEvent(self,event):
|
||||
super().resizeEvent(event)
|
||||
if hasattr(self,'empty_hint'):self._update_empty_hint()
|
||||
def find_next(self):
|
||||
if not self.rowCount():
|
||||
return None
|
||||
|
||||
@@ -6,8 +6,49 @@ from collections.abc import Callable
|
||||
import re
|
||||
from typing import Iterable
|
||||
|
||||
from PySide6.QtCore import Qt, QSignalBlocker, Signal
|
||||
from PySide6.QtWidgets import QComboBox, QGridLayout, QLabel, QLineEdit, QListWidget, QListWidgetItem, QPushButton, QVBoxLayout, QWidget
|
||||
from PySide6.QtCore import Qt, QSignalBlocker, Signal, QSize, QRect
|
||||
from PySide6.QtGui import QColor,QFont,QIcon
|
||||
from PySide6.QtWidgets import (QComboBox,QHBoxLayout,QLabel,QLineEdit,QListWidget,
|
||||
QListWidgetItem,QPushButton,QVBoxLayout,QWidget,QToolButton,QMenu,
|
||||
QStyledItemDelegate,QStyleOptionViewItem,QStyle,QApplication)
|
||||
from .command_menu import CommandMenu
|
||||
|
||||
|
||||
class TaskItemDelegate(QStyledItemDelegate):
|
||||
def sizeHint(self,option,index):
|
||||
return QSize(180,76)
|
||||
|
||||
def paint(self,painter,option,index):
|
||||
opt=QStyleOptionViewItem(option)
|
||||
self.initStyleOption(opt,index)
|
||||
text=str(index.data(Qt.ItemDataRole.DisplayRole)or'').splitlines()
|
||||
title=text[0]if text else '';status=text[1]if len(text)>1 else ''
|
||||
parts=title.split('. ',1)
|
||||
order=parts[0]if len(parts)==2 and parts[0].isdigit()else ''
|
||||
name=parts[1]if order else title
|
||||
names=name.replace('\\','/').split('/')
|
||||
if len(names)>1:
|
||||
leaf=names[-1][:-4]if names[-1].lower().endswith('.prj')else names[-1]
|
||||
if leaf==names[-2]:name=leaf
|
||||
picture=QIcon(index.data(Qt.ItemDataRole.DecorationRole));opt.text='';opt.icon=QIcon()
|
||||
style=option.widget.style()if option.widget else QApplication.style()
|
||||
style.drawControl(QStyle.ControlElement.CE_ItemViewItem,opt,painter,option.widget)
|
||||
painter.save()
|
||||
rect=option.rect.adjusted(12,11,-12,-10)
|
||||
picture.paint(painter,QRect(rect.left(),rect.top()+7,20,20))
|
||||
left=rect.left()+31;available=rect.right()-left-(24 if order else 0)
|
||||
font=QFont(option.font);font.setWeight(QFont.Weight.DemiBold);painter.setFont(font)
|
||||
painter.setPen(QColor('#35577d')if option.state&QStyle.StateFlag.State_Selected else QColor('#526983'))
|
||||
label=painter.fontMetrics().elidedText(name,Qt.TextElideMode.ElideRight,available)
|
||||
painter.drawText(QRect(left,rect.top(),available,23),Qt.AlignmentFlag.AlignVCenter,label)
|
||||
font.setWeight(QFont.Weight.Normal);font.setPointSizeF(max(8,option.font.pointSizeF()-1));painter.setFont(font)
|
||||
colors={'执行中':'#8a744d','失败':'#a15f59','已完成':'#638775','待执行':'#6b8ba8'}
|
||||
painter.setPen(QColor(colors.get(status,'#8999ac')))
|
||||
painter.drawText(QRect(left,rect.top()+27,available,19),Qt.AlignmentFlag.AlignVCenter,status)
|
||||
if order:
|
||||
painter.setPen(QColor('#94a4b8'))
|
||||
painter.drawText(QRect(rect.right()-20,rect.top()+2,20,19),Qt.AlignmentFlag.AlignRight,order)
|
||||
painter.restore()
|
||||
|
||||
|
||||
class TaskList(QWidget):
|
||||
@@ -16,8 +57,11 @@ class TaskList(QWidget):
|
||||
def __init__(self, on_open: Callable[[str], None]) -> None:
|
||||
super().__init__()
|
||||
self.setObjectName("taskNavigation")
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True)
|
||||
self._tasks = ()
|
||||
self._selected_task_id = None
|
||||
from .icons import icon
|
||||
self._project_icon = icon('project')
|
||||
self.search = QLineEdit(objectName='taskSearch')
|
||||
self.search.setPlaceholderText('搜索任务名称、目录、备注')
|
||||
self.search.setClearButtonEnabled(True)
|
||||
@@ -34,6 +78,7 @@ class TaskList(QWidget):
|
||||
self.filter.setVisible(False)
|
||||
self.filter.setMaximumHeight(0)
|
||||
self.list = QListWidget(objectName="taskList")
|
||||
self.list.setItemDelegate(TaskItemDelegate(self.list))
|
||||
self.list.setTextElideMode(Qt.TextElideMode.ElideRight)
|
||||
self.list.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||
self.new_button = QPushButton("新建", objectName="newTaskButton")
|
||||
@@ -44,23 +89,46 @@ class TaskList(QWidget):
|
||||
self.queue_button.setToolTip('按保存的执行顺序执行本批全部任务,不受搜索和显示排序影响。')
|
||||
self.up_button = QPushButton("上移任务", objectName="moveTaskUp")
|
||||
self.down_button = QPushButton("下移任务", objectName="moveTaskDown")
|
||||
actions = QGridLayout()
|
||||
actions.addWidget(self.new_button, 0, 0)
|
||||
actions.addWidget(self.edit_button, 0, 1)
|
||||
actions.addWidget(self.delete_button, 1, 0)
|
||||
actions.addWidget(self.restore_button, 1, 1)
|
||||
actions.addWidget(self.up_button, 2, 0)
|
||||
actions.addWidget(self.down_button, 2, 1)
|
||||
actions.addWidget(self.queue_button, 3, 0, 1, 2)
|
||||
self.new_button.setProperty('appearance','quiet')
|
||||
self.new_button.setText('新建任务')
|
||||
self.new_button.setToolTip('从目录创建工程任务')
|
||||
self.manage_menu=CommandMenu(self)
|
||||
for button in (self.edit_button,self.restore_button,self.up_button,self.down_button):
|
||||
self.manage_menu.add_button(button)
|
||||
self.manage_menu.addSeparator()
|
||||
self.manage_menu.add_button(self.delete_button)
|
||||
self.manage_button=QToolButton(objectName='taskManageMenu')
|
||||
self.manage_button.setText('任务管理')
|
||||
self.manage_button.setIcon(icon('more'))
|
||||
self.manage_button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
|
||||
self.manage_button.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||
self.manage_button.setMenu(self.manage_menu)
|
||||
self.manage_button.setProperty('appearance','quiet')
|
||||
self.sort_menu=QMenu(self)
|
||||
for i in range(self.sort.count()):
|
||||
action=self.sort_menu.addAction(self.sort.itemText(i));action.setCheckable(True)
|
||||
action.triggered.connect(lambda checked=False,index=i:self.sort.setCurrentIndex(index)if self.sort.isEnabled()else None)
|
||||
self.sort_menu.aboutToShow.connect(lambda a=action,index=i:(a.setChecked(self.sort.currentIndex()==index),a.setEnabled(self.sort.isEnabled())))
|
||||
self.sort.setParent(self)
|
||||
self.sort.hide()
|
||||
sort_button=QToolButton(objectName='taskSortMenu');sort_button.setIcon(icon('sort'))
|
||||
sort_button.setToolTip('显示排序不改变实际执行顺序')
|
||||
sort_button.setMenu(self.sort_menu);sort_button.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
|
||||
sort_button.setProperty('appearance','quiet')
|
||||
heading=QHBoxLayout();heading.addWidget(QLabel('工程任务',objectName='taskSectionTitle'));heading.addStretch();heading.addWidget(self.new_button)
|
||||
batch=QHBoxLayout();batch.addWidget(self.count,1);batch.addWidget(sort_button)
|
||||
footer=QHBoxLayout();footer.addWidget(self.recycle_button);footer.addStretch();footer.addWidget(self.manage_button)
|
||||
self.recycle_button.setProperty('appearance','quiet')
|
||||
self.queue_button.setProperty('appearance','batch')
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(8, 8, 8, 8)
|
||||
layout.addWidget(QLabel('任务', objectName='taskSectionTitle'))
|
||||
layout.setContentsMargins(10, 14, 10, 10)
|
||||
layout.setSpacing(11)
|
||||
layout.addLayout(heading)
|
||||
layout.addWidget(self.search)
|
||||
layout.addWidget(self.sort)
|
||||
layout.addWidget(self.recycle_button)
|
||||
layout.addWidget(self.count)
|
||||
layout.addLayout(batch)
|
||||
layout.addWidget(self.list, 1)
|
||||
layout.addLayout(actions)
|
||||
layout.addWidget(self.queue_button)
|
||||
layout.addLayout(footer)
|
||||
def selected():
|
||||
self._selected_task_id = self.current_task_id()
|
||||
on_open(self._selected_task_id or '')
|
||||
@@ -111,6 +179,7 @@ class TaskList(QWidget):
|
||||
'completed': '已完成', 'failed': '失败', 'deleted': '已删除'}
|
||||
item = QListWidgetItem(prefix + str(getattr(task, "name")) + f"\n{labels.get(status, status)}")
|
||||
item.setData(Qt.ItemDataRole.UserRole, str(getattr(task, "task_id")))
|
||||
item.setIcon(self._project_icon)
|
||||
item.setToolTip(f'{task.name}\n{task.discovery_root or ""}\n{task.note}'.strip())
|
||||
self.list.addItem(item)
|
||||
if getattr(task, "task_id") == selected:
|
||||
|
||||