Skip to content

Commit

Permalink
Merge pull request #67 from BlockMechanic/segwit
Browse files Browse the repository at this point in the history
qt fixes
  • Loading branch information
BlockMechanic authored May 17, 2022
2 parents 7196604 + e2c0731 commit 3bd4722
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ void CoinControlDialog::updateLabels(CCoinControl& m_coin_control, WalletModel *
}

// actually update labels
int nDisplayUnit = CrownUnits::BTC;
int nDisplayUnit = CrownUnits::CRW;
if (model && model->getOptionsModel())
nDisplayUnit = model->getOptionsModel()->getDisplayUnit();

Expand Down
4 changes: 2 additions & 2 deletions src/qt/crownamountfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class AmountSpinBox: public QAbstractSpinBox

const QFontMetrics fm(fontMetrics());
int h = lineEdit()->minimumSizeHint().height();
int w = GUIUtil::TextWidth(fm, CrownUnits::format(CrownUnits::BTC, CrownUnits::maxMoney(), false, CrownUnits::SeparatorStyle::ALWAYS));
int w = GUIUtil::TextWidth(fm, CrownUnits::format(CrownUnits::CRW, CrownUnits::maxMoney(), false, CrownUnits::SeparatorStyle::ALWAYS));
w += 2; // cursor blinking space

QStyleOptionSpinBox opt;
Expand All @@ -148,7 +148,7 @@ class AmountSpinBox: public QAbstractSpinBox
}

private:
int currentUnit{CrownUnits::BTC};
int currentUnit{CrownUnits::CRW};
CAmount singleStep{CAmount(100000)}; // satoshis
mutable QSize cachedMinimumSizeHint;
bool m_allow_empty{true};
Expand Down
42 changes: 21 additions & 21 deletions src/qt/crownunits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <cassert>

static constexpr auto MAX_DIGITS_BTC = 16;
static constexpr auto MAX_DIGITS_CRW = 16;

