Skip to content

Commit 50216bc

Browse files
committed
qt: Add SubFeeFromAmount option
1 parent 6499928 commit 50216bc

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

src/qt/forms/optionsdialog.ui

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,16 @@
206206
<string>Expert</string>
207207
</property>
208208
<layout class="QVBoxLayout" name="verticalLayout_2">
209+
<item>
210+
<widget class="QCheckBox" name="subFeeFromAmount">
211+
<property name="toolTip">
212+
<string extracomment="This is a toolTip, Located at Options dialog under the Wallet tab. Select default setting for subtract the fee from the amount checkbox while creating new recipients.">Default setting to whether Subtact Fee From Amount or not.</string>
213+
</property>
214+
<property name="text">
215+
<string extracomment="Located at Options dialog under the Wallet tab. Select default setting for subtract the fee from the amount checkbox while creating new recipients.">Subtract &amp;Fee From Amount</string>
216+
</property>
217+
</widget>
218+
</item>
209219
<item>
210220
<widget class="QCheckBox" name="coinControlFeatures">
211221
<property name="toolTip">

src/qt/optionsdialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ void OptionsDialog::setMapper()
239239
/* Wallet */
240240
mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange);
241241
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
242+
mapper->addMapping(ui->subFeeFromAmount, OptionsModel::SubFeeFromAmount);
242243
mapper->addMapping(ui->externalSignerPath, OptionsModel::ExternalSignerPath);
243244

244245
/* Network */

src/qt/optionsmodel.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ void OptionsModel::Init(bool resetSettings)
124124
if (!gArgs.SoftSetArg("-signer", settings.value("external_signer_path").toString().toStdString())) {
125125
addOverriddenOption("-signer");
126126
}
127+
128+
if (!settings.contains("SubFeeFromAmount")) {
129+
settings.setValue("SubFeeFromAmount", false);
130+
}
131+
m_sub_fee_from_amount = settings.value("SubFeeFromAmount", false).toBool();
127132
#endif
128133

129134
// Network
@@ -346,6 +351,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
346351
return m_use_embedded_monospaced_font;
347352
case CoinControlFeatures:
348353
return fCoinControlFeatures;
354+
case SubFeeFromAmount:
355+
return m_sub_fee_from_amount;
349356
case Prune:
350357
return settings.value("bPrune");
351358
case PruneSize:
@@ -487,6 +494,11 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
487494
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
488495
Q_EMIT coinControlFeaturesChanged(fCoinControlFeatures);
489496
break;
497+
case SubFeeFromAmount:
498+
m_sub_fee_from_amount = value.toBool();
499+
settings.setValue("SubFeeFromAmount", m_sub_fee_from_amount);
500+
Q_EMIT SubFeeFromAmountChanged(m_sub_fee_from_amount);
501+
break;
490502
case Prune:
491503
if (settings.value("bPrune") != value) {
492504
settings.setValue("bPrune", value);

src/qt/optionsmodel.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class OptionsModel : public QAbstractListModel
6161
Language, // QString
6262
UseEmbeddedMonospacedFont, // bool
6363
CoinControlFeatures, // bool
64+
SubFeeFromAmount, // bool
6465
ThreadsScriptVerif, // int
6566
Prune, // bool
6667
PruneSize, // int
@@ -88,6 +89,7 @@ class OptionsModel : public QAbstractListModel
8889
QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
8990
bool getUseEmbeddedMonospacedFont() const { return m_use_embedded_monospaced_font; }
9091
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
92+
bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; }
9193
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
9294

9395
/* Explicit setters */
@@ -112,6 +114,7 @@ class OptionsModel : public QAbstractListModel
112114
QString strThirdPartyTxUrls;
113115
bool m_use_embedded_monospaced_font;
114116
bool fCoinControlFeatures;
117+
bool m_sub_fee_from_amount;
115118
/* settings that were overridden by command-line */
116119
QString strOverriddenByCommandLine;
117120

@@ -123,6 +126,7 @@ class OptionsModel : public QAbstractListModel
123126
Q_SIGNALS:
124127
void displayUnitChanged(int unit);
125128
void coinControlFeaturesChanged(bool);
129+
void SubFeeFromAmountChanged(bool);
126130
void showTrayIconChanged(bool);
127131
void useEmbeddedMonospacedFontChanged(bool);
128132
};

src/qt/sendcoinsentry.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ void SendCoinsEntry::clear()
9797
ui->payTo->clear();
9898
ui->addAsLabel->clear();
9999
ui->payAmount->clear();
100-
ui->checkboxSubtractFeeFromAmount->setCheckState(Qt::Unchecked);
100+
if (model && model->getOptionsModel()) {
101+
ui->checkboxSubtractFeeFromAmount->setChecked(model->getOptionsModel()->getSubFeeFromAmount());
102+
}
101103
ui->messageTextLabel->clear();
102104
ui->messageTextLabel->hide();
103105
ui->messageLabel->hide();

0 commit comments

Comments
 (0)