Browse Source

change some gui elements, deactivate contact request for now

pull/130/head
DenioD 4 years ago
parent
commit
7194122449
  1. 21
      src/chatmodel.cpp
  2. 42
      src/controller.cpp
  3. 2
      src/mainwindow.cpp
  4. 10
      src/mainwindow.ui
  5. 20
      src/sendtab.cpp

21
src/chatmodel.cpp

@ -36,6 +36,7 @@ void ChatModel::setItems(std::vector<ChatItem> items)
for(ChatItem c : items) for(ChatItem c : items)
{ {
this->chatItems[c.getTimestamp()] = c; this->chatItems[c.getTimestamp()] = c;
} }
} }
@ -95,7 +96,7 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListWidget *view)
line += QString(c.second.getMemo()) + QString("\n"); line += QString(c.second.getMemo()) + QString("\n");
view->addItem(line); view->addItem(line);
line =""; line ="";
} }else{}
if ((ui->MyZaddr->text().trimmed() == c.second.getAddress()) && (c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false)){ if ((ui->MyZaddr->text().trimmed() == c.second.getAddress()) && (c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false)){
line += QString("[") + myDateTime.toString("dd.MM.yyyy hh:mm:ss ") + QString("] "); line += QString("[") + myDateTime.toString("dd.MM.yyyy hh:mm:ss ") + QString("] ");
@ -321,7 +322,7 @@ Tx MainWindow::createTxForSafeContactRequest() {
QString hmemo= createHeaderMemo(type,cid,myAddr); QString hmemo= createHeaderMemo(type,cid,myAddr);
tx.toAddrs.push_back(ToFields{addr, amt, hmemo}) ; // tx.toAddrs.push_back(ToFields{addr, amt, hmemo}) ;
qDebug() << "pushback chattx"; qDebug() << "pushback chattx";
} }
@ -334,7 +335,7 @@ Tx MainWindow::createTxForSafeContactRequest() {
qDebug() << "ChatTx created"; qDebug() << "ChatTx created";
} }
//////////////////De-activated for now///////////////////
void MainWindow::safeContactRequest() { void MainWindow::safeContactRequest() {
////////////////////////////Todo: Check if its a zaddr////////// ////////////////////////////Todo: Check if its a zaddr//////////
@ -357,9 +358,9 @@ void MainWindow::safeContactRequest() {
// return; // return;
// } // }
Tx tx = createTxForSafeContactRequest(); /* Tx tx = createTxForSafeContactRequest();
QString error = doSendChatTxValidations(tx); QString error = doSendRequestTxValidations(tx);
if (!error.isEmpty()) { if (!error.isEmpty()) {
// Something went wrong, so show an error and exit // Something went wrong, so show an error and exit
@ -419,14 +420,14 @@ void MainWindow::safeContactRequest() {
QMessageBox::critical(this, QObject::tr("Transaction Error"), errStr, QMessageBox::Ok); QMessageBox::critical(this, QObject::tr("Transaction Error"), errStr, QMessageBox::Ok);
} }
); );*/
} }
QString MainWindow::doSendRequestTxValidations(Tx tx) { QString MainWindow::doSendRequestTxValidations(Tx tx) {
// Check to see if we have enough verified funds to send the Tx. // Check to see if we have enough verified funds to send the Tx.
CAmount total; /* CAmount total;
for (auto toAddr : tx.toAddrs) { for (auto toAddr : tx.toAddrs) {
if (!Settings::isValidAddress(toAddr.addr)) { if (!Settings::isValidAddress(toAddr.addr)) {
QString addr = (toAddr.addr.length() > 100 ? toAddr.addr.left(100) + "..." : toAddr.addr); QString addr = (toAddr.addr.length() > 100 ? toAddr.addr.left(100) + "..." : toAddr.addr);
@ -450,5 +451,5 @@ QString MainWindow::doSendRequestTxValidations(Tx tx) {
.arg(available.toDecimalhushString(), total.toDecimalhushString()); .arg(available.toDecimalhushString(), total.toDecimalhushString());
} }
return ""; return "";*/
} }

42
src/controller.cpp

@ -879,37 +879,40 @@ void Controller::refreshTransactions() {
QString memo; QString memo;
if (!o["memo"].is_null()) { if (!o["memo"].is_null()) {
memo = QString::fromStdString(o["memo"]); memo = QString::fromStdString(o["memo"]);
}
ChatItem item = ChatItem( ChatItem item = ChatItem(
datetime, datetime,
address, address,
QString(""), QString(""),
memo, memo
true // is an outgoing message // true // is an outgoing message
); );
chatModel->addMessage(item); chatModel->addMessage(item);
}
items.push_back(TransactionItemDetail{address, amount, memo}); items.push_back(TransactionItemDetail{address, amount, memo});
total_amount = total_amount + amount; total_amount = total_amount + amount;
} // }
{ // {
// Concat all the addresses // Concat all the addresses
QList<QString> addresses; // QList<QString> addresses;
for (auto item : items) { // for (auto item : items) {
addresses.push_back(item.address); // addresses.push_back(item.address);
address = addresses.join(",");
} // }
} // }
txdata.push_back(TransactionItem{ txdata.push_back(TransactionItem{
"send", datetime, address, txid,confirmations, items "send", datetime, address, txid,confirmations, items
}); });
}
} else { } else {
// Incoming Transaction // Incoming Transaction
address = (it["address"].is_null() ? "" : QString::fromStdString(it["address"])); address = (it["address"].is_null() ? "" : QString::fromStdString(it["address"]));
@ -919,8 +922,14 @@ void Controller::refreshTransactions() {
if (!it["memo"].is_null()) { if (!it["memo"].is_null()) {
memo = QString::fromStdString(it["memo"]); memo = QString::fromStdString(it["memo"]);
} }
TransactionItem tx{
"Receive", datetime, address, txid,confirmations, items
};
txdata.push_back(tx);
ChatItem item = ChatItem( ChatItem item = ChatItem(
datetime, datetime,
address, address,
QString(""), QString(""),
@ -933,13 +942,6 @@ void Controller::refreshTransactions() {
CAmount::fromqint64(it["amount"].get<json::number_integer_t>()), CAmount::fromqint64(it["amount"].get<json::number_integer_t>()),
memo memo
}); });
TransactionItem tx{
"Receive", datetime, address, txid,confirmations, items
};
txdata.push_back(tx);
} }
} }

