1/*
2 * Copyright (C) 2016-2019
3 *      Jean-Luc Barriere <jlbarriere68@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18import QtQuick 2.9
19
20Item {
21    property real scaleFactor: 1.0
22    property real fontScaleFactor: 1.0
23    property real gridUnit: 8.0 * scaleFactor
24
25    function dp(p) {
26        return scaleFactor * p;
27    }
28
29    function gu(u) {
30        return gridUnit * u;
31    }
32
33    function fs(s) {
34        if (Android) {
35            if (s === "x-small")
36                return 10.0 * scaleFactor * fontScaleFactor;
37            if (s === "small")
38                return 12.0 * scaleFactor * fontScaleFactor;
39            if (s === "medium")
40                return 14.0 * scaleFactor * fontScaleFactor;
41            if (s === "large")
42                return 18.0 * scaleFactor * fontScaleFactor;
43            if (s === "x-large")
44                return 22.0 * scaleFactor * fontScaleFactor;
45        } else {
46            if (s === "x-small")
47                return 9.0 * scaleFactor * fontScaleFactor;
48            if (s === "small")
49                return 10.0 * scaleFactor * fontScaleFactor;
50            if (s === "medium")
51                return 12.0 * scaleFactor * fontScaleFactor;
52            if (s === "large")
53                return 14.0 * scaleFactor * fontScaleFactor;
54            if (s === "x-large")
55                return 16.0 * scaleFactor * fontScaleFactor;
56        }
57        return 0.0;
58    }
59
60}
61