Warning, /plasma/kdeplasma-addons/applets/weather/package/contents/ui/CompactRepresentation.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * SPDX-FileCopyrightText: 2018 Friedrich W. H. Kossebau <kossebau@kde.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 import QtQuick
0008 
0009 import QtQuick.Layouts
0010 
0011 import org.kde.plasma.plasmoid
0012 import org.kde.plasma.core as PlasmaCore
0013 import org.kde.kirigami as Kirigami
0014 import org.kde.plasma.workspace.components as WorkspaceComponents
0015 
0016 Loader {
0017     id: compactRoot
0018 
0019     property var generalModel
0020     property var observationModel
0021 
0022     readonly property bool vertical: (Plasmoid.formFactor == PlasmaCore.Types.Vertical)
0023     readonly property bool showTemperature: Plasmoid.configuration.showTemperatureInCompactMode
0024     readonly property bool useBadge: Plasmoid.configuration.showTemperatureInBadge || Plasmoid.needsToBeSquare
0025 
0026     sourceComponent: (showTemperature && !useBadge) ? iconAndTextComponent : iconComponent
0027     Layout.fillWidth: compactRoot.vertical
0028     Layout.fillHeight: !compactRoot.vertical
0029     Layout.minimumWidth: item.Layout.minimumWidth
0030     Layout.minimumHeight: item.Layout.minimumHeight
0031 
0032     MouseArea {
0033         id: compactMouseArea
0034         anchors.fill: parent
0035 
0036         hoverEnabled: true
0037 
0038         onClicked: {
0039             root.expanded = !root.expanded;
0040         }
0041     }
0042 
0043     Component {
0044         id: iconComponent
0045 
0046         Kirigami.Icon {
0047             readonly property int minIconSize: Math.max((compactRoot.vertical ? compactRoot.width : compactRoot.height), Kirigami.Units.iconSizes.small)
0048 
0049             source: Plasmoid.icon
0050             active: compactMouseArea.containsMouse
0051             // reset implicit size, so layout in free dimension does not stop at the default one
0052             implicitWidth: Kirigami.Units.iconSizes.small
0053             implicitHeight: Kirigami.Units.iconSizes.small
0054             Layout.minimumWidth: compactRoot.vertical ? Kirigami.Units.iconSizes.small : minIconSize
0055             Layout.minimumHeight: compactRoot.vertical ? minIconSize : Kirigami.Units.iconSizes.small
0056 
0057             WorkspaceComponents.BadgeOverlay {
0058                 anchors.bottom: parent.bottom
0059                 anchors.right: parent.right
0060 
0061                 visible: showTemperature && useBadge && text.length > 0
0062 
0063                 text: observationModel.temperature
0064                 icon: parent
0065             }
0066         }
0067     }
0068 
0069     Component {
0070         id: iconAndTextComponent
0071 
0072         IconAndTextItem {
0073             vertical: compactRoot.vertical
0074             iconSource: Plasmoid.icon
0075             active: compactMouseArea.containsMouse
0076             text: observationModel.temperature
0077         }
0078     }
0079 }