From 6dd78495d35af089d04262ab91a41667d1609256 Mon Sep 17 00:00:00 2001
From: "littletux89@gmail.com" <littletux89@gmail.com>
Date: Fri, 24 May 2019 00:03:47 +0300
Subject: [PATCH] [+] Added wallet creation dialog.

---
 KelvinDashboardGUI/DapServiceController.cpp   |  5 ++
 KelvinDashboardGUI/DapServiceController.h     |  2 +
 .../DapUiQmlScreenDialogAddWallet.qml         | 85 +++++++++++++++++++
 .../DapUiQmlWidgetChainWallet.qml             | 13 +++
 ...l => DapUiQmlWidgetChainWalletForm.ui.qml} | 28 +++---
 KelvinDashboardGUI/DapUiQmlWidgetModel.cpp    |  2 +-
 KelvinDashboardGUI/qml.qrc                    |  4 +-
 7 files changed, 127 insertions(+), 12 deletions(-)
 create mode 100644 KelvinDashboardGUI/DapUiQmlScreenDialogAddWallet.qml
 create mode 100644 KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml
 rename KelvinDashboardGUI/{DapUiQmlWidgetChainWallet.ui.qml => DapUiQmlWidgetChainWalletForm.ui.qml} (81%)

diff --git a/KelvinDashboardGUI/DapServiceController.cpp b/KelvinDashboardGUI/DapServiceController.cpp
index e43d06d15..5a07927aa 100644
--- a/KelvinDashboardGUI/DapServiceController.cpp
+++ b/KelvinDashboardGUI/DapServiceController.cpp
@@ -61,6 +61,11 @@ void DapServiceController::getNodeLogs(int aiTimeStamp, int aiRowCount) const
     m_pDapCommandController->getNodeLogs(aiTimeStamp, aiRowCount);
 }
 
+void DapServiceController::addWallet(const QString &asName)
+{
+    qDebug() << "NAME WALLET " << asName;
+}
+
 /// Handling service response for receiving node logs.
 /// @param aNodeLogs List of node logs.
 void DapServiceController::processGetNodeLogs(const QStringList &aNodeLogs)
diff --git a/KelvinDashboardGUI/DapServiceController.h b/KelvinDashboardGUI/DapServiceController.h
index cc18d7312..e13547f91 100644
--- a/KelvinDashboardGUI/DapServiceController.h
+++ b/KelvinDashboardGUI/DapServiceController.h
@@ -61,6 +61,8 @@ public:
     DapLogModel getLogModel() const;
     void setLogModel(const DapLogModel &dapLogModel);
 
+    Q_INVOKABLE void addWallet(const QString& asName);
+
 signals:
     /// The signal is emitted when the Brand company property changes.
     void brandChanged(const QString &brand);
