ms-components 0.7.1__tar.gz → 0.7.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ms_components-0.7.1 → ms_components-0.7.3}/PKG-INFO +1 -1
- ms_components-0.7.3/src/ms_components/icons.py +40 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_dockwidget/resources/icons/__init__.py +2 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/jobs.py +14 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/models.py +1 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/polling.py +1 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/resources.py +3 -9
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/widget.py +5 -18
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_stepper.py +70 -49
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/action_header.py +3 -15
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/cell_delegate.py +22 -15
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/smart_table_view.py +30 -22
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/table_config.py +5 -2
- ms_components-0.7.3/src/ms_components/ms_table/table_interaction.py +75 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/table_model.py +19 -13
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_tutorial/controller.py +8 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/theme.py +5 -2
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components.egg-info/PKG-INFO +1 -1
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components.egg-info/SOURCES.txt +2 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components.egg-info/scm_file_list.json +2 -0
- ms_components-0.7.3/src/ms_components.egg-info/scm_version.json +8 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_molsuite_monitor_widgets.py +15 -0
- ms_components-0.7.3/tests/test_stepper.py +24 -0
- ms_components-0.7.1/src/ms_components/ms_table/table_interaction.py +0 -42
- ms_components-0.7.1/src/ms_components.egg-info/scm_version.json +0 -8
- {ms_components-0.7.1 → ms_components-0.7.3}/.github/workflows/docs.yml +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/.github/workflows/publish.yml +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/.gitignore +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/LICENSE +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/MANIFEST.in +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/README.md +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/examples/tutorial_demo.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/examples/tutorial_demo.toml +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/licenses/lucide-LICENSE.txt +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/licenses/qt-themes-LICENSE.txt +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/pyproject.toml +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/setup.cfg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/__init__.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/backdrop.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/base.qss +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/chips.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ketcher.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/labels.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/listview.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_dockwidget/__init__.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_dockwidget/resources/__init__.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_dockwidget/resources/icons/folder.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_dockwidget/widget.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_executors.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/__init__.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/bridge.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/config.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/detail.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/formatting.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/icons/cpu.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/icons/gpu.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/icons/memory.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/palette.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_monitor/widget.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_projects/__init__.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_projects/app.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_projects/backend.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_projects/browser.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_projects/scratch.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_projects/widget.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/__init__.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/command_line.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/actions.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/box.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/center.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/display.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/export.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/hide.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/hydrogens-polar.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/hydrogens.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/menu.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/orient.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/presets.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/rock.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/save.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/selection.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/settings.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/style.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/icons/zoom.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/plugins.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_pymol/scene.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_settings/__init__.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_settings/panel.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/__init__.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/column_panel.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/example_usage.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/filter_panel.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/icons/columns.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/icons/export.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/icons/filter.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/icons/menu.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/icons/reload.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/icons/search.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/icons/settings.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/icons/sort-asc.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/icons/sort-desc.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/icons/sort.svg +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/metric_filter_bar.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/pagination_control.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/query_builder.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/session_provider.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/sort_panel.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/test_external_filters.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_table/test_toolbar.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_tutorial/__init__.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_tutorial/bindings.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_tutorial/models.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/ms_tutorial/overlay.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/opengl.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/pagination.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/palettes.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/step_dialog.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/tool_panel.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components/wheel.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components.egg-info/dependency_links.txt +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components.egg-info/requires.txt +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/src/ms_components.egg-info/top_level.txt +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/conftest.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_app_settings.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_chips.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_dock_window.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_executors_ui.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_ketcher.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_molsuite_monitor_bridge.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_monitor_config.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_ms_projects_widget.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_opengl.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_optional_integrations.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_progress_column.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_project_browser.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_pymol_command_line.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_pymol_grid.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_pymol_scene.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_pymol_toolbar.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_query_builder_keyset.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_shift_hscroll.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_split_button_style.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_step_dialog.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_table_autofill_lifecycle.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_table_interaction.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_table_toolbar.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_table_view_state.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_theme_contrast.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_theme_menu.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_tool_panel.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/tests/test_tutorial.py +0 -0
- {ms_components-0.7.1 → ms_components-0.7.3}/zensical.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ms_components
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.3
|
|
4
4
|
Summary: PySide6 UI components for MolSuite: smart table, project browser, job monitor, PyMOL dock, steppers.
|
|
5
5
|
Author: Mario S. Valdés-Tresanco, Mario E. Valdés-Tresanco
|
|
6
6
|
License-Expression: MIT
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""SVG icons recoloured (currentColor → a palette colour) and rendered once per (file, colour, size, dpr).
|
|
2
|
+
|
|
3
|
+
A theme change asks for a new colour, so it is a new key: nothing to invalidate.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from functools import lru_cache
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from PySide6.QtCore import QByteArray, QSize, Qt
|
|
12
|
+
from PySide6.QtGui import QIcon, QPainter, QPixmap
|
|
13
|
+
from PySide6.QtSvg import QSvgRenderer
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# ponytail: unbounded in practice (icons x themes x sizes is a few hundred); maxsize caps a leak.
|
|
17
|
+
@lru_cache(maxsize=1024)
|
|
18
|
+
def svg_pixmap(path: str | Path, color_hex: str, width: int, height: int, dpr: float) -> QPixmap:
|
|
19
|
+
svg = Path(path).read_bytes().replace(b"currentColor", color_hex.encode())
|
|
20
|
+
pixmap = QPixmap(max(1, round(width * dpr)), max(1, round(height * dpr)))
|
|
21
|
+
pixmap.fill(Qt.GlobalColor.transparent)
|
|
22
|
+
with QPainter(pixmap) as painter:
|
|
23
|
+
QSvgRenderer(QByteArray(svg)).render(painter)
|
|
24
|
+
pixmap.setDevicePixelRatio(dpr)
|
|
25
|
+
return pixmap
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@lru_cache(maxsize=1024)
|
|
29
|
+
def svg_icon(path: str | Path, color_hex: str, width: int, height: int, dpr: float) -> QIcon:
|
|
30
|
+
return QIcon(svg_pixmap(path, color_hex, width, height, dpr))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def widget_svg_icon(widget, path: str | Path, size: QSize | None = None) -> QIcon:
|
|
34
|
+
"""`path` in the widget's button-text colour at its device pixel ratio (16 px by default)."""
|
|
35
|
+
size = size or QSize(16, 16)
|
|
36
|
+
return svg_icon(str(path), widget.palette().buttonText().color().name(), size.width(), size.height(),
|
|
37
|
+
max(1.0, widget.devicePixelRatioF()))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
__all__ = ["svg_icon", "svg_pixmap", "widget_svg_icon"]
|
|
@@ -5,6 +5,8 @@ apart) and the time left at the speed of the last minutes. Active jobs come firs
|
|
|
5
5
|
"""
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
|
+
from dataclasses import replace
|
|
9
|
+
|
|
8
10
|
from PySide6.QtCore import QEasingCurve, Property, QPropertyAnimation, QRectF, QSize, Qt, Signal
|
|
9
11
|
from PySide6.QtGui import QBrush, QColor, QFont, QFontMetricsF, QLinearGradient, QPainter, QPalette, QPen
|
|
10
12
|
from PySide6.QtWidgets import QAbstractItemView, QApplication, QListWidget, QListWidgetItem, QStyle, QStyledItemDelegate, QWidget
|
|
@@ -223,6 +225,17 @@ class _JobRow(QStyledItemDelegate):
|
|
|
223
225
|
p.restore()
|
|
224
226
|
|
|
225
227
|
|
|
228
|
+
def _with_what_they_wait_for(jobs: list[JobMonitorState]) -> list[JobMonitorState]:
|
|
229
|
+
"""A waiting job that came after listed jobs still going says it waits for them, by name."""
|
|
230
|
+
going = {job.job_id: job.title or job.name for job in jobs if not job.is_terminal}
|
|
231
|
+
said = []
|
|
232
|
+
for job in jobs:
|
|
233
|
+
names = [going[key] for key in job.after if key in going and key != job.job_id]
|
|
234
|
+
waits = job.status == "waiting" and names and not job.note
|
|
235
|
+
said.append(replace(job, note="waits for " + ", ".join(dict.fromkeys(names))) if waits else job)
|
|
236
|
+
return said
|
|
237
|
+
|
|
238
|
+
|
|
226
239
|
class JobList(QListWidget):
|
|
227
240
|
"""The jobs, as polled, active first. `job_selected` says the job picked by the user."""
|
|
228
241
|
|
|
@@ -244,6 +257,7 @@ class JobList(QListWidget):
|
|
|
244
257
|
def set_jobs(self, jobs: list[JobMonitorState]) -> None:
|
|
245
258
|
"""The rows follow `jobs`; the selected one stays selected while it is listed."""
|
|
246
259
|
chosen = self.selected_job_id()
|
|
260
|
+
jobs = _with_what_they_wait_for(jobs)
|
|
247
261
|
if [self.item(i).data(_ROLE).job_id for i in range(self.count())] != [job.job_id for job in jobs]:
|
|
248
262
|
self.blockSignals(True)
|
|
249
263
|
self.clear()
|
|
@@ -54,6 +54,7 @@ class JobMonitorState:
|
|
|
54
54
|
note: str = "" # what its source says it is at, while it runs (a campaign: in the queue, how far there)
|
|
55
55
|
canceling: bool = False # canceled, waiting for its other machine to stop it there
|
|
56
56
|
steps: tuple = () # every step its source went through, (epoch seconds, line), quick ones too
|
|
57
|
+
after: tuple = () # the job_ids of the jobs it was submitted after: the list says which it waits for
|
|
57
58
|
chunks_retried: int = 0
|
|
58
59
|
peak_mem_mb: int = 0
|
|
59
60
|
usage: dict = field(default_factory=dict) # what it used, kept once it ended: see ms_flow's JobSnapshot.usage
|
|
@@ -36,6 +36,7 @@ def job_state(job, now: float) -> JobMonitorState:
|
|
|
36
36
|
note=getattr(job, "note", None) or "", # an older ms_flow does not say
|
|
37
37
|
canceling=getattr(job, "canceling", False),
|
|
38
38
|
steps=tuple(getattr(job, "steps", ())),
|
|
39
|
+
after=tuple(getattr(job, "after", None) or ()), # an older ms_flow does not say
|
|
39
40
|
chunks_retried=job.chunks_retried,
|
|
40
41
|
peak_mem_mb=job.peak_mem_mb,
|
|
41
42
|
usage=getattr(job, "usage", None) or {}, # ms_flow < 0.8 does not keep it
|
|
@@ -24,12 +24,12 @@ from dataclasses import dataclass, field
|
|
|
24
24
|
|
|
25
25
|
from pathlib import Path
|
|
26
26
|
|
|
27
|
-
from PySide6.QtCore import
|
|
27
|
+
from PySide6.QtCore import QObject, QPointF, QRectF, Qt, Signal
|
|
28
28
|
from PySide6.QtGui import QColor, QPainter, QPainterPath, QPalette, QPen, QPixmap
|
|
29
|
-
from PySide6.QtSvg import QSvgRenderer
|
|
30
29
|
from PySide6.QtWidgets import (QFrame, QGridLayout, QHBoxLayout, QLabel, QScrollArea, QStackedWidget, QToolButton,
|
|
31
30
|
QToolTip, QVBoxLayout, QWidget)
|
|
32
31
|
|
|
32
|
+
from ms_components.icons import svg_pixmap
|
|
33
33
|
from ms_components.labels import ElidedLabel
|
|
34
34
|
from ms_components.theme import color
|
|
35
35
|
|
|
@@ -517,13 +517,7 @@ class _Asked(QWidget):
|
|
|
517
517
|
|
|
518
518
|
|
|
519
519
|
def _icon(name: str, color_hex: str, size: int, dpr: float) -> QPixmap:
|
|
520
|
-
|
|
521
|
-
pixmap = QPixmap(round(size * dpr), round(size * dpr))
|
|
522
|
-
pixmap.fill(Qt.transparent)
|
|
523
|
-
with QPainter(pixmap) as painter:
|
|
524
|
-
QSvgRenderer(QByteArray(svg)).render(painter)
|
|
525
|
-
pixmap.setDevicePixelRatio(dpr)
|
|
526
|
-
return pixmap
|
|
520
|
+
return svg_pixmap(str(_ICONS / f"{name}.svg"), color_hex, size, size, dpr)
|
|
527
521
|
|
|
528
522
|
|
|
529
523
|
def queue_asked(jobs) -> dict:
|
|
@@ -8,15 +8,15 @@ from dataclasses import dataclass, field, replace
|
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
from typing import Any
|
|
10
10
|
|
|
11
|
+
from ms_components.icons import widget_svg_icon
|
|
11
12
|
from ms_components.labels import ElidedLabel
|
|
12
13
|
from ms_components.ms_dockwidget.widget import MSDockWidget
|
|
13
14
|
from ms_components.opengl import pymol_context_error, pymol_surface_format
|
|
14
15
|
|
|
15
16
|
os.environ.setdefault("QT_API", "pyside6")
|
|
16
17
|
|
|
17
|
-
from PySide6.QtCore import
|
|
18
|
-
from PySide6.QtGui import QAction, QActionGroup, QGuiApplication, QIcon
|
|
19
|
-
from PySide6.QtSvg import QSvgRenderer
|
|
18
|
+
from PySide6.QtCore import QEvent, QSize, Qt, QTimer, Signal
|
|
19
|
+
from PySide6.QtGui import QAction, QActionGroup, QGuiApplication, QIcon
|
|
20
20
|
from PySide6.QtWidgets import (
|
|
21
21
|
QFileDialog,
|
|
22
22
|
QFrame,
|
|
@@ -451,22 +451,9 @@ class PymolControlBar(QFrame):
|
|
|
451
451
|
return action
|
|
452
452
|
|
|
453
453
|
def _toolbar_icon(self, name: str) -> QIcon:
|
|
454
|
-
svg = (_TOOLBAR_ICONS / name).read_bytes().replace(
|
|
455
|
-
b"currentColor", self.palette().buttonText().color().name().encode()
|
|
456
|
-
)
|
|
457
|
-
dpr = max(1.0, self.devicePixelRatioF())
|
|
458
454
|
toolbar = self.toolbar
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
max(1, round(size.width() * dpr)),
|
|
462
|
-
max(1, round(size.height() * dpr)),
|
|
463
|
-
)
|
|
464
|
-
pixmap.setDevicePixelRatio(dpr)
|
|
465
|
-
pixmap.fill(Qt.GlobalColor.transparent)
|
|
466
|
-
painter = QPainter(pixmap)
|
|
467
|
-
QSvgRenderer(QByteArray(svg)).render(painter)
|
|
468
|
-
painter.end()
|
|
469
|
-
return QIcon(pixmap)
|
|
455
|
+
return widget_svg_icon(self, _TOOLBAR_ICONS / name,
|
|
456
|
+
toolbar.iconSize() if toolbar is not None and isValid(toolbar) else None)
|
|
470
457
|
|
|
471
458
|
def _refresh_toolbar_icons(self) -> None:
|
|
472
459
|
for action, icon_name in tuple(self._toolbar_action_icons.items()):
|
|
@@ -633,7 +633,7 @@ class QStepper(QWidget):
|
|
|
633
633
|
title, caption, icon, **kwargs)
|
|
634
634
|
step.changed.connect(self._refresh_headers)
|
|
635
635
|
self._steps.append(step)
|
|
636
|
-
self.
|
|
636
|
+
self._append(step)
|
|
637
637
|
if self._current == -1:
|
|
638
638
|
self.set_current_index(0)
|
|
639
639
|
return step
|
|
@@ -746,6 +746,27 @@ class QStepper(QWidget):
|
|
|
746
746
|
if 0 <= self._current < len(self._steps):
|
|
747
747
|
self._sync_content()
|
|
748
748
|
|
|
749
|
+
def _append(self, step: QStep) -> None:
|
|
750
|
+
"""Add the new step's header and page; the steps already there stay where they are.
|
|
751
|
+
Taking them out and putting them back (a rebuild per step) re-parents and re-polishes
|
|
752
|
+
every widget they hold: 270 ms for the four steps of a docking studio."""
|
|
753
|
+
index = len(self._steps) - 1
|
|
754
|
+
if self.orientation == Orientation.HORIZONTAL:
|
|
755
|
+
if index:
|
|
756
|
+
self._header.addWidget(self._make_hconnector(), 1, self._header_align)
|
|
757
|
+
self._header.addWidget(self._header_item(index), 0, self._header_align)
|
|
758
|
+
self._stack.addWidget(step)
|
|
759
|
+
else:
|
|
760
|
+
self._column.insertWidget(index, self._vertical_block(index, step)) # before the stretch
|
|
761
|
+
self._refresh_headers()
|
|
762
|
+
self._refresh_nav()
|
|
763
|
+
|
|
764
|
+
def _header_item(self, index: int) -> "_HeaderItem":
|
|
765
|
+
item = _HeaderItem(self.theme.diameter, self.alternative_labels)
|
|
766
|
+
item.clicked.connect(lambda idx=index: self._on_header_clicked(idx))
|
|
767
|
+
self._header_items.append(item)
|
|
768
|
+
return item
|
|
769
|
+
|
|
749
770
|
def _make_hconnector(self) -> QWidget:
|
|
750
771
|
line = QFrame()
|
|
751
772
|
line.setObjectName("stepperConnector")
|
|
@@ -774,15 +795,11 @@ class QStepper(QWidget):
|
|
|
774
795
|
align = (Qt.AlignmentFlag.AlignTop if self.alternative_labels
|
|
775
796
|
else Qt.AlignmentFlag.AlignVCenter)
|
|
776
797
|
|
|
798
|
+
self._header, self._header_align = h, align
|
|
777
799
|
for i, step in enumerate(self._steps):
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
self.
|
|
781
|
-
h.addWidget(item, 0, align)
|
|
782
|
-
if i < len(self._steps) - 1:
|
|
783
|
-
conn = self._make_hconnector()
|
|
784
|
-
h.addWidget(conn, 1, align if self.alternative_labels
|
|
785
|
-
else Qt.AlignmentFlag.AlignVCenter)
|
|
800
|
+
if i:
|
|
801
|
+
h.addWidget(self._make_hconnector(), 1, align)
|
|
802
|
+
h.addWidget(self._header_item(i), 0, align)
|
|
786
803
|
|
|
787
804
|
self._root.addWidget(header)
|
|
788
805
|
|
|
@@ -803,51 +820,55 @@ class QStepper(QWidget):
|
|
|
803
820
|
v.setContentsMargins(0, 0, 0, 0)
|
|
804
821
|
v.setSpacing(0)
|
|
805
822
|
|
|
823
|
+
self._column = v
|
|
806
824
|
for i, step in enumerate(self._steps):
|
|
807
|
-
|
|
808
|
-
row = QHBoxLayout(block)
|
|
809
|
-
row.setContentsMargins(0, 0, 0, 0)
|
|
810
|
-
row.setSpacing(8)
|
|
811
|
-
|
|
812
|
-
rail = _VRail(self.theme.diameter, self.theme.connector)
|
|
813
|
-
rail.clicked.connect(lambda idx=i: self._on_header_clicked(idx))
|
|
814
|
-
self._rails.append(rail)
|
|
815
|
-
|
|
816
|
-
right = QVBoxLayout()
|
|
817
|
-
right.setContentsMargins(0, 0, 0, 0)
|
|
818
|
-
right.setSpacing(2)
|
|
819
|
-
|
|
820
|
-
title_lbl = QLabel(step.title)
|
|
821
|
-
caption_lbl = QLabel(step.caption)
|
|
822
|
-
title_lbl.setObjectName("stepperTitle")
|
|
823
|
-
caption_lbl.setObjectName("stepperCaption")
|
|
824
|
-
cf = QFont(caption_lbl.font())
|
|
825
|
-
cf.setPointSizeF(max(8.0, cf.pointSizeF() - 1.5))
|
|
826
|
-
caption_lbl.setFont(cf)
|
|
827
|
-
caption_lbl.setVisible(bool(step.caption))
|
|
828
|
-
rail._title_lbl = title_lbl # type: ignore[attr-defined]
|
|
829
|
-
rail._caption_lbl = caption_lbl # type: ignore[attr-defined]
|
|
830
|
-
|
|
831
|
-
if self.inline_label:
|
|
832
|
-
head = QHBoxLayout()
|
|
833
|
-
head.setContentsMargins(0, 0, 0, 0)
|
|
834
|
-
head.setSpacing(8)
|
|
835
|
-
head.addWidget(title_lbl)
|
|
836
|
-
head.addWidget(caption_lbl)
|
|
837
|
-
head.addStretch(1)
|
|
838
|
-
right.addLayout(head)
|
|
839
|
-
else:
|
|
840
|
-
right.addWidget(title_lbl)
|
|
841
|
-
right.addWidget(caption_lbl)
|
|
842
|
-
right.addWidget(step)
|
|
843
|
-
|
|
844
|
-
row.addWidget(rail, 0, Qt.AlignmentFlag.AlignTop)
|
|
845
|
-
row.addLayout(right, 1)
|
|
846
|
-
v.addWidget(block)
|
|
825
|
+
v.addWidget(self._vertical_block(i, step))
|
|
847
826
|
|
|
848
827
|
v.addStretch(1)
|
|
849
828
|
self._root.addWidget(container, 1)
|
|
850
829
|
|
|
830
|
+
def _vertical_block(self, i: int, step: QStep) -> QWidget:
|
|
831
|
+
block = QWidget()
|
|
832
|
+
row = QHBoxLayout(block)
|
|
833
|
+
row.setContentsMargins(0, 0, 0, 0)
|
|
834
|
+
row.setSpacing(8)
|
|
835
|
+
|
|
836
|
+
rail = _VRail(self.theme.diameter, self.theme.connector)
|
|
837
|
+
rail.clicked.connect(lambda idx=i: self._on_header_clicked(idx))
|
|
838
|
+
self._rails.append(rail)
|
|
839
|
+
|
|
840
|
+
right = QVBoxLayout()
|
|
841
|
+
right.setContentsMargins(0, 0, 0, 0)
|
|
842
|
+
right.setSpacing(2)
|
|
843
|
+
|
|
844
|
+
title_lbl = QLabel(step.title)
|
|
845
|
+
caption_lbl = QLabel(step.caption)
|
|
846
|
+
title_lbl.setObjectName("stepperTitle")
|
|
847
|
+
caption_lbl.setObjectName("stepperCaption")
|
|
848
|
+
cf = QFont(caption_lbl.font())
|
|
849
|
+
cf.setPointSizeF(max(8.0, cf.pointSizeF() - 1.5))
|
|
850
|
+
caption_lbl.setFont(cf)
|
|
851
|
+
caption_lbl.setVisible(bool(step.caption))
|
|
852
|
+
rail._title_lbl = title_lbl # type: ignore[attr-defined]
|
|
853
|
+
rail._caption_lbl = caption_lbl # type: ignore[attr-defined]
|
|
854
|
+
|
|
855
|
+
if self.inline_label:
|
|
856
|
+
head = QHBoxLayout()
|
|
857
|
+
head.setContentsMargins(0, 0, 0, 0)
|
|
858
|
+
head.setSpacing(8)
|
|
859
|
+
head.addWidget(title_lbl)
|
|
860
|
+
head.addWidget(caption_lbl)
|
|
861
|
+
head.addStretch(1)
|
|
862
|
+
right.addLayout(head)
|
|
863
|
+
else:
|
|
864
|
+
right.addWidget(title_lbl)
|
|
865
|
+
right.addWidget(caption_lbl)
|
|
866
|
+
right.addWidget(step)
|
|
867
|
+
|
|
868
|
+
row.addWidget(rail, 0, Qt.AlignmentFlag.AlignTop)
|
|
869
|
+
row.addLayout(right, 1)
|
|
870
|
+
return block
|
|
871
|
+
|
|
851
872
|
# =====================================================================
|
|
852
873
|
# State / colour refresh
|
|
853
874
|
# =====================================================================
|
|
@@ -8,19 +8,18 @@ Requires PySide6.QtSvg.
|
|
|
8
8
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
|
-
from functools import lru_cache
|
|
12
11
|
from pathlib import Path
|
|
13
12
|
from typing import Any
|
|
14
13
|
|
|
15
|
-
from PySide6.QtCore import
|
|
14
|
+
from PySide6.QtCore import QPoint, QRect, Qt, Signal
|
|
16
15
|
from PySide6.QtGui import QDoubleValidator, QPainter, QPixmap
|
|
17
|
-
from PySide6.QtSvg import QSvgRenderer
|
|
18
16
|
from PySide6.QtWidgets import (
|
|
19
17
|
QCheckBox, QComboBox, QFrame, QHBoxLayout,
|
|
20
18
|
QHeaderView, QLabel, QLineEdit, QPushButton, QStyle, QStyleOptionHeader,
|
|
21
19
|
QVBoxLayout, QWidget,
|
|
22
20
|
)
|
|
23
21
|
|
|
22
|
+
from ..icons import svg_pixmap
|
|
24
23
|
from .table_config import ColumnDef, ColumnKind, FilterOperator, FilterSpec, SortSpec, TableConfig
|
|
25
24
|
|
|
26
25
|
_ICONS = Path(__file__).parent / "icons"
|
|
@@ -34,19 +33,8 @@ _ICON_FILES: dict[str, str] = {
|
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
|
|
37
|
-
@lru_cache(maxsize=128)
|
|
38
36
|
def _svg_pixmap(name: str, color_hex: str, size: int, dpr: float) -> QPixmap:
|
|
39
|
-
|
|
40
|
-
svg = (_ICONS / _ICON_FILES[name]).read_bytes().replace(b"currentColor", color_hex.encode())
|
|
41
|
-
renderer = QSvgRenderer(QByteArray(svg))
|
|
42
|
-
actual = max(1, int(size * dpr))
|
|
43
|
-
pixmap = QPixmap(actual, actual)
|
|
44
|
-
pixmap.setDevicePixelRatio(dpr)
|
|
45
|
-
pixmap.fill(Qt.GlobalColor.transparent)
|
|
46
|
-
p = QPainter(pixmap)
|
|
47
|
-
renderer.render(p)
|
|
48
|
-
p.end()
|
|
49
|
-
return pixmap
|
|
37
|
+
return svg_pixmap(str(_ICONS / _ICON_FILES[name]), color_hex, size, size, dpr)
|
|
50
38
|
|
|
51
39
|
|
|
52
40
|
# ── ActionHeader ──────────────────────────────────────────────────────────────
|
|
@@ -56,6 +56,7 @@ Every factory receives `row_data: dict` with the full row
|
|
|
56
56
|
|
|
57
57
|
from __future__ import annotations
|
|
58
58
|
|
|
59
|
+
from functools import lru_cache
|
|
59
60
|
from typing import Any, Callable, Optional
|
|
60
61
|
|
|
61
62
|
from PySide6.QtCore import QModelIndex, QPoint, QRect, QRectF, QSize, Qt
|
|
@@ -74,6 +75,26 @@ from .table_config import ColumnKind
|
|
|
74
75
|
# Rendering helpers
|
|
75
76
|
# ──────────────────────────────────────────────────────────────────────────────
|
|
76
77
|
|
|
78
|
+
# ponytail: keyed by the SVG bytes, so a paint_factory that builds the same SVG for every row renders
|
|
79
|
+
# it once; one that bakes per-row data into it fills the cache (maxsize) and gains nothing.
|
|
80
|
+
@lru_cache(maxsize=512)
|
|
81
|
+
def _svg_to_pixmap(svg_bytes: bytes, width: int, height: int) -> Optional[QPixmap]:
|
|
82
|
+
try:
|
|
83
|
+
from PySide6.QtSvg import QSvgRenderer
|
|
84
|
+
size = QSize(width, height)
|
|
85
|
+
renderer = QSvgRenderer(svg_bytes)
|
|
86
|
+
default_size = renderer.defaultSize()
|
|
87
|
+
render_size = default_size.scaled(size, Qt.KeepAspectRatio) if default_size.isValid() else size
|
|
88
|
+
pixmap = QPixmap(render_size)
|
|
89
|
+
pixmap.fill(Qt.transparent)
|
|
90
|
+
painter = QPainter(pixmap)
|
|
91
|
+
renderer.render(painter, QRectF(0, 0, render_size.width(), render_size.height()))
|
|
92
|
+
painter.end()
|
|
93
|
+
return pixmap
|
|
94
|
+
except Exception:
|
|
95
|
+
return None
|
|
96
|
+
|
|
97
|
+
|
|
77
98
|
def _to_pixmap(source: Any, size: QSize) -> Optional[QPixmap]:
|
|
78
99
|
"""
|
|
79
100
|
Convert several source types into a QPixmap ready to paint.
|
|
@@ -100,21 +121,7 @@ def _to_pixmap(source: Any, size: QSize) -> Optional[QPixmap]:
|
|
|
100
121
|
)
|
|
101
122
|
|
|
102
123
|
if isinstance(source, (bytes, str)):
|
|
103
|
-
|
|
104
|
-
try:
|
|
105
|
-
from PySide6.QtSvg import QSvgRenderer
|
|
106
|
-
svg_bytes = source.encode() if isinstance(source, str) else source
|
|
107
|
-
renderer = QSvgRenderer(svg_bytes)
|
|
108
|
-
default_size = renderer.defaultSize()
|
|
109
|
-
render_size = default_size.scaled(size, Qt.KeepAspectRatio) if default_size.isValid() else size
|
|
110
|
-
pixmap = QPixmap(render_size)
|
|
111
|
-
pixmap.fill(Qt.transparent)
|
|
112
|
-
painter = QPainter(pixmap)
|
|
113
|
-
renderer.render(painter, QRectF(0, 0, render_size.width(), render_size.height()))
|
|
114
|
-
painter.end()
|
|
115
|
-
return pixmap
|
|
116
|
-
except Exception:
|
|
117
|
-
return None
|
|
124
|
+
return _svg_to_pixmap(source.encode() if isinstance(source, str) else source, size.width(), size.height())
|
|
118
125
|
|
|
119
126
|
# QSvgRenderer, or any object with .render(QPainter)
|
|
120
127
|
if hasattr(source, "render"):
|
|
@@ -47,17 +47,17 @@ from pathlib import Path
|
|
|
47
47
|
from typing import Any, Optional
|
|
48
48
|
|
|
49
49
|
from PySide6.QtCore import (
|
|
50
|
-
|
|
50
|
+
QEvent, QItemSelectionModel, QObject, QRunnable, QSize,
|
|
51
51
|
QSortFilterProxyModel, Qt, QThreadPool, QTimer, Signal,
|
|
52
52
|
)
|
|
53
|
-
from PySide6.QtGui import QAction, QIcon
|
|
54
|
-
from PySide6.QtSvg import QSvgRenderer
|
|
53
|
+
from PySide6.QtGui import QAction, QIcon
|
|
55
54
|
from PySide6.QtWidgets import (
|
|
56
55
|
QAbstractItemView, QApplication, QFileDialog, QHBoxLayout,
|
|
57
|
-
QHeaderView, QLabel, QMenu, QPushButton, QSizePolicy, QFrame,
|
|
56
|
+
QHeaderView, QLabel, QMenu, QPushButton, QSizePolicy, QFrame, QStyle, QStyleOptionHeader,
|
|
58
57
|
QTableView, QToolBar, QToolButton, QVBoxLayout, QWidget
|
|
59
58
|
)
|
|
60
59
|
from ..backdrop import Backdrop
|
|
60
|
+
from ..icons import widget_svg_icon
|
|
61
61
|
from .action_header import ActionHeader, FilterPopup, SearchPopup
|
|
62
62
|
from .cell_delegate import CellWidgetDelegate
|
|
63
63
|
from .column_panel import ColumnConfigDialog
|
|
@@ -89,6 +89,25 @@ class _Query(QRunnable):
|
|
|
89
89
|
self._delivery.done.emit(self._finish, result)
|
|
90
90
|
|
|
91
91
|
|
|
92
|
+
class _RowNumberHeader(QHeaderView):
|
|
93
|
+
"""The vertical header: row numbers only, at a fixed row height.
|
|
94
|
+
|
|
95
|
+
QHeaderView.sizeHint() measures up to 200 sections, asking the model for five roles each:
|
|
96
|
+
~1000 calls into Python per relayout, a third of the time a tool switch took. The widest
|
|
97
|
+
number is the last row's, so one section is measured instead.
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
def sizeHint(self) -> QSize:
|
|
101
|
+
model = self.model()
|
|
102
|
+
rows = model.rowCount() if model is not None else 0
|
|
103
|
+
option = QStyleOptionHeader()
|
|
104
|
+
self.initStyleOption(option)
|
|
105
|
+
option.orientation = Qt.Vertical
|
|
106
|
+
option.text = str(model.headerData(rows - 1, Qt.Vertical) or rows) if rows else "0"
|
|
107
|
+
hint = self.style().sizeFromContents(QStyle.CT_HeaderSection, option, QSize(), self)
|
|
108
|
+
return QSize(hint.width(), self.defaultSectionSize())
|
|
109
|
+
|
|
110
|
+
|
|
92
111
|
class SmartTableView(QWidget):
|
|
93
112
|
"""
|
|
94
113
|
Smart table with pagination, filtering, sorting and column configuration.
|
|
@@ -359,7 +378,10 @@ class SmartTableView(QWidget):
|
|
|
359
378
|
if self._config.allow_column_reorder:
|
|
360
379
|
self._header.setSectionsMovable(True)
|
|
361
380
|
|
|
362
|
-
v_header = self._table
|
|
381
|
+
v_header = _RowNumberHeader(Qt.Vertical, self._table)
|
|
382
|
+
v_header.setSectionsClickable(True) # as QTableView's own: a click selects the row
|
|
383
|
+
v_header.setHighlightSections(True)
|
|
384
|
+
self._table.setVerticalHeader(v_header)
|
|
363
385
|
if self._config.row_height:
|
|
364
386
|
v_header.setDefaultSectionSize(self._config.row_height)
|
|
365
387
|
v_header.setVisible(self._config.show_vertical_header)
|
|
@@ -979,23 +1001,9 @@ class SmartTableView(QWidget):
|
|
|
979
1001
|
return action, button
|
|
980
1002
|
|
|
981
1003
|
def _toolbar_icon(self, name: str) -> QIcon:
|
|
982
|
-
"""
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
b"currentColor", self.palette().buttonText().color().name().encode()
|
|
986
|
-
)
|
|
987
|
-
dpr = max(1.0, self.devicePixelRatioF())
|
|
988
|
-
logical_size = self._toolbar.iconSize() if self._toolbar is not None else QSize(16, 16)
|
|
989
|
-
pixmap = QPixmap(
|
|
990
|
-
max(1, round(logical_size.width() * dpr)),
|
|
991
|
-
max(1, round(logical_size.height() * dpr)),
|
|
992
|
-
)
|
|
993
|
-
pixmap.setDevicePixelRatio(dpr)
|
|
994
|
-
pixmap.fill(Qt.GlobalColor.transparent)
|
|
995
|
-
painter = QPainter(pixmap)
|
|
996
|
-
QSvgRenderer(QByteArray(svg)).render(painter)
|
|
997
|
-
painter.end()
|
|
998
|
-
return QIcon(pixmap)
|
|
1004
|
+
"""A currentColor SVG in the live palette (rendered once per colour and size)."""
|
|
1005
|
+
return widget_svg_icon(self, _TOOLBAR_ICONS / name,
|
|
1006
|
+
self._toolbar.iconSize() if self._toolbar is not None else None)
|
|
999
1007
|
|
|
1000
1008
|
def _refresh_toolbar_icons(self) -> None:
|
|
1001
1009
|
for action, icon_name in self._builtin_action_icons.items():
|
|
@@ -176,8 +176,11 @@ class ColumnDef:
|
|
|
176
176
|
|
|
177
177
|
@property
|
|
178
178
|
def display_key(self) -> str:
|
|
179
|
-
"""Unique key used internally (dots replaced)."""
|
|
180
|
-
|
|
179
|
+
"""Unique key used internally (dots replaced). Asked per cell and role on every paint."""
|
|
180
|
+
cached = self.__dict__.get("_display_key")
|
|
181
|
+
if cached is None or cached[0] != self.field:
|
|
182
|
+
cached = self.__dict__["_display_key"] = (self.field, self.field.replace(".", "__"))
|
|
183
|
+
return cached[1]
|
|
181
184
|
|
|
182
185
|
@property
|
|
183
186
|
def is_joined(self) -> bool:
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Table input signals, independent of any viewer or data model."""
|
|
2
|
+
|
|
3
|
+
from PySide6.QtCore import QEvent, QObject, Qt, Signal
|
|
4
|
+
from PySide6.QtWidgets import QAbstractItemView, QWidget
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class _Hub(QObject):
|
|
8
|
+
"""Where every table's `TableInteraction` repeats what it saw, for those that watch a window."""
|
|
9
|
+
|
|
10
|
+
pressed = Signal(object, object, Qt.KeyboardModifiers)
|
|
11
|
+
reselected = Signal(object, object, Qt.KeyboardModifiers)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
_hub: _Hub | None = None
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _the_hub() -> _Hub:
|
|
18
|
+
global _hub
|
|
19
|
+
if _hub is None:
|
|
20
|
+
_hub = _Hub()
|
|
21
|
+
return _hub
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class TableInteraction(QObject):
|
|
25
|
+
"""Observe one Qt table, or the tables under a window, including tables added later.
|
|
26
|
+
|
|
27
|
+
``pressed(view, index, modifiers)`` precedes native selection changes;
|
|
28
|
+
``reselected`` reports a click on an already selected cell.
|
|
29
|
+
|
|
30
|
+
A window hears the tables that have one of their own (every `SmartTableView` has): a filter
|
|
31
|
+
on the whole application, the way it was done before, put each of its events through Python,
|
|
32
|
+
some 40 ms of every big view opened.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
pressed = Signal(object, object, Qt.KeyboardModifiers)
|
|
36
|
+
reselected = Signal(object, object, Qt.KeyboardModifiers)
|
|
37
|
+
|
|
38
|
+
def __init__(self, parent: QWidget):
|
|
39
|
+
super().__init__(parent)
|
|
40
|
+
self._pressed = None
|
|
41
|
+
hub = _the_hub()
|
|
42
|
+
if isinstance(parent, QAbstractItemView):
|
|
43
|
+
parent.viewport().installEventFilter(self)
|
|
44
|
+
else:
|
|
45
|
+
hub.pressed.connect(self._heard_pressed)
|
|
46
|
+
hub.reselected.connect(self._heard_reselected)
|
|
47
|
+
|
|
48
|
+
def _under(self, view) -> bool:
|
|
49
|
+
return view is self.parent() or self.parent().isAncestorOf(view)
|
|
50
|
+
|
|
51
|
+
def _heard_pressed(self, view, index, modifiers) -> None:
|
|
52
|
+
if self._under(view):
|
|
53
|
+
self.pressed.emit(view, index, modifiers)
|
|
54
|
+
|
|
55
|
+
def _heard_reselected(self, view, index, modifiers) -> None:
|
|
56
|
+
if self._under(view):
|
|
57
|
+
self.reselected.emit(view, index, modifiers)
|
|
58
|
+
|
|
59
|
+
def eventFilter(self, watched, event):
|
|
60
|
+
view = self.parent()
|
|
61
|
+
if event.type() == QEvent.Type.MouseButtonPress and event.button() == Qt.MouseButton.LeftButton:
|
|
62
|
+
index = view.indexAt(event.position().toPoint())
|
|
63
|
+
if index.isValid():
|
|
64
|
+
modifiers = event.modifiers()
|
|
65
|
+
self._pressed = (index, modifiers, view.selectionModel().isSelected(index))
|
|
66
|
+
self.pressed.emit(view, index, modifiers)
|
|
67
|
+
_the_hub().pressed.emit(view, index, modifiers)
|
|
68
|
+
elif event.type() == QEvent.Type.MouseButtonRelease and self._pressed is not None:
|
|
69
|
+
index, modifiers, was_selected = self._pressed
|
|
70
|
+
self._pressed = None
|
|
71
|
+
if (event.button() == Qt.MouseButton.LeftButton and was_selected
|
|
72
|
+
and view.indexAt(event.position().toPoint()) == index):
|
|
73
|
+
self.reselected.emit(view, index, modifiers)
|
|
74
|
+
_the_hub().reselected.emit(view, index, modifiers)
|
|
75
|
+
return False # never touch a deleted `watched` (teardown re-enters filters; errors chain and balloon)
|