Merge pull request #10 from DenioD/chat

Chat
This commit is contained in:
Strider
2020-05-06 19:21:12 +02:00
committed by GitHub
23 changed files with 721 additions and 70 deletions

View File

@@ -23,6 +23,15 @@
<file>res/Pinguin.png</file> <file>res/Pinguin.png</file>
<file>res/Stag.png</file> <file>res/Stag.png</file>
<file>res/Elsa.png</file> <file>res/Elsa.png</file>
<file>res/send.png</file>
<file>res/send.svg</file>
<file>res/addcontact.svg</file>
<file>res/send-new.svg</file>
<file>res/add_contact.svg</file>
<file>res/notification.svg</file>
<file>res/send-new-white.png</file>
<file>res/add_contact.png</file>
<file>res/notification.png</file>
</qresource> </qresource>
<qresource prefix="/img"> <qresource prefix="/img">
<file>res/hushdlogo.gif</file> <file>res/hushdlogo.gif</file>

BIN
res/add_contact.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

9
res/add_contact.svg Normal file
View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 265.7 283.5" style="enable-background:new 0 0 265.7 283.5;" xml:space="preserve">
<g>
<path d="M132.9,0C59.8,0,0,59.8,0,132.9c0,73,59.8,132.9,132.9,132.9c73,0,132.9-59.8,132.9-132.9C265.7,59.8,205.9,0,132.9,0
L132.9,0z M199.3,146.2h-53.1v53.1h-26.6v-53.1H66.4v-26.6h53.1V66.4h26.6v53.1h53.1V146.2z M199.3,146.2"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 604 B

