Fluid
Loading...
Searching...
No Matches
device.h
Go to the documentation of this file.
1/*
2 * This file is part of Fluid.
3 *
4 * Copyright (C) 2018 Michael Spencer <sonrisesoftware@gmail.com>
5 *
6 * $BEGIN_LICENSE:MPL2$
7 *
8 * This Source Code Form is subject to the terms of the Mozilla Public
9 * License, v. 2.0. If a copy of the MPL was not distributed with this
10 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 *
12 * $END_LICENSE$
13 */
14
15#pragma once
16
17#include <QObject>
18
19#include <QQmlEngine>
20#include <QGuiApplication>
21#include <QScreen>
22#include <QQmlEngine>
23
24class Device : public QObject
25{
26 Q_OBJECT
28 Q_PROPERTY(QString name READ name NOTIFY geometryChanged)
29 Q_PROPERTY(QString iconName READ iconName NOTIFY geometryChanged)
30 Q_PROPERTY(bool isPortrait READ isPortrait NOTIFY geometryChanged)
31 Q_PROPERTY(bool isMobile READ isMobile CONSTANT)
32 Q_PROPERTY(bool hasTouchScreen READ hasTouchScreen CONSTANT)
33 Q_PROPERTY(bool hoverEnabled READ hoverEnabled CONSTANT)
34 Q_PROPERTY(int gridUnit READ gridUnit NOTIFY geometryChanged)
35 QML_ELEMENT
36 QML_SINGLETON
37public:
39 Q_ENUM(FormFactor)
40
41 explicit Device(QObject *parent = nullptr);
42
43 FormFactor formFactor() const;
44 QString name() const;
45 QString iconName() const;
46
47 bool isPortrait() const;
48 bool hasTouchScreen() const;
49 bool isMobile() const;
50 bool hoverEnabled() const;
51
52 int gridUnit() const;
53
54 static Device *create(QQmlEngine *engine, QJSEngine *jsEngine);
55
56Q_SIGNALS:
58
59private Q_SLOTS:
60 void screenChanged();
61
62private:
63 qreal calculateDiagonal() const;
64
65 QScreen *m_screen;
66};
67
Definition device.h:25
QString iconName
Definition device.h:29
FormFactor formFactor
Definition device.h:27
bool hoverEnabled
Definition device.h:33
int gridUnit
Definition device.h:34
static Device * create(QQmlEngine *engine, QJSEngine *jsEngine)
Definition device.cpp:140
bool isMobile
Definition device.h:31
void geometryChanged()
FormFactor
Definition device.h:38
@ Unknown
Definition device.h:38
@ Phablet
Definition device.h:38
@ TV
Definition device.h:38
@ Computer
Definition device.h:38
@ Tablet
Definition device.h:38
@ Phone
Definition device.h:38
bool isPortrait
Definition device.h:30
QString name
Definition device.h:28
bool hasTouchScreen
Definition device.h:32