make Addressbook HushChat address changeable and show it earlier
This commit is contained in:
@@ -138,6 +138,24 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
|||||||
// Connect the dialog's closing to updating the label address completor
|
// Connect the dialog's closing to updating the label address completor
|
||||||
QObject::connect(&d, &QDialog::finished, [=] (auto) { parent->updateLabels(); });
|
QObject::connect(&d, &QDialog::finished, [=] (auto) { parent->updateLabels(); });
|
||||||
|
|
||||||
|
Controller* rpc = parent->getRPC();
|
||||||
|
bool sapling = true;
|
||||||
|
rpc->createNewZaddr(sapling, [=] (json reply) {
|
||||||
|
QString myAddr = QString::fromStdString(reply.get<json::array_t>()[0]);
|
||||||
|
// QString myAddr = "zs1flslqurcnummsw37mfxkhx6d7uwpevlc78cdjyqrgng7357t8f3stm9fneeqtuupfnrt7f933a9";
|
||||||
|
QString message = QString("New Chat Address for your partner: ") + myAddr;
|
||||||
|
|
||||||
|
parent->ui->listReceiveAddresses->insertItem(0, myAddr);
|
||||||
|
parent->ui->listReceiveAddresses->setCurrentIndex(0);
|
||||||
|
// ab.addr_chat->setText(myAddr);
|
||||||
|
qDebug() << "new generated myAddr" << myAddr;
|
||||||
|
//
|
||||||
|
ab.addr_chat->setText(myAddr);
|
||||||
|
// AddressBook::getInstance()->addAddressLabel(newLabel, ab.addr->text(), myAddr, cid);
|
||||||
|
});
|
||||||
|
model.updateUi(); //todo fix updating gui after adding
|
||||||
|
rpc->refresh(true);
|
||||||
|
|
||||||
// If there is a target then make it the addr for the "Add to" button
|
// If there is a target then make it the addr for the "Add to" button
|
||||||
if (target != nullptr && Settings::isValidAddress(target->text()))
|
if (target != nullptr && Settings::isValidAddress(target->text()))
|
||||||
{
|
{
|
||||||
@@ -148,7 +166,11 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
|||||||
// Add new address button
|
// Add new address button
|
||||||
QObject::connect(ab.addNew, &QPushButton::clicked, [&] () {
|
QObject::connect(ab.addNew, &QPushButton::clicked, [&] () {
|
||||||
auto addr = ab.addr->text().trimmed();
|
auto addr = ab.addr->text().trimmed();
|
||||||
|
auto myAddr = ab.addr->text().trimmed();
|
||||||
QString newLabel = ab.label->text();
|
QString newLabel = ab.label->text();
|
||||||
|
QString cid = QUuid::createUuid().toString(QUuid::WithoutBraces);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (addr.isEmpty() || newLabel.isEmpty())
|
if (addr.isEmpty() || newLabel.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -183,32 +205,23 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Controller* rpc = parent->getRPC();
|
|
||||||
bool sapling = true;
|
////// We need a better popup here.
|
||||||
rpc->createNewZaddr(sapling, [=] (json reply) {
|
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid);
|
||||||
QString myAddr = QString::fromStdString(reply.get<json::array_t>()[0]);
|
|
||||||
QString message = QString("New Chat Address for your partner: ") + myAddr;
|
|
||||||
QMessageBox::critical(
|
QMessageBox::critical(
|
||||||
parent,
|
parent,
|
||||||
QObject::tr("Success"),
|
QObject::tr("Add Successfully"),
|
||||||
message, //todo translate this
|
QObject::tr("juhu").arg(newLabel),
|
||||||
QMessageBox::Ok
|
QMessageBox::Ok
|
||||||
);
|
);
|
||||||
parent->ui->listReceiveAddresses->insertItem(0, addr);
|
return;
|
||||||
parent->ui->listReceiveAddresses->setCurrentIndex(0);
|
|
||||||
// ab.addr_chat->setText(myAddr);
|
|
||||||
qDebug() << "new generated myAddr" << myAddr;
|
rpc->refresh(true);
|
||||||
QString cid = QUuid::createUuid().toString(QUuid::WithoutBraces); //
|
model.updateUi();
|
||||||
AddressBook::getInstance()->addAddressLabel(newLabel, ab.addr->text(), myAddr, cid);
|
|
||||||
});
|
|
||||||
model.updateUi(); //todo fix updating gui after adding
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Generate CID for Contact
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// AddressBook::getInstance()->addAddressLabel(newLabel, ab.addr->text(), cid);
|
// AddressBook::getInstance()->addAddressLabel(newLabel, ab.addr->text(), cid);
|
||||||
|
|
||||||
// Import Button
|
// Import Button
|
||||||
|
|||||||
@@ -20,7 +20,17 @@
|
|||||||
<string>Add New Address</string>
|
<string>Add New Address</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_1">
|
||||||
|
<property name="text">
|
||||||
|
<string>Address (z-Addr or t-Addr)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLineEdit" name="addr"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>HushChat Address - give this Address only to your contact</string>
|
<string>HushChat Address - give this Address only to your contact</string>
|
||||||
@@ -30,10 +40,10 @@
|
|||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLineEdit" name="addr_chat"/>
|
<widget class="QLineEdit" name="addr_chat"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="label_1">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Address (z-Addr or t-Addr)</string>
|
<string>Label</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -47,16 +57,6 @@
|
|||||||
<item row="6" column="0">
|
<item row="6" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
<layout class="QHBoxLayout" name="horizontalLayout"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Label</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLineEdit" name="addr"/>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="QPushButton" name="addNew">
|
<widget class="QPushButton" name="addNew">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|||||||
Reference in New Issue
Block a user