CompactRepresentation.qml 2.93 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
 *   Copyright 2019 Marco Martin <mart@kde.org>
 *   Copyright 2019 David Edmundson <davidedmundson@kde.org>
 *   Copyright 2019 Arjen Hiemstra <ahiemstra@heimr.nl>
 *
 *   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 2.9
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.2
Konrad Materka's avatar
Konrad Materka committed
25
26
import QtQml 2.15

27
28
29
30
31
32
33
34
35
36
37
38
39
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.quickcharts 1.0 as Charts

import org.kde.ksysguard.sensors 1.0 as Sensors
import org.kde.ksysguard.faces 1.0 as Faces

import org.kde.kirigami 2.8 as Kirigami

Control {
    id: chartFace
    Layout.fillWidth: contentItem ? contentItem.Layout.fillWidth : false
    Layout.fillHeight: contentItem ? contentItem.Layout.fillHeight : false

Marco Martin's avatar
Marco Martin committed
40
41
    Layout.minimumWidth: (contentItem ? contentItem.Layout.minimumWidth : 0) + leftPadding + rightPadding
    Layout.minimumHeight: (contentItem ? contentItem.Layout.minimumHeight : 0) + leftPadding + rightPadding
42

Marco Martin's avatar
Marco Martin committed
43
44
    Layout.preferredWidth: (contentItem ? contentItem.Layout.preferredWidth : 0) + leftPadding + rightPadding
    Layout.preferredHeight: (contentItem ? contentItem.Layout.preferredHeight : 0) + leftPadding + rightPadding
45

Marco Martin's avatar
Marco Martin committed
46
47
    Layout.maximumWidth: (contentItem ? contentItem.Layout.maximumWidth : 0) + leftPadding + rightPadding
    Layout.maximumHeight: (contentItem ? contentItem.Layout.maximumHeight : 0) + leftPadding + rightPadding
48

Marco Martin's avatar
Marco Martin committed
49
    Kirigami.Theme.inherit: false
50
51
    Kirigami.Theme.textColor: PlasmaCore.ColorScope.textColor

52
53
54
55
56
    leftPadding: 0
    topPadding: 0
    rightPadding: 0
    bottomPadding: 0

57
58
59
    anchors.fill: parent
    contentItem: plasmoid.nativeInterface.faceController.compactRepresentation

60
61
62
63
64
    Binding {
        target: plasmoid.nativeInterface.faceController.compactRepresentation
        property: "formFactor"
        value: {
            switch (plasmoid.formFactor) {
Marco Martin's avatar
Marco Martin committed
65
66
67
            case PlasmaCore.Types.Horizontal:
                return Faces.SensorFace.Horizontal;
            case PlasmaCore.Types.Vertical:
68
                return Faces.SensorFace.Vertical;
69
            default:
Marco Martin's avatar
Marco Martin committed
70
                return Faces.SensorFace.Planar;
71
72
            }
        }
Konrad Materka's avatar
Konrad Materka committed
73
        restoreMode: Binding.RestoreBinding
74
75
    }

76
77
78
79
80
81
    MouseArea {
        parent: chartFace
        anchors.fill: parent
        onClicked: plasmoid.expanded = !plasmoid.expanded
    }
}