7
res/addcontact.svg Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Svg Vector Icons : http://www.onlinewebfonts.com/icon -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
<metadata> Svg Vector Icons : http://www.onlinewebfonts.com/icon </metadata>
<g><path d="M870.2,797.3l-99.5-2.4l2.4-99.7c0.4-15.7-12.1-28.8-27.8-29.2c-15.7-0.4-28.8,12-29.2,27.8l-2.4,99.7l-99.6-2.4c-15.7-0.4-28.8,12.1-29.2,27.8c-0.4,15.7,12,28.8,27.8,29.2l99.6,2.4l-2.4,99.7c-0.4,15.7,12,28.8,27.8,29.2c15.7,0.4,28.8-12,29.2-27.8l2.4-99.6l99.5,2.4c15.6,0.4,28.8-12,29.2-27.8C898.3,810.8,885.9,797.7,870.2,797.3L870.2,797.3z"/><path d="M515.1,568.6c2.2,15.9,16.9,27.1,32.7,25.1c117.1-14.5,232.6,25.5,316.9,109.9c11.4,11.4,29.8,11.5,41.1,0.3c11.3-11.2,11.2-29.7-0.3-41.1C808.3,565.4,675,519.2,539.9,536C524.4,538,512.9,553.1,515.1,568.6z M113.8,990c15.9,0.5,29.2-12.2,29.7-28.4c6.3-209.1,178.4-374.1,383.6-367.9c158.1,4.8,290.6-122.2,295.5-283.1c4.8-160.9-119.8-295.7-277.9-300.5C386.6,5.4,254.1,132.4,249.2,293.3c-3.2,106.5,52.2,207,142.4,260.6C216.3,608.1,91.5,772.7,85.8,959.9C85.3,976,97.9,989.5,113.8,990z M542.9,68.8c126.3,3.8,225.8,111.5,221.9,240.1C761,437.5,655.2,539,528.9,535.1c-126.2-3.8-225.6-111.5-221.8-240.1C311,166.6,416.8,65.1,542.9,68.8z"/></g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -1,5 +1,5 @@
QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QTableView::item, QScrollArea, QGroupBox, QPlainTextEdit, QLineEdit, QLabel, MainWindow QWidget, QMainWindow, QMenuBar, QMenu, QDialog, QTabWidget, QTableView, QTableView::item, QScrollArea, QGroupBox, QPlainTextEdit, QLineEdit, QLabel, MainWindow, ChatModel, requestDialog
{ {
background-color: #303335; background-color: #303335;
color: #ffffff; color: #ffffff;

BIN
res/notification.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

10
res/notification.svg Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 225.9 283.5" style="enable-background:new 0 0 225.9 283.5;" xml:space="preserve">
<g>
<path d="M113,265.7c14.6,0,26.5-11.9,26.5-26.6H86.4C86.4,253.8,98.4,265.7,113,265.7L113,265.7z M199.3,186v-73
c0-41.2-27.9-74.4-66.4-83.7v-9.4C132.9,9.3,123.6,0,113,0C102.3,0,93,9.3,93,19.9v9.4C54.5,38.5,26.6,71.8,26.6,113v73L0,212.6
v13.3h225.9v-13.3L199.3,186z M199.3,186"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 655 B

BIN
res/send-new-white.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

19
res/send-new.svg Normal file
View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 300.2 283.5" style="enable-background:new 0 0 300.2 283.5;" xml:space="preserve">
<!--<style type="text/css">-->
<!--.st0{clip-path:url(#SVGID_2_);}-->
<!--</style>-->
<g>
<!--<g>-->
<!--<defs>-->
<!--<rect id="SVGID_1_" x="2.6" width="297.6" height="265.7"/>-->
<!--</defs>-->
<!--<clipPath id="SVGID_2_">-->
<!--<use xlink:href="#SVGID_1_" style="overflow:visible;"/>-->
<!--</clipPath>-->
<path class="st0" d="M2.6,255.1l297.7-127.5L2.6,0v99.2l212.6,28.3L2.6,155.9V255.1z M2.6,255.1"/>
<!--</g>-->
</g>
</svg>

After

Width:  |  Height:  |  Size: 808 B

BIN
res/send.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

6
res/send.svg Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" ?><svg id="Layer_1" style="enable-background:new 0 0 137.3 139.3;" version="1.1" viewBox="0 0 137.3 139.3" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><style type="text/css">
.st0{fill:#2C8AAA;}
.st1{opacity:0.19;clip-path:url(#XMLID_39_);fill:#070808;}
.st2{fill:#FFFFFF;}
.st3{opacity:0.19;fill:#070808;}
</style><g id="XMLID_2671_"><g id="XMLID_2704_"><circle class="st0" cx="68.5" cy="69.6" id="XMLID_2708_" r="66.2"/><g id="XMLID_2705_"><defs><circle cx="68.7" cy="69.6" id="XMLID_2706_" r="66.2"/></defs><clipPath id="XMLID_39_"><use style="overflow:visible;" xlink:href="#XMLID_2706_"/></clipPath><polyline class="st1" id="XMLID_2707_" points="95.7,41 155.1,91.1 134,135.8 112,146.2 33.3,62.9 "/></g></g></g><g id="XMLID_2719_"><polygon class="st2" id="XMLID_2718_" points="74.3,103.9 95.7,41 33.3,62.9 50.9,76.8 60.4,76.8 60.3,86.1 "/><polygon class="st3" id="XMLID_2713_" points="60.7,84.9 95.7,41 50.9,76.8 60.4,76.8 "/><polygon class="st3" id="XMLID_2703_" points="60.4,76.8 95.7,41 60.3,86.1 "/></g></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -126,6 +126,7 @@ FORMS += \
src/mobileappconnector.ui \ src/mobileappconnector.ui \
src/createhushconfdialog.ui \ src/createhushconfdialog.ui \
src/recurringdialog.ui \ src/recurringdialog.ui \
src/requestContactDialog.ui \
src/newrecurring.ui \ src/newrecurring.ui \
src/requestdialog.ui \ src/requestdialog.ui \
src/recurringmultiple.ui \ src/recurringmultiple.ui \

View File

@@ -1,3 +1,5 @@
// Copyright 2019-2020 The Hush developers
// GPLv3
#include "addressbook.h" #include "addressbook.h"
#include "ui_addressbook.h" #include "ui_addressbook.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"

View File

@@ -6,6 +6,7 @@
#include "controller.h" #include "controller.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "ui_requestContactDialog.h"
#include "addressbook.h" #include "addressbook.h"
#include "ui_memodialog.h" #include "ui_memodialog.h"
#include "ui_contactrequest.h" #include "ui_contactrequest.h"
@@ -83,6 +84,7 @@ void ChatModel::showMessages()
{ {
qDebug() << c.second.toChatLine(); qDebug() << c.second.toChatLine();
} }
} }
void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView &view) void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView &view)
@@ -97,7 +99,10 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView &view)
void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view) void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
{ {
QObject::connect(ui->pushContact, &QPushButton::clicked,[&] ()
{
renderContactRequest();
});
QStandardItemModel* chat = new QStandardItemModel(); QStandardItemModel* chat = new QStandardItemModel();
@@ -137,14 +142,97 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
} }
}
} }
void ChatModel::renderContactRequest(){
Ui_requestDialog requestContact;
QDialog dialog(main);
requestContact.setupUi(&dialog);
Settings::saveRestore(&dialog);
{
QStandardItemModel* contactRequest = new QStandardItemModel();
for (auto &c : this->chatItems) {
if ((c.second.getType() == "cont") && (c.second.isOutgoing() == false) && (c.second.getMemo().startsWith("{"))) {
QStandardItem* Items = new QStandardItem(c.second.getAddress());
contactRequest->appendRow(Items);
requestContact.requestContact->setModel(contactRequest);
// requestContact.requestContact->show();
}
}
}
// }
QObject::connect(requestContact.requestContact, &QTableView::clicked, [&] () {
for (auto &c : this->chatItems){
QModelIndex index = requestContact.requestContact->currentIndex();
QString label_contact = index.data(Qt::DisplayRole).toString();
QStandardItemModel* contactMemo = new QStandardItemModel();
if (c.second.isOutgoing() == false) {
if (label_contact == c.second.getAddress()) {
if(c.second.getMemo().startsWith("{")){
}else{
QStandardItem* Items = new QStandardItem(c.second.getMemo());
contactMemo->appendRow(Items);
requestContact.requestMemo->setModel(contactMemo);
requestContact.requestMemo->show();
requestContact.requestZaddr->setText(c.second.getRequestZaddr());
requestContact.requestCID->setText(c.second.getCid());
requestContact.requestMyAddr->setText(c.second.getAddress());
}
}
}
}
});
QObject::connect(requestContact.pushButton, &QPushButton::clicked, [&] () {
QString cid = requestContact.requestCID->text();
auto addr = requestContact.requestZaddr->text().trimmed();
QString newLabel = requestContact.requestLabel->text().trimmed();
auto myAddr = requestContact.requestMyAddr->text().trimmed();
QString avatar = QString("res/") + requestContact.comboBoxAvatar->currentText() + QString(".png");
qDebug()<<"Beginn kopiert" <<cid << addr << newLabel << myAddr;
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
});
dialog.exec();
} }
void ChatModel::addCid(QString tx, QString cid) void ChatModel::addCid(QString tx, QString cid)
{ {
this->cidMap[tx] = cid; this->cidMap[tx] = cid;
} }
void ChatModel::addrequestZaddr(QString tx, QString requestZaddr)
{
this->requestZaddrMap[tx] = requestZaddr;
}
QString ChatModel::getCidByTx(QString tx) QString ChatModel::getCidByTx(QString tx)
{ {
for(auto& pair : this->cidMap) for(auto& pair : this->cidMap)
@@ -160,11 +248,31 @@ QString ChatModel::getCidByTx(QString tx)
return QString("0xdeadbeef"); return QString("0xdeadbeef");
} }
QString ChatModel::getrequestZaddrByTx(QString tx)
{
for(auto& pair : this->requestZaddrMap)
{
}
if(this->requestZaddrMap.count(tx) > 0)
{
return this->requestZaddrMap[tx];
}
return QString("0xdeadbeef");
}
void ChatModel::killCidCache() void ChatModel::killCidCache()
{ {
this->cidMap.clear(); this->cidMap.clear();
} }
void ChatModel::killrequestZaddrCache()
{
this->requestZaddrMap.clear();
}
QString MainWindow::createHeaderMemo(QString type, QString cid, QString zaddr, int version=0, int headerNumber=1) QString MainWindow::createHeaderMemo(QString type, QString cid, QString zaddr, int version=0, int headerNumber=1)
{ {
@@ -183,6 +291,7 @@ QString MainWindow::createHeaderMemo(QString type, QString cid, QString zaddr,
header = j.toJson(); header = j.toJson();
qDebug() << "made header=" << header; qDebug() << "made header=" << header;
return header; return header;
} }

View File

@@ -14,6 +14,7 @@
#include "camount.h" #include "camount.h"
class ListViewDelegate : public QAbstractItemDelegate class ListViewDelegate : public QAbstractItemDelegate
{ {
int d_radius; int d_radius;
@@ -164,6 +165,8 @@ class ChatItem
QString _address; QString _address;
QString _contact; QString _contact;
QString _memo; QString _memo;
QString _requestZaddr;
QString _type;
QString _cid; QString _cid;
QString _txid; QString _txid;
bool _outgoing = false; bool _outgoing = false;
@@ -171,24 +174,28 @@ class ChatItem
public: public:
ChatItem() {} ChatItem() {}
ChatItem(long timestamp, QString address, QString contact, QString memo, QString cid, QString txid) ChatItem(long timestamp, QString address, QString contact, QString memo,QString requestZaddr, QString type, QString cid, QString txid)
{ {
_timestamp = timestamp; _timestamp = timestamp;
_address = address; _address = address;
_contact = contact; _contact = contact;
_memo = memo; _memo = memo;
_requestZaddr = requestZaddr;
_type = type;
_cid = cid; _cid = cid;
_txid = txid; _txid = txid;
_outgoing = false; _outgoing = false;
} }
ChatItem(long timestamp, QString address, QString contact, QString memo, QString cid, QString txid, bool outgoing) ChatItem(long timestamp, QString address, QString contact, QString memo, QString requestZaddr, QString type, QString cid, QString txid, bool outgoing)
{ {
_timestamp = timestamp; _timestamp = timestamp;
_address = address; _address = address;
_contact = contact; _contact = contact;
_memo = memo; _memo = memo;
_requestZaddr = requestZaddr;
_type = type;
_cid = cid; _cid = cid;
_txid = txid; _txid = txid;
_outgoing = outgoing; _outgoing = outgoing;
@@ -215,6 +222,15 @@ class ChatItem
return _memo; return _memo;
} }
QString getRequestZaddr()
{
return _requestZaddr;
}
QString getType()
{
return _type;
}
QString getCid() QString getCid()
{ {
return _cid; return _cid;
@@ -225,6 +241,7 @@ class ChatItem
return _txid; return _txid;
} }
bool isOutgoing() bool isOutgoing()
{ {
return _outgoing; return _outgoing;
@@ -250,6 +267,16 @@ class ChatItem
_memo = memo; _memo = memo;
} }
void setRequestZaddr(QString requestZaddr)
{
_requestZaddr = requestZaddr;
}
void setType(QString type)
{
_type = type;
}
void setCid(QString cid) void setCid(QString cid)
{ {
_cid = cid; _cid = cid;
@@ -291,6 +318,7 @@ class ChatModel
Ui::MainWindow* ui; Ui::MainWindow* ui;
MainWindow* main; MainWindow* main;
std::map<QString, QString> cidMap; std::map<QString, QString> cidMap;
std::map<QString, QString> requestZaddrMap;
public: public:
ChatModel() {}; ChatModel() {};
@@ -303,13 +331,19 @@ class ChatModel
void setItems(std::vector<ChatItem> items); void setItems(std::vector<ChatItem> items);
void renderChatBox(Ui::MainWindow* ui, QListView &view); void renderChatBox(Ui::MainWindow* ui, QListView &view);
void renderChatBox(Ui::MainWindow* ui, QListView *view); void renderChatBox(Ui::MainWindow* ui, QListView *view);
void renderContactRequest();
void triggerRequest();
void showMessages(); void showMessages();
void clear(); void clear();
//void renderContactRequest(Ui::MainWindow* ui, QListView *view);
void addMessage(ChatItem item); void addMessage(ChatItem item);
void addMessage(QString timestamp, ChatItem item); void addMessage(QString timestamp, ChatItem item);
void addCid(QString tx, QString cid); void addCid(QString tx, QString cid);
void addrequestZaddr(QString tx, QString requestZaddr);
QString getCidByTx(QString tx); QString getCidByTx(QString tx);
QString getrequestZaddrByTx(QString tx);
void killCidCache(); void killCidCache();
void killrequestZaddrCache();
}; };

View File

@@ -5,6 +5,7 @@
#include "ui_connection.h" #include "ui_connection.h"
#include "precompiled.h" #include "precompiled.h"
using json = nlohmann::json; using json = nlohmann::json;
class Controller; class Controller;

View File

@@ -1,6 +1,9 @@
// Copyright 2019-2020 The Hush developers
// GPLv3
#include "contactmodel.h" #include "contactmodel.h"
#include "addressbook.h" #include "addressbook.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "chatmodel.h"
void ContactModel::renderContactList(QListView* view) void ContactModel::renderContactList(QListView* view)
{ {
@@ -12,7 +15,7 @@ void ContactModel::renderContactList(QListView* view)
auto theme = Settings::getInstance()->get_theme_name(); auto theme = Settings::getInstance()->get_theme_name();
if ((theme == "dark" || theme == "midnight")) { if ((theme == "dark" || theme == "midnight")) {
QString avatar = c.getAvatar(); QString avatar = c.getAvatar();
QStandardItem* Items1 = new QStandardItem(QIcon(avatar) ,c.getName()); QStandardItem* Items1 = new QStandardItem(QIcon(avatar) ,c.getName());
contact->appendRow(Items1); contact->appendRow(Items1);
@@ -24,8 +27,6 @@ void ContactModel::renderContactList(QListView* view)
} }
} }
} }

View File

@@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Send a contact request</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="1" colspan="2"> <item row="0" column="1" colspan="2">

View File

@@ -1,3 +1,6 @@
// Copyright 2019-2020 The Hush developers
// GPLv3
#include "controller.h" #include "controller.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "addressbook.h" #include "addressbook.h"
@@ -6,6 +9,7 @@
#include "camount.h" #include "camount.h"
#include "websockets.h" #include "websockets.h"
#include "DataStore.h" #include "DataStore.h"
template<> template<>
DataStore<QString>* DataStore<QString>::instance = nullptr; DataStore<QString>* DataStore<QString>::instance = nullptr;
template<> template<>
@@ -860,7 +864,8 @@ 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"]);
} }
QString cid; QString cid;
QString contact; QString contact;
@@ -869,20 +874,22 @@ void Controller::refreshTransactions() {
if (address == c.getPartnerAddress()){ if (address == c.getPartnerAddress()){
contact = c.getName(); contact = c.getName();
}else{ contact = "";} }else{ contact = "";}
}
ChatItem item = ChatItem( ChatItem item = ChatItem(
datetime, datetime,
address, address,
contact, contact,
memo, memo,
QString(""),
QString(""),
cid, // we have to set the cid here, its included in our Addressbook for this contact cid, // we have to set the cid here, its included in our Addressbook for this contact
txid, txid,
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;
@@ -930,46 +937,47 @@ void Controller::refreshTransactions() {
QString type; QString type;
QString cid; QString cid;
QString requestZaddr1;
QString requestZaddr;
if (memo.startsWith("{")) { if (memo.startsWith("{")) {
type = memo.mid(75,4); type = memo.mid(75,4);
cid = memo.mid(14,36); cid = memo.mid(14,36);
requestZaddr1 = memo.right(82);
requestZaddr = requestZaddr1.left(78);
qDebug()<<type;
qDebug()<<cid;
chatModel->addCid(txid, cid); chatModel->addCid(txid, cid);
chatModel->addrequestZaddr(txid, requestZaddr);
} }
if (type == "cont")
{
qDebug()<< "Als Request erkannt";
}
if (chatModel->getCidByTx(txid) != QString("0xdeadbeef")){ if (chatModel->getCidByTx(txid) != QString("0xdeadbeef")){
cid = chatModel->getCidByTx(txid); cid = chatModel->getCidByTx(txid);
} }
else{ else{
cid = ""; cid = "";
} }
if (chatModel->getrequestZaddrByTx(txid) != QString("0xdeadbeef")){
requestZaddr = chatModel->getrequestZaddrByTx(txid);
}
else{
requestZaddr = "";
}
QString contact; QString contact;
for(auto &c : AddressBook::getInstance()->getAllAddressLabels()) for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
{ {
if (address == c.getMyAddress()){ if (address == c.getMyAddress()){
contact = c.getName(); contact = c.getName();
qDebug()<< "Addressbuch Addresse: " << c.getMyAddress();
qDebug()<< "Addresse: " << address;
}else{ contact = "";} }else{ contact = "";}
@@ -978,13 +986,15 @@ void Controller::refreshTransactions() {
address, address,
contact, contact,
memo, memo,
requestZaddr,
type,
cid, // we have to set the cid here, its included in the headermemo cid, // we have to set the cid here, its included in the headermemo
txid, txid,
false false
); );
chatModel->addMessage(item); chatModel->addMessage(item);
} }
} }
} }

