Warning, /pim/itinerary/src/app/TransportIcon.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 import QtQuick
0007 import QtQuick.Layouts
0008 import org.kde.kirigami as Kirigami
0009 
0010 /** Displays a transport line or mode logo/icon.
0011  *  Mainly to hide ugly implementation details of Icon not
0012  *  handling non-square SVG assets in the way we need it here.
0013  */
0014 Item {
0015     id: root
0016     // properties match those of Icon
0017     property string source
0018     property alias isMask: __icon.isMask
0019     property alias color: __icon.color
0020 
0021     // icon size (height for non-square ones)
0022     property int size: Kirigami.Units.iconSizes.small
0023 
0024     property bool __isIcon: !source.startsWith("file:")
0025 
0026 
0027     implicitWidth: __isIcon ? root.size : Math.round(root.size * __image.implicitWidth / __image.implicitHeight)
0028     implicitHeight: root.size
0029 
0030     Layout.preferredWidth: root.implicitWidth
0031     Layout.preferredHeight: root.implicitHeight
0032 
0033     Kirigami.Icon {
0034         id: __icon
0035         source: root.__isIcon ? root.source : ""
0036         visible: source !== ""
0037         anchors.fill: parent
0038     }
0039     Image {
0040         id: __image
0041         source: root.__isIcon ? "" : root.source
0042         visible: source !== ""
0043         anchors.fill: parent
0044         fillMode: Image.PreserveAspectFit
0045     }
0046 }