20 #include <QMessageBox> 23 #include <QTextDocument> 29 platformStyle(_platformStyle)
57 tableView->verticalHeader()->hide();
58 tableView->setAlternatingRowColors(
true);
59 tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
60 tableView->setSelectionMode(QAbstractItemView::ContiguousSelection);
63 if (!tableView->horizontalHeader()->restoreState(settings.value(
"RecentRequestsViewHeaderState").toByteArray())) {
68 tableView->horizontalHeader()->setStretchLastSection(
true);
86 connect(tableView->selectionModel(),
87 &QItemSelectionModel::selectionChanged,
this,
91 auto add_address_type = [&](
OutputType type,
const QString& text,
const QString& tooltip) {
94 ui->
addressType->setItemData(index, tooltip, Qt::ToolTipRole);
97 add_address_type(
OutputType::LEGACY,
"Base58 (Legacy)",
"Not recommended due to higher fees and less protection against typos.");
98 add_address_type(
OutputType::P2SH_SEGWIT,
"Base58 (P2SH-SegWit)",
"Generates an address compatible with older wallets.");
99 add_address_type(
OutputType::BECH32,
"Bech32 (SegWit)",
"Generates a native segwit address (BIP-173). Some old wallets don't support it.");
101 add_address_type(
OutputType::BECH32M,
"Bech32m (Taproot)",
"Bech32m (BIP-350) is an upgrade to Bech32, wallet support is still limited.");
117 settings.setValue(
"RecentRequestsViewHeaderState",
ui->
recentRequestsView->horizontalHeader()->saveState());
160 case AddressTableModel::EditStatus::OK: {
165 dialog->setAttribute(Qt::WA_DeleteOnClose);
166 dialog->setModel(
model);
167 dialog->setInfo(info);
174 case AddressTableModel::EditStatus::WALLET_UNLOCK_FAILURE:
175 QMessageBox::critical(
this, windowTitle(),
176 tr(
"Could not unlock wallet."),
177 QMessageBox::Ok, QMessageBox::Ok);
179 case AddressTableModel::EditStatus::KEY_GENERATION_FAILURE:
180 QMessageBox::critical(
this, windowTitle(),
181 tr(
"Could not generate new %1 address").arg(QString::fromStdString(
FormatOutputType(address_type))),
182 QMessageBox::Ok, QMessageBox::Ok);
185 case AddressTableModel::EditStatus::INVALID_ADDRESS:
186 case AddressTableModel::EditStatus::DUPLICATE_ADDRESS:
187 case AddressTableModel::EditStatus::NO_CHANGES:
198 dialog->
setInfo(submodel->
entry(index.row()).recipient);
199 dialog->setAttribute(Qt::WA_DeleteOnClose);
217 for (
const QModelIndex& index : selection) {
227 if(selection.empty())
230 QModelIndex firstIndex = selection.at(0);
237 return QModelIndex();
239 if(selection.empty())
240 return QModelIndex();
242 QModelIndex firstIndex = selection.at(0);
250 if (!firstIndex.isValid()) {
260 if (!sel.isValid()) {
278 if (!sel.isValid()) {
291 if (!sel.isValid()) {
296 const QString address = submodel->
entry(sel.row()).recipient.address;
Model for list of recently generated payment requests / bitcoin: URIs.
void addNewRequest(const SendCoinsRecipient &recipient)
Dialog for requesting payment of bitcoins.
virtual bool canGetAddresses()=0
OptionsModel * getOptionsModel() const
interfaces::Wallet & wallet() const
Utility functions used by the Bitcoin Qt UI.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
void canGetAddressesChanged()
virtual OutputType getDefaultAddressType()=0
QPushButton * receiveButton
void recentRequestsView_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
BitcoinAmountField * reqAmount
void setupUi(QDialog *ReceiveCoinsDialog)
BitcoinUnit getDisplayUnit() const
QAction * copyMessageAction
Ui::ReceiveCoinsDialog * ui
QString formatBitcoinURI(const SendCoinsRecipient &info)
QModelIndex selectedRow()
QString addRow(const QString &type, const QString &label, const QString &address, const OutputType address_type)
QPushButton * showRequestButton
constexpr auto dialog_flags
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
void setModel(WalletModel *model)
QPushButton * clearButton
void copyColumnToClipboard(int column)
RecentRequestsTableModel * getRecentRequestsTableModel() const
void displayUnitChanged(BitcoinUnit unit)
QAction * copyLabelAction
void setClipboard(const QString &str)
void on_recentRequestsView_doubleClicked(const QModelIndex &index)
void setInfo(const SendCoinsRecipient &info)
SendCoinsRecipient recipient
const RecentRequestEntry & entry(int row) const
ReceiveCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent=nullptr)
QTableView * recentRequestsView
const std::string & FormatOutputType(OutputType type)
void on_removeRequestButton_clicked()
virtual bool taprootEnabled()=0
void on_receiveButton_clicked()
Interface to Bitcoin wallet from Qt view code.
void clear()
Make field empty and ready for new input.
void on_showRequestButton_clicked()
static const QString Receive
Specifies receive address.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
QPushButton * removeRequestButton
void showMenu(const QPoint &point)
AddressTableModel * getAddressTableModel() const
EditStatus getEditStatus() const
void setDisplayUnit(BitcoinUnit new_unit)
Change unit used to display amount.
QAction * copyAmountAction
void setModel(WalletModel *model)