2
src/mainwindow.cpp

@ -974,7 +974,7 @@ void MainWindow::setupTransactionsTab() {
qApp->processEvents(); qApp->processEvents();
// Click the memo button // Click the memo button
this->memoButtonClicked(1, true); this->memoButtonClicked(1, true);
}); });
} }
} }

10
src/mainwindow.ui

@ -1460,7 +1460,7 @@
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>To:</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Send to :&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="ContactName"> <widget class="QLabel" name="ContactName">
@ -1468,18 +1468,18 @@
<rect> <rect>
<x>340</x> <x>340</x>
<y>490</y> <y>490</y>
<width>161</width> <width>81</width>
<height>17</height> <height>17</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="text">
<string>Your HushChat zaddr:</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;My zaddr :&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="ContactZaddr"> <widget class="QLabel" name="ContactZaddr">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>370</x> <x>420</x>
<y>460</y> <y>460</y>
<width>691</width> <width>691</width>
<height>20</height> <height>20</height>
@ -1514,7 +1514,7 @@
<widget class="QLabel" name="MyZaddr"> <widget class="QLabel" name="MyZaddr">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>490</x> <x>420</x>
<y>490</y> <y>490</y>
<width>691</width> <width>691</width>
<height>20</height> <height>20</height>

20
src/sendtab.cpp

@ -35,7 +35,7 @@ void MainWindow::setupSendTab() {
}); });
// The first Memo button // The first Memo button
QObject::connect(ui->MemoBtn1, &QPushButton::clicked, [=] () { QObject::connect(ui->MemoBtn1, &QPushButton::clicked, [=] () {
this->memoButtonClicked(1); this->memoButtonClicked(1);
}); });
setMemoEnabled(1, false); setMemoEnabled(1, false);
@ -377,15 +377,15 @@ void MainWindow::setMemoEnabled(int number, bool enabled) {
void MainWindow::memoButtonClicked(int number, bool includeReplyTo) { void MainWindow::memoButtonClicked(int number, bool includeReplyTo) {
// Memos can only be used with zAddrs. So check that first // Memos can only be used with zAddrs. So check that first
auto addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") + QString::number(number)); // auto addr = ui->sendToWidgets->findChild<QLineEdit*>(QString("Address") + QString::number(number));
if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) { //if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) {
QMessageBox msg(QMessageBox::Critical, tr("Memos can only be used with z-addresses"), // QMessageBox msg(QMessageBox::Critical, tr("Memos can only be used with z-addresses"),
tr("The memo field can only be used with a z-address.\n") + addr->text() + tr("\ndoesn't look like a z-address"), // tr("The memo field can only be used with a z-address.\n") + addr->text() + tr("\ndoesn't look like a z-address"),
QMessageBox::Ok, this); // QMessageBox::Ok, this);
msg.exec(); // msg.exec();
return; // return;
} // }
// Get the current memo if it exists // Get the current memo if it exists
auto memoTxt = ui->sendToWidgets->findChild<QLabel *>(QString("MemoTxt") + QString::number(number)); auto memoTxt = ui->sendToWidgets->findChild<QLabel *>(QString("MemoTxt") + QString::number(number));

Loading…
Cancel
Save