diff --git a/KelvinDashboardGUI/DapUiQmlScreenDialogAddWallet.qml b/KelvinDashboardGUI/DapUiQmlScreenDialogAddWallet.qml
new file mode 100644
index 000000000..e40c42e6e
--- /dev/null
+++ b/KelvinDashboardGUI/DapUiQmlScreenDialogAddWallet.qml
@@ -0,0 +1,85 @@
+import QtQuick 2.9
+import QtQuick.Controls 2.4
+import KelvinDashboard 1.0
+
+Dialog {
+    id: dialogAddWallet
+    focus: true
+    modal: true
+    title: qsTr("Add wallet...")
+
+    width: parent.width/1.5
+    height: 150
+
+    x: parent.width / 2 - width / 2
+    y: parent.height / 2 - height / 2
+
+    function show() {
+            dialogAddWallet.open();
+        }
+    contentItem:
+
+        Rectangle
+        {
+            anchors.fill: parent
+
+            TextField
+                {
+                            background: Rectangle {
+                                radius: 2
+                                border.color: "gray"
+                                border.width: 1
+                            }
+
+                    id: textFieldNameWallet
+                    selectByMouse: true
+                    height: 35
+                    anchors.bottom: buttonOk.top
+                    anchors.bottomMargin: 20
+                    anchors.right: parent.right
+                    anchors.rightMargin: 10
+                    anchors.left: parent.left
+                    anchors.leftMargin: 10
+                    font.pixelSize: 20
+                    clip: true
+
+
+                }
+
+            Button
+            {
+                id: buttonCancle
+                text: "Cancel"
+                width: 100
+                height: 30
+                anchors.right: buttonOk.left
+                anchors.rightMargin: 10
+                anchors.bottom: parent.bottom
+                anchors.bottomMargin: 10
+                onClicked:
+                {
+                    textFieldNameWallet.clear()
+                    close()
+                }
+            }
+
+            Button
+            {
+                id: buttonOk
+                text: "OK"
+                width: 100
+                height: 30
+                anchors.right: parent.right
+                anchors.rightMargin: 10
+                anchors.bottom: parent.bottom
+                anchors.bottomMargin: 10
+                onClicked:
+                {
+                    dapServiceController.addWallet(textFieldNameWallet.text)
+                    textFieldNameWallet.clear()
+                    close()
+                }
+            }
+        }
+
+}
diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml b/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml
new file mode 100644
index 000000000..9767571a9
--- /dev/null
+++ b/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.4
+
+DapUiQmlWidgetChainWalletForm {
+    id: dapQmlWidgetChainWallet
+
+
+
+    save.onClicked: {
+        dialogAddWallet.show()
+}
+
+
+}
diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml
similarity index 81%
rename from KelvinDashboardGUI/DapUiQmlWidgetChainWallet.ui.qml
rename to KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml
index 4128f6ee5..386d3a68b 100644
--- a/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.ui.qml
+++ b/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml
@@ -1,25 +1,28 @@
-import QtQuick 2.9
+import QtQuick 2.11
 import QtQuick.Controls 2.2
 
 Page {
     id: dapUiQmlWidgetChainWallet
-    
+
     title: qsTr("Wallet")
 
+    property alias save: save
+    property alias dialogAddWallet: dialogAddWallet
+
     ListView {
         id: listViewWallet
         anchors.fill: parent
         anchors.margins: 10
         spacing: 10
 
-        delegate: Item {
+       delegate: Item {
             width: parent.width
             height: 150
 
             Rectangle {
                 id: rectangleWallet
                 anchors.fill: parent
-                color: "lightgray"
+               color: "lightgray"
                 opacity: 0.5
                 radius: 5
                 border.color: "gray"
@@ -32,7 +35,7 @@ Page {
                     width: 140
                     border.color: "gray"
                     anchors.left: parent.left
-                    anchors.leftMargin: 5
+                   anchors.leftMargin: 5
                     anchors.verticalCenter: parent.verticalCenter
                     radius: 3.5
 
@@ -43,7 +46,7 @@ Page {
                     }
                 }
 
-                Column
+               Column
                 {
                     anchors.verticalCenter: parent.verticalCenter
                     anchors.left: iconWallet.right
@@ -62,7 +65,7 @@ Page {
 
                     Text {
                         id: lableAddress
-                        text: "Address:"
+                       text: "Address:"
                         font.pixelSize: 18
                         color: "gray"
                     }
@@ -74,7 +77,7 @@ Page {
                         font.pixelSize: 16
                         wrapMode: Text.Wrap
                         selectByMouse: true
-    //                    clip: true
+   //                    clip: true
     //                    elide: Text.ElideRight
                     }
                 }
@@ -84,12 +87,12 @@ Page {
         model: ListModel {
             ListElement {
                 name: "mywallet"
-                address: "RpiDC8c1SxrTNbxwSTVP6mAHhXvUAgCthoCfpVmUSm889M3zt5JfBxo6iRoAPmJkCPihSWNxhRtdTxnd7LXwcj1nbVd5NQyW1kCgXyM6"
+               address: "RpiDC8c1SxrTNbxwSTVP6mAHhXvUAgCthoCfpVmUSm889M3zt5JfBxo6iRoAPmJkCPihSWNxhRtdTxnd7LXwcj1nbVd5NQyW1kCgXyM6"
             }
 
             ListElement {
                 name: "mywallet"
-                address: "RpiDC8c1SxrTNbxwSTVP6mAHhXvUAgCthoCfpVmUSm889M3zt5JfBxo6iRoAPmJkCPihSWNxhRtdTxnd7LXwcj1nbVd5NQyW1kCgXyM6"
+               address: "RpiDC8c1SxrTNbxwSTVP6mAHhXvUAgCthoCfpVmUSm889M3zt5JfBxo6iRoAPmJkCPihSWNxhRtdTxnd7LXwcj1nbVd5NQyW1kCgXyM6"
             }
 
             ListElement {
@@ -103,8 +106,12 @@ Page {
             }
         }
     }
+    DapUiQmlScreenDialogAddWallet {
+        id: dialogAddWallet
+            }
 
     RoundButton {
+            id: save
            text: qsTr("+")
            highlighted: true
            anchors.margins: 10
@@ -112,3 +119,4 @@ Page {
            anchors.bottom: parent.bottom
     }
 }
+
diff --git a/KelvinDashboardGUI/DapUiQmlWidgetModel.cpp b/KelvinDashboardGUI/DapUiQmlWidgetModel.cpp
index 41c2b477e..11ff0ae6f 100755
--- a/KelvinDashboardGUI/DapUiQmlWidgetModel.cpp
+++ b/KelvinDashboardGUI/DapUiQmlWidgetModel.cpp
@@ -7,7 +7,7 @@ DapUiQmlWidgetModel::DapUiQmlWidgetModel(QObject *parent) : QAbstractListModel(p
     m_dapUiQmlWidgets.append(new DapUiQmlWidget( "Services client", "DapUiQmlWidgetChainServicesClient.ui.qml", "qrc:/Resources/Icons/add.png"));
     m_dapUiQmlWidgets.append(new DapUiQmlWidget( "Services share control", "DapUiQmlWidgetChainServicesShareControl.ui.qml", "qrc:/Resources/Icons/add.png"));
     m_dapUiQmlWidgets.append(new DapUiQmlWidget( "Settings", "DapUiQmlWidgetChainSettings.ui.qml", "qrc:/Resources/Icons/add.png"));
-    m_dapUiQmlWidgets.append(new DapUiQmlWidget( "Wallet", "DapUiQmlWidgetChainWallet.ui.qml", "qrc:/Resources/Icons/add.png"));
+    m_dapUiQmlWidgets.append(new DapUiQmlWidget( "Wallet", "DapUiQmlWidgetChainWallet.qml", "qrc:/Resources/Icons/add.png"));
     m_dapUiQmlWidgets.append(new DapUiQmlWidget( "Logs", "DapUiQmlWidgetChainNodeLogs.ui.qml", "qrc:/Resources/Icons/add.png"));
 }
 
diff --git a/KelvinDashboardGUI/qml.qrc b/KelvinDashboardGUI/qml.qrc
index f4f9481fe..4d465d5ce 100755
--- a/KelvinDashboardGUI/qml.qrc
+++ b/KelvinDashboardGUI/qml.qrc
@@ -9,7 +9,6 @@
         <file>DapUiQmlWidgetChainServicesClient.ui.qml</file>
         <file>DapUiQmlWidgetChainServicesShareControl.ui.qml</file>
         <file>DapUiQmlWidgetChainSettings.ui.qml</file>
-        <file>DapUiQmlWidgetChainWallet.ui.qml</file>
         <file>DapUiQmlScreenDialog.qml</file>
         <file>Resources/Icons/icon.png</file>
         <file>DapUiQmlScreenAbout.ui.qml</file>
@@ -27,5 +26,8 @@
         <file>Resources/Icons/settings.png</file>
         <file>Resources/Icons/dialog.png</file>
         <file>Resources/Icons/exit.png</file>
+        <file>DapUiQmlScreenDialogAddWallet.qml</file>
+        <file>DapUiQmlWidgetChainWallet.qml</file>
+        <file>DapUiQmlWidgetChainWalletForm.ui.qml</file>
     </qresource>
 </RCC>
-- 
GitLab