The picker's live retint: try a palette on the real desktop, put the old one back when the pointer leaves. More...
#include <PhosphorShellPicker/RetintController.h>
Signals | |
| void | runnerChanged () |
| void | storeChanged () |
| void | debounceMsChanged () |
| void | persistPathChanged () |
| void | previewPathChanged () |
| void | previewingChanged () |
| void | busyChanged () |
| void | lastErrorChanged () |
| void | previewApplied (const QString &path) |
| The store now shows path's palette. | |
| void | previewFailed (const QString &path, const QString &reason) |
| The runner could not produce a palette for path. | |
Public Member Functions | |
| RetintController (QObject *parent=nullptr) | |
| Where commit() writes the committed palette, in the { "tokens":
{ ... } } shape PaletteStore reads. | |
| ~RetintController () override | |
| QObject * | runner () const |
| void | setRunner (QObject *runner) |
| QObject * | store () const |
| void | setStore (QObject *store) |
| int | debounceMs () const |
| void | setDebounceMs (int ms) |
| QString | persistPath () const |
| void | setPersistPath (const QString &path) |
| QString | previewPath () const |
| bool | isPreviewing () const |
| bool | isBusy () const |
| QString | lastError () const |
| void | preview (const QString &wallpaperPath) |
| Hover a wallpaper candidate: debounced, cancels the previous run. | |
| void | previewTokens (const QVariantMap &tokens, const QString &label) |
| Hover a theme tile: its tokens are applied at once under label. | |
| void | clearPreview () |
| The pointer left without Apply: put the snapshot back. | |
| void | commit () |
| Apply: keep what is live (and what a still-pending run lands), forget the snapshot, and write persistPath when set. | |
Static Public Member Functions | |
| static QString | defaultPersistPath () |
| The palette file the shell reads at startup and commit() writes: <AppLocalDataLocation>/palettes/current.json, the layout phosphor-theme-cli's --apply uses. | |
| static QVariantMap | withoutBrandStops (const QVariantMap &tokens) |
| tokens without the four brand stops. Pure, for the tests. | |
| static bool | writePalette (const QString &path, const QVariantMap &tokens) |
| Write tokens to path atomically in the wrapped shape. | |
The picker's live retint: try a palette on the real desktop, put the old one back when the pointer leaves.
preview(path) is the hover path. It is debounced (150 ms by default) so a pointer sweeping across the strip runs matugen once, for the candidate it stops on; each new preview cancels the runner's in-flight run first. When the runner reports a palette for the candidate still pending, the tokens go to the store and the whole shell retints through the Theme singleton's bindings. previewTokens(map) is the same for a theme tile, without the runner.
The first preview snapshots the store's palette. clearPreview() re-applies that snapshot (the pointer left, or Escape), commit() drops it (Apply), so the live palette stays. Incoming tokens are filtered to the keys the snapshot already publishes, which is what makes the restore exact (the store merges and cannot forget a key) and is why a preview can never introduce a token the shell does not know.
The four brand_stop_* tokens never change through this controller (05 §4: the spectrum is fixed; matugen moves ground, containers and text). They are stripped from every incoming map before it is applied, and the store's merge leaves them as they were.
runner and store are duck-typed QObjects so a test can stand in a fake for the matugen subprocess. The runner needs run(QString), cancel() and the paletteReady(QVariantMap, QString) / failed(QString, QString) signals of PhosphorTheme::MatugenRunner; the store needs a palette QVariantMap property and applyTokens(QVariantMap), the shape of PhosphorTheme::PaletteStore.
|
explicit |
Where commit() writes the committed palette, in the { "tokens": { ... } } shape PaletteStore reads.
Empty (the default) writes nothing. See defaultPersistPath(). defaultPersistPath() for QML, which cannot call a static through the type name of a non-singleton: persistPath: retint.defaultPersistPath. The candidate (a wallpaper path, or a theme tile's label) whose palette is live, or empty when the store shows its own palette. True while a snapshot is held: a preview is showing or pending. True while the runner is working on a preview.
|
override |
|
signal |
| void PhosphorShellPicker::RetintController::clearPreview | ( | ) |
The pointer left without Apply: put the snapshot back.
| void PhosphorShellPicker::RetintController::commit | ( | ) |
Apply: keep what is live (and what a still-pending run lands), forget the snapshot, and write persistPath when set.
|
nodiscard |
|
signal |
|
staticnodiscard |
The palette file the shell reads at startup and commit() writes: <AppLocalDataLocation>/palettes/current.json, the layout phosphor-theme-cli's --apply uses.
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
signal |
|
nodiscard |
|
signal |
| void PhosphorShellPicker::RetintController::preview | ( | const QString & | wallpaperPath | ) |
Hover a wallpaper candidate: debounced, cancels the previous run.
|
signal |
The store now shows path's palette.
|
signal |
The runner could not produce a palette for path.
|
signal |
|
nodiscard |
|
signal |
| void PhosphorShellPicker::RetintController::previewTokens | ( | const QVariantMap & | tokens, |
| const QString & | label ) |
Hover a theme tile: its tokens are applied at once under label.
|
nodiscard |
|
signal |
| void PhosphorShellPicker::RetintController::setDebounceMs | ( | int | ms | ) |
| void PhosphorShellPicker::RetintController::setPersistPath | ( | const QString & | path | ) |
| void PhosphorShellPicker::RetintController::setRunner | ( | QObject * | runner | ) |
| void PhosphorShellPicker::RetintController::setStore | ( | QObject * | store | ) |
|
nodiscard |
|
signal |
|
staticnodiscard |
tokens without the four brand stops. Pure, for the tests.
|
staticnodiscard |
Write tokens to path atomically in the wrapped shape.