Libksysguard

CompactSensorFace.qml
1/*
2 SPDX-FileCopyrightText: 2024 Arjen Hiemstra <ahiemstra@heimr.nl>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4 */
5
6import QtQuick
7import QtQuick.Layouts
8
9import org.kde.kirigami as Kirigami
10
11// Sensor face subtype intended to be use for compact representations of faces
12SensorFace {
13 // Convenience properties to make sizing logic for faces simpler
14 readonly property bool horizontalFormFactor: formFactor == SensorFace.Horizontal
15 readonly property bool verticalFormFactor: formFactor == SensorFace.Vertical
16 readonly property bool constrainedFormFactor: formFactor == SensorFace.Constrained
17 readonly property real goldenRatio: 1.618
18 readonly property real defaultMinimumSize: Kirigami.Units.gridUnit
20 Layout.minimumWidth: defaultMinimumSize
21 Layout.minimumHeight: defaultMinimumSize
23 // By default, prefer a rectangular size base on the golden ratio for horizontal panels
24 Layout.preferredWidth: horizontalFormFactor ? Math.max(height * goldenRatio, Layout.minimumWidth) : -1
25 // For vertical panels, just try to keep things square since increasing height usually does not make sense
26 Layout.preferredHeight: verticalFormFactor ? Math.max(width, Layout.minimumHeight) : -1
27
28 // Limit the maximum size to a reasonably sensible value. This matches what some Plasmoids do.
29 Layout.maximumWidth: horizontalFormFactor ? Math.max(Kirigami.Units.iconSizes.enormous, Layout.minimumWidth) : -1
30 Layout.maximumHeight: verticalFormFactor ? Math.max(Kirigami.Units.iconSizes.huge, Layout.minimumHeight) : -1
31}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:02:44 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.