From e3950edc808ca34ba607ed0d98e905327a6e9ee0 Mon Sep 17 00:00:00 2001 From: Vyacheslav Kott <vyacheslav.kott@gitlab.demlabs.net> Date: Tue, 20 Aug 2024 14:51:36 +0300 Subject: [PATCH 1/3] [*] add fee component on the new payment panel --- .../Modules/DapModulesController.cpp | 6 + .../Modules/DapModulesController.h | 10 ++ .../Modules/Wallet/DapModuleWallet.cpp | 7 +- .../Modules/Wallet/DapModuleWallet.h | 5 +- .../DapNewPaymentMainRightPanel.qml | 23 +++- .../DapNewPaymentMainRightPanelForm.qml | 120 +++++++++++++++++- 6 files changed, 161 insertions(+), 10 deletions(-) diff --git a/CellFrameDashboardGUI/Modules/DapModulesController.cpp b/CellFrameDashboardGUI/Modules/DapModulesController.cpp index d24c8fbae..7f307f07a 100644 --- a/CellFrameDashboardGUI/Modules/DapModulesController.cpp +++ b/CellFrameDashboardGUI/Modules/DapModulesController.cpp @@ -253,3 +253,9 @@ void DapModulesController::restoreIndex() setCurrentWalletIndex(0); } + +QString DapModulesController::getMainTokenName(const QString& network) const +{ + bool check = !network.isEmpty() && m_tokens.contains(network); + return check ? m_tokens[network] : "-"; +} diff --git a/CellFrameDashboardGUI/Modules/DapModulesController.h b/CellFrameDashboardGUI/Modules/DapModulesController.h index 250ce2b14..5afa52bd2 100644 --- a/CellFrameDashboardGUI/Modules/DapModulesController.h +++ b/CellFrameDashboardGUI/Modules/DapModulesController.h @@ -62,6 +62,8 @@ public: Q_PROPERTY (int nodeLoadProgress READ nodeLoadProgress NOTIFY nodeLoadProgressChanged) int nodeLoadProgress(){return m_nodeLoadProgress;} + Q_INVOKABLE QString getMainTokenName(const QString& network) const; + public slots: Q_INVOKABLE void updateListWallets(); Q_INVOKABLE void updateListNetwork(); @@ -115,6 +117,14 @@ private: ConfigWorker *m_configWorker = nullptr; bool m_isNodeWorking = false; + + const QMap<QString, QString> m_tokens = {{"Backbone", QString("CELL")}, + {"KelVPN", QString("KEL")}, + {"raiden", QString("tCELL")}, + {"riemann", QString("tKEL")}, + {"mileena", QString("tMIL")}, + {"subzero", QString("tCELL")}}; + }; #endif // DAPMODULESCONTROLLER_H diff --git a/CellFrameDashboardGUI/Modules/Wallet/DapModuleWallet.cpp b/CellFrameDashboardGUI/Modules/Wallet/DapModuleWallet.cpp index f115696b3..3ebf2b79a 100644 --- a/CellFrameDashboardGUI/Modules/Wallet/DapModuleWallet.cpp +++ b/CellFrameDashboardGUI/Modules/Wallet/DapModuleWallet.cpp @@ -1,6 +1,7 @@ #include "DapModuleWallet.h" #include <QStringList> #include "../DapTypes/DapCoin.h" +#include "../DapTypes/DapExpConvert.h" DapModuleWallet::DapModuleWallet(DapModulesController *parent) : DapAbstractModule(parent) @@ -685,7 +686,7 @@ QVariantMap DapModuleWallet::getAvailableBalance(QVariantMap data) QString balanceDatoshi = balances.value("balanceSendDatoshi").toString(); QVariant commission = mathWorker.sumCoins(fee.netFee["fee_datoshi"], - fee.validatorFee["median_fee_datoshi"], + DapExpConvert::coinsToDatoshi(m_userFee), false); if(!stringWorker.testAmount(balancePayFee, commission.toString())) @@ -778,7 +779,7 @@ void DapModuleWallet::sendTx(QVariantMap data) { MathWorker mathWorker; QString net = data.value("network").toString(); - QString feeDatoshi = m_feeInfo[net].validatorFee["median_fee_datoshi"]; + QString feeDatoshi = DapExpConvert::coinsToDatoshi(m_userFee); QString amount = mathWorker.coinsToBalance(data.value("amount")).toString(); QStringList listData; @@ -893,7 +894,7 @@ QVariantMap DapModuleWallet::isCreateOrder(const QString& network, const QString if(feeInfo.validatorFee.contains("fee_ticker") && feeInfo.validatorFee.contains("median_fee_coins")) { valFeeTicker = feeInfo.validatorFee["fee_ticker"]; - valFee = feeInfo.validatorFee["median_fee_coins"]; + valFee = m_userFee; } if(!valFee.isEmpty() && valFee != "0.0") diff --git a/CellFrameDashboardGUI/Modules/Wallet/DapModuleWallet.h b/CellFrameDashboardGUI/Modules/Wallet/DapModuleWallet.h index b0bfd9223..4dfc50c9e 100644 --- a/CellFrameDashboardGUI/Modules/Wallet/DapModuleWallet.h +++ b/CellFrameDashboardGUI/Modules/Wallet/DapModuleWallet.h @@ -64,6 +64,9 @@ public: Q_PROPERTY(QString balanceDEX READ getBalanceDEX NOTIFY currantBalanceDEXChanged) Q_INVOKABLE QString getBalanceDEX(const QString& tokenName = "") const; Q_INVOKABLE void updateBalanceDEX(); + Q_INVOKABLE void setUserFee(const QString& userFee) { m_userFee = userFee;}; + Q_INVOKABLE void tryUpdateFee(); + private: void initConnect(); void updateWalletModel(QVariant, bool isSingle); @@ -109,7 +112,6 @@ private slots: void startUpdateCurrentWallet(); void rcvFee(const QVariant &rcvData); - void tryUpdateFee(); private: WalletHashManager *m_walletHashManager; @@ -135,6 +137,7 @@ private: bool m_firstDataLoad = false; QString m_currentTokenDEX = ""; + QString m_userFee = ""; private: const int TIME_FEE_UPDATE = 2000; const int TIME_WALLET_UPDATE = 5000; diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml index 0e04db443..6ecbb466a 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml @@ -55,6 +55,12 @@ DapNewPaymentMainRightPanelForm console.warn("An attempt to transfer tokens to your address.") dapTextNotEnoughTokensWarning.text = qsTr("Error. An attempt to transfer tokens to your address.") } + else if (dapFeeController.currentValue === "") + { + console.warn("Need value of fee") + dapTextNotEnoughTokensWarning.text = qsTr("Need value of fee") + } + else if (dapTextInputRecipientWalletAddress.text.length != 104 && dapTextInputRecipientWalletAddress.text != "null") { console.log("Wrong address length") @@ -89,11 +95,18 @@ DapNewPaymentMainRightPanelForm case 0: console.log("Correct tx data") console.log("dapWalletMessagePopup.smartOpen") - walletModule.stopUpdateFee() - dapWalletMessagePopup.network = dapComboboxNetwork.displayText - dapWalletMessagePopup.smartOpen( - qsTr("Confirming the transaction"), - qsTr("Attention, the transaction fee will be ")) + if(showNetFeePopup) + { + walletModule.stopUpdateFee() + dapWalletMessagePopup.network = dapComboboxNetwork.displayText + dapWalletMessagePopup.smartOpen( + qsTr("Confirming the transaction"), + qsTr("Attention, the transaction fee will be ")) + } + else + { + dapWalletMessagePopup.signalAccept(true) + } break; case 1: console.warn("Rcv fee error") diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml index 3fd5f1aaa..f6067194e 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml @@ -27,7 +27,7 @@ DapRectangleLitAndShaded property alias dapChainGroup: chainGroup - + property alias dapFeeController: feeController property alias dapComboBoxToken: comboboxToken property alias dapFrameAmountPayment: frameAmountPayment @@ -43,6 +43,7 @@ DapRectangleLitAndShaded property alias dapTextInputRecipientWalletAddress: textInputRecipientWalletAddress property alias balance: balance + property bool showNetFeePopup: false color: currTheme.secondaryBackground radius: currTheme.frameRadius @@ -51,6 +52,7 @@ DapRectangleLitAndShaded Component.onCompleted: { + walletModule.tryUpdateFee() updateWindow() } @@ -58,6 +60,9 @@ DapRectangleLitAndShaded { id: walletMessagePopup dapButtonCancel.visible: true + fee2Layout.visible: false + height: 258 + } contentData: @@ -514,6 +519,99 @@ DapRectangleLitAndShaded } } + // Validator fee + Rectangle + { + id: frameValidatorFee + Layout.topMargin: 20 + Layout.fillWidth: true + color: currTheme.mainBackground + height: 30 + Text + { + id: textValidatorFee + color: currTheme.white + text: qsTr("Validator fee") + font: mainFont.dapFont.medium12 + horizontalAlignment: Text.AlignLeft + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 16 + } + } + + DapFeeComponent + { + property string medianStr: "" + + id: feeController + + Layout.fillWidth: true + Layout.topMargin: 20 + Layout.leftMargin: 16 + Layout.rightMargin: 16 + + onCurrentValueChanged: + { + walletModule.setUserFee(currentValue) + } + + Component.onCompleted: + { + walletModule.tryUpdateFee() + } + + Component.onDestruction: + { + walletModule.setUserFee("") + } + + function getFeeData() + { + var resFee = walletModule.getFee(dapComboboxNetwork.displayText) + if(resFee.error === 0 && resFee.validator_fee !== "" && resFee.network_fee !== "") + { + var new_median = resFee.validator_fee + if(new_median !== feeController.medianStr) + { + if(feeController.medianStr !== "") + { + notifyAboutChange(new_median) + } + else + { + init(generateRanges(new_median)) + } + feeController.medianStr = new_median + } + showNetFeePopup = !(resFee.network_fee === "0.0") + } + } + + function notifyAboutChange(new_median) + { + var new_ranges = generateRanges(new_median) + feeController.rangeValues = new_ranges + initStates() + dapTextNotEnoughTokensWarning.text = + qsTr("Validator fee was been changed. New median data: %1") + .arg(new_median) + } + + function generateRanges(median_str) + { + var median = parseFloat(median_str); + return { + "veryLow": 0, + "low": median/2, + "middle": median, + "high": median * 1.5, + "veryHigh": median * 2 + } + } + } + + Item{Layout.fillHeight: true} Text @@ -588,6 +686,8 @@ DapRectangleLitAndShaded frameRecipientWallet.visible = false frameRecipientWalletAddress.visible = false textNotEnoughTokensWarning.visible = false + frameValidatorFee.visible = false + feeController.visible = false buttonSend.visible = false } else @@ -597,14 +697,32 @@ DapRectangleLitAndShaded frameRecipientWallet.visible = true frameRecipientWalletAddress.visible = true textNotEnoughTokensWarning.visible = true + frameValidatorFee.visible = true + feeController.visible = true buttonSend.visible = true } if(comboboxNetwork.displayText !== "") + { walletModule.getComission(dapComboboxNetwork.displayText) + feeController.valueName = modulesController.getMainTokenName(dapComboboxNetwork.displayText) + feeController.medianStr = "" + feeController.getFeeData() + + } balance.fullText = walletTokensModel.get(dapComboBoxToken.displayText).value + " " + dapComboBoxToken.displayText } } + + Connections + { + target: walletModule + function onFeeInfoUpdated() + { + feeController.getFeeData() + } + } + } -- GitLab From 0f32df5f8b97239ce1659698fbc1c6e88ca579a3 Mon Sep 17 00:00:00 2001 From: Vyacheslav Kott <vyacheslav.kott@gitlab.demlabs.net> Date: Wed, 4 Sep 2024 15:15:25 +0300 Subject: [PATCH 2/3] [*] update to develop --- .../DapNewPaymentMainRightPanelForm.qml | 960 +++++++++--------- dap-ui-sdk | 2 +- 2 files changed, 490 insertions(+), 472 deletions(-) diff --git a/CellFrameDashboard/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml b/CellFrameDashboard/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml index f6067194e..c5c462395 100644 --- a/CellFrameDashboard/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml +++ b/CellFrameDashboard/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml @@ -65,542 +65,559 @@ DapRectangleLitAndShaded } - contentData: - ColumnLayout + Item { - anchors.fill: parent - spacing: 0 + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + height: 42 - Item + HeaderButtonForRightPanels { - Layout.fillWidth: true - height: 42 - - HeaderButtonForRightPanels{ - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: 16 - - id: itemButtonClose - height: 20 - width: 20 - heightImage: 20 - widthImage: 20 - - normalImage: "qrc:/Resources/"+pathTheme+"/icons/other/cross.svg" - hoverImage: "qrc:/Resources/"+pathTheme+"/icons/other/cross_hover.svg" - } - - Text - { - id: textHeader - text: qsTr("New payment") - verticalAlignment: Qt.AlignLeft - anchors.left: itemButtonClose.right - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: 10 - - font: mainFont.dapFont.bold14 - color: currTheme.white - } + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 16 + + id: itemButtonClose + height: 20 + width: 20 + heightImage: 20 + widthImage: 20 + + normalImage: "qrc:/Resources/"+pathTheme+"/icons/other/cross.svg" + hoverImage: "qrc:/Resources/"+pathTheme+"/icons/other/cross_hover.svg" } - // Sender wallet - Rectangle + Text { - id: frameSenderWallet - Layout.fillWidth: true - color: currTheme.mainBackground - height: 30 - Text - { - id: textFrameSenderWallet - color: currTheme.white - text: qsTr("From") - font: mainFont.dapFont.medium12 - horizontalAlignment: Text.AlignLeft - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 16 - } + id: textHeader + text: qsTr("New payment") + verticalAlignment: Qt.AlignLeft + anchors.left: itemButtonClose.right + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 10 + + font: mainFont.dapFont.bold14 + color: currTheme.white } + } - ColumnLayout + contentData: + Controls.ScrollView + { + id: scrollView + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.topMargin: 42 + + Controls.ScrollBar.horizontal.policy: Controls.ScrollBar.AlwaysOff + Controls.ScrollBar.vertical.policy: Controls.ScrollBar.AlwaysOn + clip: true + + contentData: + ColumnLayout { - id: frameSenderWalletAddress - - Layout.fillWidth: true - spacing: 10 - Layout.margins: 10 - Layout.leftMargin: 16 + width: scrollView.width + spacing: 0 + // Sender wallet Rectangle { - id: frameSignatureType - height: 42 - color: "transparent" + id: frameSenderWallet Layout.fillWidth: true - - DapCustomComboBox + color: currTheme.mainBackground + height: 30 + Text { - id: comboboxNetwork - - anchors.centerIn: parent - anchors.fill: parent - anchors.leftMargin: 5 - anchors.rightMargin: 5 - backgroundColorShow: currTheme.secondaryBackground - mainTextRole: "networkName" - font: mainFont.dapFont.regular16 - model: walletModelInfo - defaultText: qsTr("Networks") - - Component.onCompleted: - { - walletModule.getComission(displayText) - } - - onCurrantDisplayTextChanged: - { - walletModule.setWalletTokenModel(dapComboboxNetwork.displayText) - updateWindow() - } + id: textFrameSenderWallet + color: currTheme.white + text: qsTr("From") + font: mainFont.dapFont.medium12 + horizontalAlignment: Text.AlignLeft + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 16 } } - RowLayout + ColumnLayout { - id: chainGroup + id: frameSenderWalletAddress Layout.fillWidth: true - Layout.minimumHeight: 40 - Layout.maximumHeight: 40 - visible: false - - Text - { - Layout.fillWidth: true - color: currTheme.white - text: qsTr("Chain:") - font: mainFont.dapFont.regular14 - horizontalAlignment: Text.AlignLeft - } + spacing: 10 + Layout.margins: 10 + Layout.leftMargin: 16 Rectangle { - width: 200 - height: 40 + id: frameSignatureType + height: 42 color: "transparent" + Layout.fillWidth: true DapCustomComboBox { - id: comboboxChain + id: comboboxNetwork anchors.centerIn: parent anchors.fill: parent - + anchors.leftMargin: 5 + anchors.rightMargin: 5 + backgroundColorShow: currTheme.secondaryBackground + mainTextRole: "networkName" font: mainFont.dapFont.regular16 + model: walletModelInfo + defaultText: qsTr("Networks") + + Component.onCompleted: + { + walletModule.getComission(displayText) + } + + onCurrantDisplayTextChanged: + { + walletModule.setWalletTokenModel(dapComboboxNetwork.displayText) + updateWindow() + } } } - } - } - // Amount payment - Rectangle - { - id: frameAmountPayment - Layout.fillWidth: true - color: currTheme.mainBackground - height: 30 + RowLayout + { + id: chainGroup - RowLayout{ - anchors.fill: parent - spacing: 0 + Layout.fillWidth: true + Layout.minimumHeight: 40 + Layout.maximumHeight: 40 + visible: false - Text - { - Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter - Layout.leftMargin: 16 + Text + { + Layout.fillWidth: true + color: currTheme.white + text: qsTr("Chain:") + font: mainFont.dapFont.regular14 + horizontalAlignment: Text.AlignLeft + } - color: currTheme.white - text: qsTr("Amount") - font: mainFont.dapFont.medium12 - horizontalAlignment: Text.AlignLeft + Rectangle + { + width: 200 + height: 40 + color: "transparent" + + DapCustomComboBox + { + id: comboboxChain + + anchors.centerIn: parent + anchors.fill: parent + + font: mainFont.dapFont.regular16 + } + } } + } + + // Amount payment + Rectangle + { + id: frameAmountPayment + Layout.fillWidth: true + color: currTheme.mainBackground + height: 30 RowLayout{ - Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - Layout.maximumWidth: 150 + anchors.fill: parent spacing: 0 Text { - Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - color: currTheme.gray - text: qsTr("Balance: ") + Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter + Layout.leftMargin: 16 + + color: currTheme.white + text: qsTr("Amount") font: mainFont.dapFont.medium12 horizontalAlignment: Text.AlignLeft } - DapBigText - { - id: balance - textElement.horizontalAlignment: Text.AlignRight - Layout.fillWidth: true - Layout.fillHeight: true + RowLayout{ Layout.alignment: Qt.AlignRight | Qt.AlignVCenter - Layout.rightMargin: 16 - textFont: mainFont.dapFont.medium12 - textColor: currTheme.white + Layout.maximumWidth: 150 + spacing: 0 - Component.onCompleted: + Text { - fullText = walletTokensModel.get(dapComboBoxToken.displayText).value + " " + dapComboBoxToken.displayText + Layout.alignment: Qt.AlignRight | Qt.AlignVCenter + color: currTheme.gray + text: qsTr("Balance: ") + font: mainFont.dapFont.medium12 + horizontalAlignment: Text.AlignLeft } - } + DapBigText + { + id: balance + textElement.horizontalAlignment: Text.AlignRight + Layout.fillWidth: true + Layout.fillHeight: true + Layout.alignment: Qt.AlignRight | Qt.AlignVCenter + Layout.rightMargin: 16 + textFont: mainFont.dapFont.medium12 + textColor: currTheme.white + + Component.onCompleted: + { + fullText = walletTokensModel.get(dapComboBoxToken.displayText).value + " " + dapComboBoxToken.displayText + } + } + + } } } - } - - ColumnLayout - { - id: frameInputAmountPayment - Layout.fillWidth: true - Layout.margins: 10 - - Layout.topMargin: 20 - Layout.leftMargin: 36 - Layout.rightMargin: 16 - spacing: 10 - - RowLayout + ColumnLayout { - id: frameAmountField + id: frameInputAmountPayment Layout.fillWidth: true - Layout.margins: 0 + Layout.margins: 10 - DapTextField - { - property string realAmount: "0.00" - property string abtAmount: "0.00" + Layout.topMargin: 20 + Layout.leftMargin: 36 + Layout.rightMargin: 16 - id: textInputAmountPayment - Layout.fillWidth: true - width: 171 - Layout.minimumHeight: 40 - Layout.maximumHeight: 40 - placeholderText: "0.0" - validator: RegExpValidator { regExp: /[0-9]*\.?[0-9]{0,18}/ } - font: mainFont.dapFont.regular16 - horizontalAlignment: Text.AlignRight - borderWidth: 1 - borderRadius: 4 - selectByMouse: true - DapContextMenu{} - } + spacing: 10 - Rectangle + RowLayout { - id: frameSenderWalletToken - color: "transparent" - height: 42 - width: 125 - Layout.leftMargin: 5 - Layout.rightMargin: 0 - DapCustomComboBox + id: frameAmountField + Layout.fillWidth: true + Layout.margins: 0 + + DapTextField { - id: comboboxToken - anchors.fill: parent + property string realAmount: "0.00" + property string abtAmount: "0.00" - defaultText: qsTr("Tokens") - backgroundColorShow: currTheme.secondaryBackground - mainTextRole: "tokenName" - model: walletTokensModel + id: textInputAmountPayment + Layout.fillWidth: true + width: 171 + Layout.minimumHeight: 40 + Layout.maximumHeight: 40 + placeholderText: "0.0" + validator: RegExpValidator { regExp: /[0-9]*\.?[0-9]{0,18}/ } font: mainFont.dapFont.regular16 + horizontalAlignment: Text.AlignRight + borderWidth: 1 + borderRadius: 4 + selectByMouse: true + DapContextMenu{} + } - onCurrentTextChanged: { - button25.selected = false - button50.selected = false - button75.selected = false - button100.selected = false + Rectangle + { + id: frameSenderWalletToken + color: "transparent" + height: 42 + width: 125 + Layout.leftMargin: 5 + Layout.rightMargin: 0 + DapCustomComboBox + { + id: comboboxToken + anchors.fill: parent + + defaultText: qsTr("Tokens") + backgroundColorShow: currTheme.secondaryBackground + mainTextRole: "tokenName" + model: walletTokensModel + font: mainFont.dapFont.regular16 + + onCurrentTextChanged: { + button25.selected = false + button50.selected = false + button75.selected = false + button100.selected = false + } } } - } - - } - RowLayout - { - Layout.fillWidth: true - Layout.rightMargin: 20 + } - DapButton + RowLayout { - id: button25 Layout.fillWidth: true - implicitHeight: 26 - textButton: qsTr("25%") - horizontalAligmentText: Text.AlignHCenter - indentTextRight: 0 - fontButton: mainFont.dapFont.medium12 - selected: false - onClicked: + Layout.rightMargin: 20 + + DapButton { - button25.selected = true - button50.selected = false - button75.selected = false - button100.selected = false - - var data = { - "network" : dapComboboxNetwork.displayText, - "percent" : 25, - "send_ticker" : dapComboBoxToken.displayText, - "wallet_name" : walletInfo.name} - - var res = walletModule.calculatePrecentAmount(data); - textInputAmountPayment.text = res - textInputAmountPayment.cursorPosition = 0 + id: button25 + Layout.fillWidth: true + implicitHeight: 26 + textButton: qsTr("25%") + horizontalAligmentText: Text.AlignHCenter + indentTextRight: 0 + fontButton: mainFont.dapFont.medium12 + selected: false + onClicked: + { + button25.selected = true + button50.selected = false + button75.selected = false + button100.selected = false + + var data = { + "network" : dapComboboxNetwork.displayText, + "percent" : 25, + "send_ticker" : dapComboBoxToken.displayText, + "wallet_name" : walletInfo.name} + + var res = walletModule.calculatePrecentAmount(data); + textInputAmountPayment.text = res + textInputAmountPayment.cursorPosition = 0 + } } - } - DapButton - { - id: button50 - Layout.fillWidth: true - implicitHeight: 26 - textButton: qsTr("50%") - horizontalAligmentText: Text.AlignHCenter - indentTextRight: 0 - fontButton: mainFont.dapFont.medium12 - selected: false - onClicked: + DapButton { - button25.selected = false - button50.selected = true - button75.selected = false - button100.selected = false - - var data = { - "network" : dapComboboxNetwork.displayText, - "percent" : 50, - "send_ticker" : dapComboBoxToken.displayText, - "wallet_name" : walletInfo.name} - - var res = walletModule.calculatePrecentAmount(data); - textInputAmountPayment.text = res - textInputAmountPayment.cursorPosition = 0 + id: button50 + Layout.fillWidth: true + implicitHeight: 26 + textButton: qsTr("50%") + horizontalAligmentText: Text.AlignHCenter + indentTextRight: 0 + fontButton: mainFont.dapFont.medium12 + selected: false + onClicked: + { + button25.selected = false + button50.selected = true + button75.selected = false + button100.selected = false + + var data = { + "network" : dapComboboxNetwork.displayText, + "percent" : 50, + "send_ticker" : dapComboBoxToken.displayText, + "wallet_name" : walletInfo.name} + + var res = walletModule.calculatePrecentAmount(data); + textInputAmountPayment.text = res + textInputAmountPayment.cursorPosition = 0 + } } - } - DapButton - { - id: button75 - Layout.fillWidth: true - implicitHeight: 26 - textButton: qsTr("75%") - horizontalAligmentText: Text.AlignHCenter - indentTextRight: 0 - fontButton: mainFont.dapFont.medium12 - selected: false - onClicked: + DapButton { - button25.selected = false - button50.selected = false - button75.selected = true - button100.selected = false - - var data = { - "network" : dapComboboxNetwork.displayText, - "percent" : 75, - "send_ticker" : dapComboBoxToken.displayText, - "wallet_name" : walletInfo.name} - - var res = walletModule.calculatePrecentAmount(data); - textInputAmountPayment.text = res - textInputAmountPayment.cursorPosition = 0 + id: button75 + Layout.fillWidth: true + implicitHeight: 26 + textButton: qsTr("75%") + horizontalAligmentText: Text.AlignHCenter + indentTextRight: 0 + fontButton: mainFont.dapFont.medium12 + selected: false + onClicked: + { + button25.selected = false + button50.selected = false + button75.selected = true + button100.selected = false + + var data = { + "network" : dapComboboxNetwork.displayText, + "percent" : 75, + "send_ticker" : dapComboBoxToken.displayText, + "wallet_name" : walletInfo.name} + + var res = walletModule.calculatePrecentAmount(data); + textInputAmountPayment.text = res + textInputAmountPayment.cursorPosition = 0 + } } - } - DapButton - { - id: button100 - Layout.fillWidth: true - implicitHeight: 26 - textButton: qsTr("100%") - horizontalAligmentText: Text.AlignHCenter - indentTextRight: 0 - fontButton: mainFont.dapFont.medium12 - selected: false - onClicked: + DapButton { - button25.selected = false - button50.selected = false - button75.selected = false - button100.selected = true - - var data = { - "network" : dapComboboxNetwork.displayText, - "percent" : 100, - "send_ticker" : dapComboBoxToken.displayText, - "wallet_name" : walletInfo.name} - - var res = walletModule.calculatePrecentAmount(data); - textInputAmountPayment.text = res - textInputAmountPayment.cursorPosition = 0 + id: button100 + Layout.fillWidth: true + implicitHeight: 26 + textButton: qsTr("100%") + horizontalAligmentText: Text.AlignHCenter + indentTextRight: 0 + fontButton: mainFont.dapFont.medium12 + selected: false + onClicked: + { + button25.selected = false + button50.selected = false + button75.selected = false + button100.selected = true + + var data = { + "network" : dapComboboxNetwork.displayText, + "percent" : 100, + "send_ticker" : dapComboBoxToken.displayText, + "wallet_name" : walletInfo.name} + + var res = walletModule.calculatePrecentAmount(data); + textInputAmountPayment.text = res + textInputAmountPayment.cursorPosition = 0 + } } } - } - Text{ - id: warnMtoken - Layout.fillWidth: true - height: 32 - visible: comboboxToken.currentText[0] === "m" - text: qsTr("Warning! To unstake you need to have the exact amount of mCELL in the wallet you staked") - font: mainFont.dapFont.regular12 - horizontalAlignment: Text.AlignLeft - wrapMode: Text.WordWrap - color: "#FFCD44" - } - - } + Text{ + id: warnMtoken + Layout.fillWidth: true + height: 32 + visible: comboboxToken.currentText[0] === "m" + text: qsTr("Warning! To unstake you need to have the exact amount of mCELL in the wallet you staked") + font: mainFont.dapFont.regular12 + horizontalAlignment: Text.AlignLeft + wrapMode: Text.WordWrap + color: "#FFCD44" + } - // Recipient wallet - Rectangle - { - id: frameRecipientWallet - Layout.topMargin: 10 - Layout.fillWidth: true - color: currTheme.mainBackground - height: 30 - Text - { - id: textRecipientWallet - color: currTheme.white - text: qsTr("To") - font: mainFont.dapFont.medium12 - horizontalAlignment: Text.AlignLeft - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 16 } - } - Rectangle - { - id: frameRecipientWalletAddress - Layout.fillWidth: true - Layout.leftMargin: 28 - Layout.rightMargin: 28 - height: 53 - color: "transparent" - Layout.alignment: Qt.AlignHCenter | Qt.AlignTop - - DapTextField + // Recipient wallet + Rectangle { - id: textInputRecipientWalletAddress - anchors.verticalCenter: parent.verticalCenter - anchors.fill: parent - anchors.topMargin: 20 - - placeholderText: "nTSTphWddAcMUpSNXEOTztqLUifmLuhbZMycDbGNVZCdQEelLewojIrlyQtRvwZtIFYuLEKOMoulwTEyotCdUjdZnzBEqkLnaGpQxp" - validator: RegExpValidator { regExp: /[0-9A-Za-z]+/ } - font: mainFont.dapFont.regular16 - horizontalAlignment: Text.AlignLeft - - bottomLineVisible: true - bottomLineSpacing: 6 - bottomLineLeftRightMargins: 7 - - selectByMouse: true - DapContextMenu{} + id: frameRecipientWallet + Layout.topMargin: 10 + Layout.fillWidth: true + color: currTheme.mainBackground + height: 30 + Text + { + id: textRecipientWallet + color: currTheme.white + text: qsTr("To") + font: mainFont.dapFont.medium12 + horizontalAlignment: Text.AlignLeft + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 16 + } } - } - // Validator fee - Rectangle - { - id: frameValidatorFee - Layout.topMargin: 20 - Layout.fillWidth: true - color: currTheme.mainBackground - height: 30 - Text + Rectangle { - id: textValidatorFee - color: currTheme.white - text: qsTr("Validator fee") - font: mainFont.dapFont.medium12 - horizontalAlignment: Text.AlignLeft - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 16 - } - } + id: frameRecipientWalletAddress + Layout.fillWidth: true + Layout.leftMargin: 28 + Layout.rightMargin: 28 + height: 53 + color: "transparent" + Layout.alignment: Qt.AlignHCenter | Qt.AlignTop - DapFeeComponent - { - property string medianStr: "" + DapTextField + { + id: textInputRecipientWalletAddress + anchors.verticalCenter: parent.verticalCenter + anchors.fill: parent + anchors.topMargin: 20 - id: feeController + placeholderText: "nTSTphWddAcMUpSNXEOTztqLUifmLuhbZMycDbGNVZCdQEelLewojIrlyQtRvwZtIFYuLEKOMoulwTEyotCdUjdZnzBEqkLnaGpQxp" + validator: RegExpValidator { regExp: /[0-9A-Za-z]+/ } + font: mainFont.dapFont.regular16 + horizontalAlignment: Text.AlignLeft - Layout.fillWidth: true - Layout.topMargin: 20 - Layout.leftMargin: 16 - Layout.rightMargin: 16 + bottomLineVisible: true + bottomLineSpacing: 6 + bottomLineLeftRightMargins: 7 - onCurrentValueChanged: - { - walletModule.setUserFee(currentValue) + selectByMouse: true + DapContextMenu{} + } } - Component.onCompleted: + // Validator fee + Rectangle { - walletModule.tryUpdateFee() + id: frameValidatorFee + Layout.topMargin: 20 + Layout.fillWidth: true + color: currTheme.mainBackground + height: 30 + Text + { + id: textValidatorFee + color: currTheme.white + text: qsTr("Validator fee") + font: mainFont.dapFont.medium12 + horizontalAlignment: Text.AlignLeft + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 16 + } } - Component.onDestruction: + DapFeeComponent { - walletModule.setUserFee("") - } + property string medianStr: "" - function getFeeData() - { - var resFee = walletModule.getFee(dapComboboxNetwork.displayText) - if(resFee.error === 0 && resFee.validator_fee !== "" && resFee.network_fee !== "") + id: feeController + + Layout.fillWidth: true + Layout.topMargin: 20 + Layout.leftMargin: 16 + Layout.rightMargin: 16 + + onCurrentValueChanged: + { + walletModule.setUserFee(currentValue) + } + + Component.onCompleted: + { + walletModule.tryUpdateFee() + } + + Component.onDestruction: + { + walletModule.setUserFee("") + } + + function getFeeData() { - var new_median = resFee.validator_fee - if(new_median !== feeController.medianStr) + var resFee = walletModule.getFee(dapComboboxNetwork.displayText) + if(resFee.error === 0 && resFee.validator_fee !== "" && resFee.network_fee !== "") { - if(feeController.medianStr !== "") + var new_median = resFee.validator_fee + if(new_median !== feeController.medianStr) { - notifyAboutChange(new_median) + if(feeController.medianStr !== "") + { + notifyAboutChange(new_median) + } + else + { + init(generateRanges(new_median)) + } + feeController.medianStr = new_median } - else - { - init(generateRanges(new_median)) - } - feeController.medianStr = new_median + showNetFeePopup = !(resFee.network_fee === "0.0") } - showNetFeePopup = !(resFee.network_fee === "0.0") } - } - function notifyAboutChange(new_median) - { - var new_ranges = generateRanges(new_median) - feeController.rangeValues = new_ranges - initStates() - dapTextNotEnoughTokensWarning.text = - qsTr("Validator fee was been changed. New median data: %1") - .arg(new_median) - } + function notifyAboutChange(new_median) + { + var new_ranges = generateRanges(new_median) + feeController.rangeValues = new_ranges + initStates() + dapTextNotEnoughTokensWarning.text = + qsTr("Validator fee was been changed. New median data: %1") + .arg(new_median) + } - function generateRanges(median_str) - { - var median = parseFloat(median_str); + function generateRanges(median_str) + { + var median = parseFloat(median_str); return { "veryLow": 0, "low": median/2, @@ -608,63 +625,64 @@ DapRectangleLitAndShaded "high": median * 1.5, "veryHigh": median * 2 } + } } - } - Item{Layout.fillHeight: true} - - Text - { - id: textNotEnoughTokensWarning - - Layout.fillWidth: true - Layout.bottomMargin: 12 - Layout.maximumWidth: 281 - Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom - - color: currTheme.neon - text: qsTr("Not enough available tokens. Enter a lower value.") - font: mainFont.dapFont.regular12 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode: Text.WordWrap - visible: false - } - - // Button "Send" - DapButton - { - id: buttonSend - - implicitHeight: 36 - Layout.fillWidth: true - Layout.leftMargin: 36 - Layout.rightMargin: 36 - - Layout.bottomMargin: 40 - Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom - horizontalAligmentText: Text.AlignHCenter - indentTextRight: 0 - fontButton: mainFont.dapFont.medium14 - textButton: "" + Item{Layout.fillHeight: true} Text { - anchors.fill: parent - anchors.leftMargin: 6 - anchors.rightMargin: 6 + id: textNotEnoughTokensWarning + + Layout.fillWidth: true + Layout.bottomMargin: 12 + Layout.maximumWidth: 281 + Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom + color: currTheme.neon + text: qsTr("Not enough available tokens. Enter a lower value.") + font: mainFont.dapFont.regular12 horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - font: mainFont.dapFont.medium14 - color: currTheme.white + wrapMode: Text.WordWrap + visible: false + } + + // Button "Send" + DapButton + { + id: buttonSend + + implicitHeight: 36 + Layout.fillWidth: true + Layout.leftMargin: 36 + Layout.rightMargin: 36 - text: textInputAmountPayment.text === "" ? qsTr("Send") + " 0 " + comboboxToken.displayText - : qsTr("Send") + " " + textInputAmountPayment.text + " " + comboboxToken.displayText + Layout.bottomMargin: 40 + Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom + horizontalAligmentText: Text.AlignHCenter + indentTextRight: 0 + fontButton: mainFont.dapFont.medium14 + textButton: "" - elide: Text.ElideMiddle + Text + { + anchors.fill: parent + anchors.leftMargin: 6 + anchors.rightMargin: 6 + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font: mainFont.dapFont.medium14 + color: currTheme.white + + text: textInputAmountPayment.text === "" ? qsTr("Send") + " 0 " + comboboxToken.displayText + : qsTr("Send") + " " + textInputAmountPayment.text + " " + comboboxToken.displayText + elide: Text.ElideMiddle + + } } } } @@ -711,7 +729,7 @@ DapRectangleLitAndShaded } balance.fullText = walletTokensModel.get(dapComboBoxToken.displayText).value - + " " + dapComboBoxToken.displayText + + " " + dapComboBoxToken.displayText } } diff --git a/dap-ui-sdk b/dap-ui-sdk index 7ee9f24d8..b5256a935 160000 --- a/dap-ui-sdk +++ b/dap-ui-sdk @@ -1 +1 @@ -Subproject commit 7ee9f24d8930d1429246dd892aa969928b093cb5 +Subproject commit b5256a93531653685188806e295c607327035a00 -- GitLab From 709660b400027adfb4e46ce6eeea853644a12e39 Mon Sep 17 00:00:00 2001 From: Vyacheslav Kott <vyacheslav.kott@gitlab.demlabs.net> Date: Mon, 9 Sep 2024 17:08:54 +0300 Subject: [PATCH 3/3] [*] fix ranges, add tooltip --- .../RightPanel/DapNewPaymentMainRightPanelForm.qml | 8 ++++++++ dap-ui-sdk | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CellFrameDashboard/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml b/CellFrameDashboard/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml index c5c462395..30137ed6d 100644 --- a/CellFrameDashboard/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml +++ b/CellFrameDashboard/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.qml @@ -555,6 +555,14 @@ DapRectangleLitAndShaded anchors.left: parent.left anchors.leftMargin: 16 } + + DapToolTipInfo + { + anchors.right: parent.right + anchors.rightMargin: 16 + anchors.verticalCenter: parent.verticalCenter + contentText: qsTr("Depending on the chosen fee, the transaction processing speed can vary") + } } DapFeeComponent diff --git a/dap-ui-sdk b/dap-ui-sdk index b5256a935..180ab7f6c 160000 --- a/dap-ui-sdk +++ b/dap-ui-sdk @@ -1 +1 @@ -Subproject commit b5256a93531653685188806e295c607327035a00 +Subproject commit 180ab7f6cf94c11ceab383da93dc78349bb2d80f -- GitLab