Browse Source

dont show context menu without contact #94

pull/130/head
DenioD 4 years ago
parent
commit
cdb1277b91
  1. 1
      src/Chat/Helper/ChatDelegator.h
  2. 1
      src/Model/ChatItem.cpp
  3. 14
      src/chatmodel.cpp
  4. 29
      src/controller.cpp
  5. 51
      src/mainwindow.cpp

1
src/Chat/Helper/ChatDelegator.h

@ -56,7 +56,6 @@ inline void ListViewDelegate::paint(QPainter *painter, QStyleOptionViewItem cons
qreal bodyheight = bodydoc.size().height(); qreal bodyheight = bodydoc.size().height();
int outgoing = index.data(Qt::UserRole + 1).toInt(); int outgoing = index.data(Qt::UserRole + 1).toInt();
int outdate = index.data(Qt::UserRole + 1).toInt(); int outdate = index.data(Qt::UserRole + 1).toInt();
int indate = index.data(Qt::UserRole + 1).toInt();
painter->save(); painter->save();
painter->setRenderHint(QPainter::Antialiasing); painter->setRenderHint(QPainter::Antialiasing);

1
src/Model/ChatItem.cpp

@ -178,7 +178,6 @@ QString ChatItem::toChatLine()
} }
qDebug()<<_notarize;
QString line = QString("<small>") + myDateTime.toString("yyyy-MM-dd hh:mm"); QString line = QString("<small>") + myDateTime.toString("yyyy-MM-dd hh:mm");
line += QString(lock) + QString("</small>"); line += QString(lock) + QString("</small>");
line += QString("<p>") + _memo.toHtmlEscaped() + QString("</p>"); line += QString("<p>") + _memo.toHtmlEscaped() + QString("</p>");

14
src/chatmodel.cpp

@ -237,7 +237,7 @@ void MainWindow::renderContactRequest(){
return; return;
} }
qDebug()<<"Beginn kopiert" <<cid << addr << newLabel << myAddr;
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar); AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
rpc->refreshContacts( rpc->refreshContacts(
ui->listContactWidget); ui->listContactWidget);
@ -393,7 +393,6 @@ QString MainWindow::createHeaderMemo(QString type, QString cid, QString zaddr, Q
j.setObject(h); j.setObject(h);
header = j.toJson(); header = j.toJson();
qDebug() << "made header=" << header;
return header; return header;
} }
@ -449,7 +448,6 @@ Tx MainWindow::createTxFromChatPage() {
QString hashEncryptionKey = passphrase; QString hashEncryptionKey = passphrase;
int length = hashEncryptionKey.length(); int length = hashEncryptionKey.length();
qDebug()<<"Pubkey Erstellung :"<<pubkey;
////////////////Generate the secretkey for our message encryption ////////////////Generate the secretkey for our message encryption
@ -506,7 +504,6 @@ Tx MainWindow::createTxFromChatPage() {
QString headerbytes = QByteArray(reinterpret_cast<const char*>(header), crypto_secretstream_xchacha20poly1305_HEADERBYTES).toHex(); QString headerbytes = QByteArray(reinterpret_cast<const char*>(header), crypto_secretstream_xchacha20poly1305_HEADERBYTES).toHex();
QString publickeyAlice = QByteArray(reinterpret_cast<const char*>(pk), crypto_kx_PUBLICKEYBYTES).toHex(); QString publickeyAlice = QByteArray(reinterpret_cast<const char*>(pk), crypto_kx_PUBLICKEYBYTES).toHex();
qDebug()<<"Headerbyte erstellung : "<<headerbytes;
QString hmemo= createHeaderMemo(type,cid,myAddr,headerbytes,publickeyAlice); QString hmemo= createHeaderMemo(type,cid,myAddr,headerbytes,publickeyAlice);
@ -517,9 +514,6 @@ Tx MainWindow::createTxFromChatPage() {
tx.toAddrs.push_back(ToFields{addr, amt, hmemo}); tx.toAddrs.push_back(ToFields{addr, amt, hmemo});
tx.toAddrs.push_back(ToFields{addr, amt, memo}); tx.toAddrs.push_back(ToFields{addr, amt, memo});
qDebug() << "pushback chattx";
} }
} }
@ -527,7 +521,6 @@ Tx MainWindow::createTxFromChatPage() {
return tx; return tx;
qDebug() << "ChatTx created";
} }
void MainWindow::sendChat() { void MainWindow::sendChat() {
@ -538,8 +531,7 @@ void MainWindow::sendChat() {
// might not be valid yet. // might not be valid yet.
QString Name = ui->contactNameMemo->text(); QString Name = ui->contactNameMemo->text();
int sizename = Name.size();
qDebug()<< sizename;
if ((ui->contactNameMemo->text().isEmpty()) || (ui->memoTxtChat->toPlainText().trimmed().isEmpty())) { if ((ui->contactNameMemo->text().isEmpty()) || (ui->memoTxtChat->toPlainText().trimmed().isEmpty())) {
QMessageBox msg(QMessageBox::Critical, tr("You have to select a contact and insert a Memo"), QMessageBox msg(QMessageBox::Critical, tr("You have to select a contact and insert a Memo"),
@ -577,7 +569,6 @@ void MainWindow::sendChat() {
// abort the Tx // abort the Tx
return; return;
qDebug() << "Tx aborted";
} }
auto movie = new QMovie(this); auto movie = new QMovie(this);
@ -716,7 +707,6 @@ void::MainWindow::addContact()
request.myzaddr->setText(myAddr); request.myzaddr->setText(myAddr);
ui->listReceiveAddresses->insertItem(0, myAddr); ui->listReceiveAddresses->insertItem(0, myAddr);
ui->listReceiveAddresses->setCurrentIndex(0); ui->listReceiveAddresses->setCurrentIndex(0);
qDebug() << "new generated myAddr add Contact" << myAddr;
}); });
}catch(...) }catch(...)

