Lomiri
Loading...
Searching...
No Matches
deviceconfig.h
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#pragma once
18
19#include <QObject>
20#include <memory>
21
22class DeviceInfo;
23class DeviceConfig: public QObject
24{
25 Q_OBJECT
26 Q_PROPERTY(QString name READ name NOTIFY changed)
27
28 // NOTE: When changing this properties, also update the examples in docs and data
29 Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation NOTIFY changed)
30 Q_PROPERTY(Qt::ScreenOrientations supportedOrientations READ supportedOrientations NOTIFY changed)
31 Q_PROPERTY(Qt::ScreenOrientation landscapeOrientation READ landscapeOrientation NOTIFY changed)
32 Q_PROPERTY(Qt::ScreenOrientation invertedLandscapeOrientation READ invertedLandscapeOrientation NOTIFY changed)
33 Q_PROPERTY(Qt::ScreenOrientation portraitOrientation READ portraitOrientation NOTIFY changed)
34 Q_PROPERTY(Qt::ScreenOrientation invertedPortraitOrientation READ invertedPortraitOrientation NOTIFY changed)
35 Q_PROPERTY(QString category READ category NOTIFY changed)
36 Q_PROPERTY(bool supportsMultiColorLed READ supportsMultiColorLed NOTIFY changed)
37
38 Q_PROPERTY(quint8 sensorLocationX READ sensorLocationX FINAL)
39 Q_PROPERTY(quint8 sensorLocationY READ sensorLocationY FINAL)
40 Q_PROPERTY(quint8 sensorRadius READ sensorRadius FINAL)
41
42public:
43 DeviceConfig(QObject *parent = nullptr);
44 ~DeviceConfig() = 0;
45
46 QString name() const;
47
48 Qt::ScreenOrientation primaryOrientation() const;
49 Qt::ScreenOrientations supportedOrientations() const;
50 Qt::ScreenOrientation landscapeOrientation() const;
51 Qt::ScreenOrientation invertedLandscapeOrientation() const;
52 Qt::ScreenOrientation portraitOrientation() const;
53 Qt::ScreenOrientation invertedPortraitOrientation() const;
54 QString category() const;
55 bool supportsMultiColorLed() const;
56
57 quint8 sensorLocationX() const;
58 quint8 sensorLocationY() const;
59 quint8 sensorRadius() const;
60
61// for tests
62 Q_INVOKABLE void refresh() { Q_EMIT changed(); }
63
64Q_SIGNALS:
65 void changed();
66
67private:
68 std::unique_ptr<DeviceInfo> m_info;
69
70 Qt::ScreenOrientation stringToOrientation(const std::string &orientationString, Qt::ScreenOrientation defaultValue) const;
71};