-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenmodel.h
57 lines (44 loc) · 1.88 KB
/
screenmodel.h
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
// Copyright (C) 2023 Javier O. Cordero Pérez
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include "internalmessagebroker.hpp"
#include <QAbstractListModel>
#include <QQmlEngine>
#include <QSettings>
struct ColorProperties {
int hue;
int lightness;
int saturation;
};
class ScreenModel : public QObject {
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(const QString &screenName READ getCurrentScreen WRITE setCurrentScreen NOTIFY currentScreenChanged)
Q_PROPERTY(int hue READ getScreenHue WRITE setScreenHue NOTIFY screenHueChanged)
Q_PROPERTY(int lightness READ getScreenLightness WRITE setScreenLightness NOTIFY screenLightnessChanged)
Q_PROPERTY(int saturation READ getScreenSaturation WRITE setScreenSaturation NOTIFY screenSaturationChanged)
public:
explicit ScreenModel(QObject* parent = nullptr);
QString getCurrentScreen();
int getScreenHue();
int getScreenLightness();
int getScreenSaturation();
void setCurrentScreen(const QString &screenName);
void setScreenHue(const int hue, const bool spread=true, const QString &screenName="s");
void setScreenLightness(const int lightness, const bool spread=true, const QString &screenName="s");
void setScreenSaturation(const int saturation, const bool spread=true, const QString &screenName="s");
Q_INVOKABLE void clear(const int length);
signals:
void currentScreenChanged();
void spreadHueChange(int hue, bool baseCase, const QString &);
void spreadLightnessChange(int lightness, bool baseCase, const QString &);
void spreadSaturationChange(int saturation, bool baseCase, const QString &);
void screenHueChanged();
void screenLightnessChanged();
void screenSaturationChanged();
private:
void initializeScreenMap();
std::shared_ptr<InternalMessageBroker> m_mb;
QString m_currentScreen;
QMap<const QString, ColorProperties> m_screens;
};