Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
ThemePresets.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3#pragma once
4
5#include <QObject>
6#include <QString>
7#include <QStringList>
8#include <QVariantList>
9#include <QVariantMap>
10#include <QtQmlIntegration/qqmlintegration.h>
11
12namespace PhosphorShellPicker {
13
29class ThemePresets : public QObject
30{
31 Q_OBJECT
32 QML_ELEMENT
33
35 Q_PROPERTY(QString directory READ directory WRITE setDirectory NOTIFY directoryChanged)
36 Q_PROPERTY(QVariantList presets READ presets NOTIFY presetsChanged)
37 Q_PROPERTY(int count READ count NOTIFY presetsChanged)
38
39public:
40 explicit ThemePresets(QObject* parent = nullptr);
41 ~ThemePresets() override;
42
43 [[nodiscard]] QString directory() const;
44 void setDirectory(const QString& directory);
45
46 [[nodiscard]] QVariantList presets() const;
47 [[nodiscard]] int count() const;
48
50 [[nodiscard]] static QString defaultDirectory();
51
53 [[nodiscard]] static QVariantMap darkPalette();
55 [[nodiscard]] static QVariantMap lightPalette();
56
58 [[nodiscard]] static QVariantList swatchesFor(const QVariantMap& tokens);
59
61 [[nodiscard]] Q_INVOKABLE bool isCompletePalette(const QVariantMap& tokens) const;
62
64 [[nodiscard]] static QVariantMap readPaletteFile(const QString& path);
65
68 Q_INVOKABLE void rescan();
69
71 [[nodiscard]] Q_INVOKABLE QVariantMap tokensFor(const QString& name) const;
72
73Q_SIGNALS:
76
77private:
78 QString m_directory;
79 QVariantList m_presets;
80};
81
82} // namespace PhosphorShellPicker
bool isCompletePalette(const QVariantMap &tokens) const
Whether a palette supplies every standard color used by Appearance.
static QVariantMap readPaletteFile(const QString &path)
Parse one palette file into a token map (empty on failure).
static QVariantList swatchesFor(const QVariantMap &tokens)
The five swatches a tile shows for tokens.
ThemePresets(QObject *parent=nullptr)
Where user palettes live. Defaults to defaultDirectory().
void setDirectory(const QString &directory)
static QVariantMap darkPalette()
The canonical dark palette.
QVariantMap tokensFor(const QString &name) const
The tokens of the preset called name, or an empty map.
void rescan()
Rebuild the list: the two built-ins, then the directory's files by name.
QVariantList presets() const
static QVariantMap lightPalette()
The light variant: sky, blue, violet, rose on #F6F9FF.
static QString defaultDirectory()
<AppLocalDataLocation>/palettes, beside the committed palette.
Definition AppearanceLibrary.h:13