spacr.qt.widgets.dna_rain_settings

The DNA button and the popover it opens.

The DNA rain’s controls used to be a bar pinned to the bottom of the sequencing screen: four sliders and a swatch, permanently on show, under a settings form the user is actually there to fill in. A backdrop is not worth a strip of chrome — so the controls moved behind a button.

The button is an AiToggleLabel reading DNA, sitting immediately left of the AI toggle in the actions row and built from the same class, so it inks the same white when off and the same accent blue when on, in every theme, without a second stylesheet to keep in step.

Clicking it opens DnaRainSettingsPopover — a frameless Qt.Popup holding the same DnaRainSettingsBar, laid out as a grid instead of a row. Qt.Popup is what makes it behave like a menu: it closes on a click anywhere else, on Escape, and when the screen it belongs to goes away.

The one subtlety is the click that lands on the button while the popover is open. Qt sends that press to the popup, closes the popup because the press was outside it, and then replays the press at the widget underneath — which is the button, which toggles straight back on. One click, open-close-open, and the popover looks like it will not close. REOPEN_GUARD_MS is the window in which the replayed half of that click is ignored.

The guard is armed by that press and by nothing else: not by Escape, not by a click somewhere else on the screen, not by a programmatic close. Anything broader would swallow a genuine click that happened to follow a close too quickly.

Classes

DnaRainSettingsPopover

Frameless popup holding one DnaRainSettingsBar.

DnaSettingsButton

The DNA toggle that opens the rain's settings.

Module Contents

class spacr.qt.widgets.dna_rain_settings.DnaRainSettingsPopover(bar: spacr.qt.widgets.dna_rain.DnaRainSettingsBar, parent: PySide6.QtWidgets.QWidget | None = None)[source]

Bases: PySide6.QtWidgets.QFrame

Frameless popup holding one DnaRainSettingsBar.

Parameters:
  • bar – the settings bar to show. Owned by the popover once handed over — it is reparented into it.

  • parent – parent widget; ownership only.

Variables:

closed – emitted whenever the popover stops being visible, however that happened, so the button can un-toggle itself.

Build the popover holding the DNA rain settings bar.

Parented but still a window: a Qt.Popup with a parent is destroyed with it and opens on the parent’s screen, which is what a per-screen popover wants. It is never laid out inside the parent. The bar is re-parented by addWidget rather than by an explicit setParent, which would mark it hidden and leave it blank inside a shown popover.

Parameters:
  • bar – the settings bar to show.

  • parent – the widget the popover belongs to, or None.

apply_theme() → None[source]

Re-take the popup’s colours, and the bar’s, from the palette.

A top-level window gets the application stylesheet but not the screen’s clear_container_surfaces sweep, so it has to state its own surface — otherwise it is the blanket QWidget window fill, which is flat black under every dark theme.

The bar has the same problem for the same reason, and neither is reached by the re-apply that re-styles the rest of a screen on a theme switch. Both are refreshed on every open, which is the only moment either is on screen.

hideEvent(event)[source]

Arm the guard if a click on the button is closing us.

Parameters:

event – the hide event; it is passed on to the base class unchanged before closed is emitted.

just_closed() → bool[source]

True if a click on the button closed it a moment ago.

Which means the second half of that same click is on its way to the button and must not be allowed to re-open this.

keyPressEvent(event)[source]

Escape closes, like every other popup in the app.

Parameters:

event – the key event; Escape hides the popover and is accepted, any other key goes to the base class.

mousePressEvent(event)[source]

Notice the press that is about to close us and be replayed.

A Qt.Popup receives every press while it is open, including the ones outside itself; Qt closes it after this handler returns and replays the press at the widget underneath. Only the presses that land on the button matter — that is the one that would toggle it straight back on.

Parameters:

event – the mouse press; its local and global positions decide whether it landed outside the popover on the anchor button.

open_near(anchor: PySide6.QtWidgets.QWidget) → None[source]

Show the popover just above (or below) anchor.

Parameters:

anchor – the widget the popover is positioned against, above it or else below it.

property bar: spacr.qt.widgets.dna_rain.DnaRainSettingsBar[source]

The settings bar inside this popover.

class spacr.qt.widgets.dna_rain_settings.DnaSettingsButton(bar: spacr.qt.widgets.dna_rain.DnaRainSettingsBar, parent: PySide6.QtWidgets.QWidget | None = None)[source]

Bases: spacr.qt.widgets.ai_toggle_label.AiToggleLabel

The DNA toggle that opens the rain’s settings.

Built from AiToggleLabel rather than styled to look like one, so it is the AI toggle’s twin by construction: same object name, same QSS, same off-white/on-accent behaviour under a live theme switch.

Parameters:
  • bar – the bound settings bar to put in the popover.

  • parent – parent widget; ownership only.

Build the button that opens the DNA rain settings.

Parameters:
  • bar – the settings bar the popover shows.

  • parent – parent widget, or None.

hideEvent(event)[source]

Take the popover down with the screen it belongs to.

Module screens are built once and kept in a stack, so switching tabs hides this button rather than destroying it. Without this the popover would be left floating over whatever screen the user moved to.

Parameters:

event – the hide event; it is passed on to the base class after the popover is hidden.

is_open() → bool[source]

True while the settings are on screen.

property popover: DnaRainSettingsPopover[source]

The popover this button opens.

property settings_bar: spacr.qt.widgets.dna_rain.DnaRainSettingsBar[source]

The settings bar inside the popover.