qt: Add option to (not) spend unconfirmed change

- Add a wallet tab to options dialog
- Move fee setting to wallet tab
- Add new setting to set -nospendzeroconfchange from UI
This commit is contained in:
Wladimir J. van der Laan 2014-02-15 10:38:06 +01:00
parent 05d3ded072
commit 29d45073c9
4 changed files with 101 additions and 47 deletions

View File

@ -27,52 +27,6 @@
<string>&amp;Main</string> <string>&amp;Main</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_Main"> <layout class="QVBoxLayout" name="verticalLayout_Main">
<item>
<widget class="QLabel" name="transactionFeeInfoLabel">
<property name="text">
<string>Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_1_Main">
<item>
<widget class="QLabel" name="transactionFeeLabel">
<property name="text">
<string>Pay transaction &amp;fee</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="buddy">
<cstring>transactionFee</cstring>
</property>
</widget>
</item>
<item>
<widget class="BitcoinAmountField" name="transactionFee"/>
</item>
<item>
<spacer name="horizontalSpacer_1_Main">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item> <item>
<widget class="QCheckBox" name="bitcoinAtStartup"> <widget class="QCheckBox" name="bitcoinAtStartup">
<property name="toolTip"> <property name="toolTip">
@ -194,6 +148,89 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tabWallet">
<attribute name="title">
<string>W&amp;allet</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_Network">
<item>
<widget class="QLabel" name="transactionFeeInfoLabel">
<property name="text">
<string>Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_1_Main">
<item>
<widget class="QLabel" name="transactionFeeLabel">
<property name="text">
<string>Pay transaction &amp;fee</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="buddy">
<cstring>transactionFee</cstring>
</property>
</widget>
</item>
<item>
<widget class="BitcoinAmountField" name="transactionFee"/>
</item>
<item>
<spacer name="horizontalSpacer_1_Main">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>If you disable the spending of unconfirmed change, the change from a transaction cannot be used until that transaction has at least one confirmation. This also affects how your balance is computed.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="spendZeroConfChange">
<property name="text">
<string>Spend unconfirmed change (experts only)</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabNetwork"> <widget class="QWidget" name="tabNetwork">
<attribute name="title"> <attribute name="title">
<string>&amp;Network</string> <string>&amp;Network</string>

View File

@ -148,11 +148,14 @@ void OptionsDialog::setModel(OptionsModel *model)
void OptionsDialog::setMapper() void OptionsDialog::setMapper()
{ {
/* Main */ /* Main */
mapper->addMapping(ui->transactionFee, OptionsModel::Fee);
mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup); mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup);
mapper->addMapping(ui->threadsScriptVerif, OptionsModel::ThreadsScriptVerif); mapper->addMapping(ui->threadsScriptVerif, OptionsModel::ThreadsScriptVerif);
mapper->addMapping(ui->databaseCache, OptionsModel::DatabaseCache); mapper->addMapping(ui->databaseCache, OptionsModel::DatabaseCache);
/* Wallet */
mapper->addMapping(ui->transactionFee, OptionsModel::Fee);
mapper->addMapping(ui->spendZeroConfChange, OptionsModel::SpendZeroConfChange);
/* Network */ /* Network */
mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP); mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP);

View File

@ -76,6 +76,11 @@ void OptionsModel::Init()
nTransactionFee = settings.value("nTransactionFee").toLongLong(); // if -paytxfee is set, this will be overridden later in init.cpp nTransactionFee = settings.value("nTransactionFee").toLongLong(); // if -paytxfee is set, this will be overridden later in init.cpp
if (mapArgs.count("-paytxfee")) if (mapArgs.count("-paytxfee"))
strOverriddenByCommandLine += "-paytxfee "; strOverriddenByCommandLine += "-paytxfee ";
if (!settings.contains("bSpendZeroConfChange"))
settings.setValue("bSpendZeroConfChange", true);
if (!SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
strOverriddenByCommandLine += "-spendzeroconfchange ";
#endif #endif
if (!settings.contains("nDatabaseCache")) if (!settings.contains("nDatabaseCache"))
@ -184,6 +189,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
// Todo: Consider to revert back to use just nTransactionFee here, if we don't want // Todo: Consider to revert back to use just nTransactionFee here, if we don't want
// -paytxfee to update our QSettings! // -paytxfee to update our QSettings!
return settings.value("nTransactionFee"); return settings.value("nTransactionFee");
case SpendZeroConfChange:
return settings.value("bSpendZeroConfChange");
#endif #endif
case DisplayUnit: case DisplayUnit:
return nDisplayUnit; return nDisplayUnit;
@ -274,6 +281,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
settings.setValue("nTransactionFee", (qint64)nTransactionFee); settings.setValue("nTransactionFee", (qint64)nTransactionFee);
emit transactionFeeChanged(nTransactionFee); emit transactionFeeChanged(nTransactionFee);
break; break;
case SpendZeroConfChange:
if (settings.value("bSpendZeroConfChange") != value) {
settings.setValue("bSpendZeroConfChange", value);
setRestartRequired(true);
}
break;
#endif #endif
case DisplayUnit: case DisplayUnit:
nDisplayUnit = value.toInt(); nDisplayUnit = value.toInt();

View File

@ -40,6 +40,7 @@ public:
CoinControlFeatures, // bool CoinControlFeatures, // bool
ThreadsScriptVerif, // int ThreadsScriptVerif, // int
DatabaseCache, // int DatabaseCache, // int
SpendZeroConfChange, // bool
OptionIDRowCount, OptionIDRowCount,
}; };