From cb6710c764e826c90800ba8629a63253f68cc6e4 Mon Sep 17 00:00:00 2001 From: random-zebra Date: Tue, 27 Apr 2021 20:53:34 +0200 Subject: [PATCH] [GUI] Add checkable btn in the contextual menu, for sffa with multirows --- src/qt/pivx/send.cpp | 14 +++++++++++++- src/qt/pivx/send.h | 1 + src/qt/pivx/tooltipmenu.cpp | 6 ++++++ src/qt/pivx/tooltipmenu.h | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/qt/pivx/send.cpp b/src/qt/pivx/send.cpp index af8407289cd022..226921a5765357 100644 --- a/src/qt/pivx/send.cpp +++ b/src/qt/pivx/send.cpp @@ -863,11 +863,16 @@ void SendWidget::onMenuClicked(SendMultiRow* entry) this->menu = new TooltipMenu(window, this); this->menu->setCopyBtnText(tr("Add Memo")); this->menu->setEditBtnText(tr("Save contact")); - this->menu->setMinimumSize(this->menu->width() + 30,this->menu->height()); + this->menu->setLastBtnVisible(true); + this->menu->setLastBtnText(tr("Subtract fee")); + this->menu->setMinimumHeight(157); + this->menu->setLastBtnCheckable(true, entry->getSubtractFeeFromAmount()); + this->menu->setMinimumSize(this->menu->width() + 30, this->menu->height()); connect(this->menu, &TooltipMenu::message, this, &AddressesWidget::message); connect(this->menu, &TooltipMenu::onEditClicked, this, &SendWidget::onContactMultiClicked); connect(this->menu, &TooltipMenu::onDeleteClicked, this, &SendWidget::onDeleteClicked); connect(this->menu, &TooltipMenu::onCopyClicked, this, &SendWidget::onEntryMemoClicked); + connect(this->menu, &TooltipMenu::onLastClicked, this, &SendWidget::onSubtractFeeFromAmountChecked); } else { this->menu->hide(); } @@ -932,6 +937,13 @@ void SendWidget::onEntryMemoClicked() } } +void SendWidget::onSubtractFeeFromAmountChecked() +{ + if (focusedEntry) { + focusedEntry->toggleSubtractFeeFromAmount(); + } +} + void SendWidget::onDeleteClicked() { if (focusedEntry) { diff --git a/src/qt/pivx/send.h b/src/qt/pivx/send.h index fcc4f903840820..6cf8d6129e919c 100644 --- a/src/qt/pivx/send.h +++ b/src/qt/pivx/send.h @@ -81,6 +81,7 @@ private Q_SLOTS: void onContactMultiClicked(); void onDeleteClicked(); void onEntryMemoClicked(); + void onSubtractFeeFromAmountChecked(); void onResetCustomOptions(bool fRefreshAmounts); void onResetSettings(); diff --git a/src/qt/pivx/tooltipmenu.cpp b/src/qt/pivx/tooltipmenu.cpp index f0b1722042b37f..2ca673048b3fc5 100644 --- a/src/qt/pivx/tooltipmenu.cpp +++ b/src/qt/pivx/tooltipmenu.cpp @@ -40,6 +40,12 @@ void TooltipMenu::setLastBtnText(QString btnText, int minHeight){ ui->btnLast->setMinimumHeight(minHeight); } +void TooltipMenu::setLastBtnCheckable(bool checkable, bool isChecked) +{ + ui->btnLast->setCheckable(checkable); + ui->btnLast->setChecked(isChecked); +} + void TooltipMenu::setCopyBtnVisible(bool visible){ ui->btnCopy->setVisible(visible); } diff --git a/src/qt/pivx/tooltipmenu.h b/src/qt/pivx/tooltipmenu.h index 00f0c460ffb5f7..8b5d339ee65e82 100644 --- a/src/qt/pivx/tooltipmenu.h +++ b/src/qt/pivx/tooltipmenu.h @@ -39,6 +39,7 @@ class TooltipMenu : public PWidget void setDeleteBtnVisible(bool visible); void setEditBtnVisible(bool visible); void setLastBtnVisible(bool visible); + void setLastBtnCheckable(bool checkable, bool isChecked); Q_SIGNALS: void onDeleteClicked();