visualdynamics.gui.preferences¶
preferences
¶
What the application remembers between launches: the appearance, whether the plots open in 3-D, and the creator name written into ESCDF files.
The preferences are kept in one QSettings store under one name, so a
preference set on one launch is read on the next. When
VISUALDYNAMICS_SETTINGS names a file, the store is that INI file
instead. The tests set it, so nothing a test chooses reaches the user's
own preferences.
The appearance a window uses is decided in this order: an explicit
statement for this launch (VISUALDYNAMICS_THEME, which --theme
sets), then the remembered choice, then what the platform reports.
'system' means follow the platform. It is the default, and
theme.system_scheme reads the platform's answer.
Functions:
| Name | Description |
|---|---|
settings |
The application's preference store: the platform's (a plist on |
remembered_appearance |
The remembered appearance, 'system', 'light' or 'dark'. It is |
remember_appearance |
Store the appearance choice, 'system', 'light' or 'dark'. |
remembered_3d |
Whether the plots open in 3-D: True by default, and False once |
remember_3d |
Store the 2D/3D choice. |
remembered_creator |
The name an exported ESCDF file records as its creator |
remember_creator |
Store the creator name. |
chosen_scheme |
The theme to use now: this launch's statement, else the |
wear_appearance |
Make the whole application use the chosen appearance: the window |
wear_palette |
Give Qt's own widgets the palette of the chosen scheme where the |
refresh_palettes |
Make every widget re-read the application palette. |
Functions:¶
settings
¶
The application's preference store: the platform's (a plist on
macOS, the registry on Windows, a file under ~/.config on Linux), or
the INI file VISUALDYNAMICS_SETTINGS names.
Source code in src/visualdynamics/gui/preferences.py
remembered_appearance
¶
The remembered appearance, 'system', 'light' or 'dark'. It is 'system' when nothing was chosen or the stored word is not one of these.
Source code in src/visualdynamics/gui/preferences.py
remember_appearance
¶
Store the appearance choice, 'system', 'light' or 'dark'.
'system' removes the stored choice instead of storing it. Anything else raises ValueError.
Source code in src/visualdynamics/gui/preferences.py
remembered_3d
¶
Whether the plots open in 3-D: True by default, and False once the 2-D/3-D toggle was last left on 2-D. The one choice covers the data plots and the MAC.
Source code in src/visualdynamics/gui/preferences.py
remember_3d
¶
remembered_creator
¶
The name an exported ESCDF file records as its creator (File → Creator Name…), or '' when none was set. The writer then records the login name, because a file format library must never prompt for one.
Source code in src/visualdynamics/gui/preferences.py
remember_creator
¶
chosen_scheme
¶
The theme to use now: this launch's statement, else the remembered choice, else the platform's.
Source code in src/visualdynamics/gui/preferences.py
wear_appearance
¶
Make the whole application use the chosen appearance: the window frame, the menus and every native widget, as well as the parts this program draws itself.
This is QStyleHints.setColorScheme, from Qt 6.8: Light or Dark
forces the application's appearance (on macOS, the NSApp
appearance), and Unknown follows the platform again. On an older Qt
nothing is done here, and only the parts this program draws change.
The platform then reports the forced scheme, which is what
theme.system_scheme and the colorSchemeChanged slot read, so
every later repaint agrees.
app defaults to the running QApplication, and with none nothing
happens. choice is 'system', 'light' or 'dark', and defaults to
this launch's statement, else the remembered choice ('system'
follows the platform). refresh also makes every widget already
built re-read the palette (refresh_palettes), which a change of
appearance needs. A window that is being built passes False, because
its widgets read the palette as they are made.
Source code in src/visualdynamics/gui/preferences.py
wear_palette
¶
Give Qt's own widgets the palette of the chosen scheme where the platform did not.
Asked for a scheme, macOS and Windows change the application
palette, and every widget follows. Linux without a platform-theme
plugin changes nothing: the window, the toolbars and the menus stay
light under Dark. When the palette's window color is on the wrong
side of mid-gray for the scheme that applies (choice, or for
'system' the platform's, theme.system_scheme), the application
wears theme.DARK_CHROME, or the style's standard palette for
light. A palette worn here is taken off before each new choice, so
System and a platform that does follow get the platform's own back.
Anything other than a QApplication, as in a test's stand-in, is
left alone.
Source code in src/visualdynamics/gui/preferences.py
refresh_palettes
¶
Make every widget re-read the application palette.
On macOS with Qt 6.11 the application palette follows a change of
color scheme at once, but widgets already on screen keep the palette
they resolved before it, while a new window is drawn correctly.
Setting an empty palette on a widget makes it resolve from its
parent and the application again, and leaves its WA_SetPalette
attribute clear. Widgets with that attribute set own a palette on
purpose (the tree and the tables, colored by the theme), so they are
skipped and keep theirs.