diff --git a/src/ContactsWidget.cpp b/src/ContactsWidget.cpp index 5c6b77d..9ad508e 100644 --- a/src/ContactsWidget.cpp +++ b/src/ContactsWidget.cpp @@ -96,7 +96,8 @@ void ContactsWidget::copyName() { void ContactsWidget::payTo() { QModelIndex index = ui->contacts->currentIndex(); 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) { diff --git a/src/ContactsWidget.h b/src/ContactsWidget.h index 6f6c1b5..d6c8291 100644 --- a/src/ContactsWidget.h +++ b/src/ContactsWidget.h @@ -37,7 +37,7 @@ public slots: void setSearchFilter(const QString &filter); signals: - void fillAddress(QString &address); + void fill(QString &address, QString &description); private slots: void showHeaderMenu(const QPoint &position); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 9c8814d..44b6808 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -236,7 +236,9 @@ void MainWindow::initWidgets() { m_historyWidget->setSearchText(text); 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] m_coinsWidget = new CoinsWidget(m_wallet, this); diff --git a/src/SendWidget.cpp b/src/SendWidget.cpp index 36a7d75..a00c2cf 100644 --- a/src/SendWidget.cpp +++ b/src/SendWidget.cpp @@ -112,11 +112,13 @@ void SendWidget::fill(double 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->moveCursor(QTextCursor::Start); - ui->lineDescription->setText(description); + if (overrideDescription || ui->lineDescription->text().isEmpty()) { + ui->lineDescription->setText(description); + } if (amount > 0) ui->lineAmount->setText(QString::number(amount)); diff --git a/src/SendWidget.h b/src/SendWidget.h index fa7c78d..1fece10 100644 --- a/src/SendWidget.h +++ b/src/SendWidget.h @@ -18,7 +18,7 @@ Q_OBJECT public: 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 clearFields(); void payToMany();