Warning, /system/plasma-pk-updates/src/plasma/contents/ui/PackageDelegate.qml is written in an unsupported language. File is not indexed.

0001 /***************************************************************************
0002  *   Copyright (C) 2013 by Aleix Pol Gonzalez <aleixpol@blue-systems.com>  *
0003  *   Copyright (C) 2015 by Lukáš Tinkl <lukas@kde.org>                     *
0004  *   Copyright (C) 2015 by Jan Grulich <jgrulich@redhat.com>               *
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  *   This program is distributed in the hope that it will be useful,       *
0012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0014  *   GNU General Public License for more details.                          *
0015  *                                                                         *
0016  *   You should have received a copy of the GNU General Public License     *
0017  *   along with this program; if not, write to the                         *
0018  *   Free Software Foundation, Inc.,                                       *
0019  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
0020  ***************************************************************************/
0021 
0022 import QtQuick 2.5
0023 import QtQuick.Layouts 1.12
0024 import org.kde.plasma.core 2.0 as PlasmaCore
0025 import org.kde.plasma.components 3.0 as PlasmaComponents3
0026 import org.kde.plasma.extras 2.0 as PlasmaExtras
0027 
0028 PlasmaExtras.ListItem {
0029     id: packageDelegate
0030 
0031     property string updateText
0032     property variant updateUrls: []
0033     readonly property bool expanded: ListView.isCurrentItem
0034 
0035     signal checkStateChanged(bool checked)
0036 
0037     implicitHeight: innerLayout.implicitHeight + (units.smallSpacing * 2)
0038     enabled: true
0039     checked: containsMouse || expanded
0040     // The binding is overwritten on clicks, as this is for some reason a Button
0041     onClicked: checked = Qt.binding(function(){ return containsMouse || expanded; });
0042 
0043     RowLayout {
0044         id: innerLayout
0045         anchors.left: parent.left
0046         anchors.right: parent.right
0047         anchors.verticalCenter: parent.verticalCenter
0048 
0049         PlasmaComponents3.CheckBox {
0050             Layout.alignment: Qt.AlignVCenter
0051             checked: selected
0052             onClicked: {
0053                 updatesModel.setProperty(index, "selected", checked)
0054                 packageDelegate.checkStateChanged(checked)
0055             }
0056         }
0057 
0058         ColumnLayout {
0059             spacing: units.smallSpacing / 2
0060 
0061             PlasmaComponents3.Label {
0062                 Layout.fillWidth: true
0063                 elide: Text.ElideRight
0064                 text: i18nc("Package Name (Version)", "%1 (%2)", name, version)
0065             }
0066 
0067             PlasmaComponents3.Label {
0068                 Layout.fillWidth: true
0069                 elide: Text.ElideRight
0070                 font.pointSize: theme.smallestFont.pointSize
0071                 opacity: 0.6
0072                 text: desc
0073             }
0074 
0075             ColumnLayout {
0076                 visible: packageDelegate.expanded
0077                 spacing: units.smallSpacing / 2
0078 
0079                 PlasmaCore.SvgItem {
0080                     Layout.preferredHeight: lineSvg.elementSize("horizontal-line").height
0081                     Layout.fillWidth: true
0082 
0083                     elementId: "horizontal-line";
0084 
0085                     svg: PlasmaCore.Svg {
0086                         id: lineSvg;
0087                         imagePath: "widgets/line";
0088                     }
0089                 }
0090 
0091                 PlasmaComponents3.Label {
0092                     Layout.fillWidth: true
0093                     font.weight: Font.DemiBold
0094                     text: i18nc("description of the update", "Update Description")
0095                 }
0096 
0097                 PlasmaComponents3.Label {
0098                     Layout.fillWidth: true
0099                     font.pointSize: theme.smallestFont.pointSize
0100                     opacity: 0.6
0101                     text: updateText == "" ? i18n("No description available") : updateText
0102                     wrapMode: Text.WordWrap
0103                 }
0104 
0105                 PlasmaComponents3.Label {
0106                     visible: updateUrls.count > 0
0107                     Layout.fillWidth: true
0108                     font.weight: Font.DemiBold
0109                     text: i18n("Related URLs")
0110                 }
0111 
0112                 Repeater {
0113                     model: updateUrls
0114                     PlasmaComponents3.Label {
0115                         Layout.fillWidth: true
0116                         color: theme.linkColor
0117                         font.pointSize: theme.smallestFont.pointSize
0118                         font.underline: true
0119                         opacity: 0.6
0120                         text: modelData
0121                         wrapMode: Text.WordWrap
0122 
0123                         MouseArea {
0124                             anchors.fill: parent
0125                             hoverEnabled: true
0126                             cursorShape: Qt.PointingHandCursor
0127 
0128                             onClicked: {
0129                                 Qt.openUrlExternally(modelData)
0130                             }
0131                         }
0132                     }
0133                 }
0134             }
0135         }
0136     }
0137 }