Merge pull request #2 from DenioD/chat

Chat
This commit is contained in:
Strider
2020-05-03 17:25:18 +02:00
committed by GitHub
10 changed files with 348 additions and 219 deletions

View File

@@ -8,6 +8,9 @@
<file>res/paymentreq.gif</file> <file>res/paymentreq.gif</file>
<file>res/icon.ico</file> <file>res/icon.ico</file>
<file>res/mail.png</file> <file>res/mail.png</file>
<file>res/darkwing.png</file>
<file>res/sdlogo.png</file>
<file>res/sdlogo2.png</file>
</qresource> </qresource>
<qresource prefix="/img"> <qresource prefix="/img">
<file>res/hushdlogo.gif</file> <file>res/hushdlogo.gif</file>

View File

@@ -10,6 +10,7 @@
#include <QUuid> #include <QUuid>
#include <bits/stdc++.h> #include <bits/stdc++.h>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <QtWidgets>
using namespace std; using namespace std;
using namespace boost; using namespace boost;
@@ -80,11 +81,11 @@ void ChatModel::showMessages()
{ {
for(auto &c : this->chatItems) for(auto &c : this->chatItems)
{ {
qDebug() << "[" << c.second.getTimestamp() << "] " << "<" << c.second.getAddress() << "> :" << c.second.getMemo(); qDebug() << c.second.toChatLine();
} }
} }
void ChatModel::renderChatBox(Ui::MainWindow* ui, QListWidget &view) void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView &view)
{ {
/*for(auto &c : this->chatItems) /*for(auto &c : this->chatItems)
{ {
@@ -94,66 +95,60 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListWidget &view)
//todo render items to view //todo render items to view
} }
void ChatModel::renderChatBox(Ui::MainWindow* ui, QListWidget *view) void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
{ {
while(view->count() > 0)
QStandardItemModel* chat = new QStandardItemModel();
for (auto &c : this->chatItems)
for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
{ {
view->takeItem(0);
}
QString line = "";
for(auto &c : this->chatItems){
QDateTime myDateTime;
myDateTime.setTime_t(c.second.getTimestamp());
//////Render only Memos for selected contacts. Do not render empty Memos //// Render only memos where cid=cid //////Render only Memos for selected contacts. Do not render empty Memos //// Render only memos where cid=cid
/// if (
if ((ui->ContactZaddr->text().trimmed() == c.second.getAddress()) && (c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false)) { (ui->contactNameMemo->text().trimmed() == c.second.getContact()) &&
// if (c.second.getMemo.find()) (c.second.getMemo().startsWith("{") == false) &&
line += QString("[") + myDateTime.toString("dd.MM.yyyy hh:mm:ss ") + QString("] "); (c.second.getMemo().isEmpty() == false) &&
line += QString("<") + QString("Outgoing") + QString("> :\n"); (p.getPartnerAddress() == c.second.getAddress())
line += QString(c.second.getMemo()) + QString("\n");
view->addItem(line); )
line =""; {
QStandardItem* Items = new QStandardItem(c.second.toChatLine());
Items->setData("Incoming", Qt::UserRole +1);
chat->appendRow(Items);
ui->listChat->setModel(chat);
ui->listChat->setItemDelegate(new ListViewDelegate());
}
////////////////////////////////// Todo : Render green checkmark for contacts if cid = cid - We have to search for cid in txid/cid list if (
// QString cid = c.second.getCid(); (ui->contactNameMemo->text().trimmed() == c.second.getContact()) &&
(c.second.getMemo().startsWith("{") == false) &&
(c.second.getMemo().isEmpty() == false) &&
(p.getMyAddress() == c.second.getAddress())
)
{
QStandardItem* Items1 = new QStandardItem(c.second.toChatLine());
Items1->setData("Outgoing", Qt::UserRole +1);
chat->appendRow(Items1);
} }
if ((ui->MyZaddr->text().trimmed() == c.second.getAddress()) && (c.second.getMemo().startsWith("{") == false) && (c.second.getMemo().isEmpty() == false)){ ui->listChat->setModel(chat);
for(auto &p : AddressBook::getInstance()->getAllAddressLabels()){ ui->listChat->setItemDelegate(new ListViewDelegate());
if ((ui->checkBox->isChecked() == true) && (p.getCid() != c.second.getCid()))
{
}else{
// line+= QString("[") + "Warning. Not verified!" + QString("]");
line += QString("[") + myDateTime.toString("dd.MM.yyyy hh:mm:ss ") + QString("] ");
line += QString("<") + QString("incoming") + QString("> :\n");
line += QString(c.second.getMemo()) + QString("\n");
view->addItem(line);
line ="";
}
}
} }
}
} }
@@ -220,7 +215,7 @@ Tx MainWindow::createTxFromChatPage() {
for(auto &c : AddressBook::getInstance()->getAllAddressLabels()) for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
if (ui->ContactZaddr->text().trimmed() == c.getPartnerAddress()) { if (ui->contactNameMemo->text().trimmed() == c.getName()) {
QString cid = c.getCid(); QString cid = c.getCid();
QString myAddr = c.getMyAddress(); QString myAddr = c.getMyAddress();
@@ -230,6 +225,7 @@ Tx MainWindow::createTxFromChatPage() {
QString hmemo= createHeaderMemo(type,cid,myAddr); QString hmemo= createHeaderMemo(type,cid,myAddr);
QString memo = ui->memoTxtChat->toPlainText().trimmed(); QString memo = ui->memoTxtChat->toPlainText().trimmed();
// ui->memoSizeChat->setLenDisplayLabel();// Todo -> activate lendisplay for chat // ui->memoSizeChat->setLenDisplayLabel();// Todo -> activate lendisplay for chat
tx.toAddrs.push_back(ToFields{addr, amt, hmemo}) ; tx.toAddrs.push_back(ToFields{addr, amt, hmemo}) ;
@@ -247,6 +243,9 @@ Tx MainWindow::createTxFromChatPage() {
} }
void MainWindow::sendChatButton() { void MainWindow::sendChatButton() {
////////////////////////////Todo: Check if a Contact is selected////////// ////////////////////////////Todo: Check if a Contact is selected//////////
// Create a Tx from the values on the send tab. Note that this Tx object // Create a Tx from the values on the send tab. Note that this Tx object
@@ -255,7 +254,7 @@ void MainWindow::sendChatButton() {
// Memos can only be used with zAddrs. So check that first // Memos can only be used with zAddrs. So check that first
// for(auto &c : AddressBook::getInstance()->getAllAddressLabels()) // for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
if (ui->ContactZaddr->text().trimmed().isEmpty() || ui->memoTxtChat->toPlainText().trimmed().isEmpty()) { if (ui->contactNameMemo->text().trimmed().isEmpty() || ui->memoTxtChat->toPlainText().trimmed().isEmpty()) {
// auto addr = ""; // auto addr = "";
// if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) { // if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) {
@@ -391,7 +390,7 @@ Tx MainWindow::createTxForSafeContactRequest() {
for(auto &c : AddressBook::getInstance()->getAllAddressLabels()) for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
if (ui->ContactZaddr->text().trimmed() == c.getName()) { if (ui->contactNameMemo->text().trimmed() == c.getName()) {
// QString cid = c.getCid(); // This has to be a new cid for the contact // QString cid = c.getCid(); // This has to be a new cid for the contact
// QString myAddr = c.getMyAddress(); // this should be a new HushChat zaddr // QString myAddr = c.getMyAddress(); // this should be a new HushChat zaddr

View File

@@ -1,15 +1,162 @@
#ifndef CHATMODEL_H #ifndef CHATMODEL_H
#define CHATMODEL_H #define CHATMODEL_H
#include <QString> #include <QString>
#include <QStandardItemModel>
#include <QAbstractItemDelegate>
#include <QPainter>
#include <map> #include <map>
#include <vector> #include <vector>
#include <QListWidget> #include <QListView>
#include "precompiled.h" #include "precompiled.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "controller.h" #include "controller.h"
#include "settings.h" #include "settings.h"
#include "camount.h" #include "camount.h"
class ListViewDelegate : public QAbstractItemDelegate
{
int d_radius;
int d_toppadding;
int d_bottompadding;
int d_leftpadding;
int d_rightpadding;
int d_verticalmargin;
int d_horizontalmargin;
int d_pointerwidth;
int d_pointerheight;
float d_widthfraction;
public:
inline ListViewDelegate(QObject *parent = nullptr);
protected:
inline void paint(QPainter *painter, QStyleOptionViewItem const &option, QModelIndex const &index) const;
inline QSize sizeHint(QStyleOptionViewItem const &option, QModelIndex const &index) const;
};
inline ListViewDelegate::ListViewDelegate(QObject *parent): QAbstractItemDelegate(parent), d_radius(5), d_toppadding(5), d_bottompadding(3), d_leftpadding(5), d_rightpadding(5), d_verticalmargin(15), d_horizontalmargin(10), d_pointerwidth(10), d_pointerheight(17), d_widthfraction(.7)
{
}
inline void ListViewDelegate::paint(QPainter *painter, QStyleOptionViewItem const &option, QModelIndex const &index) const
{
QTextDocument bodydoc;
QTextOption textOption(bodydoc.defaultTextOption());
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
bodydoc.setDefaultTextOption(textOption);
bodydoc.setDefaultFont(QFont("Roboto", 12));
QString bodytext(index.data(Qt::DisplayRole).toString());
bodydoc.setHtml(bodytext);
qreal contentswidth = option.rect.width() * d_widthfraction - d_horizontalmargin - d_pointerwidth - d_leftpadding - d_rightpadding;
bodydoc.setTextWidth(contentswidth);
qreal bodyheight = bodydoc.size().height();
bool outgoing = index.data(Qt::UserRole + 1).toString() == "Outgoing";
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
// uncomment to see the area provided to paint this item
//painter->drawRect(option.rect);
painter->translate(option.rect.left() + d_horizontalmargin, option.rect.top() + ((index.row() == 0) ? d_verticalmargin : 0));
// background color for chat bubble
QColor bgcolor("#535353");
if (outgoing)
bgcolor = "#eeeeee";
// create chat bubble
QPainterPath pointie;
// left bottom
pointie.moveTo(0, bodyheight + d_toppadding + d_bottompadding);
// right bottom
pointie.lineTo(0 + contentswidth + d_pointerwidth + d_leftpadding + d_rightpadding - d_radius,
bodyheight + d_toppadding + d_bottompadding);
pointie.arcTo(0 + contentswidth + d_pointerwidth + d_leftpadding + d_rightpadding - 2 * d_radius,
bodyheight + d_toppadding + d_bottompadding - 2 * d_radius,
2 * d_radius, 2 * d_radius, 270, 90);
// right top
pointie.lineTo(0 + contentswidth + d_pointerwidth + d_leftpadding + d_rightpadding, 0 + d_radius);
pointie.arcTo(0 + contentswidth + d_pointerwidth + d_leftpadding + d_rightpadding - 2 * d_radius, 0,
2 * d_radius, 2 * d_radius, 0, 90);
// left top
pointie.lineTo(0 + d_pointerwidth + d_radius, 0);
pointie.arcTo(0 + d_pointerwidth, 0, 2 * d_radius, 2 * d_radius, 90, 90);
// left bottom almost (here is the pointie)
pointie.lineTo(0 + d_pointerwidth, bodyheight + d_toppadding + d_bottompadding - d_pointerheight);
pointie.closeSubpath();
// rotate bubble for outgoing messages
if (outgoing)
{
painter->translate(option.rect.width() - pointie.boundingRect().width() - d_horizontalmargin - d_pointerwidth, 0);
painter->translate(pointie.boundingRect().center());
painter->rotate(180);
painter->translate(-pointie.boundingRect().center());
}
// now paint it!
painter->setPen(QPen(bgcolor));
painter->drawPath(pointie);
painter->fillPath(pointie, QBrush(bgcolor));
// rotate back or painter is going to paint the text rotated...
if (outgoing)
{
painter->translate(pointie.boundingRect().center());
painter->rotate(-180);
painter->translate(-pointie.boundingRect().center());
}
// set text color used to draw message body
QAbstractTextDocumentLayout::PaintContext ctx;
if (outgoing)
ctx.palette.setColor(QPalette::Text, QColor("black"));
else
ctx.palette.setColor(QPalette::Text, QColor("white"));
// draw body text
painter->translate((outgoing ? 0 : d_pointerwidth) + d_leftpadding, 0);
bodydoc.documentLayout()->draw(painter, ctx);
painter->restore();
}
inline QSize ListViewDelegate::sizeHint(QStyleOptionViewItem const &option, QModelIndex const &index) const
{
QTextDocument bodydoc;
QTextOption textOption(bodydoc.defaultTextOption());
textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
bodydoc.setDefaultTextOption(textOption);
bodydoc.setDefaultFont(QFont("Roboto", 12));
QString bodytext(index.data(Qt::DisplayRole).toString());
bodydoc.setHtml(bodytext);
// the width of the contents are the (a fraction of the window width) minus (margins + padding + width of the bubble's tail)
qreal contentswidth = option.rect.width() * d_widthfraction - d_horizontalmargin - d_pointerwidth - d_leftpadding - d_rightpadding;
// set this available width on the text document
bodydoc.setTextWidth(contentswidth);
QSize size(bodydoc.idealWidth() + d_horizontalmargin + d_pointerwidth + d_leftpadding + d_rightpadding,
bodydoc.size().height() + d_bottompadding + d_toppadding + d_verticalmargin + 1); // I dont remember why +1, haha, might not be necessary
if (index.row() == 0) // have extra margin at top of first item
size += QSize(0, d_verticalmargin);
return size;
}
class ChatItem class ChatItem
{ {
private: private:
@@ -117,6 +264,15 @@ class ChatItem
_outgoing = true; _outgoing = true;
} }
QString toChatLine()
{
QDateTime myDateTime;
myDateTime.setTime_t(_timestamp);
QString line = QString("[") + myDateTime.toString("d.M.yy hh:mm") + QString("] ") ;
line += QString("") + QString(_memo) + QString("\n\n");
return line;
}
~ChatItem() ~ChatItem()
{ {
/*delete timestamp; /*delete timestamp;
@@ -145,8 +301,8 @@ class ChatModel
void setItems(std::map<QString, ChatItem> items); void setItems(std::map<QString, ChatItem> items);
QString zaddr(); QString zaddr();
void setItems(std::vector<ChatItem> items); void setItems(std::vector<ChatItem> items);
void renderChatBox(Ui::MainWindow* ui, QListWidget &view); void renderChatBox(Ui::MainWindow* ui, QListView &view);
void renderChatBox(Ui::MainWindow* ui, QListWidget *view); void renderChatBox(Ui::MainWindow* ui, QListView *view);
void showMessages(); void showMessages();
void clear(); void clear();
void addMessage(ChatItem item); void addMessage(ChatItem item);

View File

@@ -2,15 +2,22 @@
#include "addressbook.h" #include "addressbook.h"
#include "mainwindow.h" #include "mainwindow.h"
void ContactModel::renderContactList(QListWidget* view) void ContactModel::renderContactList(QListView* view)
{ { // QStandardItem(const QIcon & icon, const QString & text)
while(view->count() > 0) QStandardItemModel* contact = new QStandardItemModel();
{ //}
view->takeItem(0);
}
for(auto &c : AddressBook::getInstance()->getAllAddressLabels()) for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
{ {
view->addItem(c.getName());
//QStandardItem* Items = new QStandardItem();
QStandardItem* Items1 = new QStandardItem(QIcon("res/darkwing.png"),c.getName());
// contact->appendRow(Items);
contact->appendRow(Items1);
view->setModel(contact);
view->setIconSize(QSize(80,100));
view->setUniformItemSizes(true);
view->setDragDropMode(QAbstractItemView::DropOnly);;
} }

View File

@@ -74,7 +74,7 @@ class ContactModel
{ {
public: public:
ContactModel() {} ContactModel() {}
void renderContactList(QListWidget* view); void renderContactList(QListView* view);
}; };
#endif #endif

View File

@@ -881,24 +881,34 @@ void Controller::refreshTransactions() {
memo = QString::fromStdString(o["memo"]); memo = QString::fromStdString(o["memo"]);
QString cid; QString cid;
QString contact;
for(auto &c : AddressBook::getInstance()->getAllAddressLabels()) for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
if ((ui->ContactZaddr->text().trimmed() == c.getPartnerAddress()) || (ui->MyZaddr->text().trimmed() == c.getMyAddress())) { {
if (ui->contactNameMemo->text().trimmed() == c.getName()) {
cid = c.getCid(); cid = c.getCid();
}else {cid = "";} }else {cid = "";}
if (address == c.getPartnerAddress()){
contact = c.getName();
}else{ contact = "";}
ChatItem item = ChatItem( ChatItem item = ChatItem(
datetime, datetime,
address, address,
QString(""), contact,
memo, memo,
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;
@@ -912,7 +922,6 @@ void Controller::refreshTransactions() {
}else{ }else{
addresses.push_back(item.address); } addresses.push_back(item.address); }
} }
@@ -958,17 +967,33 @@ void Controller::refreshTransactions() {
cid = ""; cid = "";
} }
QString contact;
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
// for (auto &p : this->chatItems)
{
if (address == c.getMyAddress()){
contact = c.getName();
qDebug()<< "Addressbuch Addresse: " << c.getMyAddress();
qDebug()<< "Addresse: " << address;
}else{ contact = "ELSE";}
ChatItem item = ChatItem( ChatItem item = ChatItem(
datetime, datetime,
address, address,
QString(""), contact,
memo, memo,
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
); );
// qDebug()<< "Message CID: " << cid; // qDebug()<< "KontaktName: " << contact;
chatModel->addMessage(item);
// qDebug()<< "Addressbuch Addresse: " << c.getMyAddress();
chatModel->addMessage(item);
}
} }
} }
@@ -990,7 +1015,7 @@ void Controller::refreshTransactions() {
// Update model data, which updates the table view // Update model data, which updates the table view
transactionsTableModel->replaceData(txdata); transactionsTableModel->replaceData(txdata);
chatModel->renderChatBox(ui, ui->listChatMemo); chatModel->renderChatBox(ui, ui->listChat);
refreshContacts( refreshContacts(
ui->listContactWidget ui->listContactWidget
@@ -998,13 +1023,13 @@ void Controller::refreshTransactions() {
}); });
} }
void Controller::refreshChat(QListWidget *listWidget) void Controller::refreshChat(QListView *listWidget)
{ {
chatModel->renderChatBox(ui, listWidget); chatModel->renderChatBox(ui, listWidget);
} }
void Controller::refreshContacts(QListWidget *listWidget) void Controller::refreshContacts(QListView *listWidget)
{ {
contactModel->renderContactList(listWidget); contactModel->renderContactList(listWidget);
} }

View File

@@ -72,8 +72,8 @@ public:
void refreshGBPCAP(); void refreshGBPCAP();
void refreshAUDCAP(); void refreshAUDCAP();
void refreshChat(QListWidget *listWidget); void refreshChat(QListView *listWidget);
void refreshContacts(QListWidget *listWidget); void refreshContacts(QListView *listWidget);
void executeStandardUITransaction(Tx tx); void executeStandardUITransaction(Tx tx);

View File

@@ -39,8 +39,12 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this); ui->setupUi(this);
ui->checkBox->setChecked(true); // ui->checkBox->setChecked(true);
logger = new Logger(this, QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite-wallet.log")); logger = new Logger(this, QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite-wallet.log"));
ui->memoTxtChat->setAutoFillBackground(false);
// ui->memoTxtChat->setStyleSheet(QString::fromUtf8("background-color: rgb(224, 224, 224);"));
ui->memoTxtChat->setPlaceholderText("Send Message");
ui->memoTxtChat->setTextColor(Qt::white);
// Status Bar // Status Bar
setupStatusBar(); setupStatusBar();
@@ -901,6 +905,17 @@ void MainWindow::setupTransactionsTab() {
}); });
// Set up context menu on transactions tab // Set up context menu on transactions tab
auto theme = Settings::getInstance()->get_theme_name();
if (theme == "dark"){
ui->listChat->setStyleSheet("background-image: url(res/sdlogo.png) ;background-attachment: fixed ;background-position: center center ;background-repeat: no-repeat;background-size: cover");
}else{ui->listChat->setStyleSheet("background-image: url(res/sdlogo2.png) ;background-attachment: fixed ;background-position: center center ;background-repeat: no-repeat;background-size: cover");}
ui->listChat->setResizeMode(QListView::Adjust);
ui->listChat->setWordWrap(true);
ui->listChat->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
ui->listChat->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->listChat->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->listChat->setMinimumSize(200,350);
ui->listChat->show();
ui->transactionsTable->setContextMenuPolicy(Qt::CustomContextMenu); ui->transactionsTable->setContextMenuPolicy(Qt::CustomContextMenu);
// Table right click // Table right click
QObject::connect(ui->transactionsTable, &QTableView::customContextMenuRequested, [=] (QPoint pos) { QObject::connect(ui->transactionsTable, &QTableView::customContextMenuRequested, [=] (QPoint pos) {
@@ -994,19 +1009,24 @@ void MainWindow::setupchatTab() {
QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () { QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () {
QModelIndex index = ui->listContactWidget->currentIndex(); QModelIndex index = ui->listContactWidget->currentIndex();
QString label_contact = index.data(Qt::DisplayRole).toString(); QString label_contact = index.data(Qt::DisplayRole).toString();
for(auto &p : AddressBook::getInstance()->getAllAddressLabels()) for(auto &p : AddressBook::getInstance()->getAllAddressLabels())
if (label_contact == p.getName()) { if (label_contact == p.getName()) {
ui->ContactZaddr->setText(p.getPartnerAddress()); // ui->ContactZaddr->setText(p.getPartnerAddress());
ui->MyZaddr->setText(p.getMyAddress()); // ui->MyZaddr->setText(p.getMyAddress());
ui->contactNameMemo->setText(p.getName()); ui->contactNameMemo->setText(p.getName());
ui->contactCid->setText(p.getCid()); ui->memoTxtChat->clear();
rpc->refresh(true); rpc->refresh(true);
// updateChat();
} }
}); });
} }
ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QPlainTextEdit(parent) { ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QPlainTextEdit(parent) {
@@ -1052,13 +1072,14 @@ void ChatMemoEdit::setSendChatButton(QPushButton* button) {
void MainWindow::updateChat() void MainWindow::updateChat()
{ {
rpc->refreshChat(ui->listChatMemo); rpc->refreshChat(ui->listChat);
rpc->refresh(true);
} }
void MainWindow::updateContacts() void MainWindow::updateContacts()
{ {
qDebug() << "Called MainWindow::updateContacts()"; //rpc->refreshContacts(ui->listContactWidget);
rpc->refreshContacts(ui->listContactWidget);
} }
void MainWindow::addNewZaddr(bool sapling) { void MainWindow::addNewZaddr(bool sapling) {

View File

@@ -55,6 +55,7 @@ public:
void createWebsocket(QString wormholecode); void createWebsocket(QString wormholecode);
void stopWebsocket(); void stopWebsocket();
void balancesReady(); void balancesReady();
void payhushURI(QString uri = "", QString myAddr = ""); void payhushURI(QString uri = "", QString myAddr = "");
@@ -92,8 +93,9 @@ private:
void setupBalancesTab(); void setupBalancesTab();
void setuphushdTab(); void setuphushdTab();
void setupchatTab(); void setupchatTab();
void updateChat();
void updateContacts(); void updateContacts();
void updateChat();
void setupSettingsModal(); void setupSettingsModal();
void setupStatusBar(); void setupStatusBar();

View File

@@ -1328,7 +1328,7 @@
<attribute name="title"> <attribute name="title">
<string>HushChat</string> <string>HushChat</string>
</attribute> </attribute>
<widget class="QListWidget" name="listContactWidget"> <widget class="QListView" name="listContactWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@@ -1351,21 +1351,24 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;Hushchat Contactlist&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;Hushchat Contactlist&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
<widget class="MemoEdit" name="memoTxtChat"> <widget class="QTextEdit" name="memoTxtChat">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>340</x> <x>340</x>
<y>410</y> <y>460</y>
<width>921</width> <width>921</width>
<height>128</height> <height>131</height>
</rect> </rect>
</property> </property>
<property name="styleSheet">
<string notr="true">font: 11pt &quot;Noto Color Emoji&quot;;</string>
</property>
</widget> </widget>
<widget class="QLabel" name="memoSizeChat"> <widget class="QLabel" name="memoSizeChat">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>1200</x> <x>1190</x>
<y>540</y> <y>610</y>
<width>47</width> <width>47</width>
<height>17</height> <height>17</height>
</rect> </rect>
@@ -1390,36 +1393,11 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
<widget class="QListWidget" name="listChatMemo">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>340</x>
<y>40</y>
<width>921</width>
<height>371</height>
</rect>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="defaultDropAction">
<enum>Qt::IgnoreAction</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::NoSelection</enum>
</property>
</widget>
<widget class="QPushButton" name="sendChatButton"> <widget class="QPushButton" name="sendChatButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>1130</x> <x>710</x>
<y>590</y> <y>610</y>
<width>114</width> <width>114</width>
<height>25</height> <height>25</height>
</rect> </rect>
@@ -1437,45 +1415,6 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="label_42">
<property name="geometry">
<rect>
<x>350</x>
<y>550</y>
<width>81</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Send To :</string>
</property>
</widget>
<widget class="QLabel" name="ContactName">
<property name="geometry">
<rect>
<x>350</x>
<y>580</y>
<width>81</width>
<height>17</height>
</rect>
</property>
<property name="text">
<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>
</widget>
<widget class="QLabel" name="ContactZaddr">
<property name="geometry">
<rect>
<x>420</x>
<y>550</y>
<width>691</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="safeContactRequest"> <widget class="QPushButton" name="safeContactRequest">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@@ -1498,58 +1437,6 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="MyZaddr">
<property name="geometry">
<rect>
<x>420</x>
<y>580</y>
<width>691</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="contactCid">
<property name="geometry">
<rect>
<x>720</x>
<y>20</y>
<width>331</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QLabel" name="contactNameMemo_2">
<property name="geometry">
<rect>
<x>590</x>
<y>20</y>
<width>131</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;Conversation ID:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBox">
<property name="geometry">
<rect>
<x>980</x>
<y>0</y>
<width>271</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Render only authenticated messages</string>
</property>
</widget>
<widget class="QLabel" name="contactNameMemo_3"> <widget class="QLabel" name="contactNameMemo_3">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@@ -1563,6 +1450,40 @@
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;Contact Name:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;Contact Name:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
</widget> </widget>
<widget class="QListView" name="listChat">
<property name="geometry">
<rect>
<x>340</x>
<y>40</y>
<width>921</width>
<height>421</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> </widget>
</widget> </widget>
</item> </item>
@@ -1734,11 +1655,6 @@
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets> <customwidgets>
<customwidget>
<class>MemoEdit</class>
<extends>QPlainTextEdit</extends>
<header>memoedit.h</header>
</customwidget>
<customwidget> <customwidget>
<class>AddressCombo</class> <class>AddressCombo</class>
<extends>QComboBox</extends> <extends>QComboBox</extends>