Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Firstpage.qml
- import QtQuick 2.0
- import Sailfish.Silica 1.0
- import "../pages/DBasestuff.js" as DBase
- Page {
- id: page
- property bool stopthisshit: false
- Component.onCompleted: {
- DBase.inDBase();
- //populateList()
- }
- onStatusChanged: {
- console.log("status changed")
- if (!stopthisshit) {
- populateList()
- }
- }
- SilicaListView {
- id:connectionsList
- anchors.fill: parent
- model:listModel
- section {
- property: 'section'
- delegate: SectionHeader {
- text: section
- }
- }
- VerticalScrollDecorator { flickable:connectionsList }
- ViewPlaceholder {
- text: qsTr("Pull down to add a new connection.")
- enabled: connectionsList.count == 0
- }
- PullDownMenu {
- MenuItem {
- text: qsTr("New SSH connection")
- onClicked: pageStack.push(Qt.resolvedUrl("CreateSSH.qml"))
- }
- MenuItem {
- text: qsTr("New Mosh connection")
- onClicked: pageStack.push(Qt.resolvedUrl("CreateMosh.qml"))
- }
- }
- header: Image {
- source: "mossh_logo.png"
- anchors {
- horizontalCenter: parent.horizontalCenter
- }
- MouseArea {
- anchors.fill: parent
- onClicked: pageStack.push(Qt.resolvedUrl("About.qml"))
- }
- }
- delegate: ListItem {
- id: listItem
- menu: contextMenuComponent
- onClicked: {
- }
- Grid{
- columns: 2
- spacing: 5
- GlassItem {
- color : "green"
- }
- Grid {
- rows:2
- Label {
- text: model.connection_name
- }
- Row {
- Label {
- text: model.type
- color: "yellow"
- font.pixelSize: Theme.fontSizeTiny
- }
- Label {
- text: " connection at " +model.username +"@"+ model.address
- color: "grey"
- font.pixelSize: Theme.fontSizeTiny
- }
- }
- }
- Component {
- id: contextMenuComponent
- ContextMenu {
- MenuItem {
- text: qsTr("Disconnect")
- visible: false //fucntion or whatever to check if active
- onClicked: {
- }
- }
- MenuItem {
- text: qsTr("Edit")
- onClicked: {
- console.log("going to edit", model.username)
- page.stopthisshit = true
- pageStack.push(Qt.resolvedUrl("EditCon.qml"), {"modelID": model})
- }
- }
- MenuItem {
- text: qsTr("Delete")
- onClicked: {
- console.log("Deleting:",model.connection_name, model.username, model.address, model.type, model.category, model.activate_on_start, model.connection_commands);
- DBase.removeConnection(model.id);
- listModel.remove(index);
- }
- }
- }
- }
- }
- }
- }
- ListModel {
- id: listModel
- }
- function populateList(){
- listModel.clear()
- var connection = DBase.getConnections()
- for (var i = 0; i < connection.rows.length; i++){
- var component = Qt.createComponent("Connection.qml")
- console.log("creating list connection", i+1);
- console.log("--->>>", connection.rows.item(i).id,connection.rows.item(i).connection_name,connection.rows.item(i).username, connection.rows.item(i).address,connection.rows.item(i).type, connection.rows.item(i).category, connection.rows.item(i).act_on_start,connection.rows.item(i).connection_commands)
- var mod = component.createObject(null, {
- section:"Connections",
- id:connection.rows.item(i).id,
- connection_name: connection.rows.item(i).connection_name,
- username: connection.rows.item(i).username,
- address: connection.rows.item(i).address,
- type: connection.rows.item(i).type,
- category: connection.rows.item(i).category,
- activate_on_start: connection.rows.item(i).act_on_start,
- connection_commands: connection.rows.item(i).connection_commands
- })
- listModel.append(mod)
- }
- }
- }
- import QtQuick 2.0
- import Sailfish.Silica 1.0
- import "../pages/DBasestuff.js" as DBase
- EDITCON.qml
- Dialog {
- id: editdialog
- property var modelID
- //FIX me Add commands Check.
- canAccept: connectionnameField.text != modelID.connection_name || usernameField.text != modelID.username || hostnameField.text != modelID.address || connectionCat.value != modelID.category || activateOnStart.checked != modelID.activate_on_start
- acceptDestinationAction: PageStackAction.Pop
- acceptDestinationProperties: {"stopthisshit": false}
- onAccepted:{
- DBase.updateConnection(modelID.id,connectionnameField.text,usernameField.text,hostnameField.text,connectionCat.value,activateOnStart.checked,"-4")
- console.log("edited connection")
- }
- SilicaFlickable {
- id: editconnection
- anchors.fill: parent
- contentHeight: editColumn.height + Theme.paddingLarge
- VerticalScrollDecorator { flickable:editconnection }
- Column {
- id: editColumn
- width: parent.width
- spacing: Theme.paddingLarge
- DialogHeader {
- id: dheader
- acceptText:qsTr("Confirm Edit")
- }
- TextField {
- id: connectionnameField
- focus: true
- width: parent.width
- text: modelID.connection_name
- label:qsTr( "Connection Name")
- labelVisible: true
- EnterKey.enabled: text.length > 0
- EnterKey.iconSource: "image://theme/icon-m-enter-next"
- EnterKey.onClicked: usernameField.focus = true
- }
- TextField {
- id:usernameField
- focus: true
- width: parent.width
- text: modelID.username
- label: qsTr("Username")
- labelVisible: true
- EnterKey.enabled: text.length > 0
- EnterKey.iconSource: "image://theme/icon-m-enter-next"
- EnterKey.onClicked: hostnameField.focus = true
- }
- TextField {
- id:hostnameField
- width: parent.width
- text: modelID.address
- label: qsTr("Host")
- labelVisible: true
- EnterKey.enabled: text.length > 0
- EnterKey.onClicked: focus = false
- }
- ComboBox {
- //FIX this to display properly the category
- id: connectionCat
- width: parent.width
- label: qsTr("Connection Category")
- menu: ContextMenu {
- MenuItem { text: "Work" }
- MenuItem { text: "Test" }
- MenuItem { text: "Personal" }
- }
- }
- TextSwitch {
- id: activateOnStart
- checked: modelID.activate_on_start
- text: "Connect on Start"
- description: qsTr("Checking this switch will activate the conneciton when MoSSH starts.")
- }
- SectionHeader {
- text:qsTr("Advanced Options")
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement