0

I am trying to write a simple qml application being a n2n frontend of the client and following the tutorial. This application is first intended for the desktop, but if it can also be used as a phone application for Ubuntu Touch, even better.

You can see the code hereunder, but since I am not really a developer, I have basic questions:

  1. How can I execute a shell command in qml (the n2n programme is run in the terminal with the "edge" command + few parameters).
  2. How can I pass variable in this shell command to be executed?
  3. How to store the parameters in a configfile for the next time?

Thanks in advance for your help!

The code:

import QtQuick 2.0
import Ubuntu.Components 0.1
import "components"
import Ubuntu.Components.ListItems 0.1
import Ubuntu.Components.Popups 0.1

/*!
\brief MainView with a Label and Button elements.
*/

MainView {
id: root
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"

// Note! applicationName needs to match the "name" field of the click manifest
applicationName: "com.ubuntu.developer.No Launchpad user ID configured..n2nedge"

/*
 This property enables the application to change orientation
 when the device is rotated. The default is false.
*/
//automaticOrientation: true

width: units.gu(30)
height: units.gu(50)

property real margins: units.gu(2)
property real buttonWidth: units.gu(9)

Page {
    title: i18n.tr("n2n edge")

    Column {
        id: pageLayout

        anchors {
            fill:parent
            margins: root.margins
        }
        spacing: units.gu(1)

        Row {
            spacing: units.gu(1)

            TextField {
                id: networkPwd
                placeholderText: "Password"
                echoMode: TextInput.normal
            }
        }
        Row {
            TextField {
                id: nodeIP
                placeholderText: "Node IP"
                echoMode: TextInput.normal
            }
        }
        Row {
            TextField {
                id: nodePort
                placeholderText: "Node port"
                echoMode: TextInput.normal
            }
        }
        Row {
            TextField {
                id: networkName
                placeholderText: "Network name"
                echoMode: TextInput.normal
            }
        }
        Row {
            TextField {
                id: clientIP
                placeholderText: "client IP"
                echoMode: TextInput.normal
            }
        }
        Row {
            Button {
                id: validatePwdButton
                text: i18n.tr("Validate")
                width: units.gu(12)
                onClicked: {
                    cmdForm.update();
                }
            }
        }
        Row {

            TextField {
                id: cmdForm
                placeholderText: "sudo edge -a ClientIP -c NetworkName -k pwdForm -l NodeIP:NodePort"
                echoMode: TextInput.normal
            }
        }
    }
}
}
vmalep
  • 659

0 Answers0