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

0001 /*
0002     SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 import QtQuick
0008 import QtQuick.Layouts
0009 import QtQuick.Controls as QQC2
0010 import org.kde.kirigami as Kirigami
0011 import org.kde.i18n.localeData
0012 import org.kde.kitinerary as KItinerary
0013 import org.kde.kirigamiaddons.formcard as FormCard
0014 import org.kde.itinerary
0015 
0016 FormCard.FormCard {
0017     id: root
0018     width: parent.width
0019 
0020     property var locationInfo
0021 
0022     FormCard.AbstractFormDelegate {
0023         background: Rectangle {
0024             id: headerBackground
0025             color: Kirigami.Theme.neutralBackgroundColor
0026             Kirigami.Theme.colorSet: Kirigami.Theme.Header
0027             Kirigami.Theme.inherit: false
0028         }
0029 
0030         contentItem: RowLayout {
0031             id: headerLayout
0032             anchors.fill: parent
0033             anchors.margins: Kirigami.Units.largeSpacing
0034 
0035             Kirigami.Icon {
0036                 source: "documentinfo"
0037                 Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium
0038                 Layout.preferredHeight: Layout.preferredWidth
0039                 isMask: true
0040             }
0041             QQC2.Label {
0042                 id: headerLabel
0043                 text: i18n("Entering %1", Country.fromAlpha2(locationInfo.isoCode).name)
0044                 Layout.fillWidth: true
0045                 Accessible.ignored: true
0046             }
0047         }
0048     }
0049 
0050     FormCard.AbstractFormDelegate {
0051         background: Item {}
0052         contentItem: Column {
0053             id: topLayout
0054             spacing: Kirigami.Units.smallSpacing
0055 
0056             QQC2.Label {
0057                 width: topLayout.width
0058                 text: locationInfo.drivingSideLabel
0059                 visible: locationInfo.drivingSideDiffers
0060                 wrapMode: Text.WordWrap
0061                 Accessible.ignored: !visible
0062             }
0063 
0064             QQC2.Label {
0065                 width: topLayout.width
0066                 text: visible ? i18n("No compatible power sockets: %1", locationInfo.powerSocketTypes) : ""
0067                 color: Kirigami.Theme.negativeTextColor
0068                 visible: locationInfo.powerPlugCompatibility == LocationInformation.Incompatible
0069                 wrapMode: Text.WordWrap
0070                 Accessible.ignored: !visible
0071             }
0072             QQC2.Label {
0073                 width: topLayout.width
0074                 text: visible ? i18n("Some incompatible power sockets: %1", locationInfo.powerSocketTypes) : ""
0075                 visible: locationInfo.powerPlugCompatibility == LocationInformation.PartiallyCompatible && locationInfo.powerSocketTypes != ""
0076                 wrapMode: Text.WordWrap
0077                 Accessible.ignored: !visible
0078             }
0079             QQC2.Label {
0080                 width: topLayout.width
0081                 text: visible ? i18n("Some incompatible power plugs: %1", locationInfo.powerPlugTypes) : ""
0082                 visible: locationInfo.powerPlugCompatibility == LocationInformation.PartiallyCompatible && locationInfo.powerPlugTypes != ""
0083                 wrapMode: Text.WordWrap
0084                 Accessible.ignored: !visible
0085             }
0086 
0087             QQC2.Label {
0088                 width: topLayout.width
0089                 text: visible ? i18n("Timezone change: %1 (%2)", locationInfo.timeZoneName,
0090                                      (locationInfo.timeZoneOffsetDelta >= 0 ? "+" : "")
0091                                      + Localizer.formatDuration(locationInfo.timeZoneOffsetDelta)) : ""
0092                 visible: locationInfo.timeZoneDiffers
0093                 wrapMode: Text.WordWrap
0094                 Accessible.ignored: !visible
0095             }
0096 
0097             QQC2.Label {
0098                 width: topLayout.width
0099                 text: {
0100                     if (!visible)
0101                         return "";
0102                     let rate = NaN;
0103                     let sourceValue = 1.0;
0104                     const homeCurrency = Country.fromAlpha2(Settings.homeCountryIsoCode).currencyCode;
0105                     if (Settings.performCurrencyConversion)
0106                         rate = UnitConversion.convertCurrency(sourceValue, homeCurrency, locationInfo.currencyCode);
0107                     while (rate < 1 && rate > 0) { // scale to a useful order of magnitude
0108                         rate *= 10;
0109                         sourceValue *= 10;
0110                     }
0111                     if (!isNaN(rate))
0112                         return i18nc("currency conversion rate", "Currency: %1 = %2",
0113                                      Localizer.formatCurrency(sourceValue, homeCurrency), Localizer.formatCurrency(rate, locationInfo.currencyCode));
0114                     return i18n("Currency: %1", locationInfo.currencyCode);
0115                 }
0116                 visible: locationInfo.currencyDiffers
0117                 wrapMode: Text.WordWrap
0118                 Accessible.ignored: !visible
0119             }
0120         }
0121     }
0122     Accessible.name: headerLabel.text
0123 }