View File

@@ -1,3 +1,5 @@
// Copyright 2019-2020 The Hush developers
// GPLv3
#include "mainwindow.h" #include "mainwindow.h"
#include "addressbook.h" #include "addressbook.h"
#include "viewalladdresses.h" #include "viewalladdresses.h"
@@ -15,6 +17,8 @@
#include "version.h" #include "version.h"
#include "connection.h" #include "connection.h"
#include "ui_contactrequest.h" #include "ui_contactrequest.h"
#include "ui_requestContactDialog.h"
#include "chatmodel.h"
#include "requestdialog.h" #include "requestdialog.h"
#include "websockets.h" #include "websockets.h"
#include <QRegularExpression> #include <QRegularExpression>
@@ -1006,22 +1010,21 @@ void MainWindow::setupchatTab() {
// Is request Contact checked? // Is request Contact checked?
if (ui->request->isChecked()) { // if (ui->request->isChecked()) {
QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::ContactRequest); // QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::ContactRequest);
// qDebug() <<ui->request->isChecked()->text(); // qDebug() <<ui->request->isChecked()->text();
}else{ // }else{
QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::sendChatButton); QObject::connect(ui->sendChatButton, &QPushButton::clicked, this, &MainWindow::sendChatButton);
} // }
QObject::connect(ui->safeContactRequest, &QPushButton::clicked, this, &MainWindow::addContact); QObject::connect(ui->safeContactRequest, &QPushButton::clicked, this, &MainWindow::addContact);
///////// Set selected Zaddr for Chat with Klick
///////// Set selected Zaddr for Chat with Doubleklick
QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () { QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () {
@@ -1045,7 +1048,6 @@ void MainWindow::setupchatTab() {
} }
ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QPlainTextEdit(parent) { ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QPlainTextEdit(parent) {
QObject::connect(this, &QPlainTextEdit::textChanged, this, &ChatMemoEdit::updateDisplay); QObject::connect(this, &QPlainTextEdit::textChanged, this, &ChatMemoEdit::updateDisplay);
} }

View File

@@ -6,6 +6,7 @@
#include "logger.h" #include "logger.h"
#include "recurring.h" #include "recurring.h"
// Forward declare to break circular dependency. // Forward declare to break circular dependency.
class Controller; class Controller;
class Settings; class Settings;
@@ -61,6 +62,10 @@ public:
void updateLabels(); void updateLabels();
void updateTAddrCombo(bool checked); void updateTAddrCombo(bool checked);
// void setChatItem(ChatItem* item);
//void ChatItem* getChatItem();
// Disable recurring on mainnet // Disable recurring on mainnet
void disableRecurring(); void disableRecurring();
@@ -74,6 +79,8 @@ public:
QLabel* statusIcon; QLabel* statusIcon;
QLabel* loadingLabel; QLabel* loadingLabel;
QWidget* hushdtab; QWidget* hushdtab;
//ChatItem* currentChatItem;
Logger* logger; Logger* logger;
@@ -84,7 +91,9 @@ public slots:
void slot_change_theme(const QString& themeName); void slot_change_theme(const QString& themeName);
void slot_change_currency(const QString& currencyName); void slot_change_currency(const QString& currencyName);
private: private:
void closeEvent(QCloseEvent* event); void closeEvent(QCloseEvent* event);
void setupSendTab(); void setupSendTab();
@@ -93,6 +102,7 @@ private:
void setupBalancesTab(); void setupBalancesTab();
void setuphushdTab(); void setuphushdTab();
void setupchatTab(); void setupchatTab();
void renderContactRequest();
void setLenDisplayLabel(QLabel* label); void setLenDisplayLabel(QLabel* label);
void updateContacts(); void updateContacts();
@@ -147,6 +157,9 @@ private:
void restoreSavedStates(); void restoreSavedStates();
bool eventFilter(QObject *object, QEvent *event); bool eventFilter(QObject *object, QEvent *event);
bool uiPaymentsReady = false; bool uiPaymentsReady = false;
QString pendingURIPayment; QString pendingURIPayment;
@@ -154,6 +167,7 @@ private:
WormholeClient* wormhole = nullptr; WormholeClient* wormhole = nullptr;
Controller* rpc = nullptr; Controller* rpc = nullptr;
QCompleter* labelCompleter = nullptr; QCompleter* labelCompleter = nullptr;
QRegExpValidator* amtValidator = nullptr; QRegExpValidator* amtValidator = nullptr;
QRegExpValidator* feesValidator = nullptr; QRegExpValidator* feesValidator = nullptr;

View File

@@ -1332,9 +1332,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>40</y> <y>90</y>
<width>341</width> <width>341</width>
<height>601</height> <height>551</height>
</rect> </rect>
</property> </property>
<property name="mouseTracking"> <property name="mouseTracking">
@@ -1354,7 +1354,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>20</y> <y>60</y>
<width>341</width> <width>341</width>
<height>20</height> <height>20</height>
</rect> </rect>
@@ -1392,10 +1392,10 @@
<widget class="QPushButton" name="sendChatButton"> <widget class="QPushButton" name="sendChatButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>720</x> <x>1170</x>
<y>640</y> <y>560</y>
<width>114</width> <width>91</width>
<height>25</height> <height>81</height>
</rect> </rect>
</property> </property>
<property name="baseSize"> <property name="baseSize">
@@ -1404,33 +1404,28 @@
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="text"> <property name="autoFillBackground">
<string>Send</string>
</property>
<property name="flat">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> <property name="text">
<widget class="QPushButton" name="safeContactRequest"> <string/>
<property name="geometry">
<rect>
<x>30</x>
<y>640</y>
<width>211</width>
<height>25</height>
</rect>
</property> </property>
<property name="baseSize"> <property name="icon">
<iconset>
<normalon>:/icons/res/send-new-white.png</normalon>
</iconset>
</property>
<property name="iconSize">
<size> <size>
<width>100</width> <width>61</width>
<height>0</height> <height>62</height>
</size> </size>
</property> </property>
<property name="text"> <property name="default">
<string>Add conversation contact</string> <bool>false</bool>
</property> </property>
<property name="flat"> <property name="flat">
<bool>false</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="contactNameMemo_3"> <widget class="QLabel" name="contactNameMemo_3">
@@ -1484,7 +1479,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>340</x> <x>340</x>
<y>650</y> <y>640</y>
<width>261</width> <width>261</width>
<height>23</height> <height>23</height>
</rect> </rect>
@@ -1493,6 +1488,73 @@
<string>Is this message a contact request?</string> <string>Is this message a contact request?</string>
</property> </property>
</widget> </widget>
<widget class="QPushButton" name="safeContactRequest">
<property name="geometry">
<rect>
<x>90</x>
<y>0</y>
<width>71</width>
<height>61</height>
</rect>
</property>
<property name="baseSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../application.qrc">
<normaloff>:/icons/res/add_contact.png</normaloff>:/icons/res/add_contact.png</iconset>
</property>
<property name="iconSize">
<size>
<width>43</width>
<height>49</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="pushContact">
<property name="geometry">
<rect>
<x>170</x>
<y>0</y>
<width>71</width>
<height>61</height>
</rect>
</property>
<property name="baseSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../application.qrc">
<normaloff>:/icons/res/notification.png</normaloff>:/icons/res/notification.png</iconset>
</property>
<property name="iconSize">
<size>
<width>43</width>
<height>49</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</widget> </widget>
</widget> </widget>
</item> </item>
@@ -1667,7 +1729,7 @@
<customwidget> <customwidget>
<class>AddressCombo</class> <class>AddressCombo</class>
<extends>QComboBox</extends> <extends>QComboBox</extends>
<header>addresscombo.h</header> <header location="global">addresscombo.h</header>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>QRCodeLabel</class> <class>QRCodeLabel</class>

355
src/requestContactDialog.ui Normal file
View File

@@ -0,0 +1,355 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>requestDialog</class>
<widget class="QDialog" name="requestDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1011</width>
<height>503</height>
</rect>
</property>
<property name="windowTitle">
<string>Incoming contact request</string>
</property>
<widget class="QListView" name="requestContact">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>256</width>
<height>461</height>
</rect>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="editTriggers">
<set>QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
</property>
<property name="alternatingRowColors">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
</widget>
<widget class="QListView" name="requestMemo">
<property name="geometry">
<rect>
<x>263</x>
<y>9</y>
<width>741</width>
<height>271</height>
</rect>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContents</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="modelColumn">
<number>0</number>
</property>
<property name="uniformItemSizes">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_8">
<property name="geometry">
<rect>
<x>276</x>
<y>296</y>
<width>101</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Request from :</string>
</property>
</widget>
<widget class="QLineEdit" name="requestZaddr">
<property name="geometry">
<rect>
<x>393</x>
<y>296</y>
<width>601</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_9">
<property name="geometry">
<rect>
<x>276</x>
<y>327</y>
<width>30</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Cid :</string>
</property>
</widget>
<widget class="QLineEdit" name="requestCID">
<property name="geometry">
<rect>
<x>393</x>
<y>327</y>
<width>601</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>276</x>
<y>358</y>
<width>71</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>My Zaddr :</string>
</property>
</widget>
<widget class="QLineEdit" name="requestMyAddr">
<property name="geometry">
<rect>
<x>393</x>
<y>358</y>
<width>601</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>276</x>
<y>389</y>
<width>68</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Nickname</string>
</property>
</widget>
<widget class="QLineEdit" name="requestLabel">
<property name="geometry">
<rect>
<x>393</x>
<y>389</y>
<width>221</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>276</x>
<y>420</y>
<width>228</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;right&quot;&gt;Choose a avatar for your contact :&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QComboBox" name="comboBoxAvatar">
<property name="geometry">
<rect>
<x>510</x>
<y>420</y>
<width>106</width>
<height>25</height>
</rect>
</property>
<item>
<property name="text">
<string>Stag</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/Stag.png</activeon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Elsa</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/res/Elsa.png</normalon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Denio</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/Denio.png</activeon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Duke</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/Duke.png</activeon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Yoda</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/Yoda.png</activeon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Berg</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/Berg.png</activeon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Sharpee</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/Sharpee.png</activeon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Garfield</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/Garfield.png</activeon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Snoopy</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/Snoopy.png</activeon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Popey</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/Popey.png</activeon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Pinguin</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/Pinguin.png</activeon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Mickey</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/Mickey.png</activeon>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>SDLogo</string>
</property>
<property name="icon">
<iconset>
<activeon>:/icons/res/sdlogo2.png</activeon>
</iconset>
</property>
</item>
</widget>
<widget class="QPushButton" name="cancel">
<property name="geometry">
<rect>
<x>300</x>
<y>470</y>
<width>80</width>
<height>25</height>
</rect>
</property>
<property name="baseSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Cancel</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>400</x>
<y>470</y>
<width>101</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Add Contact</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>