Warning, /maui/nota/src/plugins/QMLLive.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.13
0002 import QtQuick.Controls 2.13
0003 import QtQuick.Layouts 1.3
0004 
0005 import org.mauikit.controls 1.3 as Maui
0006 import org.maui.nota 1.0 as Nota
0007 
0008 Maui.Page
0009 {
0010     id: plugin
0011 
0012     property bool running : false
0013     property bool mobileMode : false
0014     property string style : "kde.org.desktop"
0015 
0016     ListModel
0017     {
0018         id: styles
0019         ListElement { key: "Plasma"; value: "org.kde.desktop" }
0020         ListElement { key: "Material"; value: "Material" }
0021         ListElement { key: "Maui"; value: "maui-style" }
0022         ListElement { key: "Fusion"; value: "Fusion" }
0023         ListElement { key: "Universal"; value: "Universal" }
0024     }
0025 
0026     Layout.fillWidth: true
0027     Layout.minimumHeight: 500
0028 
0029 
0030     Loader
0031     {
0032         anchors.centerIn: parent
0033         anchors.fill: parent
0034         id: _loader
0035 
0036         function reload()
0037         {
0038             const  sourceFile = _loader.source
0039             _loader.source = ""
0040             _loader.source = sourceFile
0041         }
0042     }
0043 
0044     footBar.leftContent:[
0045      Maui.ToolActions
0046     {
0047         checkable: false
0048         autoExclusive: false
0049         expanded: true
0050         display: ToolButton.TextBesideIcon
0051 
0052         Action
0053         {
0054             icon.name: "run-build"
0055             text: i18n("Run")
0056 
0057             onTriggered:
0058             {
0059                 console.log("trying to run a script", currentEditor.fileUrl)
0060 //                Nota.Nota.run("qmlscene", [currentEditor.fileUrl])
0061 if(_loader.source.length)
0062                     {
0063                         _loader.source = " "
0064                     }else
0065                     {
0066                         _loader.source = currentEditor.fileUrl
0067 
0068                     }
0069 
0070             }
0071         }
0072 
0073         Action
0074         {
0075             icon.name: "debug-run"
0076             text: i18n("Run & Debug")
0077             onTriggered: start("QML_IMPORT_TRACE=1 " + "QT_QUICK_CONTROLS_MOBILE=" + (plugin.mobileMode ? "1" : "0") + " QT_QUICK_CONTROLS_STYLE=" + plugin.style  +" qmlscene " + String(currentEditor.fileUrl).replace("file://", ""))
0078         }
0079 
0080         Action
0081         {
0082             icon.name: "cm_runterm"
0083             text: i18n("Run in Terminal")
0084             onTriggered: start("QT_QUICK_CONTROLS_MOBILE=" + (plugin.mobileMode ? "1" : "0") + " QT_QUICK_CONTROLS_STYLE=" + plugin.style  +" qmlscene " + String(currentEditor.fileUrl).replace("file://", "") );
0085 
0086         }
0087     },
0088 
0089     ComboBox
0090     {
0091         model: styles
0092         textRole: "key"
0093 
0094         Component.onCompleted: currentIndex = find(plugin.style, Qt.MatchExactly)
0095         onActivated:
0096         {
0097             plugin.style = styles.get(currentIndex).value
0098         }
0099     },
0100 
0101     Switch
0102     {
0103         text: i18n("Mobile")
0104         checkable: true
0105         checked: plugin.mobileMode
0106         onToggled: plugin.mobileMode = checked
0107     },
0108 
0109     ToolButton
0110     {
0111         visible: plugin.running
0112         icon.name: "process-stop"
0113         onClicked: stop()
0114 
0115     }
0116 ]
0117 
0118     function start(command)
0119     {
0120         if(currentTab.terminal)
0121         {
0122             if(!currentTab.terminal.visible)
0123             {
0124                 root.terminalVisible = true
0125             }
0126 
0127             currentTab.terminal.session.sendText(command+"\n")
0128             plugin.running = true
0129         }
0130     }
0131 
0132     function stop()
0133     {
0134           if(currentTab.terminal)
0135           {
0136               currentTab.terminal.simulateKeyPress(Qt.Key_C, Qt.ControlModifier, true, 0, "")
0137               plugin.running = false
0138           }
0139     }
0140 
0141 }