-
Notifications
You must be signed in to change notification settings - Fork 20
/
CompactRepresentation.qml
109 lines (83 loc) · 2.91 KB
/
CompactRepresentation.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
* SPDX-FileCopyrightText: 2018 Friedrich W. H. Kossebau <kossebau@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick
import QtQuick.Layouts
import org.kde.plasma.plasmoid
import org.kde.kirigami as Kirigami
import org.kde.plasma.core as PlasmaCore
import "../code/utils.js" as Utils
Loader {
id: compactRoot
sourceComponent: (!inTray && plasmoid.configuration.showCompactTemp) ? iconAndTextComponent : iconComponent
function printDebug(msg) {
if (plasmoid.configuration.logConsole) {
console.log("[debug] [CompactRep.qml] " + msg);
}
}
Layout.minimumWidth: item.Layout.minimumWidth
Layout.minimumHeight: item.Layout.minimumHeight
states: [
State {
name: "horizontalPanel"
when: plasmoid.formFactor === PlasmaCore.Types.Horizontal
PropertyChanges {
target: compactRoot
Layout.fillWidth: false
Layout.fillHeight: true
}
PropertyChanges {
target: soleIcon
minIconSize: Math.max(compactRoot.height, Kirigami.Units.iconSizes.small)
Layout.minimumWidth: minIconSize
Layout.minimumHeight: Kirigami.Units.iconSizes.small
}
},
State {
name: "verticalPanel"
when: plasmoid.formFactor === PlasmaCore.Types.Vertical
PropertyChanges {
target: compactRoot
Layout.fillWidth: false
Layout.fillHeight: true
}
PropertyChanges {
target: soleIcon
minIconSize: Math.max(compactRoot.width, Kirigami.Units.iconSizes.small)
Layout.minimumWidth: Kirigami.Units.iconSizes.small
Layout.minimumHeight: minIconSize
}
}
]
MouseArea {
id: compactMouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
root.expanded = !root.expanded;
}
}
Component {
id: iconAndTextComponent
IconAndTextItem {
id: iconAndTextItem
iconSource: Utils.getConditionIcon(iconCode)
text: appState == showDATA ? Utils.currentTempUnit(Utils.toUserTemp(weatherData["details"]["temp"]), plasmoid.configuration.tempPrecision) : "--- °X"
}
}
Component {
id: iconComponent
Kirigami.Icon {
id: soleIcon
isMask: plasmoid.configuration.applyColorScheme ? true : false
color: Kirigami.Theme.textColor
source: Utils.getConditionIcon(iconCode)
active: compactMouseArea.containsMouse
// reset implicit size, so layout in free dimension does not stop at the default one
implicitWidth: Kirigami.Units.iconSizes.small
implicitHeight: Kirigami.Units.iconSizes.small
}
}
}