<commit_before>import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Layouts 1.1
import QtGraphicalEffects 1.0

import "utils.js" as Utils
import org.BitShares.Types 1.0

import Material 0.1

Window {
   id: window
   visible: true
   width: 540
   height: 960

   property alias pageStack: __pageStack
   property alias lockAction: __lockAction
   property alias payAction: __paymentAction

   Component.onCompleted: {
      if( wallet.walletExists )
         wallet.openWallet()
      if( !( wallet.accountNames.length && wallet.accounts[wallet.accountNames[0]].isRegistered ) )
         onboardLoader.sourceComponent = onboardingUi
      else
         pageStack.push({item: assetsUi, properties: {accountName: wallet.accountNames[0]}})

      window.connectToServer()
   }

   function showError(error, buttonName, buttonCallback) {
      snack.text = error
      if( buttonName && buttonCallback ) {
         snack.buttonText = buttonName
         snack.onClick.connect(buttonCallback)
         snack.onDissapear.connect(function() {
            snack.onClick.disconnect(buttonCallback)
         })
      } else
         snack.buttonText = ""
      snack.open()
      return d.currentError = d.errorSerial++
   }
   function clearError(errorId) {
      if( d.currentError === errorId )
         errorText.text = ""
   }
   function deviceType() {
      switch(Device.type) {
      case Device.phone:
      case Device.phablet:
         return "phone"
      case Device.tablet:
         return "tablet"
      case Device.desktop:
      default:
         return "computer"
      }
   }
   function connectToServer() {
      if( !wallet.connected )
         wallet.connectToServer("localhost", 5656, "XTS7pq7tZnghnrnYvQg8aktrSCLVHE5SGyHFeYJBRdcFVvNCBBDjd",
                                "user", "pass")
   }
   function openTransferPage() {
      if( wallet.accounts[wallet.accountNames[0]].availableAssets.length )
         window.pageStack.push({item: transferUi, properties: {accountName: wallet.accountNames[0]}})
      else
         showError(qsTr("You don't have any assets, so you cannot make a transfer."), qsTr("Refresh Balances"),
                   wallet.syncAllBalances)
   }


   AppTheme {
      id: theme
      primaryColor: "#2196F3"
      backgroundColor: "#BBDEFB"
      accentColor: "#80D8FF"
   }
   Action {
      id: __lockAction
      name: qsTr("Lock Wallet")
      iconName: "action/lock"
      onTriggered: wallet.lockWallet()
   }
   Action {
      id: __paymentAction
      name: qsTr("Send Payment")
      iconName: "action/payment"
      onTriggered: openTransferPage()
   }
   QtObject {
      id: d
      property int errorSerial: 0
      property int currentError: -1
   }
   QtObject {
      id: visuals

      property real margins: units.dp(16)
   }
   Timer {
      id: refreshPoller
      running: wallet.unlocked
      triggeredOnStart: true
      interval: 10000
      repeat: true
      onTriggered: {
         if( !wallet.connected )
            connectToServer()
         else
            wallet.sync()
      }
   }
   LightWallet {
      id: wallet

      function runWhenConnected(fn) {
         Utils.connectOnce(wallet.onConnectedChanged, fn, function() { return connected })
      }

      onErrorConnecting: {
         var errorId = showError(error)

         runWhenConnected(function() {
            clearError(errorId)
         })
      }
      onNotification: showError(message)
   }

   WelcomeLayout {
      id: lockScreen
      width: window.width
      height: window.height
      backgroundColor: Theme.backgroundColor
      z: 1
      onPasswordEntered: {
         if( wallet.unlocked )
            return proceedIfUnlocked()

         wallet.unlockWallet(password)
      }

      states: [
         State {
            name: "locked"
            when: !wallet.unlocked
            PropertyChanges {
               target: lockScreen
               x: 0
            }
         },
         State {
            name: "unlocked"
            when: wallet.unlocked
            PropertyChanges {
               target: lockScreen
               x: window.width
            }
         }
      ]
      transitions: [
         Transition {
            from: "unlocked"
            to: "locked"
            SequentialAnimation {
               PropertyAnimation {
                  target: lockScreen
                  duration: 500
                  property: "x"
                  easing.type: Easing.OutBounce
               }
               ScriptAction { script: lockScreen.focus() }
            }
         },
         Transition {
            from: "locked"
            to: "unlocked"
            SequentialAnimation {
               PropertyAnimation {
                  target: lockScreen
                  duration: 500
                  property: "x"
                  easing.type: Easing.InQuad
               }
               ScriptAction { script: lockScreen.clearPassword() }
            }
         }
      ]
   }

   Item {
      id: applicationArea
      anchors.fill: parent
      enabled: wallet.unlocked && !onboardLoader.sourceComponent
      Toolbar {
         id: toolbar
         width: parent.width
         backgroundColor: Theme.primaryColor
      }
      View {
         id: criticalNotificationArea
         y: toolbar.height
         backgroundColor: "#F44336"
         height: units.dp(100)
         width: parent.width
         enabled: false
         z: -1

         //Show iff brain key is set, the main page is not active or transitioning out, and we're not already in an onboarding UI
         property bool active: wallet.brainKey.length > 0 &&
                               !onboardLoader.sourceComponent

         Label {
            anchors.verticalCenter: parent.verticalCenter
            anchors.left:  parent.left
            anchors.right: criticalNotificationButton.left
            anchors.margins: visuals.margins
            text: qsTr("Your wallet has not been backed up. You should back it up as soon as possible.")
            color: "white"
            style: "subheading"
            wrapMode: Text.WrapAtWordBoundaryOrAnywhere
         }
         Button {
            id: criticalNotificationButton
            anchors.right: parent.right
            anchors.rightMargin: visuals.margins
            anchors.verticalCenter: parent.verticalCenter
            text: qsTr("Back Up Wallet")
            textColor: "white"

            onClicked: onboardLoader.sourceComponent = backupUi
         }

         states: [
            State {
               name: "active"
               when: criticalNotificationArea.active
               PropertyChanges {
                  target: criticalNotificationArea
                  enabled: true
               }
               PropertyChanges {
                  target: pageStack
                  anchors.topMargin: criticalNotificationArea.height
               }
            }
         ]
         transitions: [
            Transition {
               from: ""
               to: "active"
               reversible: true
               PropertyAnimation { target: pageStack; property: "anchors.topMargin"; easing.type: Easing.InOutQuad }
            }
         ]
      }
      PageStack {
         id: __pageStack
         anchors {
            left: parent.left
            right: parent.right
            top: toolbar.bottom
            bottom: parent.bottom
         }

         onPushed: toolbar.push(page)
         onPopped: toolbar.pop()

         Component {
            id: assetsUi

            AssetsLayout {
               onLockRequested: {
                  wallet.lockWallet()
                  uiStack.pop()
               }
               onOpenHistory: window.pageStack.push(historyUi, {"accountName": account, "assetSymbol": symbol})
            }
         }
         Component {
            id: historyUi

            HistoryLayout {
            }
         }
         Component {
            id: transferUi

            TransferLayout {
               onTransferComplete: window.pageStack.pop()
            }
         }
         Snackbar {
            id: snack
            duration: 5000
            enabled: opened
            onClick: opened = false
            z: 21
         }
      }
   }
   Component {
      id: onboardingUi

      OnboardingLayout {
         onFinished: {
            pageStack.push({item: assetsUi, properties: {accountName: wallet.accountNames[0]}, immediate: true})
            onboardLoader.sourceComponent = undefined
         }
      }
   }
   Component {
      id: backupUi

      BackupLayout {
         onFinished: onboardLoader.sourceComponent = undefined
      }
   }
   Loader {
      id: onboardLoader
      z: 2
      anchors.fill: parent
   }
}
<commit_msg>Point Light Wallet at live network server<commit_after>import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Layouts 1.1
import QtGraphicalEffects 1.0

