Fluid
Loading...
Searching...
No Matches
src
imports
controls
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
24
class
Device
:
public
QObject
25
{
26
Q_OBJECT
27
Q_PROPERTY(
FormFactor
formFactor
READ
formFactor
NOTIFY
geometryChanged
)
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
37
public:
38
enum
FormFactor
{
Phone
,
Phablet
,
Tablet
,
Computer
,
TV
,
Unknown
};
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
56
Q_SIGNALS:
57
void
geometryChanged
();
58
59
private
Q_SLOTS:
60
void
screenChanged();
61
62
private
:
63
qreal calculateDiagonal()
const
;
64
65
QScreen *m_screen;
66
};
67
Device
Definition
device.h:25
Device::iconName
QString iconName
Definition
device.h:29
Device::formFactor
FormFactor formFactor
Definition
device.h:27
Device::hoverEnabled
bool hoverEnabled
Definition
device.h:33
Device::gridUnit
int gridUnit
Definition
device.h:34
Device::create
static Device * create(QQmlEngine *engine, QJSEngine *jsEngine)
Definition
device.cpp:140
Device::isMobile
bool isMobile
Definition
device.h:31
Device::geometryChanged
void geometryChanged()
Device::FormFactor
FormFactor
Definition
device.h:38
Device::Unknown
@ Unknown
Definition
device.h:38
Device::Phablet
@ Phablet
Definition
device.h:38
Device::TV
@ TV
Definition
device.h:38
Device::Computer
@ Computer
Definition
device.h:38
Device::Tablet
@ Tablet
Definition
device.h:38
Device::Phone
@ Phone
Definition
device.h:38
Device::isPortrait
bool isPortrait
Definition
device.h:30
Device::name
QString name
Definition
device.h:28
Device::hasTouchScreen
bool hasTouchScreen
Definition
device.h:32
Generated by
1.9.8