Warning, /maui/nota/src/plugins/ActionBar.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.ToolBar
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     position: ToolBar.Footer
0028 
0029     Maui.ToolActions
0030     {
0031         checkable: false
0032         autoExclusive: false
0033         expanded: true
0034         display: ToolButton.TextBesideIcon
0035 
0036         Action
0037         {
0038             icon.name: "run-build"
0039             text: i18n("Run")
0040 
0041             onTriggered:
0042             {
0043                 console.log("trying to run a script", currentEditor.fileUrl)
0044                 Nota.Nota.run(String("QT_QUICK_CONTROLS_MOBILE=%1 QT_QUICK_CONTROLS_STYLE=%2 qmlscene").arg(plugin.style  ,plugin.mobileMode ? "1" : "0"), [currentEditor.fileUrl])
0045 
0046             }
0047         }
0048 
0049         Action
0050         {
0051             icon.name: "debug-run"
0052             text: i18n("Run & Debug")
0053             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://", ""))
0054         }
0055 
0056         Action
0057         {
0058             icon.name: "cm_runterm"
0059             text: i18n("Run in Terminal")
0060             onTriggered: start("QT_QUICK_CONTROLS_MOBILE=" + (plugin.mobileMode ? "1" : "0") + " QT_QUICK_CONTROLS_STYLE=" + plugin.style  +" qmlscene " + String(currentEditor.fileUrl).replace("file://", "") );
0061 
0062         }
0063     }
0064 
0065     ComboBox
0066     {
0067         model: styles
0068         textRole: "key"
0069 
0070         Component.onCompleted: currentIndex = find(plugin.style, Qt.MatchExactly)
0071         onActivated:
0072         {
0073             plugin.style = styles.get(currentIndex).value
0074         }
0075     }
0076 
0077     Switch
0078     {
0079         text: i18n("Mobile")
0080         checkable: true
0081         checked: plugin.mobileMode
0082         onToggled: plugin.mobileMode = checked
0083     }
0084 
0085     ToolButton
0086     {
0087         visible: plugin.running
0088         icon.name: "process-stop"
0089         onClicked: stop()
0090 
0091     }
0092 
0093     function start(command)
0094     {
0095         if(currentTab.terminal)
0096         {
0097             if(!currentTab.terminal.visible)
0098             {
0099                 terminalVisible = true
0100             }
0101 
0102             currentTab.terminal.session.sendText(command+"\n")
0103             plugin.running = true
0104         }
0105     }
0106 
0107     function stop()
0108     {
0109           if(currentTab.terminal)
0110           {
0111               currentTab.terminal.simulateKeyPress(Qt.Key_C, Qt.ControlModifier, true, 0, "")
0112               plugin.running = false
0113           }
0114     }
0115 
0116 }