Warning, /plasma-bigscreen/mycroft-skill-installer/app/qml/InstallerBox.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * SPDX-FileCopyrightText: 2019-2020 Aditya Mehra <aix.m@outlook.org>
0003 *
0004 * SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-KDE-Accepted-GPL
0005 */
0006
0007 import QtQuick 2.9
0008 import QtQml.Models 2.3
0009 import QtQuick.Controls 2.3
0010 import QtQuick.Layouts 1.3
0011 import QtGraphicalEffects 1.0
0012 import org.kde.kirigami 2.12 as Kirigami
0013 import SysInfo 1.0
0014 import "delegates" as Delegates
0015
0016 import "code/Installer.js" as Installer
0017
0018 Popup {
0019 id: skillInstallerBox
0020 width: parent.width / 2
0021 height: parent.height
0022 x: Math.round((parent.width - width) / 2)
0023 y: Math.round((parent.height - height) / 2)
0024 dim: true
0025 property var getArch: SysInfo.getArch()
0026 property var skillInfo
0027
0028 onOpened: {
0029 installUninstallBtn.forceActiveFocus()
0030 }
0031
0032 function checkPlatformSupport() {
0033 console.log("From QML BOX: " + skillInfo.itemUpdateStatus)
0034 var platforms
0035 if(skillInfo.platforms === "all"){
0036 platforms = ["all"]
0037 } else {
0038 platforms = skillInfo.platforms.split(",")
0039 }
0040 if(platforms.indexOf("all") !== -1){
0041 return 1
0042 } else {
0043 if(platforms.indexOf(getArch) !== -1){
0044 return 1
0045 } else {
0046 installUninstallBtn.enabled = false
0047 skiStatusLabl.text = "Unsupported Architecture"
0048 skiStatusArea.visible = true
0049 return 0
0050 }
0051 }
0052 }
0053
0054 background: Rectangle {
0055 color: Kirigami.Theme.backgroundColor
0056 layer.enabled: true
0057 anchors.fill: parent
0058 anchors.margins: Kirigami.Units.gridUnit
0059 layer.effect: DropShadow {
0060 horizontalOffset: 0
0061 verticalOffset: 2
0062 radius: 8.0
0063 samples: 8
0064 color: Qt.rgba(0,0,0,0.6)
0065 }
0066 }
0067
0068 Item {
0069 id: descBox
0070 anchors.fill: parent
0071 anchors.margins: Kirigami.Units.gridUnit
0072
0073 RowLayout {
0074 id: desc
0075 anchors.top: parent.top
0076 width: parent.width
0077 height: parent.height / 4
0078
0079 Image {
0080 id: skiicon
0081 Layout.preferredWidth: Kirigami.Units.iconSizes.huge
0082 Layout.preferredHeight: Kirigami.Units.iconSizes.huge
0083 Layout.alignment: Qt.AlignCenter
0084 Layout.leftMargin: Kirigami.Units.smallSpacing
0085 fillMode: Image.Stretch
0086 source: skillInfo ? (typeof skillInfo.itemPreviewPic !== "undefined" ? skillInfo.itemPreviewPic : "") : ""
0087 }
0088
0089 Kirigami.Heading {
0090 visible: text.length > 0
0091 wrapMode: Text.WordWrap
0092 horizontalAlignment: Text.AlignHCenter
0093 verticalAlignment: Text.AlignVCenter
0094 Layout.fillWidth: true
0095 Layout.fillHeight: true
0096 level: 3
0097 maximumLineCount: 3
0098 elide: Text.ElideRight
0099 color: Kirigami.Theme.textColor
0100 text: skillInfo ? (typeof skillInfo.itemDescription !== "undefined" ? skillInfo.itemDescription : "") : ""
0101 }
0102 }
0103
0104 Kirigami.Separator {
0105 id: descSept1
0106 anchors.top: desc.bottom
0107 anchors.left: parent.left
0108 anchors.right: parent.right
0109 anchors.leftMargin: Kirigami.Units.smallSpacing
0110 anchors.rightMargin: Kirigami.Units.smallSpacing
0111 height: 1
0112 }
0113
0114 Kirigami.Heading {
0115 id: descListHeading
0116 level: 3
0117 anchors.top: descSept1.bottom
0118 width: parent.width
0119 height: Kirigami.Units.gridUnit * 2
0120 anchors.left: parent.left
0121 anchors.leftMargin: Kirigami.Units.smallSpacing
0122 text: "Some Example's To Try: " + "<i>Hey Mycroft..</i>"
0123 }
0124
0125 Kirigami.Separator {
0126 id: descSept2
0127 anchors.top: descListHeading.bottom
0128 anchors.left: parent.left
0129 anchors.right: parent.right
0130 anchors.leftMargin: Kirigami.Units.smallSpacing
0131 anchors.rightMargin: Kirigami.Units.smallSpacing
0132 height: 1
0133 }
0134
0135 Item {
0136 anchors.top: descSept2.bottom
0137 anchors.topMargin: Kirigami.Units.smallSpacing
0138 width: parent.width
0139 height: parent.height / 2
0140
0141 Kirigami.CardsListView {
0142 id: exampleRep
0143 anchors.fill: parent
0144 model: skillInfo ? (typeof skillInfo.examples !== "undefined" ? skillInfo.examples.split(",") : "") : ""
0145 spacing: 1
0146 clip: true
0147 delegate: Delegates.ListDelegate{}
0148 }
0149 }
0150
0151 Rectangle {
0152 id: skiStatusArea
0153 anchors.bottom: installUninstallBtn.top
0154 anchors.bottomMargin: Kirigami.Units.smallSpacing
0155 color: skillInfo ? (typeof skillInfo.itemUpdateStatus !== "undefined" && skillInfo.itemUpdateStatus ? "#33BB5E" : Kirigami.Theme.highlightColor) : ""
0156 height: Kirigami.Units.gridUnit * 2
0157 visible: skillInfo ? (typeof skillInfo.itemInstallStatus !== "undefined" ? skillInfo.itemInstallStatus : "") : ""
0158 width: parent.width
0159
0160 Kirigami.Heading {
0161 id: skiStatusLabl
0162 level: 3
0163 text: skillInfo ? (typeof skillInfo.itemUpdateStatus !== "undefined" && skillInfo.itemUpdateStatus ? "Status: Update Available" : "Status: Installed") : ""
0164 anchors.fill: parent
0165 visible: skiStatusArea.visible
0166 anchors.leftMargin: Kirigami.Units.smallSpacing
0167 }
0168 }
0169
0170 Button {
0171 id: installUninstallBtn
0172 anchors.bottom: parent.bottom
0173 anchors.left: parent.left
0174 anchors.leftMargin: Kirigami.Units.smallSpacing
0175 anchors.rightMargin: Kirigami.Units.smallSpacing
0176 anchors.bottomMargin: Kirigami.Units.smallSpacing
0177 anchors.right: parent.right
0178 height: Kirigami.Units.gridUnit * 2
0179
0180 background: Rectangle {
0181 Kirigami.Theme.colorSet: Kirigami.Theme.Button
0182 color: installUninstallBtn.down ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor
0183 border.color: installUninstallBtn.activeFocus ? Kirigami.Theme.hoverColor : Kirigami.Theme.disabledTextColor
0184 border.width: 1
0185 }
0186
0187 contentItem: Label {
0188 horizontalAlignment: Text.AlignHCenter
0189 verticalAlignment: Text.AlignVCenter
0190 elide: Text.ElideRight
0191 text: skillInfo ? (skillInfo.itemUpdateStatus ? "Update" : (skillInfo.itemInstallStatus ? "Uninstall" : "Install")) : ""
0192 }
0193
0194 onClicked: {
0195 if(skillInfo.itemUpdateStatus){
0196 installerArea.initializeUpdater()
0197 } else {
0198 installerArea.initializeInstaller()
0199 }
0200 }
0201
0202 Keys.onReturnPressed: {
0203 clicked()
0204 }
0205 }
0206 }
0207 }