-
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathPresetManager.h
More file actions
73 lines (57 loc) · 2.07 KB
/
PresetManager.h
File metadata and controls
73 lines (57 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef PRESETMANAGER_H
#define PRESETMANAGER_H
#include "PresetRule.h"
#include <QJsonObject>
#include <QMap>
#include <QObject>
#include <QVector>
class PresetListModel;
class PresetManager : public QObject
{
Q_OBJECT
public:
static PresetManager &instance()
{
static PresetManager _instance;
return _instance;
}
PresetManager(PresetManager const &) = delete;
PresetManager();
bool exists(const QString& name) const;
QVector<PresetRule> rules() const;
void setRules(const QVector<PresetRule> &newRules);
bool addRule(const PresetRule& rule);
void removeRule(const QString &deviceId, const QString &routeId);
// Per-preset output device association (PipeWire only).
// Lets a preset optionally remember an output device and switch to it on load.
bool hasPresetDevice(const QString& name) const;
void setPresetDevice(const QString& name);
void clearPresetDevice(const QString& name);
void applyPresetDevice(const QString& name);
PresetListModel *presetModel() const;
signals:
void presetAutoloaded(const QString& deviceName, const QString& routeName, bool anyRoute);
void wantsToWriteConfig();
public slots:
void saveToPath(const QString &filename);
bool loadFromPath(const QString &filename);
void rename(const QString &name, const QString &newName);
bool remove(const QString &name);
bool load(const QString &filename);
void save(const QString &name);
void onOutputDeviceChanged(const QString& deviceName, const QString& deviceId, const QString& outputRouteName);
void loadRules();
void saveRules() const;
private:
QVector<PresetRule> _rules;
QMap<QString, QJsonObject> _presetDevices;
PresetListModel* _presetModel;
// Suppresses applyPresetDevice() while a preset is being auto-loaded by a
// device->preset rule, to avoid a device-change feedback loop.
bool _suppressDeviceApply = false;
QString rulesPath() const;
QString presetDevicesPath() const;
void loadPresetDevices();
void savePresetDevices();
};
#endif // PRESETMANAGER_H