Warning, /plasma-bigscreen/mycroft-skill-installer/app/qml/InstallerArea.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 org.kde.kirigami 2.12 as Kirigami
0012 import QMLTermWidget 1.0
0013 
0014 import "code/Installer.js" as Installer
0015 import "code/SkillUtils.js" as SkillUtils
0016 
0017 Drawer {
0018     id: mainInstallerDrawer
0019     edge: Qt.BottomEdge
0020     width: window.width
0021     height: window.height / 2
0022     dragMargin: 0
0023     interactive: true
0024     dim: false
0025 
0026     property var currentPos
0027     property bool hasSystemDeps
0028 
0029     function initializeInstaller() {
0030         Installer.initInstallation()
0031     }
0032 
0033     function initializeUpdater() {
0034         Installer.initUpdate()
0035     }
0036 
0037     ColumnLayout {
0038         anchors.fill: parent
0039 
0040         Rectangle {
0041             id: pBarRect
0042             visible: true
0043             color: Kirigami.Theme.backgroundColor
0044             Layout.fillWidth: true
0045             Layout.preferredHeight: Kirigami.Units.gridUnit * 4
0046 
0047             Label {
0048                 id: installStep
0049                 visible: text.length > 0
0050                 anchors.top: parent.top
0051                 anchors.left: parent.left
0052                 anchors.right: parent.right
0053                 anchors.leftMargin: Kirigami.Units.largeSpacing
0054                 anchors.rightMargin: Kirigami.Units.largeSpacing
0055                 height: Kirigami.Units.gridUnit * 2
0056                 wrapMode: Text.WordWrap
0057                 horizontalAlignment: Text.AlignLeft
0058                 maximumLineCount: 1
0059                 elide: Text.ElideRight
0060                 color: Kirigami.Theme.textColor
0061             }
0062 
0063             ProgressBar {
0064                 id: pBar
0065                 anchors.top: installStep.bottom
0066                 anchors.topMargin: Kirigami.Units.largeSpacing
0067                 anchors.left: parent.left
0068                 anchors.right: parent.right
0069                 anchors.leftMargin: Kirigami.Units.largeSpacing
0070                 anchors.rightMargin: Kirigami.Units.largeSpacing
0071                 anchors.bottom: parent.bottom
0072             }
0073         }
0074 
0075         Kirigami.Separator {
0076             Layout.fillWidth: true
0077             Layout.preferredHeight: 1
0078         }
0079 
0080         Rectangle {
0081             id: terminalArea
0082             Layout.fillWidth: true
0083             Layout.preferredHeight: parent.height - (pBarRect.height + Kirigami.Units.largeSpacing)
0084             visible: true
0085             color: Kirigami.Theme.backgroundColor
0086 
0087             // @disable-check M300
0088             QMLTermWidget {
0089                 id: terminal
0090                 anchors.top: parent.top
0091                 anchors.bottom: parent.bottom
0092                 anchors.left: parent.left
0093                 anchors.right: parent.right
0094                 anchors.margins: 8
0095                 font.family: "Monospace"
0096                 font.pointSize: 8
0097                 colorScheme: "cool-retro-term"
0098                 // @disable-check M300
0099                 session: QMLTermSession{
0100                     id: mainsession
0101                     property bool hasFinished: false
0102                     initialWorkingDirectory: "$HOME"
0103                     onMatchFound: {
0104                         console.log("found at: %1 %2 %3 %4".arg(startColumn).arg(startLine).arg(endColumn).arg(endLine));
0105                     }
0106                     onNoMatchFound: {
0107                         console.log("not found");
0108                     }
0109                     onFinished: {
0110                         switch(currentPos){
0111                         case "cleanInstallerCompleted":
0112                             hasFinished = true;
0113                             if(hasSystemDeps){
0114                                 Installer.getSysDepInstallerOne()
0115                             }
0116                             else {
0117                                 Installer.getInstallers()
0118                             }
0119                             break;
0120                         case "cleanInstallerSysDepOneCompleted":
0121                             hasFinished = true;
0122                             Installer.cleanSysDepInstallerFileTwo()
0123                             break
0124                         case "cleanInstallerSysDepTwoCompleted":
0125                             hasFinished = true;
0126                             Installer.cleanSysDepInstallerFileThree()
0127                             break
0128                         case "installerOneDownloaded":
0129                             hasFinished = true;
0130                             Installer.getSysDepInstallerTwo()
0131                             break
0132                         case "installerTwoDownloaded":
0133                             hasFinished = true;
0134                             Installer.getSysDepInstallerThree()
0135                             break
0136                         case "installerDownloaded":
0137                             hasFinished = true;
0138                             if(hasSystemDeps){
0139                                 Installer.setPermissionSysDepInstallerOne()
0140                             } else {
0141                                 Installer.setPermission()
0142                             }
0143                             break;
0144 
0145                         case "permissionOneSet":
0146                             hasFinished = true;
0147                             Installer.setPermissionSysDepInstallerTwo()
0148                             break
0149 
0150                         case "permissionTwoSet":
0151                             hasFinished = true;
0152                             Installer.setPermissionSysDepInstallerThree()
0153                             break
0154 
0155                         case "permissionSet":
0156                             hasFinished = true;
0157                             if(hasSystemDeps){
0158                                 Installer.runSysDepInstallerOne()
0159                             } else {
0160                                 Installer.runInstallers()
0161                             }
0162                             break;
0163 
0164                         case "installerOneFinished":
0165                             hasFinished = true;
0166                             Installer.runSysDepInstallerTwo()
0167                             break;
0168 
0169                         case "installerFinished":
0170                             hasFinished = true
0171                             //getSkillStatus()
0172                             Installer.cleanBranchInstaller()
0173                             break;
0174                         case "cleanBranchInstallerCompleted":
0175                             hasFinished = true
0176                             Installer.getBranchInstaller()
0177                             break;
0178                         case "branchInstallerDownloaded":
0179                             hasFinished = true
0180                             Installer.setPermissionBranchInstaller()
0181                             break;
0182                         case "branchPermissionSet":
0183                             hasFinished = true
0184                             Installer.runBranchInstallers()
0185                             break;
0186                         case "branchInstallerFinished":
0187                             hasFinished = true
0188                             installStep.text = "INFO - Installation Completed"
0189                             SkillUtils.delay(3000, function() {
0190                                 installerBox.close()
0191                                 installerView.updateInstallerModel()
0192                                 mainInstallerDrawer.close()
0193                             })
0194                             break;
0195                         case "installDesktopFile":
0196                             hasFinished = true
0197                             Installer.cleanDesktopFileInstaller()
0198                             break;
0199                         case "cleanDesktopInstallerCompleted":
0200                             hasFinished = true
0201                             Installer.getDesktopFileInstaller()
0202                             break;
0203                         case "desktopFileInstallerDownloaded":
0204                             hasFinished = true
0205                             Installer.setPermissionDesktopFileInstaller()
0206                             break;
0207                         case "desktopFilePermissionSet":
0208                             hasFinished = true
0209                             Installer.runDesktopFileInstallers();
0210                             break;
0211                         case "desktopFileInstallerFinished":
0212                             hasFinished = true
0213                             installStep.text = "INFO - Installation Completed"
0214                             SkillUtils.delay(3000, function() {
0215                                 installerBox.close()
0216                                 installerView.updateInstallerModel()
0217                                 mainInstallerDrawer.close()
0218                             })
0219                             break;
0220                             //RemoverLogic
0221                         case "cleanRemoverCompleted":
0222                             hasFinished = true
0223                             Installer.getRemovers()
0224                             break;
0225                         case "cleanRemoverOneCompleted":
0226                             hasFinished = true
0227                             Installer.cleanRemoverTwo()
0228                             break;
0229                         case "removerDownloaded":
0230                             hasFinished = true
0231                             Installer.setPermissionRemover()
0232                             break;
0233                         case "permissionSetRemover":
0234                             hasFinished = true
0235                             Installer.runRemover()
0236                             break;
0237                         case "getRemoveDesktopFile":
0238                             hasFinished = true
0239                             Installer.getRemoveDesktopFile()
0240                             break;
0241                         case "setRemoveDesktopFilePerm":
0242                             hasFinished = true
0243                             Installer.setRemoveDesktopFilePerm()
0244                             break;
0245                         case "removerDesktopFilePermsSet":
0246                             hasFinished = true
0247                             Installer.runRemoverDesktopFile()
0248                             break;
0249                         case "removerFinished":
0250                             hasFinished = true
0251                             installStep.text = "INFO - Uninstall Completed"
0252                             SkillUtils.delay(3000, function() {
0253                                 installerBox.close()
0254                                 installerView.updateInstallerModel()
0255                                 mainInstallerDrawer.close()
0256                             })
0257                             break;                            
0258                         case "updaterCleared":
0259                             hasFinished = true
0260                             Installer.getUpdater()
0261                             break;
0262                         case "updaterDownloaded":
0263                             hasFinished = true
0264                             Installer.setUpdaterPermission()
0265                             break;
0266                         case "updaterPermsSet":
0267                             hasFinished = true
0268                             Installer.runUpdater()
0269                             break;
0270                         case "updaterFinished":
0271                             hasFinished = true
0272                             installStep.text = "INFO - Update Completed"
0273                             SkillUtils.delay(3000, function() {
0274                                 installerBox.close()
0275                                 installerView.updateInstallerModel()
0276                                 mainInstallerDrawer.close()
0277                             })
0278                             break;
0279                         }
0280                     }
0281                 }
0282 
0283                 QMLTermScrollbar {
0284                     terminal: terminal
0285                     width: 20
0286                     Rectangle {
0287                         opacity: 0.4
0288                         anchors.margins: 5
0289                         radius: width * 0.5
0290                         anchors.fill: parent
0291                     }
0292                 }
0293             }
0294         }
0295     }
0296 }