import "utils.js" as Utils
import org.BitShares.Types 1.0

import Material 0.1

Window {
   id: window
   visible: true
   width: 540
   height: 960

   property alias pageStack: __pageStack
   property alias lockAction: __lockAction
   property alias payAction: __paymentAction

   Component.onCompleted: {
      if( wallet.walletExists )
         wallet.openWallet()
      if( !( wallet.accountNames.length && wallet.accounts[wallet.accountNames[0]].isRegistered ) )
         onboardLoader.sourceComponent = onboardingUi
      else
         pageStack.push({item: assetsUi, properties: {accountName: wallet.accountNames[0]}})

      window.connectToServer()
   }

   function showError(error, buttonName, buttonCallback) {
      snack.text = error
      if( buttonName && buttonCallback ) {
         snack.buttonText = buttonName
         snack.onClick.connect(buttonCallback)
         snack.onDissapear.connect(function() {
            snack.onClick.disconnect(buttonCallback)
         })
      } else
         snack.buttonText = ""
      snack.open()
      return d.currentError = d.errorSerial++
   }
   function clearError(errorId) {
      if( d.currentError === errorId )
         errorText.text = ""
   }
   function deviceType() {
      switch(Device.type) {
      case Device.phone:
      case Device.phablet:
         return "phone"
      case Device.tablet:
         return "tablet"
      case Device.desktop:
      default:
         return "computer"
      }
   }
   function connectToServer() {
      if( !wallet.connected )
         wallet.connectToServer("nathanhourt.com", 5656, "BTS5LyQycuMEdo6Dxx1XqYp24KV3fVoFKuXJMXTj3x7xJsis3C3EZ",
                                "user", "pass")
   }
   function openTransferPage() {
      if( wallet.accounts[wallet.accountNames[0]].availableAssets.length )
         window.pageStack.push({item: transferUi, properties: {accountName: wallet.accountNames[0]}})
      else
         showError(qsTr("You don't have any assets, so you cannot make a transfer."), qsTr("Refresh Balances"),
                   wallet.syncAllBalances)
   }


   AppTheme {
      id: theme
      primaryColor: "#2196F3"
      backgroundColor: "#BBDEFB"
      accentColor: "#80D8FF"
   }
   Action {
      id: __lockAction
      name: qsTr("Lock Wallet")
      iconName: "action/lock"
      onTriggered: wallet.lockWallet()
   }
   Action {
      id: __paymentAction
      name: qsTr("Send Payment")
      iconName: "action/payment"
      onTriggered: openTransferPage()
   }
   QtObject {
      id: d
      property int errorSerial: 0
      property int currentError: -1
   }
   QtObject {
      id: visuals

      property real margins: units.dp(16)
   }
   Timer {
      id: refreshPoller
      running: wallet.unlocked
      triggeredOnStart: true
      interval: 10000
      repeat: true
      onTriggered: {
         if( !wallet.connected )
            connectToServer()
         else
            wallet.sync()
      }
   }
   LightWallet {
      id: wallet

      function runWhenConnected(fn) {
         Utils.connectOnce(wallet.onConnectedChanged, fn, function() { return connected })
      }

      onErrorConnecting: {
         var errorId = showError(error)

         runWhenConnected(function() {
            clearError(errorId)
         })
      }
      onNotification: showError(message)
   }

   WelcomeLayout {
      id: lockScreen
      width: window.width
      height: window.height
      backgroundColor: Theme.backgroundColor
      z: 1
      onPasswordEntered: {
         if( wallet.unlocked )
            return proceedIfUnlocked()

         wallet.unlockWallet(password)
      }

      states: [
         State {
            name: "locked"
            when: !wallet.unlocked
            PropertyChanges {
               target: lockScreen
               x: 0
            }
         },
         State {
            name: "unlocked"
            when: wallet.unlocked
            PropertyChanges {
               target: lockScreen
               x: window.width
            }
         }
      ]
      transitions: [
         Transition {
            from: "unlocked"
            to: "locked"
            SequentialAnimation {
               PropertyAnimation {
                  target: lockScreen
                  duration: 500
                  property: "x"
                  easing.type: Easing.OutBounce
               }
               ScriptAction { script: lockScreen.focus() }
            }
         },
         Transition {
            from: "locked"
            to: "unlocked"
            SequentialAnimation {
               PropertyAnimation {
                  target: lockScreen
                  duration: 500
                  property: "x"
                  easing.type: Easing.InQuad
               }
               ScriptAction { script: lockScreen.clearPassword() }
            }
         }
      ]
   }

   Item {
      id: applicationArea
      anchors.fill: parent
      enabled: wallet.unlocked && !onboardLoader.sourceComponent
      Toolbar {
         id: toolbar
         width: parent.width
         backgroundColor: Theme.primaryColor
      }
      View {
         id: criticalNotificationArea
         y: toolbar.height
         backgroundColor: "#F44336"
         height: units.dp(100)
         width: parent.width
         enabled: false
         z: -1

         //Show iff brain key is set, the main page is not active or transitioning out, and we're not already in an onboarding UI
         property bool active: wallet.brainKey.length > 0 &&
                               !onboardLoader.sourceComponent

         Label {
            anchors.verticalCenter: parent.verticalCenter
            anchors.left:  parent.left
            anchors.right: criticalNotificationButton.left
            anchors.margins: visuals.margins
            text: qsTr("Your wallet has not been backed up. You should back it up as soon as possible.")
            color: "white"
            style: "subheading"
            wrapMode: Text.WrapAtWordBoundaryOrAnywhere
         }
         Button {
            id: criticalNotificationButton
            anchors.right: parent.right
            anchors.rightMargin: visuals.margins
            anchors.verticalCenter: parent.verticalCenter
            text: qsTr("Back Up Wallet")
            textColor: "white"

            onClicked: onboardLoader.sourceComponent = backupUi
         }

         states: [
            State {
               name: "active"
               when: criticalNotificationArea.active
               PropertyChanges {
                  target: criticalNotificationArea
                  enabled: true
               }
               PropertyChanges {
                  target: pageStack
                  anchors.topMargin: criticalNotificationArea.height
               }
            }
         ]
         transitions: [
            Transition {
               from: ""
               to: "active"
               reversible: true
               PropertyAnimation { target: pageStack; property: "anchors.topMargin"; easing.type: Easing.InOutQuad }
            }
         ]
      }
      PageStack {
         id: __pageStack
         anchors {
            left: parent.left
            right: parent.right
            top: toolbar.bottom
            bottom: parent.bottom
         }

         onPushed: toolbar.push(page)
         onPopped: toolbar.pop()

         Component {
            id: assetsUi

            AssetsLayout {
               onLockRequested: {
                  wallet.lockWallet()
                  uiStack.pop()
               }
               onOpenHistory: window.pageStack.push(historyUi, {"accountName": account, "assetSymbol": symbol})
            }
         }
         Component {
            id: historyUi

            HistoryLayout {
            }
         }
         Component {
            id: transferUi

            TransferLayout {
               onTransferComplete: window.pageStack.pop()
            }
         }
         Snackbar {
            id: snack
            duration: 5000
            enabled: opened
            onClick: opened = false
            z: 21
         }
      }
   }
   Component {
      id: onboardingUi

      OnboardingLayout {
         onFinished: {
            pageStack.push({item: assetsUi, properties: {accountName: wallet.accountNames[0]}, immediate: true})
            onboardLoader.sourceComponent = undefined
         }
      }
   }
   Component {
      id: backupUi

      BackupLayout {
         onFinished: onboardLoader.sourceComponent = undefined
      }
   }
   Loader {
      id: onboardLoader
      z: 2
      anchors.fill: parent
   }
}

{'fraction_non_alphanumeric': 0.0792377701934016, 'fraction_numerical': 0.008646188850967008, 'mean_word_length': 1.5420763447079238, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1538265', 'n_tokens_mistral': 4782, 'n_tokens_neox': 4610, 'n_words': 1030}