contacts: fill description on pay to

This commit is contained in:
tobtoht 2024-08-15 20:12:54 +02:00
parent f58f8b66a5
commit 7c4bffe5dd
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
5 changed files with 11 additions and 6 deletions

View file

@ -96,7 +96,8 @@ void ContactsWidget::copyName() {
void ContactsWidget::payTo() { void ContactsWidget::payTo() {
QModelIndex index = ui->contacts->currentIndex(); QModelIndex index = ui->contacts->currentIndex();
QString address = index.model()->data(index.siblingAtColumn(AddressBookModel::Address), Qt::UserRole).toString(); QString address = index.model()->data(index.siblingAtColumn(AddressBookModel::Address), Qt::UserRole).toString();
emit fillAddress(address); QString description = index.model()->data(index.siblingAtColumn(AddressBookModel::Description), Qt::UserRole).toString();
emit fill(address, description);
} }
void ContactsWidget::setShowFullAddresses(bool show) { void ContactsWidget::setShowFullAddresses(bool show) {

View file

@ -37,7 +37,7 @@ public slots:
void setSearchFilter(const QString &filter); void setSearchFilter(const QString &filter);
signals: signals:
void fillAddress(QString &address); void fill(QString &address, QString &description);
private slots: private slots:
void showHeaderMenu(const QPoint &position); void showHeaderMenu(const QPoint &position);

View file

@ -236,7 +236,9 @@ void MainWindow::initWidgets() {
m_historyWidget->setSearchText(text); m_historyWidget->setSearchText(text);
ui->tabWidget->setCurrentIndex(this->findTab("History")); ui->tabWidget->setCurrentIndex(this->findTab("History"));
}); });
connect(m_contactsWidget, &ContactsWidget::fillAddress, m_sendWidget, &SendWidget::fillAddress); connect(m_contactsWidget, &ContactsWidget::fill, [this](const QString &address, const QString &description){
m_sendWidget->fill(address, description, 0, true);
});
// [Coins] // [Coins]
m_coinsWidget = new CoinsWidget(m_wallet, this); m_coinsWidget = new CoinsWidget(m_wallet, this);

View file

@ -112,11 +112,13 @@ void SendWidget::fill(double amount) {
ui->lineAmount->setText(QString::number(amount)); ui->lineAmount->setText(QString::number(amount));
} }
void SendWidget::fill(const QString &address, const QString &description, double amount) { void SendWidget::fill(const QString &address, const QString &description, double amount, bool overrideDescription) {
ui->lineAddress->setText(address); ui->lineAddress->setText(address);
ui->lineAddress->moveCursor(QTextCursor::Start); ui->lineAddress->moveCursor(QTextCursor::Start);
if (overrideDescription || ui->lineDescription->text().isEmpty()) {
ui->lineDescription->setText(description); ui->lineDescription->setText(description);
}
if (amount > 0) if (amount > 0)
ui->lineAmount->setText(QString::number(amount)); ui->lineAmount->setText(QString::number(amount));

View file

@ -18,7 +18,7 @@ Q_OBJECT
public: public:
explicit SendWidget(Wallet *wallet, QWidget *parent = nullptr); explicit SendWidget(Wallet *wallet, QWidget *parent = nullptr);
void fill(const QString &address, const QString &description, double amount = 0); void fill(const QString &address, const QString &description, double amount = 0, bool overrideDescription = true);
void fill(double amount); void fill(double amount);
void clearFields(); void clearFields();
void payToMany(); void payToMany();