Warning, /frameworks/knewstuff/src/qtquick/qml/NewStuffItem.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2015 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 import QtQuick 2.11 0008 import QtQuick.Controls 2.11 as QtControls 0009 import QtQuick.Layouts 1.11 as QtLayouts 0010 0011 import org.kde.kirigami 2.1 as Kirigami 0012 0013 import org.kde.newstuff 1.62 as NewStuff 0014 0015 Kirigami.SwipeListItem { 0016 id: listItem; 0017 height: Math.max(Kirigami.Units.iconSizes.huge + Kirigami.Units.smallSpacing * 2, nameText.height + descriptionText.height + Kirigami.Units.smallSpacing * 5); 0018 property QtObject listModel; 0019 enabled: true; 0020 actions: [ 0021 Kirigami.Action { 0022 text: i18ndc("knewstuff5", "Request installation of this item", "Install"); 0023 iconName: "list-add" 0024 onTriggered: { listModel.installItem(model.index, NewStuff.ItemsModel.FirstLinkId); } 0025 enabled: model.status == NewStuff.ItemsModel.DownloadableStatus || model.status == NewStuff.ItemsModel.DeletedStatus; 0026 visible: enabled; 0027 }, 0028 Kirigami.Action { 0029 text: i18ndc("knewstuff5", "Request updating of this item", "Update"); 0030 iconName: "refresh" 0031 onTriggered: { listModel.updateItem(model.index); } 0032 enabled: model.status == NewStuff.ItemsModel.UpdateableStatus; 0033 visible: enabled; 0034 }, 0035 Kirigami.Action { 0036 text: i18ndc("knewstuff5", "Request uninstallation of this item", "Uninstall"); 0037 iconName: "list-remove" 0038 onTriggered: { listModel.uninstallItem(model.index); } 0039 enabled: model.status == NewStuff.ItemsModel.InstalledStatus || model.status == NewStuff.ItemsModel.UpdateableStatus 0040 visible: enabled; 0041 } 0042 ] 0043 QtLayouts.RowLayout { 0044 Item { 0045 id: previewContainer; 0046 QtLayouts.Layout.preferredHeight: listItem.height - Kirigami.Units.smallSpacing * 2; 0047 QtLayouts.Layout.minimumWidth: Kirigami.Units.iconSizes.huge; 0048 QtLayouts.Layout.maximumWidth: Kirigami.Units.iconSizes.huge; 0049 Image { 0050 id: previewImage; 0051 anchors { 0052 fill: parent; 0053 margins: Kirigami.Units.smallSpacing; 0054 leftMargin: -Kirigami.Units.smallSpacing; 0055 } 0056 asynchronous: true; 0057 fillMode: Image.PreserveAspectFit; 0058 source: model.previewsSmall.length > 0 ? model.previewsSmall[0] : ""; 0059 Kirigami.Icon { 0060 id: updateAvailableBadge; 0061 opacity: (model.status == NewStuff.ItemsModel.UpdateableStatus) ? 1 : 0; 0062 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } 0063 anchors { 0064 bottom: parent.bottom; 0065 right: parent.right; 0066 margins: -Kirigami.Units.smallSpacing; 0067 } 0068 height: Kirigami.Units.iconSizes.smallMedium; 0069 width: height; 0070 source: "vcs-update-required"; 0071 } 0072 Kirigami.Icon { 0073 id: installedBadge; 0074 opacity: (model.status == NewStuff.ItemsModel.InstalledStatus) ? 1 : 0; 0075 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } 0076 anchors { 0077 bottom: parent.bottom; 0078 right: parent.right; 0079 margins: -Kirigami.Units.smallSpacing; 0080 } 0081 height: Kirigami.Units.iconSizes.smallMedium; 0082 width: height; 0083 source: "vcs-normal"; 0084 } 0085 } 0086 Rectangle { 0087 anchors.fill: parent 0088 opacity: installIndicator.opacity > 0 ? 0.7 : 0 0089 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } 0090 visible: opacity > 0 0091 } 0092 QtControls.BusyIndicator { 0093 id: installIndicator 0094 anchors.centerIn: parent; 0095 opacity: (model.status == NewStuff.ItemsModel.InstallingStatus || model.status == NewStuff.ItemsModel.UpdatingStatus) ? 1 : 0; 0096 Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } 0097 running: opacity > 0; 0098 QtControls.Label { 0099 anchors { 0100 horizontalCenter: parent.horizontalCenter; 0101 bottom: parent.bottom; 0102 margins: Kirigami.Units.smallSpacing; 0103 } 0104 // There is no distinction between installing and uninstalling as a status, so we have to word things accordingly 0105 text: (model.status == NewStuff.ItemsModel.InstallingStatus) ? "Working" : ((model.status == NewStuff.ItemsModel.UpdatingStatus) ? "Updating" : ""); 0106 width: paintedWidth; 0107 } 0108 } 0109 } 0110 QtLayouts.ColumnLayout { 0111 QtLayouts.Layout.fillWidth: true 0112 QtLayouts.Layout.fillHeight: true 0113 Kirigami.Heading { 0114 id: nameText 0115 QtLayouts.Layout.fillWidth: true 0116 level: 3 0117 text: model.name 0118 opacity: 1 - installIndicator.opacity 0119 } 0120 QtControls.Label { 0121 id: descriptionText 0122 QtLayouts.Layout.fillWidth: true 0123 text: model.summary.split("\n")[0]; 0124 elide: Text.ElideRight 0125 maximumLineCount: 2 0126 wrapMode: Text.Wrap 0127 opacity: 1 - installIndicator.opacity 0128 } 0129 Item { 0130 QtLayouts.Layout.fillWidth: true 0131 QtLayouts.Layout.fillHeight: true 0132 } 0133 } 0134 } 0135 }