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();
int outgoing = 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->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");
line += QString(lock) + QString("</small>");
line += QString("<p>") + _memo.toHtmlEscaped() + QString("</p>");

14
src/chatmodel.cpp

@ -237,7 +237,7 @@ void MainWindow::renderContactRequest(){
return;
}
qDebug()<<"Beginn kopiert" <<cid << addr << newLabel << myAddr;
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
rpc->refreshContacts(
ui->listContactWidget);
@ -393,7 +393,6 @@ QString MainWindow::createHeaderMemo(QString type, QString cid, QString zaddr, Q
j.setObject(h);
header = j.toJson();
qDebug() << "made header=" << header;
return header;
}
@ -449,7 +448,6 @@ Tx MainWindow::createTxFromChatPage() {
QString hashEncryptionKey = passphrase;
int length = hashEncryptionKey.length();
qDebug()<<"Pubkey Erstellung :"<<pubkey;
////////////////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 publickeyAlice = QByteArray(reinterpret_cast<const char*>(pk), crypto_kx_PUBLICKEYBYTES).toHex();
qDebug()<<"Headerbyte erstellung : "<<headerbytes;
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, memo});
qDebug() << "pushback chattx";
}
}
@ -527,7 +521,6 @@ Tx MainWindow::createTxFromChatPage() {
return tx;
qDebug() << "ChatTx created";
}
void MainWindow::sendChat() {
@ -538,8 +531,7 @@ void MainWindow::sendChat() {
// might not be valid yet.
QString Name = ui->contactNameMemo->text();
int sizename = Name.size();
qDebug()<< sizename;
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"),
@ -577,7 +569,6 @@ void MainWindow::sendChat() {
// abort the Tx
return;
qDebug() << "Tx aborted";
}
auto movie = new QMovie(this);
@ -716,7 +707,6 @@ void::MainWindow::addContact()
request.myzaddr->setText(myAddr);
ui->listReceiveAddresses->insertItem(0, myAddr);
ui->listReceiveAddresses->setCurrentIndex(0);
qDebug() << "new generated myAddr add Contact" << myAddr;
});
}catch(...)

29
src/controller.cpp

@ -1025,7 +1025,6 @@ void Controller::refreshTransactions() {
int encryptedMemoSize1 = ba.length();
int headersize = ba1.length();
//////unsigned char* as message from QString
#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
qDebug()<<"OUT decrypt:" << memodecrypt;
ChatItem item = ChatItem(
datetime,
@ -1084,26 +1081,7 @@ void Controller::refreshTransactions() {
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});
@ -1153,7 +1131,6 @@ void Controller::refreshTransactions() {
QString publickey;
QString headerbytes;
QString cid;
int position;
QString requestZaddr;
bool isContact;
@ -1261,10 +1238,6 @@ void Controller::refreshTransactions() {
chatModel->addMemo(txid, headerbytes);
}else{}
qDebug()<<"Position message :"<<position;
int lengthcid = cid.length();
QString passphrase = main->getPassword();
QString hashEncryptionKey = passphrase;
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.
rpc->shutdownhushd();
int passphraselenght = this->getPassword().length();
qDebug()<<"LÄNGE PW : "<<passphraselenght;
// Check is encryption is ON for SDl
if(passphraselenght > 0)
@ -542,9 +541,7 @@ void MainWindow::removeWalletEncryption() {
filencrypted.remove();
}else{
qDebug()<<"verschlüsselung gescheitert ";
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
QString("False password, please try again"),
QMessageBox::Ok
@ -632,8 +629,6 @@ void MainWindow::removeWalletEncryptionStartUp() {
}else{
qDebug()<<"verschlüsselung gescheitert ";
QMessageBox::critical(this, tr("Wallet Encryption Failed"),
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->pushContact, &QPushButton::clicked, this , &MainWindow::renderContactRequest);
///////// Set selected Zaddr for Chat with Klick
ui->contactNameMemo->setText("");
QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () {
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;
///////// Add contextmenu
QMenu* contextMenu;
QAction* requestAction;
QAction* editAction;
QAction* HushAction;
@ -1394,16 +1375,22 @@ void MainWindow::setupchatTab() {
HushAction = new QAction("Send a friend 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);
///////// Set selected Zaddr for Chat with click
QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () {
ui->listContactWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
ui->listContactWidget->addAction(requestAction);
ui->listContactWidget->addAction(editAction);
ui->listContactWidget->addAction(HushAction);
ui->listContactWidget->addAction(requestHushAction);
ui->listContactWidget->addAction(subatomicAction);
QObject::connect(requestHushAction, &QAction::triggered, [=]() {
QObject::connect(requestHushAction, &QAction::triggered, [=]() {
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())
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();
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);
}
void MainWindow::updateChat()
{
rpc->refreshChat(ui->listChat,ui->memoSizeChat);

Loading…
Cancel
Save