/* * Copyright 2019 Marco Martin * Copyright 2019 David Edmundson * Copyright 2019 Arjen Hiemstra * Copyright 2020 David Redondo * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick import QtQuick.Controls as QQC2 import QtQuick.Layouts import org.kde.kirigami as Kirigami import org.kde.ksysguard.sensors as Sensors import org.kde.ksysguard.faces as Faces import org.kde.ksysguard.formatter as Formatter import org.kde.quickcharts as Charts Faces.SensorFace { id: root readonly property int columnCount: root.controller.faceConfiguration.columnCount // When automatically determining the number of columns, use the square root // of the number of sensors, rounded up. This should give us a number of // columns that generally divides things evenly across the grid. readonly property int autoColumnCount: Math.ceil(Math.sqrt(controller.highPrioritySensorIds.length)) // Arbitrary minimumWidth to make easier to align plasmoids in a predictable way Layout.minimumWidth: Math.max(Kirigami.Units.gridUnit * 8, grid.Layout.minimumWidth) Layout.preferredWidth: grid.preferredWidth + Kirigami.Units.largeSpacing contentItem: FaceGrid { id: grid compact: false columns: root.columnCount > 0 ? root.columnCount : root.autoColumnCount } }