8#include <qt/forms/ui_receivecoinsdialog.h>
23#include <QTextDocument>
28 platformStyle(_platformStyle)
33 ui->clearButton->setIcon(QIcon());
34 ui->receiveButton->setIcon(QIcon());
35 ui->showRequestButton->setIcon(QIcon());
36 ui->removeRequestButton->setIcon(QIcon());
39 ui->receiveButton->setIcon(_platformStyle->
SingleColorIcon(
":/icons/receiving_addresses"));
41 ui->removeRequestButton->setIcon(_platformStyle->
SingleColorIcon(
":/icons/remove"));
55 QTableView* tableView =
ui->recentRequestsView;
56 tableView->verticalHeader()->hide();
57 tableView->setAlternatingRowColors(
true);
58 tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
59 tableView->setSelectionMode(QAbstractItemView::ContiguousSelection);
62 if (!tableView->horizontalHeader()->restoreState(settings.value(
"RecentRequestsViewHeaderState").toByteArray())) {
67 tableView->horizontalHeader()->setStretchLastSection(
true);
81 QTableView* tableView =
ui->recentRequestsView;
85 connect(tableView->selectionModel(),
86 &QItemSelectionModel::selectionChanged,
this,
90 auto add_address_type = [&](
OutputType type,
const QString& text,
const QString& tooltip) {
91 const auto index =
ui->addressType->count();
92 ui->addressType->addItem(text, (
int) type);
93 ui->addressType->setItemData(index, tooltip, Qt::ToolTipRole);
96 add_address_type(
OutputType::LEGACY, tr(
"Base58 (Legacy)"), tr(
"Not recommended due to higher fees and less protection against typos."));
97 add_address_type(
OutputType::P2SH_SEGWIT, tr(
"Base58 (P2SH-SegWit)"), tr(
"Generates an address compatible with older wallets."));
98 add_address_type(
OutputType::BECH32, tr(
"Bech32 (SegWit)"), tr(
"Generates a native segwit address (BIP-173). Some old wallets don't support it."));
100 add_address_type(
OutputType::BECH32M, tr(
"Bech32m (Taproot)"), tr(
"Bech32m (BIP-350) is an upgrade to Bech32, wallet support is still limited."));
116 settings.setValue(
"RecentRequestsViewHeaderState",
ui->recentRequestsView->horizontalHeader()->saveState());
122 ui->reqAmount->clear();
123 ui->reqLabel->setText(
"");
124 ui->reqMessage->setText(
"");
152 QString label =
ui->reqLabel->text();
159 case AddressTableModel::EditStatus::OK: {
162 ui->reqAmount->value(),
ui->reqMessage->text());
164 dialog->setAttribute(Qt::WA_DeleteOnClose);
173 case AddressTableModel::EditStatus::WALLET_UNLOCK_FAILURE:
174 QMessageBox::critical(
this, windowTitle(),
175 tr(
"Could not unlock wallet."),
176 QMessageBox::Ok, QMessageBox::Ok);
178 case AddressTableModel::EditStatus::KEY_GENERATION_FAILURE:
179 QMessageBox::critical(
this, windowTitle(),
180 tr(
"Could not generate new %1 address").arg(QString::fromStdString(
FormatOutputType(address_type))),
181 QMessageBox::Ok, QMessageBox::Ok);
184 case AddressTableModel::EditStatus::INVALID_ADDRESS:
185 case AddressTableModel::EditStatus::DUPLICATE_ADDRESS:
186 case AddressTableModel::EditStatus::NO_CHANGES:
198 dialog->setAttribute(Qt::WA_DeleteOnClose);
205 bool enable = !
ui->recentRequestsView->selectionModel()->selectedRows().isEmpty();
206 ui->showRequestButton->setEnabled(enable);
207 ui->removeRequestButton->setEnabled(enable);
214 QModelIndexList selection =
ui->recentRequestsView->selectionModel()->selectedRows();
216 for (
const QModelIndex& index : selection) {
225 QModelIndexList selection =
ui->recentRequestsView->selectionModel()->selectedRows();
226 if(selection.empty())
229 QModelIndex firstIndex = selection.at(0);
236 return QModelIndex();
237 QModelIndexList selection =
ui->recentRequestsView->selectionModel()->selectedRows();
238 if(selection.empty())
239 return QModelIndex();
241 QModelIndex firstIndex = selection.at(0);
249 if (!firstIndex.isValid()) {
259 if (!sel.isValid()) {
277 if (!sel.isValid()) {
290 if (!sel.isValid()) {
EditStatus getEditStatus() const
QString addRow(const QString &type, const QString &label, const QString &address, const OutputType address_type)
static const QString Receive
Specifies receive address.
void displayUnitChanged(BitcoinUnit unit)
BitcoinUnit getDisplayUnit() const
Dialog for requesting payment of bitcoins.
Ui::ReceiveCoinsDialog * ui
void on_removeRequestButton_clicked()
@ AMOUNT_MINIMUM_COLUMN_WIDTH
QAction * copyMessageAction
void on_showRequestButton_clicked()
void on_recentRequestsView_doubleClicked(const QModelIndex &index)
QAction * copyLabelAction
void recentRequestsView_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
void setModel(WalletModel *model)
void showMenu(const QPoint &point)
void on_receiveButton_clicked()
ReceiveCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent=nullptr)
QAction * copyAmountAction
QModelIndex selectedRow()
void copyColumnToClipboard(int column)
void setModel(WalletModel *model)
void setInfo(const SendCoinsRecipient &info)
SendCoinsRecipient recipient
Model for list of recently generated payment requests / bitcoin: URIs.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
const RecentRequestEntry & entry(int row) const
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
void addNewRequest(const SendCoinsRecipient &recipient)
Interface to Bitcoin wallet from Qt view code.
RecentRequestsTableModel * getRecentRequestsTableModel() const
AddressTableModel * getAddressTableModel() const
interfaces::Wallet & wallet() const
OptionsModel * getOptionsModel() const
void canGetAddressesChanged()
virtual OutputType getDefaultAddressType()=0
virtual bool taprootEnabled()=0
virtual bool canGetAddresses()=0
Utility functions used by the Bitcoin Qt UI.
QString formatBitcoinURI(const SendCoinsRecipient &info)
constexpr auto dialog_flags
void setClipboard(const QString &str)
const std::string & FormatOutputType(OutputType type)