| 1 |
/* |
| 2 |
* Copyright 2019 Marco Martin <[email protected]> |
| 3 |
* Copyright 2019 David Edmundson <[email protected]> |
| 4 |
* Copyright 2019 Arjen Hiemstra <[email protected]> |
| 5 |
* Copyright 2020 David Redondo <[email protected]> |
| 6 |
* |
| 7 |
* This program is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU Library General Public License as |
| 9 |
* published by the Free Software Foundation; either version 2, or |
| 10 |
* (at your option) any later version. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU General Public License for more details |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Library General Public |
| 18 |
* License along with this program; if not, write to the |
| 19 |
* Free Software Foundation, Inc., |
| 20 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 21 |
*/ |
| 22 |
|
| 23 |
import QtQuick |
| 24 |
import QtQuick.Controls as QQC2 |
| 25 |
import QtQuick.Layouts |
| 26 |
|
| 27 |
import org.kde.kirigami as Kirigami |
| 28 |
|
| 29 |
import org.kde.ksysguard.sensors as Sensors |
| 30 |
import org.kde.ksysguard.faces as Faces |
| 31 |
import org.kde.ksysguard.formatter as Formatter |
| 32 |
|
| 33 |
import org.kde.quickcharts as Charts |
| 34 |
|
| 35 |
Faces.SensorFace { |
| 36 |
id: root |
| 37 |
|
| 38 |
readonly property int columnCount: root.controller.faceConfiguration.columnCount |
| 39 |
|
| 40 |
// When automatically determining the number of columns, use the square root |
| 41 |
// of the number of sensors, rounded up. This should give us a number of |
| 42 |
// columns that generally divides things evenly across the grid. |
| 43 |
readonly property int autoColumnCount: Math.ceil(Math.sqrt(controller.highPrioritySensorIds.length)) |
| 44 |
|
| 45 |
// Arbitrary minimumWidth to make easier to align plasmoids in a predictable way |
| 46 |
Layout.minimumWidth: Math.max(Kirigami.Units.gridUnit * 8, grid.Layout.minimumWidth) |
| 47 |
Layout.preferredWidth: grid.preferredWidth + Kirigami.Units.largeSpacing |
| 48 |
|
| 49 |
contentItem: FaceGrid { |
| 50 |
id: grid |
| 51 |
compact: false |
| 52 |
columns: root.columnCount > 0 ? root.columnCount : root.autoColumnCount |
| 53 |
} |
| 54 |
} |