6 #include "ui_sendassetsentry.h" 22 #include <QGraphicsDropShadowEffect> 23 #include <QApplication> 25 #include <validation.h> 27 #include <QStringListModel> 28 #include <QSortFilterProxyModel> 32 QStackedWidget(parent),
35 platformStyle(_platformStyle)
45 setCurrentWidget(
ui->SendCoins);
48 ui->payToLayout->setSpacing(4);
49 #if QT_VERSION >= 0x040700 50 ui->addAsLabel->setPlaceholderText(tr(
"Enter a label for this address to add it to your address book"));
60 connect(
ui->deleteButton, SIGNAL(clicked()),
this, SLOT(
deleteClicked()));
61 connect(
ui->deleteButton_is, SIGNAL(clicked()),
this, SLOT(
deleteClicked()));
62 connect(
ui->deleteButton_s, SIGNAL(clicked()),
this, SLOT(
deleteClicked()));
63 connect(
ui->assetSelectionBox, SIGNAL(activated(
int)),
this, SLOT(
onAssetSelected(
int)));
66 ui->administratorCheckbox->setToolTip(tr(
"Select to view administrator assets to transfer"));
73 for (
auto name : myAssetsNames)
79 proxy =
new QSortFilterProxyModel;
81 proxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
83 ui->assetSelectionBox->setModel(
proxy);
84 ui->assetSelectionBox->setEditable(
true);
87 completer->setCompletionMode(QCompleter::PopupCompletion);
88 completer->setCaseSensitivity(Qt::CaseInsensitive);
91 ui->assetSelectionBox->lineEdit()->setPlaceholderText(tr(
"Select an asset to transfer"));
92 ui->assetSelectionBox->setMinimumWidth(32);
95 ui->ownershipWarningMessage->hide();
119 ui->payAssetAmount->setDisabled(
false);
132 ui->memoBox->installEventFilter(
this);
146 ui->payTo->setText(QApplication::clipboard()->text());
158 ui->payAssetAmount->setFocus();
169 this->
model = _model;
181 ui->addAsLabel->clear();
182 ui->messageTextLabel->clear();
183 ui->messageTextLabel->hide();
184 ui->messageLabel->hide();
186 ui->memoTextLabel_is->clear();
188 ui->payTo_s->clear();
189 ui->memoTextLabel_s->clear();
191 ui->payAssetAmount->clear();
194 ui->assetSelectionBox->setCurrentIndex(0);
216 ui->payTo->setValid(
false);
220 if (
ui->assetSelectionBox->currentIndex() == 0) {
225 if (!
ui->payAssetAmount->validate())
230 if (
ui->payAssetAmount->value(0) <= 0)
232 ui->payAssetAmount->setValid(
false);
236 if (!
ui->memoBox->text().isEmpty()) {
238 ui->messageTextLabel->show();
239 ui->messageTextLabel->setText(tr(
"Memos can only be added once RIP5 is voted in"));
244 size_t size =
ui->memoBox->text().size();
259 std::string
error =
"";
290 QWidget::setTabOrder(prev,
ui->payTo);
291 QWidget::setTabOrder(
ui->payTo,
ui->addAsLabel);
292 QWidget::setTabOrder(
ui->addressBookButton,
ui->pasteButton);
293 QWidget::setTabOrder(
ui->pasteButton,
ui->deleteButton);
294 QWidget::setTabOrder(
ui->deleteButton,
ui->payAssetAmount);
295 QWidget::setTabOrder(
ui->payAssetAmount,
ui->memoBox);
305 ui->assetSelectionBox->setCurrentIndex(index);
312 ui->payTo->setText(address);
313 ui->payAssetAmount->setFocus();
318 return ui->payTo->text().isEmpty() &&
ui->payTo_is->text().isEmpty() &&
ui->payTo_s->text().isEmpty();
323 ui->payTo->setFocus();
328 ui->assetSelectionBox->setFocus();
338 if(!associatedLabel.isEmpty())
340 ui->addAsLabel->setText(associatedLabel);
349 ui->assetSelectionBox->lineEdit()->setStyleSheet(
"");
350 QString name =
ui->assetSelectionBox->currentText();
353 ui->assetAmountLabel->clear();
354 if(!
ui->administratorCheckbox->isChecked())
355 ui->payAssetAmount->setDisabled(
false);
356 ui->payAssetAmount->clear();
361 bool fIsOwnerAsset =
false;
363 fIsOwnerAsset =
true;
364 name = name.split(
"!").first();
372 if (!currentActiveAssetCache->GetAssetMetaDataIfExists(name.toStdString(), asset)) {
375 ui->messageLabel->show();
376 ui->messageTextLabel->show();
377 ui->messageTextLabel->setText(tr(
"Failed to get asset metadata for: ") + name +
"." + tr(
" The transaction in which the asset was issued must be mined into a block before you can transfer it"));
378 ui->assetAmountLabel->clear();
387 std::map<std::string, std::vector<COutput> > mapAssets;
395 if (!mapAssets.count(name.toStdString())) {
397 ui->messageLabel->show();
398 ui->messageTextLabel->show();
399 ui->messageTextLabel->setText(tr(
"Failed to get asset outpoints from database"));
403 auto vec = mapAssets.at(name.toStdString());
406 for (
auto txout : vec) {
408 if (
GetAssetData(txout.tx->tx->vout[txout.i].scriptPubKey, data))
416 ui->assetAmountLabel->setText(
417 displayBalance +
": <b>" + QString::fromStdString(
ValueFromAmountString(amount, units)) +
"</b> " + name);
419 ui->messageLabel->hide();
420 ui->messageTextLabel->hide();
423 if (!fIsOwnerAsset) {
424 ui->payAssetAmount->setUnit(asset.
units);
425 ui->payAssetAmount->setDisabled(
false);
444 if (fIsAssetControl) {
445 ui->administratorCheckbox->setDisabled(
true);
452 if (index < ui->assetSelectionBox->count()) {
453 ui->assetSelectionBox->setCurrentIndex(index);
454 ui->assetSelectionBox->activated(index);
472 ui->administratorCheckbox->setChecked(
true);
474 std::vector<std::string> names;
479 for (
auto name: names)
480 list << QString::fromStdString(name);
484 ui->assetSelectionBox->lineEdit()->setPlaceholderText(tr(
"Select an administrator asset to transfer"));
485 ui->assetSelectionBox->setFocus();
487 ui->payTo->setFocus();
491 ui->payAssetAmount->setValue(1);
492 ui->payAssetAmount->setDisabled(
true);
495 ui->assetAmountLabel->clear();
497 ui->ownershipWarningMessage->setText(tr(
"Warning: Transferring administrator asset"));
498 ui->ownershipWarningMessage->setStyleSheet(
"color: red");
499 ui->ownershipWarningMessage->show();
501 ui->administratorCheckbox->setChecked(
false);
503 std::vector<std::string> names;
507 for (
auto name : names) {
509 list << QString::fromStdString(name);
513 ui->assetSelectionBox->lineEdit()->setPlaceholderText(tr(
"Select an asset to transfer"));
514 ui->payAssetAmount->clear();
516 ui->assetAmountLabel->clear();
517 ui->assetSelectionBox->setFocus();
519 ui->payTo->setFocus();
521 ui->ownershipWarningMessage->hide();
527 if (
object ==
ui->memoBox && event->type() == QEvent::FocusIn)
530 ui->memoBox->setStyleSheet(
"");
532 return QWidget::eventFilter(
object, event);
void on_pasteButton_clicked()
QGraphicsDropShadowEffect * getShadowEffect()
SendAssetsEntry(const PlatformStyle *platformStyle, const QStringList myAssetsNames, QWidget *parent=0)
void setModel(AddressTableModel *model)
void onSendOwnershipChanged()
void onAssetSelected(int index)
void setValue(const SendAssetsRecipient &value)
CCriticalSection cs_main
Global state.
QWidget * setupTabChain(QWidget *prev)
Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://...
bool IsInitialized() const
Open address book to pick address.
bool eventFilter(QObject *object, QEvent *event)
AddressTableModel * getAddressTableModel()
PaymentRequestPlus paymentRequest
void on_addressBookButton_clicked()
A single entry in the dialog for sending ravens.
bool GetAssetData(const CScript &script, CAssetOutputEntry &data)
int64_t CAmount
Amount in corbies (Can be negative)
void setFocusAssetListBox()
bool fShowAdministratorList
void GetAllMyAssets(CWallet *pwallet, std::vector< std::string > &names, int nMinConf, bool fIncludeAdministrator, bool fOnlyAdministrator)
void setAddress(const QString &address)
bool AreMessagingDeployed()
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
std::string DecodeAssetData(std::string encoded)
Decode and Encode IPFS hashes, or OIP hashes.
static CCoinControl * assetControl
CAssetsCache * GetCurrentAssetCache()
#define STRING_LABEL_COLOR
QString labelForAddress(const QString &address) const
std::string ValueFromAmountString(const CAmount &amount, const int8_t units)
const PlatformStyle * platformStyle
Widget that shows a list of sending or receiving addresses.
bool isClear()
Return whether the entry is still empty and unedited.
void removeEntry(SendAssetsEntry *entry)
void GetAllAdministrativeAssets(CWallet *pwallet, std::vector< std::string > &names, int nMinConf)
bool validateAddress(const QString &address)
bool HasAssetSelected() const
void AvailableAssets(std::map< std::string, std::vector< COutput > > &mapAssetCoins, bool fOnlySafe=true, const CCoinControl *coinControl=nullptr, const CAmount &nMinimumAmount=1, const CAmount &nMaximumAmount=MAX_MONEY, const CAmount &nMinimumSumAmount=MAX_MONEY, const uint64_t &nMaximumCount=0, const int &nMinDepth=0, const int &nMaxDepth=9999999) const
Helper function that calls AvailableCoinsAll, used for transfering assets.
bool updateLabel(const QString &address)
void setModel(WalletModel *model)
Interface to Raven wallet from Qt view code.
void setCurrentIndex(int index)
QSortFilterProxyModel * proxy
void switchAdministratorList(bool fSwitchStatus=true)
void on_payTo_textChanged(const QString &address)
bool CheckEncoded(const std::string &hash, std::string &strError)
Check the Encoded hash and make sure it is either an IPFS hash or a OIP hash.
SendAssetsRecipient getValue()
bool error(const char *fmt, const Args &... args)
void IsAssetControl(bool fIsAssetControl, bool fIsOwner)
QStringListModel * stringModel
CWallet * getWallet() const
SendAssetsRecipient recipient
const QString & getReturnValue() const
bool IsAssetNameAnOwner(const std::string &name)
Check if an asset is an owner.