lightfall 0.1.1__py3-none-any.whl
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.
- lightfall/__init__.py +8 -0
- lightfall/__main__.py +10 -0
- lightfall/_version.py +24 -0
- lightfall/acquire/__init__.py +74 -0
- lightfall/acquire/buffer.py +363 -0
- lightfall/acquire/device_wrapper.py +416 -0
- lightfall/acquire/engine/__init__.py +155 -0
- lightfall/acquire/engine/base.py +587 -0
- lightfall/acquire/engine/bluesky.py +358 -0
- lightfall/acquire/engine/mock.py +165 -0
- lightfall/acquire/engine/plugins/__init__.py +9 -0
- lightfall/acquire/engine/plugins/bluesky_plugin.py +56 -0
- lightfall/acquire/engine/plugins/mock_plugin.py +55 -0
- lightfall/acquire/engine/protocol.py +145 -0
- lightfall/acquire/engine/registry.py +152 -0
- lightfall/acquire/engine/state.py +32 -0
- lightfall/acquire/engine/waiting_hook.py +225 -0
- lightfall/acquire/nats_bridge.py +62 -0
- lightfall/acquire/plan_ui.py +78 -0
- lightfall/acquire/plans/__init__.py +38 -0
- lightfall/acquire/plans/adaptive.py +288 -0
- lightfall/acquire/plans/example_plans.py +995 -0
- lightfall/acquire/plans/lightfall_plans.py +587 -0
- lightfall/acquire/plans/registry.py +543 -0
- lightfall/acquire/plans/standard_plans.py +186 -0
- lightfall/acquire/plans/user_plans.py +470 -0
- lightfall/acquire/runengine.py +36 -0
- lightfall/acquire/signals.py +452 -0
- lightfall/acquire/triggers/__init__.py +16 -0
- lightfall/acquire/triggers/base.py +25 -0
- lightfall/acquire/triggers/filter.py +37 -0
- lightfall/acquire/triggers/manager.py +73 -0
- lightfall/acquire/triggers/manual.py +36 -0
- lightfall/acquire/triggers/run_end.py +74 -0
- lightfall/acquire/triggers/run_start.py +52 -0
- lightfall/auth/__init__.py +38 -0
- lightfall/auth/policy.py +518 -0
- lightfall/auth/providers/__init__.py +30 -0
- lightfall/auth/providers/base.py +124 -0
- lightfall/auth/providers/keycloak.py +1017 -0
- lightfall/auth/providers/local.py +319 -0
- lightfall/auth/providers/pam.py +250 -0
- lightfall/auth/service_key.py +173 -0
- lightfall/auth/service_key_auth.py +79 -0
- lightfall/auth/session.py +656 -0
- lightfall/claude/__init__.py +52 -0
- lightfall/claude/_internal/__init__.py +1 -0
- lightfall/claude/_internal/serialization.py +195 -0
- lightfall/claude/_internal/threading.py +61 -0
- lightfall/claude/_internal/worker.py +757 -0
- lightfall/claude/_session_assembly.py +124 -0
- lightfall/claude/agent.py +596 -0
- lightfall/claude/lightfall_core_tools.py +410 -0
- lightfall/claude/markdown.py +103 -0
- lightfall/claude/permission_manager.py +588 -0
- lightfall/claude/tools/__init__.py +45 -0
- lightfall/claude/tools/controller.py +143 -0
- lightfall/claude/tools/interaction.py +177 -0
- lightfall/claude/tools/introspection.py +127 -0
- lightfall/claude/tools/logs.py +155 -0
- lightfall/claude/tools/screenshot.py +87 -0
- lightfall/claude/widget.py +851 -0
- lightfall/claude/widgets/__init__.py +5 -0
- lightfall/claude/widgets/permission_request.py +282 -0
- lightfall/claude/widgets/question_request.py +227 -0
- lightfall/claude/widgets/task_card.py +223 -0
- lightfall/config/__init__.py +23 -0
- lightfall/config/layers.py +317 -0
- lightfall/config/manager.py +244 -0
- lightfall/config/schema.py +154 -0
- lightfall/core/__init__.py +23 -0
- lightfall/core/application.py +727 -0
- lightfall/core/services.py +235 -0
- lightfall/devices/__init__.py +53 -0
- lightfall/devices/backends/__init__.py +17 -0
- lightfall/devices/backends/bcs.py +448 -0
- lightfall/devices/backends/happi.py +986 -0
- lightfall/devices/backends/mock.py +646 -0
- lightfall/devices/base.py +338 -0
- lightfall/devices/catalog.py +1039 -0
- lightfall/devices/connection_manager.py +676 -0
- lightfall/devices/model.py +290 -0
- lightfall/devices/monitoring.py +442 -0
- lightfall/devices/sim/__init__.py +26 -0
- lightfall/devices/sim/areadetector.py +436 -0
- lightfall/devices/sim/generators.py +223 -0
- lightfall/devices/sim/plugins.py +116 -0
- lightfall/epics/__init__.py +28 -0
- lightfall/epics/ca/__init__.py +10 -0
- lightfall/epics/ca/context.py +100 -0
- lightfall/epics/ca/pv.py +303 -0
- lightfall/epics/widgets/__init__.py +49 -0
- lightfall/epics/widgets/areadetector/__init__.py +16 -0
- lightfall/epics/widgets/areadetector/areadetector.py +281 -0
- lightfall/epics/widgets/areadetector/controls.py +478 -0
- lightfall/epics/widgets/areadetector/image_view.py +447 -0
- lightfall/epics/widgets/auto.py +319 -0
- lightfall/epics/widgets/base.py +404 -0
- lightfall/epics/widgets/checkbox.py +239 -0
- lightfall/epics/widgets/combobox.py +202 -0
- lightfall/epics/widgets/label.py +176 -0
- lightfall/epics/widgets/lineedit.py +253 -0
- lightfall/epics/widgets/motor.py +694 -0
- lightfall/epics/widgets/ophyd_base.py +469 -0
- lightfall/epics/widgets/ophyd_combobox.py +86 -0
- lightfall/epics/widgets/ophyd_label.py +54 -0
- lightfall/epics/widgets/ophyd_lineedit.py +170 -0
- lightfall/epics/widgets/ophyd_spinbox.py +79 -0
- lightfall/epics/widgets/slider.py +272 -0
- lightfall/epics/widgets/status_indicator.py +98 -0
- lightfall/epics/widgets/style.py +188 -0
- lightfall/exporter/__init__.py +1 -0
- lightfall/exporter/cli.py +67 -0
- lightfall/exporter/converters/__init__.py +26 -0
- lightfall/exporter/converters/base.py +39 -0
- lightfall/exporter/converters/noop.py +39 -0
- lightfall/exporter/converters/nxsas.py +73 -0
- lightfall/exporter/service.py +200 -0
- lightfall/exporter/tiled_utils.py +92 -0
- lightfall/ipc/__init__.py +6 -0
- lightfall/ipc/service.py +701 -0
- lightfall/ipc/trust.py +144 -0
- lightfall/logbook/__init__.py +46 -0
- lightfall/logbook/action_dialog.py +207 -0
- lightfall/logbook/action_logger.py +432 -0
- lightfall/logbook/block_mapper.py +562 -0
- lightfall/logbook/client.py +799 -0
- lightfall/logbook/converter.py +273 -0
- lightfall/logbook/editors/__init__.py +19 -0
- lightfall/logbook/editors/highlighter.py +305 -0
- lightfall/logbook/editors/markdown_editor.py +319 -0
- lightfall/logbook/editors/richtext_editor.py +1397 -0
- lightfall/logbook/entry_widget.py +1065 -0
- lightfall/logbook/event_listener.py +221 -0
- lightfall/logbook/fragment_widgets.py +925 -0
- lightfall/logbook/position_mapper.py +320 -0
- lightfall/logbook/protection.py +402 -0
- lightfall/logbook/style.py +394 -0
- lightfall/logbook/url.py +29 -0
- lightfall/logbook/visual_protection.py +330 -0
- lightfall/logbook/widget.py +680 -0
- lightfall/main.py +1091 -0
- lightfall/pipelines/__init__.py +4 -0
- lightfall/pipelines/client.py +148 -0
- lightfall/plugins/__init__.py +119 -0
- lightfall/plugins/agent_plugin.py +106 -0
- lightfall/plugins/agents/__init__.py +10 -0
- lightfall/plugins/agents/_mcp_helpers.py +52 -0
- lightfall/plugins/agents/alignment.py +94 -0
- lightfall/plugins/agents/autonomous_experiment/__init__.py +12 -0
- lightfall/plugins/agents/autonomous_experiment/nats_tools.py +210 -0
- lightfall/plugins/agents/autonomous_experiment/plugin.py +60 -0
- lightfall/plugins/agents/autonomous_experiment/prompts.py +164 -0
- lightfall/plugins/agents/current_esaf.py +435 -0
- lightfall/plugins/agents/device_tools.py +1043 -0
- lightfall/plugins/agents/engine_tools.py +720 -0
- lightfall/plugins/agents/ipython_tools.py +444 -0
- lightfall/plugins/agents/panel_builder.py +637 -0
- lightfall/plugins/agents/panel_design/references/cross_panel_patterns.md +95 -0
- lightfall/plugins/agents/panel_design/references/panel_design.md +680 -0
- lightfall/plugins/agents/panel_design.py +94 -0
- lightfall/plugins/agents/plan_design/references/plan_design.md +398 -0
- lightfall/plugins/agents/plan_design.py +90 -0
- lightfall/plugins/agents/plan_tools.py +878 -0
- lightfall/plugins/agents/scan_planning.py +101 -0
- lightfall/plugins/builtin_manifest.py +348 -0
- lightfall/plugins/controller_plugin.py +162 -0
- lightfall/plugins/engine_plugin.py +124 -0
- lightfall/plugins/errors.py +104 -0
- lightfall/plugins/info.py +112 -0
- lightfall/plugins/loader.py +878 -0
- lightfall/plugins/manifest.py +150 -0
- lightfall/plugins/panel_plugin.py +119 -0
- lightfall/plugins/plan_plugin.py +163 -0
- lightfall/plugins/registry.py +309 -0
- lightfall/plugins/settings_plugin.py +226 -0
- lightfall/plugins/statusbar_plugin.py +289 -0
- lightfall/plugins/theme_plugin.py +165 -0
- lightfall/plugins/types.py +136 -0
- lightfall/plugins/user_plugins.py +764 -0
- lightfall/project/__init__.py +37 -0
- lightfall/project/model.py +375 -0
- lightfall/project/service.py +427 -0
- lightfall/project/welcome.py +106 -0
- lightfall/resources/__init__.py +126 -0
- lightfall/resources/images/__init__.py +1 -0
- lightfall/resources/images/icon.ico +0 -0
- lightfall/resources/images/icon.png +0 -0
- lightfall/resources/images/logo.png +0 -0
- lightfall/services/__init__.py +33 -0
- lightfall/services/_alshub_client.py +73 -0
- lightfall/services/access_stamper.py +240 -0
- lightfall/services/als_beam_status.py +347 -0
- lightfall/services/ca_tunnel.py +325 -0
- lightfall/services/threaded_tiled_writer.py +174 -0
- lightfall/services/tiled_auth.py +21 -0
- lightfall/services/tiled_service.py +971 -0
- lightfall/services/tiled_writer_patch.py +301 -0
- lightfall/settings/__init__.py +1 -0
- lightfall/settings/image_helpers.py +30 -0
- lightfall/settings/user_settings_client.py +232 -0
- lightfall/ui/__init__.py +28 -0
- lightfall/ui/annotations.py +208 -0
- lightfall/ui/common/__init__.py +7 -0
- lightfall/ui/dialogs/__init__.py +26 -0
- lightfall/ui/dialogs/about_dialog.py +131 -0
- lightfall/ui/dialogs/add_trigger_dialog.py +152 -0
- lightfall/ui/dialogs/base.py +44 -0
- lightfall/ui/dialogs/bug_report_dialog.py +353 -0
- lightfall/ui/dialogs/create_plan_dialog.py +189 -0
- lightfall/ui/dialogs/device_edit_dialog.py +183 -0
- lightfall/ui/dialogs/export_dialog.py +565 -0
- lightfall/ui/dialogs/go_to_position_dialog.py +192 -0
- lightfall/ui/dialogs/login_dialog.py +756 -0
- lightfall/ui/dialogs/oauth_browser_dialog.py +305 -0
- lightfall/ui/dialogs/run_pipeline_dialog.py +131 -0
- lightfall/ui/dialogs/sample_metadata_dialog.py +316 -0
- lightfall/ui/docking/__init__.py +22 -0
- lightfall/ui/docking/icon_sidebar.py +806 -0
- lightfall/ui/docking/manager.py +682 -0
- lightfall/ui/docking/state.py +113 -0
- lightfall/ui/docking/theme.py +399 -0
- lightfall/ui/docking/widget.py +214 -0
- lightfall/ui/events.py +75 -0
- lightfall/ui/mainwindow.py +1006 -0
- lightfall/ui/models/__init__.py +49 -0
- lightfall/ui/models/device_selection.py +389 -0
- lightfall/ui/models/device_tree.py +1095 -0
- lightfall/ui/models/thread_model.py +667 -0
- lightfall/ui/models/tiled_model.py +384 -0
- lightfall/ui/panels/__init__.py +28 -0
- lightfall/ui/panels/base.py +525 -0
- lightfall/ui/panels/bluesky_panel.py +619 -0
- lightfall/ui/panels/claude/__init__.py +9 -0
- lightfall/ui/panels/claude/agent_registry.py +168 -0
- lightfall/ui/panels/claude_panel.py +887 -0
- lightfall/ui/panels/device_panel.py +370 -0
- lightfall/ui/panels/documents_panel.py +166 -0
- lightfall/ui/panels/ipython_panel.py +580 -0
- lightfall/ui/panels/logbook_entries_panel.py +84 -0
- lightfall/ui/panels/logbook_panel.py +627 -0
- lightfall/ui/panels/logging_panel.py +587 -0
- lightfall/ui/panels/pipeline_jobs_panel.py +160 -0
- lightfall/ui/panels/pipeline_triggers_panel.py +170 -0
- lightfall/ui/panels/plugins/__init__.py +34 -0
- lightfall/ui/panels/plugins/bluesky_plugin.py +27 -0
- lightfall/ui/panels/plugins/claude_plugin.py +29 -0
- lightfall/ui/panels/plugins/device_plugin.py +27 -0
- lightfall/ui/panels/plugins/documents_plugin.py +26 -0
- lightfall/ui/panels/plugins/ipython_plugin.py +27 -0
- lightfall/ui/panels/plugins/logbook_entries_plugin.py +23 -0
- lightfall/ui/panels/plugins/logbook_plugin.py +27 -0
- lightfall/ui/panels/plugins/logging_plugin.py +27 -0
- lightfall/ui/panels/plugins/pipeline_jobs_plugin.py +23 -0
- lightfall/ui/panels/plugins/pipeline_triggers_plugin.py +25 -0
- lightfall/ui/panels/plugins/queue_plugin.py +29 -0
- lightfall/ui/panels/plugins/synoptic_plugin.py +38 -0
- lightfall/ui/panels/plugins/threads_plugin.py +27 -0
- lightfall/ui/panels/plugins/tiled_browser_plugin.py +27 -0
- lightfall/ui/panels/plugins/visualization_plugin.py +27 -0
- lightfall/ui/panels/queue.py +754 -0
- lightfall/ui/panels/registry.py +483 -0
- lightfall/ui/panels/synoptic/__init__.py +27 -0
- lightfall/ui/panels/synoptic/editors.py +481 -0
- lightfall/ui/panels/synoptic/items.py +556 -0
- lightfall/ui/panels/synoptic/models.py +336 -0
- lightfall/ui/panels/synoptic/panel.py +889 -0
- lightfall/ui/panels/synoptic/serialization.py +300 -0
- lightfall/ui/panels/synoptic/view.py +504 -0
- lightfall/ui/panels/threads_panel.py +621 -0
- lightfall/ui/panels/tiled_browser_panel.py +854 -0
- lightfall/ui/panels/visualization_panel.py +508 -0
- lightfall/ui/preferences/__init__.py +24 -0
- lightfall/ui/preferences/backend.py +148 -0
- lightfall/ui/preferences/builtin.py +220 -0
- lightfall/ui/preferences/claude_settings.py +762 -0
- lightfall/ui/preferences/device_settings.py +461 -0
- lightfall/ui/preferences/dialog.py +234 -0
- lightfall/ui/preferences/editor_settings.py +227 -0
- lightfall/ui/preferences/ipc_settings.py +226 -0
- lightfall/ui/preferences/logbook_settings.py +232 -0
- lightfall/ui/preferences/login_settings.py +183 -0
- lightfall/ui/preferences/manager.py +562 -0
- lightfall/ui/preferences/plugin_settings.py +392 -0
- lightfall/ui/preferences/proxy_settings.py +561 -0
- lightfall/ui/preferences/skill_settings.py +28 -0
- lightfall/ui/preferences/tiled_settings.py +469 -0
- lightfall/ui/preferences/tool_settings.py +393 -0
- lightfall/ui/preferences/user_portable_backend.py +131 -0
- lightfall/ui/preferences/user_profile_settings.py +316 -0
- lightfall/ui/preferences/visualization_settings.py +159 -0
- lightfall/ui/resources/__init__.py +1 -0
- lightfall/ui/resources/logo.png +0 -0
- lightfall/ui/statusbar/__init__.py +11 -0
- lightfall/ui/statusbar/manager.py +379 -0
- lightfall/ui/statusbar/plugins/__init__.py +28 -0
- lightfall/ui/statusbar/plugins/als_beam_status.py +218 -0
- lightfall/ui/statusbar/plugins/auth_status.py +116 -0
- lightfall/ui/statusbar/plugins/connection_status.py +100 -0
- lightfall/ui/statusbar/plugins/thread_status.py +556 -0
- lightfall/ui/statusbar/plugins/tiled_status.py +179 -0
- lightfall/ui/statusbar/plugins/user_status.py +84 -0
- lightfall/ui/theater/__init__.py +28 -0
- lightfall/ui/theater/manager.py +124 -0
- lightfall/ui/theater/overlay.py +279 -0
- lightfall/ui/theater/proxy.py +111 -0
- lightfall/ui/theme/__init__.py +18 -0
- lightfall/ui/theme/builtin.py +1015 -0
- lightfall/ui/theme/manager.py +875 -0
- lightfall/ui/theme/registry.py +195 -0
- lightfall/ui/toast.py +221 -0
- lightfall/ui/tutorial.py +1100 -0
- lightfall/ui/widgets/__init__.py +110 -0
- lightfall/ui/widgets/base_control.py +259 -0
- lightfall/ui/widgets/camera/__init__.py +36 -0
- lightfall/ui/widgets/camera/base.py +815 -0
- lightfall/ui/widgets/camera/dark_frames.py +213 -0
- lightfall/ui/widgets/camera/image_view.py +649 -0
- lightfall/ui/widgets/camera/panels/__init__.py +14 -0
- lightfall/ui/widgets/camera/panels/cooler.py +320 -0
- lightfall/ui/widgets/camera/panels/temperature.py +192 -0
- lightfall/ui/widgets/camera/plan_based.py +202 -0
- lightfall/ui/widgets/compact_motor.py +522 -0
- lightfall/ui/widgets/controller_matcher.py +278 -0
- lightfall/ui/widgets/controller_registry.py +144 -0
- lightfall/ui/widgets/device_control.py +411 -0
- lightfall/ui/widgets/device_selector.py +438 -0
- lightfall/ui/widgets/device_tree_tab.py +461 -0
- lightfall/ui/widgets/document_stream.py +1028 -0
- lightfall/ui/widgets/favorites_tab.py +191 -0
- lightfall/ui/widgets/motor_control.py +1120 -0
- lightfall/ui/widgets/observers/__init__.py +8 -0
- lightfall/ui/widgets/observers/camera.py +48 -0
- lightfall/ui/widgets/observers/image_view.py +130 -0
- lightfall/ui/widgets/plan_config.py +954 -0
- lightfall/ui/widgets/plan_edit_dialog.py +294 -0
- lightfall/ui/widgets/plan_selector.py +452 -0
- lightfall/ui/widgets/profile_avatar.py +128 -0
- lightfall/ui/widgets/queue_view.py +647 -0
- lightfall/ui/widgets/runengine_control.py +549 -0
- lightfall/ui/widgets/signal_control.py +793 -0
- lightfall/ui/widgets/skill_trigger_button.py +183 -0
- lightfall/ui/widgets/tiled_filter_widget.py +314 -0
- lightfall/ui/widgets/tiled_status.py +149 -0
- lightfall/ui/widgets/warning_banner.py +185 -0
- lightfall/utils/__init__.py +53 -0
- lightfall/utils/crash_diagnostics.py +454 -0
- lightfall/utils/data_migration.py +22 -0
- lightfall/utils/editor_launcher.py +594 -0
- lightfall/utils/error_collector.py +245 -0
- lightfall/utils/git_tracker.py +197 -0
- lightfall/utils/log_buffer.py +233 -0
- lightfall/utils/logging.py +229 -0
- lightfall/utils/module_resolver.py +70 -0
- lightfall/utils/sentry.py +722 -0
- lightfall/utils/threads.py +991 -0
- lightfall/utils/tiled_helpers.py +96 -0
- lightfall/visualization/__init__.py +50 -0
- lightfall/visualization/base.py +5 -0
- lightfall/visualization/base_visualization.py +74 -0
- lightfall/visualization/fitting/__init__.py +24 -0
- lightfall/visualization/fitting/base.py +267 -0
- lightfall/visualization/fitting/fitters.py +325 -0
- lightfall/visualization/fitting/panel.py +265 -0
- lightfall/visualization/memory.py +392 -0
- lightfall/visualization/motor_mixin.py +524 -0
- lightfall/visualization/pg.py +156 -0
- lightfall/visualization/registry.py +144 -0
- lightfall/visualization/spec.py +79 -0
- lightfall/visualization/theme.py +266 -0
- lightfall/visualization/widgets/__init__.py +28 -0
- lightfall/visualization/widgets/adaptive/__init__.py +1 -0
- lightfall/visualization/widgets/adaptive/heatmap.py +655 -0
- lightfall/visualization/widgets/adaptive/plot.py +233 -0
- lightfall/visualization/widgets/heatmap.py +264 -0
- lightfall/visualization/widgets/image_stack.py +316 -0
- lightfall/visualization/widgets/image_view_toolbar.py +227 -0
- lightfall/visualization/widgets/lazy_image_view.py +590 -0
- lightfall/visualization/widgets/plot_1d.py +262 -0
- lightfall/visualization/widgets/scatter.py +247 -0
- lightfall/visualization/widgets/table.py +221 -0
- lightfall/visualization/widgets/time_axis.py +93 -0
- lightfall-0.1.1.dist-info/METADATA +223 -0
- lightfall-0.1.1.dist-info/RECORD +388 -0
- lightfall-0.1.1.dist-info/WHEEL +4 -0
- lightfall-0.1.1.dist-info/entry_points.txt +6 -0
- lightfall-0.1.1.dist-info/licenses/LEGAL.md +13 -0
- lightfall-0.1.1.dist-info/licenses/LICENSE.md +33 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"""Tiled status plugin for NCS status bar.
|
|
2
|
+
|
|
3
|
+
Displays the Tiled data catalog connection state.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Any, ClassVar
|
|
9
|
+
|
|
10
|
+
from PySide6.QtCore import Slot
|
|
11
|
+
|
|
12
|
+
from lightfall.plugins.statusbar_plugin import StatusBarPlugin, StatusBarPluginMetadata
|
|
13
|
+
from lightfall.ui.theme import ThemeManager
|
|
14
|
+
from lightfall.utils.logging import logger
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TiledStatusPlugin(StatusBarPlugin):
|
|
18
|
+
"""Status bar plugin showing Tiled connection state.
|
|
19
|
+
|
|
20
|
+
Displays connection state with theme-aware color coding:
|
|
21
|
+
- success: Connected
|
|
22
|
+
- warning: Connecting
|
|
23
|
+
- error: Error
|
|
24
|
+
- text_secondary: Disabled/Disconnected
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
metadata: ClassVar[StatusBarPluginMetadata] = StatusBarPluginMetadata(
|
|
28
|
+
id="lightfall.statusbar.tiled",
|
|
29
|
+
name="Tiled Status",
|
|
30
|
+
description="Shows Tiled data catalog connection state",
|
|
31
|
+
priority=40,
|
|
32
|
+
position="permanent",
|
|
33
|
+
tooltip="Tiled data catalog status",
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
def __init__(self) -> None:
|
|
37
|
+
"""Initialize the Tiled status plugin."""
|
|
38
|
+
super().__init__()
|
|
39
|
+
self._service = None
|
|
40
|
+
self._theme_manager: ThemeManager | None = None
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def name(self) -> str:
|
|
44
|
+
"""Plugin name."""
|
|
45
|
+
return "tiled_status"
|
|
46
|
+
|
|
47
|
+
def update(self) -> None:
|
|
48
|
+
"""Update the button with current Tiled state."""
|
|
49
|
+
if self._theme_manager is None:
|
|
50
|
+
self._theme_manager = ThemeManager.get_instance()
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
from lightfall.services.tiled_service import TiledConnectionState, TiledService
|
|
54
|
+
|
|
55
|
+
service = TiledService.get_instance()
|
|
56
|
+
self._service = service
|
|
57
|
+
|
|
58
|
+
if not service.config.enabled:
|
|
59
|
+
self._update_display_disabled()
|
|
60
|
+
elif service.state == TiledConnectionState.CONNECTED:
|
|
61
|
+
self._update_display_connected()
|
|
62
|
+
elif service.state == TiledConnectionState.CONNECTING:
|
|
63
|
+
self._update_display_connecting()
|
|
64
|
+
elif service.state == TiledConnectionState.ERROR:
|
|
65
|
+
self._update_display_error(service.error_message)
|
|
66
|
+
else:
|
|
67
|
+
self._update_display_disconnected()
|
|
68
|
+
|
|
69
|
+
except Exception as e:
|
|
70
|
+
logger.debug("Could not get TiledService state: {}", e)
|
|
71
|
+
self._update_display_disabled()
|
|
72
|
+
|
|
73
|
+
def connect_signals(self) -> None:
|
|
74
|
+
"""Connect to Tiled service signals."""
|
|
75
|
+
if self._theme_manager is None:
|
|
76
|
+
self._theme_manager = ThemeManager.get_instance()
|
|
77
|
+
self._theme_manager.colors_changed.connect(self.update)
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
from lightfall.services.tiled_service import TiledService
|
|
81
|
+
|
|
82
|
+
service = TiledService.get_instance()
|
|
83
|
+
self._service = service
|
|
84
|
+
service.connection_changed.connect(self._on_connection_changed)
|
|
85
|
+
|
|
86
|
+
except Exception as e:
|
|
87
|
+
logger.debug("Could not connect to TiledService: {}", e)
|
|
88
|
+
|
|
89
|
+
def disconnect_signals(self) -> None:
|
|
90
|
+
"""Disconnect from Tiled service signals."""
|
|
91
|
+
if self._service is not None:
|
|
92
|
+
try:
|
|
93
|
+
self._service.connection_changed.disconnect(self._on_connection_changed)
|
|
94
|
+
except RuntimeError:
|
|
95
|
+
pass
|
|
96
|
+
|
|
97
|
+
if self._theme_manager is not None:
|
|
98
|
+
try:
|
|
99
|
+
self._theme_manager.colors_changed.disconnect(self.update)
|
|
100
|
+
except RuntimeError:
|
|
101
|
+
pass
|
|
102
|
+
|
|
103
|
+
@Slot(object, str)
|
|
104
|
+
def _on_connection_changed(self, state, message: str) -> None:
|
|
105
|
+
"""Handle connection state change."""
|
|
106
|
+
from lightfall.services.tiled_service import TiledConnectionState
|
|
107
|
+
|
|
108
|
+
if state == TiledConnectionState.CONNECTED:
|
|
109
|
+
self._update_display_connected()
|
|
110
|
+
elif state == TiledConnectionState.CONNECTING:
|
|
111
|
+
self._update_display_connecting()
|
|
112
|
+
elif state == TiledConnectionState.ERROR:
|
|
113
|
+
self._update_display_error(message)
|
|
114
|
+
elif state == TiledConnectionState.DISCONNECTED:
|
|
115
|
+
try:
|
|
116
|
+
from lightfall.services.tiled_service import TiledService
|
|
117
|
+
|
|
118
|
+
service = TiledService.get_instance()
|
|
119
|
+
if not service.config.enabled:
|
|
120
|
+
self._update_display_disabled()
|
|
121
|
+
else:
|
|
122
|
+
self._update_display_disconnected()
|
|
123
|
+
except Exception:
|
|
124
|
+
self._update_display_disconnected()
|
|
125
|
+
|
|
126
|
+
@property
|
|
127
|
+
def _colors(self):
|
|
128
|
+
"""Resolve theme colors, falling back to the singleton on first use."""
|
|
129
|
+
if self._theme_manager is None:
|
|
130
|
+
self._theme_manager = ThemeManager.get_instance()
|
|
131
|
+
return self._theme_manager.colors
|
|
132
|
+
|
|
133
|
+
def _update_display_connected(self) -> None:
|
|
134
|
+
self.set_text("Tiled: Connected")
|
|
135
|
+
self.set_color(self._colors.success)
|
|
136
|
+
self.set_tooltip("Connected to Tiled server")
|
|
137
|
+
|
|
138
|
+
def _update_display_connecting(self) -> None:
|
|
139
|
+
self.set_text("Tiled: Connecting...")
|
|
140
|
+
self.set_color(self._colors.warning)
|
|
141
|
+
self.set_tooltip("Connecting to Tiled server...")
|
|
142
|
+
|
|
143
|
+
def _update_display_error(self, message: str = "") -> None:
|
|
144
|
+
self.set_text("Tiled: Error")
|
|
145
|
+
self.set_color(self._colors.error)
|
|
146
|
+
tooltip = "Tiled connection error"
|
|
147
|
+
if message:
|
|
148
|
+
tooltip = f"Tiled error: {message}"
|
|
149
|
+
self.set_tooltip(tooltip)
|
|
150
|
+
|
|
151
|
+
def _update_display_disconnected(self) -> None:
|
|
152
|
+
self.set_text("Tiled: Disconnected")
|
|
153
|
+
self.set_color(self._colors.text_secondary)
|
|
154
|
+
self.set_tooltip("Disconnected from Tiled server")
|
|
155
|
+
|
|
156
|
+
def _update_display_disabled(self) -> None:
|
|
157
|
+
self.set_text("Tiled: Off")
|
|
158
|
+
self.set_color(self._colors.text_secondary)
|
|
159
|
+
self.set_tooltip("Tiled integration is disabled")
|
|
160
|
+
|
|
161
|
+
def get_introspection_data(self) -> dict[str, Any]:
|
|
162
|
+
"""Get introspection data for MCP tools."""
|
|
163
|
+
data = super().get_introspection_data()
|
|
164
|
+
|
|
165
|
+
try:
|
|
166
|
+
from lightfall.services.tiled_service import TiledService
|
|
167
|
+
|
|
168
|
+
service = TiledService.get_instance()
|
|
169
|
+
data["tiled_enabled"] = service.config.enabled
|
|
170
|
+
data["tiled_state"] = service.state.name
|
|
171
|
+
data["tiled_url"] = service.config.url or ""
|
|
172
|
+
if service.error_message:
|
|
173
|
+
data["tiled_error"] = service.error_message
|
|
174
|
+
|
|
175
|
+
except Exception:
|
|
176
|
+
data["tiled_enabled"] = False
|
|
177
|
+
data["tiled_state"] = "UNAVAILABLE"
|
|
178
|
+
|
|
179
|
+
return data
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""User status plugin for NCS status bar.
|
|
2
|
+
|
|
3
|
+
Displays the current user's display name.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Any, ClassVar
|
|
9
|
+
|
|
10
|
+
from lightfall.auth.session import SessionManager
|
|
11
|
+
from lightfall.plugins.statusbar_plugin import StatusBarPlugin, StatusBarPluginMetadata
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class UserStatusPlugin(StatusBarPlugin):
|
|
15
|
+
"""Status bar plugin showing the current user.
|
|
16
|
+
|
|
17
|
+
Displays the user's display name and updates when the user changes
|
|
18
|
+
(login/logout).
|
|
19
|
+
|
|
20
|
+
Example display:
|
|
21
|
+
"User: John Doe"
|
|
22
|
+
"User: Guest"
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
metadata: ClassVar[StatusBarPluginMetadata] = StatusBarPluginMetadata(
|
|
26
|
+
id="lightfall.statusbar.user",
|
|
27
|
+
name="User Status",
|
|
28
|
+
description="Shows the current logged-in user",
|
|
29
|
+
priority=10,
|
|
30
|
+
position="permanent",
|
|
31
|
+
tooltip="Current user",
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
def __init__(self) -> None:
|
|
35
|
+
"""Initialize the user status plugin."""
|
|
36
|
+
super().__init__()
|
|
37
|
+
self._session_manager: SessionManager | None = None
|
|
38
|
+
|
|
39
|
+
@property
|
|
40
|
+
def name(self) -> str:
|
|
41
|
+
"""Plugin name."""
|
|
42
|
+
return "user_status"
|
|
43
|
+
|
|
44
|
+
def update(self) -> None:
|
|
45
|
+
"""Update the button with current user."""
|
|
46
|
+
if self._session_manager is None:
|
|
47
|
+
self._session_manager = SessionManager.get_instance()
|
|
48
|
+
|
|
49
|
+
user = self._session_manager.current_user
|
|
50
|
+
self.set_text(f"User: {user.display_name}")
|
|
51
|
+
self.set_tooltip(f"Logged in as {user.username}")
|
|
52
|
+
|
|
53
|
+
def connect_signals(self) -> None:
|
|
54
|
+
"""Connect to session manager signals."""
|
|
55
|
+
if self._session_manager is None:
|
|
56
|
+
self._session_manager = SessionManager.get_instance()
|
|
57
|
+
|
|
58
|
+
self._session_manager.user_changed.connect(self._on_user_changed)
|
|
59
|
+
|
|
60
|
+
def disconnect_signals(self) -> None:
|
|
61
|
+
"""Disconnect from session manager signals."""
|
|
62
|
+
if self._session_manager is not None:
|
|
63
|
+
try:
|
|
64
|
+
self._session_manager.user_changed.disconnect(self._on_user_changed)
|
|
65
|
+
except RuntimeError:
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
def _on_user_changed(self, user: Any) -> None:
|
|
69
|
+
"""Handle user change signal."""
|
|
70
|
+
self.update()
|
|
71
|
+
|
|
72
|
+
def get_introspection_data(self) -> dict[str, Any]:
|
|
73
|
+
"""Get introspection data for MCP tools."""
|
|
74
|
+
data = super().get_introspection_data()
|
|
75
|
+
|
|
76
|
+
if self._session_manager is not None:
|
|
77
|
+
user = self._session_manager.current_user
|
|
78
|
+
data["current_user"] = {
|
|
79
|
+
"username": user.username,
|
|
80
|
+
"display_name": user.display_name,
|
|
81
|
+
"roles": [r.name for r in user.roles],
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return data
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Theater mode — generic widget expansion overlay.
|
|
2
|
+
|
|
3
|
+
Usage with install (existing widget in a layout)::
|
|
4
|
+
|
|
5
|
+
from lightfall.ui.theater import theater_manager
|
|
6
|
+
|
|
7
|
+
plot = pg.PlotWidget()
|
|
8
|
+
layout.addWidget(plot)
|
|
9
|
+
theater_manager.install(plot)
|
|
10
|
+
|
|
11
|
+
Usage with direct proxy construction::
|
|
12
|
+
|
|
13
|
+
from lightfall.ui.theater import TheaterProxy
|
|
14
|
+
|
|
15
|
+
proxy = TheaterProxy(my_image_view)
|
|
16
|
+
layout.addWidget(proxy)
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from lightfall.ui.theater.manager import TheaterManager, theater_manager
|
|
20
|
+
from lightfall.ui.theater.overlay import TheaterOverlay
|
|
21
|
+
from lightfall.ui.theater.proxy import TheaterProxy
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"TheaterManager",
|
|
25
|
+
"TheaterOverlay",
|
|
26
|
+
"TheaterProxy",
|
|
27
|
+
"theater_manager",
|
|
28
|
+
]
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""TheaterManager — singleton coordinator for theater mode."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from functools import partial
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from PySide6.QtWidgets import QWidget
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from lightfall.ui.theater.overlay import TheaterOverlay
|
|
12
|
+
from lightfall.ui.theater.proxy import TheaterProxy
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TheaterManager:
|
|
16
|
+
"""Coordinates TheaterProxy instances and the TheaterOverlay."""
|
|
17
|
+
|
|
18
|
+
def __init__(self) -> None:
|
|
19
|
+
self._proxies: dict[int, TheaterProxy] = {}
|
|
20
|
+
self._slots: dict[int, partial] = {}
|
|
21
|
+
self._overlay: TheaterOverlay | None = None
|
|
22
|
+
|
|
23
|
+
def register(self, proxy: TheaterProxy) -> None:
|
|
24
|
+
"""Register a proxy and connect its expand signal."""
|
|
25
|
+
widget_id = id(proxy.target_widget)
|
|
26
|
+
self._proxies[widget_id] = proxy
|
|
27
|
+
slot = partial(self.activate, proxy)
|
|
28
|
+
self._slots[widget_id] = slot
|
|
29
|
+
proxy.expand_requested.connect(slot)
|
|
30
|
+
proxy.destroyed.connect(lambda: self._on_proxy_destroyed(widget_id))
|
|
31
|
+
|
|
32
|
+
def unregister(self, proxy: TheaterProxy) -> None:
|
|
33
|
+
"""Unregister a proxy."""
|
|
34
|
+
widget_id = id(proxy.target_widget)
|
|
35
|
+
self._proxies.pop(widget_id, None)
|
|
36
|
+
slot = self._slots.pop(widget_id, None)
|
|
37
|
+
if slot is not None:
|
|
38
|
+
try:
|
|
39
|
+
proxy.expand_requested.disconnect(slot)
|
|
40
|
+
except RuntimeError:
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
def _on_proxy_destroyed(self, widget_id: int) -> None:
|
|
44
|
+
"""Auto-cleanup when a proxy is destroyed without unregister."""
|
|
45
|
+
self._proxies.pop(widget_id, None)
|
|
46
|
+
self._slots.pop(widget_id, None)
|
|
47
|
+
|
|
48
|
+
def install(self, widget: QWidget) -> TheaterProxy:
|
|
49
|
+
"""Wrap an already-laid-out widget in a TheaterProxy.
|
|
50
|
+
|
|
51
|
+
Finds the widget's parent layout and replaces the widget
|
|
52
|
+
at the same index with a new TheaterProxy.
|
|
53
|
+
"""
|
|
54
|
+
from lightfall.ui.theater.proxy import TheaterProxy
|
|
55
|
+
|
|
56
|
+
parent = widget.parentWidget()
|
|
57
|
+
if parent is None:
|
|
58
|
+
msg = "Cannot install theater mode on a widget without a parent"
|
|
59
|
+
raise ValueError(msg)
|
|
60
|
+
layout = parent.layout()
|
|
61
|
+
if layout is None:
|
|
62
|
+
msg = "Cannot install theater mode: parent widget has no layout"
|
|
63
|
+
raise ValueError(msg)
|
|
64
|
+
|
|
65
|
+
index = layout.indexOf(widget)
|
|
66
|
+
if index < 0:
|
|
67
|
+
msg = "Widget not found in parent's layout"
|
|
68
|
+
raise ValueError(msg)
|
|
69
|
+
|
|
70
|
+
proxy = TheaterProxy(widget)
|
|
71
|
+
layout.insertWidget(index, proxy)
|
|
72
|
+
return proxy
|
|
73
|
+
|
|
74
|
+
def uninstall(self, widget: QWidget) -> None:
|
|
75
|
+
"""Remove theater mode from a widget, restoring it to its layout."""
|
|
76
|
+
widget_id = id(widget)
|
|
77
|
+
proxy = self._proxies.get(widget_id)
|
|
78
|
+
if proxy is None:
|
|
79
|
+
return
|
|
80
|
+
|
|
81
|
+
# Deactivate if currently in theater mode
|
|
82
|
+
if self._overlay is not None and self._overlay._active_proxy is proxy:
|
|
83
|
+
self._overlay._finish_deactivate()
|
|
84
|
+
|
|
85
|
+
# Restore widget to layout
|
|
86
|
+
parent = proxy.parentWidget()
|
|
87
|
+
layout = parent.layout() if parent else None
|
|
88
|
+
|
|
89
|
+
if layout is not None:
|
|
90
|
+
index = layout.indexOf(proxy)
|
|
91
|
+
target = proxy.take_widget()
|
|
92
|
+
layout.removeWidget(proxy)
|
|
93
|
+
if index >= 0:
|
|
94
|
+
layout.insertWidget(index, target)
|
|
95
|
+
else:
|
|
96
|
+
layout.addWidget(target)
|
|
97
|
+
|
|
98
|
+
self.unregister(proxy)
|
|
99
|
+
proxy.deleteLater()
|
|
100
|
+
|
|
101
|
+
def activate(self, proxy: TheaterProxy) -> None:
|
|
102
|
+
"""Expand a proxy's widget onto the overlay."""
|
|
103
|
+
if self._overlay is None:
|
|
104
|
+
from lightfall.ui.theater.overlay import TheaterOverlay
|
|
105
|
+
|
|
106
|
+
parent = proxy.window()
|
|
107
|
+
self._overlay = TheaterOverlay(parent)
|
|
108
|
+
self._overlay.activate(proxy)
|
|
109
|
+
|
|
110
|
+
def deactivate(self) -> None:
|
|
111
|
+
"""Collapse the currently expanded widget."""
|
|
112
|
+
if self._overlay is not None:
|
|
113
|
+
self._overlay.deactivate()
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
def is_active(self) -> bool:
|
|
117
|
+
"""Whether a widget is currently in theater mode."""
|
|
118
|
+
return (
|
|
119
|
+
self._overlay is not None
|
|
120
|
+
and self._overlay._active_proxy is not None
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
theater_manager = TheaterManager()
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"""TheaterOverlay — fullscreen expansion overlay with dimmed backdrop."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from PySide6.QtCore import (
|
|
8
|
+
Property,
|
|
9
|
+
QEasingCurve,
|
|
10
|
+
QEvent,
|
|
11
|
+
QParallelAnimationGroup,
|
|
12
|
+
QPoint,
|
|
13
|
+
QPropertyAnimation,
|
|
14
|
+
QRect,
|
|
15
|
+
Qt,
|
|
16
|
+
)
|
|
17
|
+
from PySide6.QtGui import QColor, QKeySequence, QPainter, QShortcut
|
|
18
|
+
from PySide6.QtWidgets import QToolButton, QWidget
|
|
19
|
+
|
|
20
|
+
try:
|
|
21
|
+
import qtawesome as qta
|
|
22
|
+
except ImportError: # pragma: no cover
|
|
23
|
+
qta = None
|
|
24
|
+
|
|
25
|
+
if TYPE_CHECKING:
|
|
26
|
+
from lightfall.ui.theater.proxy import TheaterProxy
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class TheaterOverlay(QWidget):
|
|
30
|
+
"""Overlay that displays an expanded widget with a dimmed backdrop."""
|
|
31
|
+
|
|
32
|
+
_MARGIN = 20
|
|
33
|
+
_ANIM_DURATION_BACKDROP = 200
|
|
34
|
+
_ANIM_DURATION_GEOMETRY = 300
|
|
35
|
+
|
|
36
|
+
def __init__(self, parent: QWidget) -> None:
|
|
37
|
+
super().__init__(parent)
|
|
38
|
+
self.setObjectName("TheaterOverlay")
|
|
39
|
+
|
|
40
|
+
self._active_proxy: TheaterProxy | None = None
|
|
41
|
+
self._active_widget: QWidget | None = None
|
|
42
|
+
self._backdrop_opacity_value: int = 0
|
|
43
|
+
self._is_animating: bool = False
|
|
44
|
+
self._anim_group: QParallelAnimationGroup | None = None
|
|
45
|
+
|
|
46
|
+
# Collapse button
|
|
47
|
+
self._collapse_btn = QToolButton(self)
|
|
48
|
+
self._collapse_btn.setFixedSize(28, 28)
|
|
49
|
+
self._collapse_btn.setCursor(Qt.CursorShape.ArrowCursor)
|
|
50
|
+
self._collapse_btn.setObjectName("TheaterCollapseButton")
|
|
51
|
+
self._collapse_btn.setStyleSheet(
|
|
52
|
+
"QToolButton { background: rgba(0,0,0,160); border: none; "
|
|
53
|
+
"border-radius: 4px; padding: 2px; }"
|
|
54
|
+
"QToolButton:hover { background: rgba(0,0,0,220); }"
|
|
55
|
+
)
|
|
56
|
+
if qta is not None:
|
|
57
|
+
try:
|
|
58
|
+
self._collapse_btn.setIcon(
|
|
59
|
+
qta.icon("mdi6.arrow-collapse-all", color="#e0e0e0")
|
|
60
|
+
)
|
|
61
|
+
except Exception:
|
|
62
|
+
self._collapse_btn.setText("\u2716")
|
|
63
|
+
else:
|
|
64
|
+
self._collapse_btn.setText("\u2716")
|
|
65
|
+
self._collapse_btn.clicked.connect(self.deactivate)
|
|
66
|
+
self._collapse_btn.setVisible(False)
|
|
67
|
+
|
|
68
|
+
# Escape shortcut (works even when child widgets have focus)
|
|
69
|
+
self._escape_shortcut = QShortcut(
|
|
70
|
+
QKeySequence(Qt.Key.Key_Escape), self
|
|
71
|
+
)
|
|
72
|
+
self._escape_shortcut.setContext(
|
|
73
|
+
Qt.ShortcutContext.WidgetWithChildrenShortcut
|
|
74
|
+
)
|
|
75
|
+
self._escape_shortcut.activated.connect(self.deactivate)
|
|
76
|
+
|
|
77
|
+
self.setVisible(False)
|
|
78
|
+
self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
|
|
79
|
+
|
|
80
|
+
# Track parent resize
|
|
81
|
+
parent.installEventFilter(self)
|
|
82
|
+
|
|
83
|
+
# -- backdrop_opacity property for QPropertyAnimation -----------------
|
|
84
|
+
|
|
85
|
+
def _get_backdrop_opacity(self) -> int:
|
|
86
|
+
return self._backdrop_opacity_value
|
|
87
|
+
|
|
88
|
+
def _set_backdrop_opacity(self, value: int) -> None:
|
|
89
|
+
self._backdrop_opacity_value = value
|
|
90
|
+
self.update()
|
|
91
|
+
|
|
92
|
+
backdrop_opacity = Property(int, _get_backdrop_opacity, _set_backdrop_opacity)
|
|
93
|
+
|
|
94
|
+
# -- public API -------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
def activate(self, proxy: TheaterProxy) -> None:
|
|
97
|
+
"""Expand the proxy's widget onto the overlay."""
|
|
98
|
+
if self._is_animating:
|
|
99
|
+
return
|
|
100
|
+
if self._active_proxy is not None:
|
|
101
|
+
self._finish_deactivate()
|
|
102
|
+
|
|
103
|
+
self._active_proxy = proxy
|
|
104
|
+
widget = proxy.take_widget()
|
|
105
|
+
self._active_widget = widget
|
|
106
|
+
|
|
107
|
+
# Resize overlay to fill parent
|
|
108
|
+
parent = self.parentWidget()
|
|
109
|
+
self.setGeometry(0, 0, parent.width(), parent.height())
|
|
110
|
+
|
|
111
|
+
# Capture origin rect (proxy position in overlay coords)
|
|
112
|
+
origin = self.mapFromGlobal(proxy.mapToGlobal(QPoint(0, 0)))
|
|
113
|
+
origin_rect = QRect(origin, proxy.size())
|
|
114
|
+
target_rect = self._expanded_rect()
|
|
115
|
+
|
|
116
|
+
# Reparent widget into overlay
|
|
117
|
+
widget.setParent(self)
|
|
118
|
+
widget.setGeometry(origin_rect)
|
|
119
|
+
widget.show()
|
|
120
|
+
|
|
121
|
+
# Show overlay
|
|
122
|
+
self._backdrop_opacity_value = 0
|
|
123
|
+
self.setVisible(True)
|
|
124
|
+
self.raise_()
|
|
125
|
+
self.setFocus()
|
|
126
|
+
self._collapse_btn.setVisible(True)
|
|
127
|
+
self._collapse_btn.raise_()
|
|
128
|
+
self._update_collapse_btn_position(target_rect)
|
|
129
|
+
|
|
130
|
+
# Animate
|
|
131
|
+
self._is_animating = True
|
|
132
|
+
self._animate_open(origin_rect, target_rect, widget)
|
|
133
|
+
|
|
134
|
+
def deactivate(self) -> None:
|
|
135
|
+
"""Collapse the widget back to its proxy."""
|
|
136
|
+
if self._is_animating or self._active_proxy is None:
|
|
137
|
+
return
|
|
138
|
+
|
|
139
|
+
proxy = self._active_proxy
|
|
140
|
+
widget = self._active_widget
|
|
141
|
+
|
|
142
|
+
# Recapture proxy position (may have changed during resize)
|
|
143
|
+
target_origin = self.mapFromGlobal(proxy.mapToGlobal(QPoint(0, 0)))
|
|
144
|
+
target_rect = QRect(target_origin, proxy.size())
|
|
145
|
+
current_rect = widget.geometry()
|
|
146
|
+
|
|
147
|
+
self._collapse_btn.setVisible(False)
|
|
148
|
+
self._is_animating = True
|
|
149
|
+
self._animate_close(current_rect, target_rect, widget)
|
|
150
|
+
|
|
151
|
+
# -- animation --------------------------------------------------------
|
|
152
|
+
|
|
153
|
+
def _cleanup_animation(self) -> None:
|
|
154
|
+
"""Stop and clean up any running animation group."""
|
|
155
|
+
if self._anim_group is not None:
|
|
156
|
+
self._anim_group.stop()
|
|
157
|
+
try:
|
|
158
|
+
self._anim_group.finished.disconnect()
|
|
159
|
+
except RuntimeError:
|
|
160
|
+
pass
|
|
161
|
+
self._anim_group.deleteLater()
|
|
162
|
+
self._anim_group = None
|
|
163
|
+
|
|
164
|
+
def _animate_open(
|
|
165
|
+
self, origin: QRect, target: QRect, widget: QWidget
|
|
166
|
+
) -> None:
|
|
167
|
+
self._cleanup_animation()
|
|
168
|
+
backdrop_anim = QPropertyAnimation(self, b"backdrop_opacity")
|
|
169
|
+
backdrop_anim.setDuration(self._ANIM_DURATION_BACKDROP)
|
|
170
|
+
backdrop_anim.setStartValue(0)
|
|
171
|
+
backdrop_anim.setEndValue(150)
|
|
172
|
+
backdrop_anim.setEasingCurve(QEasingCurve.Type.OutCubic)
|
|
173
|
+
|
|
174
|
+
geo_anim = QPropertyAnimation(widget, b"geometry")
|
|
175
|
+
geo_anim.setDuration(self._ANIM_DURATION_GEOMETRY)
|
|
176
|
+
geo_anim.setStartValue(origin)
|
|
177
|
+
geo_anim.setEndValue(target)
|
|
178
|
+
geo_anim.setEasingCurve(QEasingCurve.Type.OutCubic)
|
|
179
|
+
|
|
180
|
+
self._anim_group = QParallelAnimationGroup(self)
|
|
181
|
+
self._anim_group.addAnimation(backdrop_anim)
|
|
182
|
+
self._anim_group.addAnimation(geo_anim)
|
|
183
|
+
self._anim_group.finished.connect(self._on_activate_finished)
|
|
184
|
+
self._anim_group.start()
|
|
185
|
+
|
|
186
|
+
def _animate_close(
|
|
187
|
+
self, current: QRect, target: QRect, widget: QWidget
|
|
188
|
+
) -> None:
|
|
189
|
+
self._cleanup_animation()
|
|
190
|
+
backdrop_anim = QPropertyAnimation(self, b"backdrop_opacity")
|
|
191
|
+
backdrop_anim.setDuration(self._ANIM_DURATION_BACKDROP)
|
|
192
|
+
backdrop_anim.setStartValue(self._backdrop_opacity_value)
|
|
193
|
+
backdrop_anim.setEndValue(0)
|
|
194
|
+
backdrop_anim.setEasingCurve(QEasingCurve.Type.OutCubic)
|
|
195
|
+
|
|
196
|
+
geo_anim = QPropertyAnimation(widget, b"geometry")
|
|
197
|
+
geo_anim.setDuration(self._ANIM_DURATION_GEOMETRY)
|
|
198
|
+
geo_anim.setStartValue(current)
|
|
199
|
+
geo_anim.setEndValue(target)
|
|
200
|
+
geo_anim.setEasingCurve(QEasingCurve.Type.OutCubic)
|
|
201
|
+
|
|
202
|
+
self._anim_group = QParallelAnimationGroup(self)
|
|
203
|
+
self._anim_group.addAnimation(backdrop_anim)
|
|
204
|
+
self._anim_group.addAnimation(geo_anim)
|
|
205
|
+
self._anim_group.finished.connect(self._finish_deactivate)
|
|
206
|
+
self._anim_group.start()
|
|
207
|
+
|
|
208
|
+
def _on_activate_finished(self) -> None:
|
|
209
|
+
self._is_animating = False
|
|
210
|
+
|
|
211
|
+
def _finish_deactivate(self) -> None:
|
|
212
|
+
"""Return the widget to its proxy and hide the overlay."""
|
|
213
|
+
self._is_animating = False
|
|
214
|
+
if self._active_proxy is None:
|
|
215
|
+
return
|
|
216
|
+
proxy = self._active_proxy
|
|
217
|
+
widget = self._active_widget
|
|
218
|
+
proxy.return_widget(widget)
|
|
219
|
+
self._active_proxy = None
|
|
220
|
+
self._active_widget = None
|
|
221
|
+
self._collapse_btn.setVisible(False)
|
|
222
|
+
self.setVisible(False)
|
|
223
|
+
|
|
224
|
+
# -- geometry helpers -------------------------------------------------
|
|
225
|
+
|
|
226
|
+
def _expanded_rect(self) -> QRect:
|
|
227
|
+
return QRect(
|
|
228
|
+
self._MARGIN,
|
|
229
|
+
self._MARGIN,
|
|
230
|
+
self.width() - 2 * self._MARGIN,
|
|
231
|
+
self.height() - 2 * self._MARGIN,
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
def _update_collapse_btn_position(
|
|
235
|
+
self, content_rect: QRect | None = None
|
|
236
|
+
) -> None:
|
|
237
|
+
if content_rect is None and self._active_widget is not None:
|
|
238
|
+
content_rect = self._active_widget.geometry()
|
|
239
|
+
if content_rect is None:
|
|
240
|
+
return
|
|
241
|
+
self._collapse_btn.move(
|
|
242
|
+
content_rect.right() - self._collapse_btn.width() - 8,
|
|
243
|
+
content_rect.top() + 8,
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
# -- events -----------------------------------------------------------
|
|
247
|
+
|
|
248
|
+
def paintEvent(self, event) -> None:
|
|
249
|
+
if self._backdrop_opacity_value > 0:
|
|
250
|
+
painter = QPainter(self)
|
|
251
|
+
painter.fillRect(
|
|
252
|
+
self.rect(), QColor(0, 0, 0, self._backdrop_opacity_value)
|
|
253
|
+
)
|
|
254
|
+
painter.end()
|
|
255
|
+
|
|
256
|
+
def keyPressEvent(self, event) -> None:
|
|
257
|
+
"""Fallback Escape handler when overlay itself has focus."""
|
|
258
|
+
if event.key() == Qt.Key.Key_Escape:
|
|
259
|
+
self.deactivate()
|
|
260
|
+
else:
|
|
261
|
+
super().keyPressEvent(event)
|
|
262
|
+
|
|
263
|
+
def mousePressEvent(self, event) -> None:
|
|
264
|
+
"""Click on backdrop (outside widget) dismisses the overlay."""
|
|
265
|
+
if self._active_widget is not None:
|
|
266
|
+
if not self._active_widget.geometry().contains(event.pos()):
|
|
267
|
+
self.deactivate()
|
|
268
|
+
return
|
|
269
|
+
super().mousePressEvent(event)
|
|
270
|
+
|
|
271
|
+
def eventFilter(self, obj, event) -> bool:
|
|
272
|
+
if obj is self.parentWidget() and event.type() == QEvent.Type.Resize:
|
|
273
|
+
new_size = event.size()
|
|
274
|
+
self.setGeometry(0, 0, new_size.width(), new_size.height())
|
|
275
|
+
if self._active_widget is not None and not self._is_animating:
|
|
276
|
+
target_rect = self._expanded_rect()
|
|
277
|
+
self._active_widget.setGeometry(target_rect)
|
|
278
|
+
self._update_collapse_btn_position(target_rect)
|
|
279
|
+
return super().eventFilter(obj, event)
|