Warning, /system/mycroft-gui/import/qml/Units.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * Copyright 2021 by Aditya Mehra <aix.m@outlook.com> 0003 * 0004 * Licensed under the Apache License, Version 2.0 (the "License"); 0005 * you may not use this file except in compliance with the License. 0006 * You may obtain a copy of the License at 0007 * 0008 * http://www.apache.org/licenses/LICENSE-2.0 0009 * 0010 * Unless required by applicable law or agreed to in writing, software 0011 * distributed under the License is distributed on an "AS IS" BASIS, 0012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0013 * See the License for the specific language governing permissions and 0014 * limitations under the License. 0015 * 0016 */ 0017 0018 import QtQuick 2.15 0019 import QtQuick.Window 2.15 0020 0021 pragma Singleton 0022 0023 QtObject { 0024 id: units 0025 0026 // The fundamental unit of space that should be used for sizes 0027 property int gridUnit: 16 0028 property real devicePixelRatio: Math.max(1, ((fontMetrics.font.pixelSize*0.75) / fontMetrics.font.pointSize)) 0029 property int largeSpacing: gridUnit / 2 0030 property int smallSpacing: largeSpacing / 2 0031 0032 property variant fontMetrics: FontMetrics { 0033 function roundedIconSize(size) { 0034 if (size < 16) { 0035 return size; 0036 } else if (size < 22) { 0037 return 16; 0038 } else if (size < 32) { 0039 return 22; 0040 } else if (size < 48) { 0041 return 32; 0042 } else if (size < 64) { 0043 return 48; 0044 } else { 0045 return size; 0046 } 0047 } 0048 } 0049 0050 property QtObject iconSizes: QtObject { 0051 property int small: fontMetrics.roundedIconSize(16 * devicePixelRatio) 0052 property int smallMedium: fontMetrics.roundedIconSize(22 * devicePixelRatio) 0053 property int medium: fontMetrics.roundedIconSize(32 * devicePixelRatio) 0054 property int large: fontMetrics.roundedIconSize(48 * devicePixelRatio) 0055 property int huge: fontMetrics.roundedIconSize(64 * devicePixelRatio) 0056 property int enormous: 128 * devicePixelRatio 0057 } 0058 }