Warning, /plasma/plasma-disks/src/kcm/package/contents/main.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0002 // SPDX-FileCopyrightText: 2020-2021 Harald Sitter <sitter@kde.org>
0003 
0004 import org.kde.kcm 1.2 as KCM
0005 import QtQuick 2.14
0006 import QtQml.Models 2.14
0007 import QtQuick.Layouts 1.14
0008 import SMART 1.0 as SMART
0009 import org.kde.kirigami 2.12 as Kirigami
0010 import QtQuick.Controls 2.14
0011 
0012 KCM.SimpleKCM {
0013     id: root
0014     implicitWidth: Kirigami.Units.gridUnit * 28
0015     implicitHeight: Kirigami.Units.gridUnit * 20
0016 
0017     Kirigami.CardsListView {
0018         id: listView
0019         width: 110
0020         height: 160
0021         model: SMART.DeviceModel { id: deviceModel }
0022 
0023         SMART.ServiceRunner {
0024             id: partitionManagerRunner
0025             name: "org.kde.partitionmanager"
0026         }
0027 
0028         SMART.ServiceRunner {
0029             id: kupRunner
0030             name: "kcm_kup"
0031         }
0032 
0033         Kirigami.PlaceholderMessage {
0034             anchors.centerIn: parent
0035             width: parent.width - (Kirigami.Units.largeSpacing * 4)
0036 
0037             opacity: !deviceModel.valid
0038             Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration; easing.type: Easing.InOutQuad } }
0039 
0040             icon.name: "messagebox_warning"
0041             text: i18nc("@info/status", "Unable to obtain data. KDED is not running.")
0042         }
0043 
0044         Kirigami.PlaceholderMessage {
0045             anchors.centerIn: parent
0046             width: parent.width - (Kirigami.Units.largeSpacing * 4)
0047 
0048             opacity: deviceModel.valid && !deviceModel.waiting && parent.count <= 0
0049             Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration; easing.type: Easing.InOutQuad } }
0050 
0051             icon.name: "edit-none"
0052             text: i18nc("@info/status", "No S.M.A.R.T. devices found.")
0053         }
0054 
0055         delegate: Kirigami.Card {
0056             banner.title: "%1 (%2)".arg(product).arg(path)
0057             banner.titleIcon: {
0058                 if (failed) {
0059                     return "data-warning"
0060                 }
0061                 if (instabilities.length !== 0) {
0062                     return "data-information"
0063                 }
0064                 return ""
0065             }
0066 
0067             contentItem: Label {
0068                 width: parent.width
0069                 wrapMode: Text.Wrap
0070                 text: {
0071                     if (failed) {
0072                         return i18nc("@info",
0073                             "The SMART system of this device is reporting problems. This may be a sign of imminent device failure or data reliability being compromised. " +
0074                             "Back up your data and replace this drive as soon as possible to avoid losing any data.")
0075                     }
0076                     if (instabilities.length !== 0) {
0077                         var items = instabilities.map(item => "<li>%1</li>".arg(item))
0078                         return i18nc("@info %1 is a bunch of <li> with the strings from instabilities.cpp",
0079                             "<p>The SMART firmware is not reporting a failure, but there are early signs of malfunction. " +
0080                             "This might not point at imminent device failure but requires longer term analysis. " +
0081                             "Back up your data and contact the manufacturer of this disk, or replace it preemptively just to be safe.</p>" +
0082                             "<ul>%1</ul>", items.join(''))
0083                     }
0084                     return i18nc("@info",
0085                             "This device appears to be working as expected.")
0086                 }
0087             }
0088 
0089             actions: [
0090                 Kirigami.Action {
0091                     visible: partitionManagerRunner.canRun
0092                     text: i18nc("@action/button action button to start partition manager", "Partition Manager")
0093                     icon.name: "partitionmanager"
0094                     onTriggered: partitionManagerRunner.run()
0095                 },
0096                 Kirigami.Action {
0097                     visible: kupRunner.canRun
0098                     text: i18nc("@action/button action button to start backup program", "Backup")
0099                     icon.name: "kup"
0100                     onTriggered: kupRunner.run()
0101                 },
0102                 Kirigami.Action {
0103                     text: ignore
0104                           ? i18nc("@action/button action button to monitor a device for smart failure", "Monitor")
0105                           : i18nc("@action/button action button to ignore smart failures for a device", "Ignore")
0106                     icon.name: ignore ? "view-visible" : "view-hidden"
0107                     onTriggered: {
0108                         model.ignore = !ignore
0109                     }
0110                 },
0111                 Kirigami.Action {
0112                     visible: model.advancedReport !== ''
0113                     text: i18nc("@action/button show detailed smart report", "Detailed Information")
0114                     icon.name: "dialog-scripts"
0115                     onTriggered: {
0116                         // NB: push daftly hardcodes ui/ as prefix....
0117                         kcm.push("ReportPage.qml", {title: product, text: advancedReport})
0118                     }
0119                 }
0120             ]
0121         }
0122     }
0123 }