29
src/controller.cpp

@ -1025,7 +1025,6 @@ void Controller::refreshTransactions() {
int encryptedMemoSize1 = ba.length(); int encryptedMemoSize1 = ba.length();
int headersize = ba1.length();
//////unsigned char* as message from QString //////unsigned char* as message from QString
#define MESSAGE2 (const unsigned char *) encryptedMemo #define MESSAGE2 (const unsigned char *) encryptedMemo
@ -1062,8 +1061,6 @@ void Controller::refreshTransactions() {
//////////////Give us the output of the decrypted message as debug to see if it was successfully //////////////Give us the output of the decrypted message as debug to see if it was successfully
qDebug()<<"OUT decrypt:" << memodecrypt;
ChatItem item = ChatItem( ChatItem item = ChatItem(
datetime, datetime,
@ -1084,26 +1081,7 @@ void Controller::refreshTransactions() {
updateUIBalances(); updateUIBalances();
} }
/*else{
ChatItem item = ChatItem(
datetime,
address,
QString(""),
memo,
QString(""),
QString(""),
cid,
txid,
confirmations,
true,
isNotarized,
false
);
DataStore::getChatDataStore()->setData(ChatIDGenerator::getInstance()->generateID(item), item);
updateUIBalances();
}*/
} }
items.push_back(TransactionItemDetail{address, amount, memo}); items.push_back(TransactionItemDetail{address, amount, memo});
@ -1153,7 +1131,6 @@ void Controller::refreshTransactions() {
QString publickey; QString publickey;
QString headerbytes; QString headerbytes;
QString cid; QString cid;
int position;
QString requestZaddr; QString requestZaddr;
bool isContact; bool isContact;
@ -1261,10 +1238,6 @@ void Controller::refreshTransactions() {
chatModel->addMemo(txid, headerbytes); chatModel->addMemo(txid, headerbytes);
}else{} }else{}
qDebug()<<"Position message :"<<position;
int lengthcid = cid.length();
QString passphrase = main->getPassword(); QString passphrase = main->getPassword();
QString hashEncryptionKey = passphrase; QString hashEncryptionKey = passphrase;
int length = hashEncryptionKey.length(); int length = hashEncryptionKey.length();

51
src/mainwindow.cpp

@ -292,7 +292,6 @@ void MainWindow::closeEvent(QCloseEvent* event) {
// Let the RPC know to shut down any running service. // Let the RPC know to shut down any running service.
rpc->shutdownhushd(); rpc->shutdownhushd();
int passphraselenght = this->getPassword().length(); int passphraselenght = this->getPassword().length();
qDebug()<<"LÄNGE PW : "<<passphraselenght;
// Check is encryption is ON for SDl // Check is encryption is ON for SDl
if(passphraselenght > 0) if(passphraselenght > 0)
@ -542,9 +541,7 @@ void MainWindow::removeWalletEncryption() {
filencrypted.remove(); filencrypted.remove();
}else{ }else{
qDebug()<<"verschlüsselung gescheitert ";
QMessageBox::critical(this, tr("Wallet Encryption Failed"), QMessageBox::critical(this, tr("Wallet Encryption Failed"),
QString("False password, please try again"), QString("False password, please try again"),
QMessageBox::Ok QMessageBox::Ok
@ -632,8 +629,6 @@ void MainWindow::removeWalletEncryptionStartUp() {
}else{ }else{
qDebug()<<"verschlüsselung gescheitert ";
QMessageBox::critical(this, tr("Wallet Encryption Failed"), QMessageBox::critical(this, tr("Wallet Encryption Failed"),
QString("false password please try again"), QString("false password please try again"),
@ -1365,24 +1360,10 @@ void MainWindow::setupchatTab() {
QObject::connect(ui->safeContactRequest, &QPushButton::clicked, this, &MainWindow::addContact); QObject::connect(ui->safeContactRequest, &QPushButton::clicked, this, &MainWindow::addContact);
QObject::connect(ui->pushContact, &QPushButton::clicked, this , &MainWindow::renderContactRequest); QObject::connect(ui->pushContact, &QPushButton::clicked, this , &MainWindow::renderContactRequest);
///////// Set selected Zaddr for Chat with Klick
ui->contactNameMemo->setText(""); ui->contactNameMemo->setText("");
QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () { ///////// Add contextmenu
QMenu* contextMenu;
QModelIndex index = ui->listContactWidget->currentIndex();
QString label_contact = index.data(Qt::DisplayRole).toString();
for(auto &p : AddressBook::getInstance()->getAllAddressLabels())
if (label_contact == p.getName()) {
ui->contactNameMemo->setText(p.getName());
rpc->refresh(true);
}
});
QMenu* contextMenu;
QAction* requestAction; QAction* requestAction;
QAction* editAction; QAction* editAction;
QAction* HushAction; QAction* HushAction;
@ -1394,16 +1375,22 @@ void MainWindow::setupchatTab() {
HushAction = new QAction("Send a friend some Hush - coming soon",contextMenu); HushAction = new QAction("Send a friend some Hush - coming soon",contextMenu);
requestHushAction = new QAction("Request some Hush - coming soon",contextMenu); requestHushAction = new QAction("Request some Hush - coming soon",contextMenu);
subatomicAction = new QAction("Make a subatomic swap with a friend- coming soon",contextMenu); subatomicAction = new QAction("Make a subatomic swap with a friend- coming soon",contextMenu);
///////// Set selected Zaddr for Chat with click
QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () {
ui->listContactWidget->setContextMenuPolicy(Qt::ActionsContextMenu); ui->listContactWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
ui->listContactWidget->addAction(requestAction); ui->listContactWidget->addAction(requestAction);
ui->listContactWidget->addAction(editAction); ui->listContactWidget->addAction(editAction);
ui->listContactWidget->addAction(HushAction); ui->listContactWidget->addAction(HushAction);
ui->listContactWidget->addAction(requestHushAction); ui->listContactWidget->addAction(requestHushAction);
ui->listContactWidget->addAction(subatomicAction); ui->listContactWidget->addAction(subatomicAction);
QObject::connect(requestHushAction, &QAction::triggered, [=]() { QObject::connect(requestHushAction, &QAction::triggered, [=]() {
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()) {
@ -1415,7 +1402,7 @@ void MainWindow::setupchatTab() {
}); });
QObject::connect(editAction, &QAction::triggered, [=]() { QObject::connect(editAction, &QAction::triggered, [=]() {
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();
@ -1436,12 +1423,20 @@ void MainWindow::setupchatTab() {
} }
}); });
QModelIndex index = ui->listContactWidget->currentIndex();
QString label_contact = index.data(Qt::DisplayRole).toString();
for(auto &p : AddressBook::getInstance()->getAllAddressLabels())
if (label_contact == p.getName()) {
ui->contactNameMemo->setText(p.getName());
rpc->refresh(true);
}
});
ui->memoTxtChat->setLenDisplayLabelChat(ui->memoSizeChat); ui->memoTxtChat->setLenDisplayLabelChat(ui->memoSizeChat);
} }
void MainWindow::updateChat() void MainWindow::updateChat()
{ {
rpc->refreshChat(ui->listChat,ui->memoSizeChat); rpc->refreshChat(ui->listChat,ui->memoSizeChat);

Loading…
Cancel
Save