ms-components 0.7.2__tar.gz → 0.8.0__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.2 → ms_components-0.8.0}/PKG-INFO +1 -1
- ms_components-0.8.0/src/ms_components/labels.py +99 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/detail.py +10 -12
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/widget.py +13 -7
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_projects/__init__.py +3 -1
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_projects/browser.py +65 -19
- ms_components-0.8.0/src/ms_components/ms_projects/naming.py +51 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_projects/widget.py +15 -8
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_stepper.py +70 -49
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/action_header.py +49 -5
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/smart_table_view.py +5 -0
- ms_components-0.8.0/src/ms_components/ms_table/table_interaction.py +75 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_tutorial/controller.py +8 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components.egg-info/PKG-INFO +1 -1
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components.egg-info/SOURCES.txt +4 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components.egg-info/scm_file_list.json +4 -0
- ms_components-0.8.0/src/ms_components.egg-info/scm_version.json +8 -0
- ms_components-0.8.0/tests/test_labels.py +77 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_molsuite_monitor_widgets.py +35 -7
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_project_browser.py +50 -2
- ms_components-0.8.0/tests/test_project_folder_naming.py +43 -0
- ms_components-0.8.0/tests/test_stepper.py +24 -0
- ms_components-0.7.2/src/ms_components/labels.py +0 -36
- ms_components-0.7.2/src/ms_components/ms_table/table_interaction.py +0 -43
- ms_components-0.7.2/src/ms_components.egg-info/scm_version.json +0 -8
- {ms_components-0.7.2 → ms_components-0.8.0}/.github/workflows/docs.yml +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/.github/workflows/publish.yml +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/.gitignore +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/LICENSE +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/MANIFEST.in +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/README.md +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/examples/tutorial_demo.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/examples/tutorial_demo.toml +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/licenses/lucide-LICENSE.txt +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/licenses/qt-themes-LICENSE.txt +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/pyproject.toml +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/setup.cfg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/__init__.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/backdrop.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/base.qss +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/chips.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/icons.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ketcher.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/listview.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_dockwidget/__init__.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_dockwidget/resources/__init__.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_dockwidget/resources/icons/__init__.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_dockwidget/resources/icons/folder.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_dockwidget/widget.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_executors.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/__init__.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/bridge.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/config.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/formatting.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/icons/cpu.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/icons/gpu.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/icons/memory.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/jobs.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/models.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/palette.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/polling.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_monitor/resources.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_projects/app.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_projects/backend.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_projects/scratch.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/__init__.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/command_line.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/actions.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/box.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/center.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/display.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/export.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/hide.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/hydrogens-polar.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/hydrogens.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/menu.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/orient.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/presets.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/rock.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/save.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/selection.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/settings.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/style.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/icons/zoom.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/plugins.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/scene.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_pymol/widget.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_settings/__init__.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_settings/panel.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/__init__.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/cell_delegate.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/column_panel.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/example_usage.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/filter_panel.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/icons/columns.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/icons/export.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/icons/filter.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/icons/menu.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/icons/reload.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/icons/search.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/icons/settings.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/icons/sort-asc.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/icons/sort-desc.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/icons/sort.svg +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/metric_filter_bar.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/pagination_control.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/query_builder.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/session_provider.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/sort_panel.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/table_config.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/table_model.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/test_external_filters.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_table/test_toolbar.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_tutorial/__init__.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_tutorial/bindings.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_tutorial/models.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/ms_tutorial/overlay.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/opengl.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/pagination.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/palettes.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/step_dialog.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/theme.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/tool_panel.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components/wheel.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components.egg-info/dependency_links.txt +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components.egg-info/requires.txt +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/src/ms_components.egg-info/top_level.txt +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/conftest.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_app_settings.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_chips.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_dock_window.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_executors_ui.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_ketcher.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_molsuite_monitor_bridge.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_monitor_config.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_ms_projects_widget.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_opengl.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_optional_integrations.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_progress_column.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_pymol_command_line.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_pymol_grid.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_pymol_scene.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_pymol_toolbar.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_query_builder_keyset.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_shift_hscroll.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_split_button_style.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_step_dialog.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_table_autofill_lifecycle.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_table_interaction.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_table_toolbar.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_table_view_state.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_theme_contrast.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_theme_menu.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_tool_panel.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/tests/test_tutorial.py +0 -0
- {ms_components-0.7.2 → ms_components-0.8.0}/zensical.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ms_components
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
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,99 @@
|
|
|
1
|
+
"""Labels shared by the components."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import math
|
|
5
|
+
|
|
6
|
+
from PySide6.QtCore import QSize, Qt
|
|
7
|
+
from PySide6.QtGui import QPalette
|
|
8
|
+
from PySide6.QtWidgets import QFrame, QLabel, QSizePolicy, QTextEdit
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ElidedLabel(QLabel):
|
|
12
|
+
"""A label that never widens its row: what does not fit ends in an ellipsis. `text()` is the
|
|
13
|
+
whole text."""
|
|
14
|
+
|
|
15
|
+
def __init__(self, text: str = "", parent=None) -> None:
|
|
16
|
+
super().__init__(parent)
|
|
17
|
+
self._full = ""
|
|
18
|
+
self.setText(text)
|
|
19
|
+
|
|
20
|
+
def setText(self, text: str) -> None: # noqa: N802
|
|
21
|
+
self._full = str(text)
|
|
22
|
+
self.updateGeometry()
|
|
23
|
+
self._elide()
|
|
24
|
+
|
|
25
|
+
def text(self) -> str:
|
|
26
|
+
return self._full
|
|
27
|
+
|
|
28
|
+
def sizeHint(self) -> QSize: # noqa: N802
|
|
29
|
+
return QSize(self.fontMetrics().horizontalAdvance(self._full) + 4, super().sizeHint().height())
|
|
30
|
+
|
|
31
|
+
def minimumSizeHint(self) -> QSize: # noqa: N802
|
|
32
|
+
return QSize(0, super().minimumSizeHint().height())
|
|
33
|
+
|
|
34
|
+
def resizeEvent(self, event) -> None: # noqa: N802
|
|
35
|
+
super().resizeEvent(event)
|
|
36
|
+
self._elide()
|
|
37
|
+
|
|
38
|
+
def _elide(self) -> None:
|
|
39
|
+
super().setText(self.fontMetrics().elidedText(self._full, Qt.ElideRight, self.width()))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class WrappedText(QTextEdit):
|
|
43
|
+
"""Read-only wrapped text that is as tall as its lines, up to `max_lines`, and scrolls past them.
|
|
44
|
+
|
|
45
|
+
A word-wrapped QLabel in a layout sized to its content (SetMinimumSize) gets the height of a
|
|
46
|
+
narrower width and clips its first and last lines. This one measures its own document at the
|
|
47
|
+
width it is drawn at, again on every resize. It draws no frame or background, like a label;
|
|
48
|
+
colour it with a style sheet (`color: ...`). `text()` is the whole text, surrounding blank
|
|
49
|
+
lines dropped."""
|
|
50
|
+
|
|
51
|
+
#: The theme styles every QTextEdit as an input (border, padding): that drew a box and a
|
|
52
|
+
#: scroll bar around the text, and the padding was not in the height `_fit` asked for. Kept
|
|
53
|
+
#: in this widget's own sheet, which outranks the application's, whatever a caller adds.
|
|
54
|
+
_PLAIN = "QTextEdit { border: none; padding: 0; background: transparent; }"
|
|
55
|
+
|
|
56
|
+
def __init__(self, text: str = "", parent=None, *, max_lines: int = 6) -> None:
|
|
57
|
+
super().__init__(parent)
|
|
58
|
+
self._max_lines = max(1, int(max_lines))
|
|
59
|
+
self.setReadOnly(True)
|
|
60
|
+
self.setFrameShape(QFrame.NoFrame)
|
|
61
|
+
self.setStyleSheet("")
|
|
62
|
+
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
|
63
|
+
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
|
|
64
|
+
palette = self.viewport().palette()
|
|
65
|
+
palette.setColor(QPalette.ColorRole.Base, Qt.transparent)
|
|
66
|
+
self.viewport().setPalette(palette)
|
|
67
|
+
self.viewport().setAutoFillBackground(False)
|
|
68
|
+
self.document().setDocumentMargin(0)
|
|
69
|
+
self.setText(text)
|
|
70
|
+
|
|
71
|
+
def setText(self, text: str) -> None: # noqa: N802
|
|
72
|
+
self.setPlainText(str(text or "").strip())
|
|
73
|
+
self._fit()
|
|
74
|
+
|
|
75
|
+
def text(self) -> str:
|
|
76
|
+
return self.toPlainText()
|
|
77
|
+
|
|
78
|
+
def setStyleSheet(self, sheet: str) -> None: # noqa: N802
|
|
79
|
+
"""`sheet` on top of the plain look; bare declarations ("color: ...") apply to the text."""
|
|
80
|
+
sheet = str(sheet or "").strip()
|
|
81
|
+
if sheet and "{" not in sheet:
|
|
82
|
+
sheet = f"QTextEdit {{ {sheet} }}"
|
|
83
|
+
super().setStyleSheet(f"{self._PLAIN}\n{sheet}")
|
|
84
|
+
self._fit()
|
|
85
|
+
|
|
86
|
+
def _fit(self) -> None:
|
|
87
|
+
document = self.document()
|
|
88
|
+
document.setTextWidth(self.viewport().width())
|
|
89
|
+
cap = self._max_lines * self.fontMetrics().lineSpacing()
|
|
90
|
+
# Rounded up: a fraction of a pixel short still brought up the scroll bar, which then
|
|
91
|
+
# took its width from the text. It only ever shows past `max_lines`.
|
|
92
|
+
needed = math.ceil(document.size().height())
|
|
93
|
+
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded if needed > cap else Qt.ScrollBarAlwaysOff)
|
|
94
|
+
self.setFixedHeight(min(needed, cap) + 2 * self.frameWidth())
|
|
95
|
+
|
|
96
|
+
def resizeEvent(self, event) -> None: # noqa: N802
|
|
97
|
+
super().resizeEvent(event)
|
|
98
|
+
if event.size().width() != event.oldSize().width():
|
|
99
|
+
self._fit() # another width wraps into another number of lines
|
|
@@ -440,9 +440,9 @@ class JobDetail(QWidget):
|
|
|
440
440
|
self._steps.setFrameShape(QFrame.NoFrame)
|
|
441
441
|
self._steps.header().setSectionResizeMode(QHeaderView.ResizeToContents)
|
|
442
442
|
self._steps.header().setStretchLastSection(True)
|
|
443
|
+
self._tabs.addTab(self._summary, "Summary")
|
|
443
444
|
self._tabs.addTab(self._tasks, "Running")
|
|
444
445
|
self._tabs.addTab(errors, "Errors")
|
|
445
|
-
self._tabs.addTab(self._summary, "Summary")
|
|
446
446
|
self._tabs.addTab(self._steps, "Steps")
|
|
447
447
|
self._tabs.setTabVisible(self._tabs.indexOf(self._steps), False) # only a job whose source says its steps (a campaign)
|
|
448
448
|
self._errors.currentItemChanged.connect(self._show_traceback)
|
|
@@ -455,6 +455,7 @@ class JobDetail(QWidget):
|
|
|
455
455
|
self.set_job(None)
|
|
456
456
|
|
|
457
457
|
def set_job(self, job: JobMonitorState | None) -> None:
|
|
458
|
+
previous = self._job
|
|
458
459
|
self._job = job
|
|
459
460
|
for widget in (self._swatch, self._badge, self._on, self._chip, self._meta):
|
|
460
461
|
widget.setVisible(job is not None)
|
|
@@ -473,6 +474,7 @@ class JobDetail(QWidget):
|
|
|
473
474
|
self.set_failures([], 0)
|
|
474
475
|
self._set_summary(None)
|
|
475
476
|
self._set_steps(None)
|
|
477
|
+
self.show_summary()
|
|
476
478
|
return
|
|
477
479
|
hue = status_color(job.status)
|
|
478
480
|
self._name.setText(job.label)
|
|
@@ -532,24 +534,20 @@ class JobDetail(QWidget):
|
|
|
532
534
|
self._set_tasks(job)
|
|
533
535
|
self._set_summary(job)
|
|
534
536
|
self._set_steps(job)
|
|
537
|
+
if previous is None or (previous.job_id, previous.status) != (job.job_id, job.status):
|
|
538
|
+
self._tabs.setCurrentWidget(self._tasks if job.status == "running" else self._summary)
|
|
539
|
+
|
|
540
|
+
def show_summary(self) -> None:
|
|
541
|
+
self._tabs.setCurrentWidget(self._summary)
|
|
535
542
|
|
|
536
543
|
def set_color(self, color: str) -> None:
|
|
537
544
|
"""The job's own color, as the list paints it."""
|
|
538
545
|
self._swatch.setStyleSheet(f"background:{color}; border-radius:3px;")
|
|
539
546
|
|
|
540
547
|
def _set_steps(self, job: JobMonitorState | None) -> None:
|
|
541
|
-
"""
|
|
542
|
-
with steps (a campaign) has them as its first tab, shown when it is chosen."""
|
|
548
|
+
"""Show the stages a campaign went through, with how long each took."""
|
|
543
549
|
steps = job.steps if job is not None else ()
|
|
544
|
-
|
|
545
|
-
if bool(steps) != (at == 0):
|
|
546
|
-
self._tabs.removeTab(at)
|
|
547
|
-
at = self._tabs.insertTab(0 if steps else self._tabs.count(), self._steps, "Steps")
|
|
548
|
-
self._tabs.setTabVisible(at, bool(steps))
|
|
549
|
-
chosen = job.job_id if job is not None else None
|
|
550
|
-
if steps and chosen != getattr(self, "_steps_of", None):
|
|
551
|
-
self._tabs.setCurrentIndex(at)
|
|
552
|
-
self._steps_of = chosen if steps else None
|
|
550
|
+
self._tabs.setTabVisible(self._tabs.indexOf(self._steps), bool(steps))
|
|
553
551
|
if not steps or (steps == getattr(self, "_shown_steps", None) and job.is_terminal):
|
|
554
552
|
return
|
|
555
553
|
self._shown_steps = steps
|
|
@@ -32,7 +32,8 @@ class MolSuiteMonitorWidget(QWidget):
|
|
|
32
32
|
super().__init__(parent)
|
|
33
33
|
self._bridge = None
|
|
34
34
|
self._snapshot: ProjectMonitorState | None = None
|
|
35
|
-
self.
|
|
35
|
+
self._shown_once = False
|
|
36
|
+
self._reopen_on_snapshot: bool | None = None
|
|
36
37
|
# The failures of the selected job come from the journal: read again only when the job
|
|
37
38
|
# changes or fails more, not each poll, so the list does not jump while it is read.
|
|
38
39
|
self._failures_key = None
|
|
@@ -179,9 +180,12 @@ class MolSuiteMonitorWidget(QWidget):
|
|
|
179
180
|
def showEvent(self, event):
|
|
180
181
|
super().showEvent(event)
|
|
181
182
|
self.select_active_job()
|
|
183
|
+
if self._shown_once:
|
|
184
|
+
self._detail.show_summary()
|
|
182
185
|
# A hidden monitor can still hold the previous poll. Focus once more when
|
|
183
186
|
# fresh data arrives, unless the user changes selection in the meantime.
|
|
184
|
-
self.
|
|
187
|
+
self._reopen_on_snapshot = self._shown_once
|
|
188
|
+
self._shown_once = True
|
|
185
189
|
if self._bridge is not None:
|
|
186
190
|
self._bridge.request_refresh()
|
|
187
191
|
|
|
@@ -236,7 +240,7 @@ class MolSuiteMonitorWidget(QWidget):
|
|
|
236
240
|
|
|
237
241
|
def clear_snapshot(self) -> None:
|
|
238
242
|
self._snapshot = None
|
|
239
|
-
self.
|
|
243
|
+
self._reopen_on_snapshot = None
|
|
240
244
|
self._title_label.setText("No active project")
|
|
241
245
|
self._summary_label.setText("Open a project to monitor jobs.")
|
|
242
246
|
self._update_sync_state(None)
|
|
@@ -254,8 +258,8 @@ class MolSuiteMonitorWidget(QWidget):
|
|
|
254
258
|
self._failures_key = None
|
|
255
259
|
|
|
256
260
|
def update_snapshot(self, snapshot: ProjectMonitorState) -> None:
|
|
257
|
-
|
|
258
|
-
self.
|
|
261
|
+
reopening = self._reopen_on_snapshot
|
|
262
|
+
self._reopen_on_snapshot = None
|
|
259
263
|
self._snapshot = snapshot
|
|
260
264
|
if not snapshot.has_project:
|
|
261
265
|
self.clear_snapshot()
|
|
@@ -273,9 +277,11 @@ class MolSuiteMonitorWidget(QWidget):
|
|
|
273
277
|
self._jobs_view.set_jobs(snapshot.jobs)
|
|
274
278
|
self._hosts.set_jobs(snapshot.jobs)
|
|
275
279
|
self._rebuild_filters(snapshot)
|
|
276
|
-
if
|
|
280
|
+
if reopening is not None or self._selected_job() is None:
|
|
277
281
|
self.select_active_job()
|
|
278
282
|
self._show_selected()
|
|
283
|
+
if reopening:
|
|
284
|
+
self._detail.show_summary()
|
|
279
285
|
|
|
280
286
|
def _rebuild_filters(self, snapshot: ProjectMonitorState) -> None:
|
|
281
287
|
current_status = self._status_filter.currentData()
|
|
@@ -346,7 +352,7 @@ class MolSuiteMonitorWidget(QWidget):
|
|
|
346
352
|
self._bridge.resume_job(job_id, executor)
|
|
347
353
|
|
|
348
354
|
def _on_current_job_changed(self, job_id) -> None:
|
|
349
|
-
self.
|
|
355
|
+
self._reopen_on_snapshot = None
|
|
350
356
|
if self._bridge is not None:
|
|
351
357
|
self._bridge.select_job(job_id)
|
|
352
358
|
self._show_selected()
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
from .browser import ProjectBrowserPanel, ProjectBrowserWindow, ProjectFormDialog
|
|
2
|
+
from .naming import folder_for, folder_name
|
|
2
3
|
from .widget import ProjectsMenuWidget
|
|
3
4
|
|
|
4
|
-
__all__ = ["ProjectBrowserPanel", "ProjectBrowserWindow", "ProjectFormDialog", "ProjectsMenuWidget"
|
|
5
|
+
__all__ = ["ProjectBrowserPanel", "ProjectBrowserWindow", "ProjectFormDialog", "ProjectsMenuWidget",
|
|
6
|
+
"folder_for", "folder_name"]
|
|
@@ -2,15 +2,16 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import sys
|
|
4
4
|
from dataclasses import dataclass, field
|
|
5
|
+
from html import escape
|
|
5
6
|
from pathlib import Path
|
|
6
7
|
from typing import TYPE_CHECKING, Any, List, Optional
|
|
7
8
|
|
|
8
9
|
from PySide6.QtCore import (
|
|
9
|
-
Qt, Signal, QRect, QSize, QAbstractTableModel, QModelIndex, QEvent,
|
|
10
|
+
Qt, Signal, QPoint, QRect, QSize, QAbstractTableModel, QModelIndex, QEvent,
|
|
10
11
|
)
|
|
11
12
|
from PySide6.QtGui import (
|
|
12
13
|
QAction, QFont, QPainter, QColor, QPen, QBrush, QPainterPath, QMouseEvent,
|
|
13
|
-
QFontMetrics, QKeySequence, QPalette, QShortcut,
|
|
14
|
+
QFontMetrics, QKeySequence, QPalette, QShortcut, QTextLayout, QTextOption,
|
|
14
15
|
)
|
|
15
16
|
from PySide6.QtWidgets import (
|
|
16
17
|
QAbstractItemView, QApplication, QComboBox, QDialog, QDialogButtonBox,
|
|
@@ -18,10 +19,11 @@ from PySide6.QtWidgets import (
|
|
|
18
19
|
QHeaderView, QLabel, QLineEdit, QMainWindow, QMenu, QMessageBox,
|
|
19
20
|
QProgressDialog, QPushButton, QSpinBox, QSplitter, QStyledItemDelegate,
|
|
20
21
|
QStyle, QTabWidget, QTableWidget, QTableWidgetItem, QTextEdit, QToolButton,
|
|
21
|
-
QTreeView, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget,
|
|
22
|
+
QToolTip, QTreeView, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget,
|
|
22
23
|
)
|
|
23
24
|
|
|
24
25
|
from ms_components.ms_projects.backend import create_catalog_backend
|
|
26
|
+
from ms_components.ms_projects.naming import folder_for, folder_name
|
|
25
27
|
from ms_components.theme import color as theme_color
|
|
26
28
|
|
|
27
29
|
if TYPE_CHECKING:
|
|
@@ -514,6 +516,8 @@ class ProjectRowDelegate(QStyledItemDelegate):
|
|
|
514
516
|
_AVATAR = 34
|
|
515
517
|
_BTN_SIZE = 26
|
|
516
518
|
_BTN_R = 6
|
|
519
|
+
_DESCRIPTION_LINES = 3
|
|
520
|
+
_DESCRIPTION_PADDING = 8
|
|
517
521
|
|
|
518
522
|
def __init__(self, parent=None):
|
|
519
523
|
super().__init__(parent)
|
|
@@ -523,7 +527,10 @@ class ProjectRowDelegate(QStyledItemDelegate):
|
|
|
523
527
|
self._hover_row = row
|
|
524
528
|
|
|
525
529
|
def sizeHint(self, option, index) -> QSize:
|
|
526
|
-
|
|
530
|
+
font = self._font(option.font, 9)
|
|
531
|
+
metrics = QFontMetrics(font, option.widget)
|
|
532
|
+
description_height = self._DESCRIPTION_LINES * metrics.lineSpacing() + 2 * self._DESCRIPTION_PADDING
|
|
533
|
+
return QSize(option.rect.width(), max(62, description_height))
|
|
527
534
|
|
|
528
535
|
def paint(self, painter: QPainter, option, index):
|
|
529
536
|
painter.save()
|
|
@@ -555,22 +562,22 @@ class ProjectRowDelegate(QStyledItemDelegate):
|
|
|
555
562
|
painter.drawRect(QRect(rect.left(), rect.top()+1, 3, rect.height()-1))
|
|
556
563
|
self._paint_name_col(painter, rect, project, palette, option.font)
|
|
557
564
|
|
|
558
|
-
elif col
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
)
|
|
564
|
-
|
|
565
|
-
|
|
565
|
+
elif col == _COL_META:
|
|
566
|
+
painter.setPen(palette.color(QPalette.ColorRole.Text))
|
|
567
|
+
painter.setFont(self._font(option.font, 9))
|
|
568
|
+
bounds = rect.adjusted(6, self._DESCRIPTION_PADDING, -6, -self._DESCRIPTION_PADDING)
|
|
569
|
+
metrics = painter.fontMetrics()
|
|
570
|
+
for i, line in enumerate(self._description_lines(index.data(Qt.DisplayRole) or "", painter, bounds.width())):
|
|
571
|
+
baseline = bounds.top() + metrics.ascent() + i * metrics.lineSpacing()
|
|
572
|
+
painter.drawText(QPoint(bounds.left(), baseline), line)
|
|
573
|
+
|
|
574
|
+
elif col in (_COL_PATH, _COL_DATE):
|
|
575
|
+
painter.setPen(palette.color(QPalette.ColorRole.PlaceholderText))
|
|
576
|
+
painter.setFont(self._font(option.font, 8))
|
|
566
577
|
text = index.data(Qt.DisplayRole) or ""
|
|
567
578
|
if col == _COL_PATH: # the full path is in the tooltip
|
|
568
579
|
text = painter.fontMetrics().elidedText(text, Qt.ElideMiddle, max(0, rect.width() - 12))
|
|
569
|
-
|
|
570
|
-
if col == _COL_META:
|
|
571
|
-
flags = Qt.AlignLeft | Qt.TextWordWrap
|
|
572
|
-
painter.drawText(rect.adjusted(6, 8 if col == _COL_META else 0, -6, -8 if col == _COL_META else 0),
|
|
573
|
-
flags, text)
|
|
580
|
+
painter.drawText(rect.adjusted(6, 0, -6, 0), Qt.AlignLeft | Qt.AlignVCenter, text)
|
|
574
581
|
|
|
575
582
|
elif col == _COL_STAR:
|
|
576
583
|
self._paint_star(painter, rect, project, is_hover, palette, option.font)
|
|
@@ -580,6 +587,43 @@ class ProjectRowDelegate(QStyledItemDelegate):
|
|
|
580
587
|
|
|
581
588
|
painter.restore()
|
|
582
589
|
|
|
590
|
+
def _description_lines(self, text: str, painter: QPainter, width: int) -> list[str]:
|
|
591
|
+
text = text.strip() # blank lines around it would take rows and fake an ellipsis
|
|
592
|
+
if not text or width <= 0:
|
|
593
|
+
return []
|
|
594
|
+
# QTextLayout treats a line separator as a forced break and reports UTF-16 positions.
|
|
595
|
+
text = text.replace("\r\n", "\n").replace("\r", "\n").replace("\n", "\u2028")
|
|
596
|
+
encoded = text.encode("utf-16-le")
|
|
597
|
+
layout = QTextLayout(text, painter.font(), painter.device())
|
|
598
|
+
options = QTextOption()
|
|
599
|
+
options.setWrapMode(QTextOption.WrapAtWordBoundaryOrAnywhere)
|
|
600
|
+
layout.setTextOption(options)
|
|
601
|
+
lines = []
|
|
602
|
+
end = 0
|
|
603
|
+
layout.beginLayout()
|
|
604
|
+
for _ in range(self._DESCRIPTION_LINES):
|
|
605
|
+
line = layout.createLine()
|
|
606
|
+
if not line.isValid():
|
|
607
|
+
break
|
|
608
|
+
line.setLineWidth(width)
|
|
609
|
+
start = line.textStart()
|
|
610
|
+
end = start + line.textLength()
|
|
611
|
+
lines.append(encoded[2 * start:2 * end].decode("utf-16-le").rstrip())
|
|
612
|
+
layout.endLayout()
|
|
613
|
+
if lines and 2 * end < len(encoded):
|
|
614
|
+
lines[-1] = painter.fontMetrics().elidedText(lines[-1] + "…", Qt.ElideRight, width)
|
|
615
|
+
return lines
|
|
616
|
+
|
|
617
|
+
def helpEvent(self, event, view, option, index):
|
|
618
|
+
if event.type() == QEvent.ToolTip and index.column() == _COL_META:
|
|
619
|
+
description = index.data(Qt.DisplayRole)
|
|
620
|
+
if description:
|
|
621
|
+
# Rich text gives the tooltip word wrapping. Escape project text before adding markup.
|
|
622
|
+
text = escape(description).replace("\r\n", "\n").replace("\r", "\n").replace("\n", "<br>")
|
|
623
|
+
QToolTip.showText(event.globalPos(), f"<qt>{text}</qt>", view.viewport(), option.rect)
|
|
624
|
+
return True
|
|
625
|
+
return super().helpEvent(event, view, option, index)
|
|
626
|
+
|
|
583
627
|
def _paint_name_col(
|
|
584
628
|
self,
|
|
585
629
|
painter: QPainter,
|
|
@@ -1404,8 +1448,10 @@ class ProjectBrowserPanel(QWidget):
|
|
|
1404
1448
|
try:
|
|
1405
1449
|
folder = fd["path"].expanduser().resolve()
|
|
1406
1450
|
name = fd["name"].strip()
|
|
1407
|
-
if folder.name != name:
|
|
1408
|
-
|
|
1451
|
+
if folder.name != folder_name(name):
|
|
1452
|
+
# The name stays as typed; the folder is what a path parser can carry (see
|
|
1453
|
+
# `naming`), as in `ProjectsMenuWidget.on_create_project`.
|
|
1454
|
+
folder = folder_for(folder, name)
|
|
1409
1455
|
ctx = self.backend.create_project(
|
|
1410
1456
|
name=name, folder=folder, description=fd["description"],
|
|
1411
1457
|
tags=fd["tags"], app_id=fd["app_id"])
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""The folder a project gets on disk, from the name its author typed.
|
|
2
|
+
|
|
3
|
+
A project's name is theirs to write: spaces, punctuation, accents, emoji. The folder under it
|
|
4
|
+
is read back by other programs, and some of them parse a path badly -- Uni-Dock splits each
|
|
5
|
+
line of its ligand list on whitespace, so a project called "AmpC DUDE-Z screening (Unidock)"
|
|
6
|
+
made it abort on every ligand. The name stays whole in the catalog; only the folder is held to
|
|
7
|
+
what a file system and a plain parser can both carry.
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import re
|
|
12
|
+
import unicodedata
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
#: Letters, digits and the three separators every file system and parser takes.
|
|
16
|
+
_KEEP = re.compile(r"[^A-Za-z0-9._-]+")
|
|
17
|
+
_RUNS = re.compile(r"_{2,}")
|
|
18
|
+
#: Reserved on Windows, whatever the extension; a folder named this cannot be opened there.
|
|
19
|
+
_RESERVED = {"CON", "PRN", "AUX", "NUL", *(f"COM{i}" for i in range(1, 10)),
|
|
20
|
+
*(f"LPT{i}" for i in range(1, 10))}
|
|
21
|
+
_MAX = 64 # keeps the whole path well inside the limits a deep project tree still has to fit
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def folder_name(name: str) -> str:
|
|
25
|
+
"""The folder name for a project called `name`: its words, joined by `_`.
|
|
26
|
+
|
|
27
|
+
Accents fold to their plain letters ("Mantén" -> "Manten") and anything else is dropped, so
|
|
28
|
+
the result holds no space, quote, newline or shell character. Never empty, never a name
|
|
29
|
+
Windows reserves, never longer than 64 characters.
|
|
30
|
+
"""
|
|
31
|
+
folded = unicodedata.normalize("NFKD", str(name or "")).encode("ascii", "ignore").decode()
|
|
32
|
+
slug = _RUNS.sub("_", _KEEP.sub("_", folded)).strip("._-")[:_MAX].strip("._-")
|
|
33
|
+
if not slug or slug.split(".")[0].upper() in _RESERVED:
|
|
34
|
+
slug = f"project_{slug}" if slug else "project"
|
|
35
|
+
return slug
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def folder_for(parent: Path | str, name: str) -> Path:
|
|
39
|
+
"""A folder under `parent` for a project called `name`, free for it to be created in.
|
|
40
|
+
|
|
41
|
+
Two names that fold to one slug ("A/B run" and "A B run") would otherwise open the same
|
|
42
|
+
folder and write over each other's project, so the second gets `_2`, the third `_3`.
|
|
43
|
+
"""
|
|
44
|
+
parent = Path(parent)
|
|
45
|
+
base = folder_name(name)
|
|
46
|
+
candidate = parent / base
|
|
47
|
+
for n in range(2, 1000):
|
|
48
|
+
if not candidate.exists():
|
|
49
|
+
return candidate
|
|
50
|
+
candidate = parent / f"{base}_{n}"
|
|
51
|
+
return candidate
|
|
@@ -18,6 +18,7 @@ from PySide6.QtWidgets import (
|
|
|
18
18
|
)
|
|
19
19
|
|
|
20
20
|
from ms_components.ms_projects.backend import create_catalog_backend
|
|
21
|
+
from ms_components.ms_projects.naming import folder_for, folder_name
|
|
21
22
|
from ms_components.ms_projects.browser import PROJECT_DATE_FORMAT, ProjectFormDialog, ProjectItem, ProjectTreeWidget
|
|
22
23
|
|
|
23
24
|
if TYPE_CHECKING:
|
|
@@ -185,8 +186,11 @@ class ProjectsMenuWidget(QFrame):
|
|
|
185
186
|
try:
|
|
186
187
|
folder = data["path"].expanduser().resolve()
|
|
187
188
|
name = data["name"].strip()
|
|
188
|
-
if folder.name != name:
|
|
189
|
-
|
|
189
|
+
if folder.name != folder_name(name):
|
|
190
|
+
# The name stays as typed; the folder is what a path parser can carry (see
|
|
191
|
+
# `naming`): a project named "AmpC DUDE-Z screening (Unidock)" docked nothing,
|
|
192
|
+
# because Uni-Dock split its ligand list on the spaces in every path.
|
|
193
|
+
folder = folder_for(folder, name)
|
|
190
194
|
context = self.backend.create_project(
|
|
191
195
|
name=name,
|
|
192
196
|
folder=folder,
|
|
@@ -278,12 +282,15 @@ class ProjectsMenuWidget(QFrame):
|
|
|
278
282
|
return
|
|
279
283
|
in_use = [p for p in projects if self.active_project_id and str(p.id) == self.active_project_id]
|
|
280
284
|
projects = [p for p in projects if p not in in_use]
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
if
|
|
285
|
-
|
|
286
|
-
|
|
285
|
+
# Asked now, requested last: the host answers by closing and restarting the
|
|
286
|
+
# application, which destroys this widget (and the progress dialog parented to it).
|
|
287
|
+
confirmed = [p for p in in_use if self._confirm_open_project_delete(p)]
|
|
288
|
+
if projects:
|
|
289
|
+
self._delete_closed_projects(projects)
|
|
290
|
+
for project in confirmed:
|
|
291
|
+
self.active_project_delete_requested.emit(str(project.id))
|
|
292
|
+
|
|
293
|
+
def _delete_closed_projects(self, projects: list[ProjectItem]) -> None:
|
|
287
294
|
progress = QProgressDialog("Deleting projects...", None, 0, len(projects), self)
|
|
288
295
|
progress.setWindowTitle("Delete projects")
|
|
289
296
|
progress.setWindowModality(Qt.WindowModal)
|
|
@@ -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
|
# =====================================================================
|