CrownUnits::CrownUnits(QObject *parent):
QAbstractListModel(parent),
Expand All @@ -19,9 +19,9 @@ CrownUnits::CrownUnits(QObject *parent):
QList<CrownUnits::Unit> CrownUnits::availableUnits()
{
QList<CrownUnits::Unit> unitlist;
unitlist.append(BTC);
unitlist.append(mBTC);
unitlist.append(uBTC);
unitlist.append(CRW);
unitlist.append(mCRW);
unitlist.append(uCRW);
unitlist.append(SAT);
return unitlist;
}
Expand All @@ -30,9 +30,9 @@ bool CrownUnits::valid(int unit)
{
switch(unit)
{
case BTC:
case mBTC:
case uBTC:
case CRW:
case mCRW:
case uCRW:
case SAT:
return true;
default:
Expand All @@ -44,9 +44,9 @@ QString CrownUnits::longName(int unit)
{
switch(unit)
{
case BTC: return QString("BTC");
case mBTC: return QString("mBTC");
case uBTC: return QString::fromUtf8("µBTC (bits)");
case CRW: return QString("CRW");
case mCRW: return QString("mCRW");
case uCRW: return QString::fromUtf8("µCRW (bits)");
case SAT: return QString("Satoshi (sat)");
default: return QString("???");
}
Expand All @@ -56,7 +56,7 @@ QString CrownUnits::shortName(int unit)
{
switch(unit)
{
case uBTC: return QString::fromUtf8("bits");
case uCRW: return QString::fromUtf8("bits");
case SAT: return QString("sat");
default: return longName(unit);
}
Expand All @@ -66,9 +66,9 @@ QString CrownUnits::description(int unit)
{
switch(unit)
{
case BTC: return QString("Crowns");
case mBTC: return QString("Milli-Crowns (1 / 1" THIN_SP_UTF8 "000)");
case uBTC: return QString("Micro-Crowns (bits) (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
case CRW: return QString("Crowns");
case mCRW: return QString("Milli-Crowns (1 / 1" THIN_SP_UTF8 "000)");
case uCRW: return QString("Micro-Crowns (bits) (1 / 1" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
case SAT: return QString("Satoshi (sat) (1 / 100" THIN_SP_UTF8 "000" THIN_SP_UTF8 "000)");
default: return QString("???");
}
Expand All @@ -78,9 +78,9 @@ qint64 CrownUnits::factor(int unit)
{
switch(unit)
{
case BTC: return 100000000;
case mBTC: return 100000;
case uBTC: return 100;
case CRW: return 100000000;
case mCRW: return 100000;
case uCRW: return 100;
case SAT: return 1;
default: return 100000000;
}
Expand All @@ -90,9 +90,9 @@ int CrownUnits::decimals(int unit)
{
switch(unit)
{
case BTC: return 8;
case mBTC: return 5;
case uBTC: return 2;
case CRW: return 8;
case mCRW: return 5;
case uCRW: return 2;
case SAT: return 0;
default: return 0;
}
Expand All @@ -111,7 +111,7 @@ QString CrownUnits::format(int unit, const CAmount& nIn, bool fPlus, SeparatorSt
qint64 quotient = n_abs / coin;
QString quotient_str = QString::number(quotient);
if (justify) {
quotient_str = quotient_str.rightJustified(MAX_DIGITS_BTC - num_decimals, ' ');
quotient_str = quotient_str.rightJustified(MAX_DIGITS_CRW - num_decimals, ' ');
}

// Use SI-style thin space separators as these are locale independent and can't be
Expand Down
6 changes: 3 additions & 3 deletions src/qt/crownunits.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class CrownUnits: public QAbstractListModel
*/
enum Unit
{
BTC,
mBTC,
uBTC,
CRW,
mCRW,
uCRW,
SAT
};

Expand Down
4 changes: 2 additions & 2 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bool parseCrownURI(const QUrl &uri, SendAssetsRecipient *out)
{
if(!i->second.isEmpty())
{
if(!CrownUnits::parse(CrownUnits::BTC, i->second, &rv.amount))
if(!CrownUnits::parse(CrownUnits::CRW, i->second, &rv.amount))
{
return false;
}
Expand Down Expand Up @@ -183,7 +183,7 @@ QString formatCrownURI(const SendAssetsRecipient &info)

if (info.amount)
{
ret += QString("?amount=%1").arg(CrownUnits::format(CrownUnits::BTC, info.amount, false, CrownUnits::SeparatorStyle::NEVER));
ret += QString("?amount=%1").arg(CrownUnits::format(CrownUnits::CRW, info.amount, false, CrownUnits::SeparatorStyle::NEVER));
paramCount++;
}

Expand Down
2 changes: 1 addition & 1 deletion src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void OptionsModel::Init(bool resetSettings)

// Display
if (!settings.contains("nDisplayUnit"))
settings.setValue("nDisplayUnit", CrownUnits::BTC);
settings.setValue("nDisplayUnit", CrownUnits::CRW);
nDisplayUnit = settings.value("nDisplayUnit").toInt();

if (!settings.contains("strThirdPartyTxUrls"))
Expand Down
4 changes: 2 additions & 2 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TxViewDelegate : public QAbstractItemDelegate
Q_OBJECT
public:
explicit TxViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr):
QAbstractItemDelegate(parent), unit(CrownUnits::BTC),
QAbstractItemDelegate(parent), unit(CrownUnits::CRW),
platformStyle(_platformStyle)
{
connect(this, &TxViewDelegate::width_changed, this, &TxViewDelegate::sizeHintChanged);
Expand Down Expand Up @@ -292,7 +292,7 @@ void OverviewPage::setWalletModel(WalletModel *model)
});
}

// update the display unit, to not use the default ("BTC")
// update the display unit, to not use the default ("CRW")
updateDisplayUnit();
}

Expand Down
4 changes: 2 additions & 2 deletions src/qt/psbtoperationsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ std::string PSBTOperationsDialog::renderTransaction(const PartiallySignedTransac
ExtractDestination(out.scriptPubKey, address);
totalAmount += out.nValue;
tx_description.append(tr(" * Sends %1 to %2")
.arg(CrownUnits::formatWithUnit(CrownUnits::BTC, out.nValue))
.arg(CrownUnits::formatWithUnit(CrownUnits::CRW, out.nValue))
.arg(QString::fromStdString(EncodeDestination(address))));
tx_description.append("<br>");
}
Expand All @@ -177,7 +177,7 @@ std::string PSBTOperationsDialog::renderTransaction(const PartiallySignedTransac
tx_description.append(tr("Unable to calculate transaction fee or total transaction amount."));
} else {
tx_description.append(tr("Pays transaction fee: "));
tx_description.append(CrownUnits::formatWithUnit(CrownUnits::BTC, *analysis.fee));
tx_description.append(CrownUnits::formatWithUnit(CrownUnits::CRW, *analysis.fee));

// add total amount in all subdivision units
tx_description.append("<hr />");
Expand Down
10 changes: 6 additions & 4 deletions src/qt/transactionrecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const interface
// Debit
//
CAmountMap nTxFee = nDebit - wtx.tx->GetValueOutMap();

for (unsigned int nOut = 0; nOut < wtx.tx->vout.size(); nOut++)
{
const CTxOut& txout = wtx.tx->vout[nOut];
for (unsigned int nOut = 0; nOut < (wtx.tx->nVersion >= TX_ELE_VERSION ? wtx.tx->vpout.size() : wtx.tx->vout.size()) ; nOut++){
CTxOutAsset txout = (wtx.tx->nVersion >= TX_ELE_VERSION ? wtx.tx->vpout[nOut] : wtx.tx->vout[nOut]);

//for (unsigned int nOut = 0; nOut < wtx.tx->vout.size(); nOut++)
//{
//const CTxOut& txout = wtx.tx->vout[nOut];
TransactionRecord sub(hash, nTime);
sub.idx = nOut;
sub.involvesWatchAddress = involvesWatchAddress;
Expand Down

0 comments on commit 3bd4722

Please sign in to comment.