Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorShellPicker::RetintController Class Reference

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>

Inheritance diagram for PhosphorShellPicker::RetintController:
[legend]

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ RetintController()

PhosphorShellPicker::RetintController::RetintController ( QObject * parent = nullptr)
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.

◆ ~RetintController()

PhosphorShellPicker::RetintController::~RetintController ( )
override

Member Function Documentation

◆ busyChanged

void PhosphorShellPicker::RetintController::busyChanged ( )
signal

◆ clearPreview()

void PhosphorShellPicker::RetintController::clearPreview ( )

The pointer left without Apply: put the snapshot back.

◆ commit()

void PhosphorShellPicker::RetintController::commit ( )

Apply: keep what is live (and what a still-pending run lands), forget the snapshot, and write persistPath when set.

◆ debounceMs()

int PhosphorShellPicker::RetintController::debounceMs ( ) const
nodiscard

◆ debounceMsChanged

void PhosphorShellPicker::RetintController::debounceMsChanged ( )
signal

◆ defaultPersistPath()

QString PhosphorShellPicker::RetintController::defaultPersistPath ( )
staticnodiscard

The palette file the shell reads at startup and commit() writes: <AppLocalDataLocation>/palettes/current.json, the layout phosphor-theme-cli's --apply uses.

◆ isBusy()

bool PhosphorShellPicker::RetintController::isBusy ( ) const
nodiscard

◆ isPreviewing()

bool PhosphorShellPicker::RetintController::isPreviewing ( ) const
nodiscard

◆ lastError()

QString PhosphorShellPicker::RetintController::lastError ( ) const
nodiscard

◆ lastErrorChanged

void PhosphorShellPicker::RetintController::lastErrorChanged ( )
signal

◆ persistPath()

QString PhosphorShellPicker::RetintController::persistPath ( ) const
nodiscard

◆ persistPathChanged

void PhosphorShellPicker::RetintController::persistPathChanged ( )
signal

◆ preview()

void PhosphorShellPicker::RetintController::preview ( const QString & wallpaperPath)

Hover a wallpaper candidate: debounced, cancels the previous run.

◆ previewApplied

void PhosphorShellPicker::RetintController::previewApplied ( const QString & path)
signal

The store now shows path's palette.

◆ previewFailed

void PhosphorShellPicker::RetintController::previewFailed ( const QString & path,
const QString & reason )
signal

The runner could not produce a palette for path.

◆ previewingChanged

void PhosphorShellPicker::RetintController::previewingChanged ( )
signal

◆ previewPath()

QString PhosphorShellPicker::RetintController::previewPath ( ) const
nodiscard

◆ previewPathChanged

void PhosphorShellPicker::RetintController::previewPathChanged ( )
signal

◆ previewTokens()

void PhosphorShellPicker::RetintController::previewTokens ( const QVariantMap & tokens,
const QString & label )

Hover a theme tile: its tokens are applied at once under label.

◆ runner()

QObject * PhosphorShellPicker::RetintController::runner ( ) const
nodiscard

◆ runnerChanged

void PhosphorShellPicker::RetintController::runnerChanged ( )
signal

◆ setDebounceMs()

void PhosphorShellPicker::RetintController::setDebounceMs ( int ms)

◆ setPersistPath()

void PhosphorShellPicker::RetintController::setPersistPath ( const QString & path)

◆ setRunner()

void PhosphorShellPicker::RetintController::setRunner ( QObject * runner)

◆ setStore()

void PhosphorShellPicker::RetintController::setStore ( QObject * store)

◆ store()

QObject * PhosphorShellPicker::RetintController::store ( ) const
nodiscard

◆ storeChanged

void PhosphorShellPicker::RetintController::storeChanged ( )
signal

◆ withoutBrandStops()

QVariantMap PhosphorShellPicker::RetintController::withoutBrandStops ( const QVariantMap & tokens)
staticnodiscard

tokens without the four brand stops. Pure, for the tests.

◆ writePalette()

bool PhosphorShellPicker::RetintController::writePalette ( const QString & path,
const QVariantMap & tokens )
staticnodiscard

Write tokens to path atomically in the wrapped shape.


The documentation for this class was generated from the following file: