add contextmenu for chatitems #78
This commit is contained in:
@@ -115,6 +115,8 @@ void MainWindow::renderContactRequest(){
|
|||||||
|
|
||||||
QStandardItemModel* contactRequest = new QStandardItemModel();
|
QStandardItemModel* contactRequest = new QStandardItemModel();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (auto &c : DataStore::getChatDataStore()->getAllNewContactRequests())
|
for (auto &c : DataStore::getChatDataStore()->getAllNewContactRequests())
|
||||||
|
|
||||||
|
|
||||||
@@ -134,6 +136,7 @@ void MainWindow::renderContactRequest(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStandardItemModel* contactRequestOld = new QStandardItemModel();
|
QStandardItemModel* contactRequestOld = new QStandardItemModel();
|
||||||
|
|
||||||
for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
||||||
@@ -158,12 +161,15 @@ void MainWindow::renderContactRequest(){
|
|||||||
QString label_contact = index.data(Qt::DisplayRole).toString();
|
QString label_contact = index.data(Qt::DisplayRole).toString();
|
||||||
QStandardItemModel* contactMemo = new QStandardItemModel();
|
QStandardItemModel* contactMemo = new QStandardItemModel();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ((c.second.isOutgoing() == false) && (requestContact.zaddrnew->text() == c.second.getAddress()) && (c.second.getType() != "Cont"))
|
if ((c.second.isOutgoing() == false) && (requestContact.zaddrnew->text() == c.second.getAddress()) && (c.second.getType() != "Cont"))
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
QStandardItem* Items = new QStandardItem(c.second.getMemo());
|
QStandardItem* Items = new QStandardItem(c.second.getMemo());
|
||||||
contactMemo->appendRow(Items);
|
contactMemo->appendRow(Items);
|
||||||
requestContact.requestMemo->setModel(contactMemo);
|
requestContact.requestMemo->setModel(contactMemo);
|
||||||
requestContact.requestMemo->show();
|
requestContact.requestMemo->show();
|
||||||
|
|
||||||
@@ -172,17 +178,18 @@ void MainWindow::renderContactRequest(){
|
|||||||
requestContact.requestZaddr->setText(c.second.getRequestZaddr());
|
requestContact.requestZaddr->setText(c.second.getRequestZaddr());
|
||||||
requestContact.requestMyAddr->setText(c.second.getAddress());
|
requestContact.requestMyAddr->setText(c.second.getAddress());
|
||||||
}else{}
|
}else{}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QObject::connect(requestContact.requestContactOld, &QTableView::clicked, [&] () {
|
QObject::connect(requestContact.requestContactOld, &QTableView::clicked, [&] () {
|
||||||
|
|
||||||
for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){
|
for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){
|
||||||
/* QModelIndex index = requestContact.requestContactOld->currentIndex();
|
QModelIndex index = requestContact.requestContactOld->currentIndex();
|
||||||
QString label_contactold = index.data(Qt::DisplayRole).toString();*/
|
QString label_contactold = index.data(Qt::DisplayRole).toString();
|
||||||
QStandardItemModel* contactMemo = new QStandardItemModel();
|
QStandardItemModel* contactMemo = new QStandardItemModel();
|
||||||
|
|
||||||
if ((c.second.isOutgoing() == false) && (requestContact.zaddrold->text() == c.second.getAddress()) && (c.second.getType() != "Cont"))
|
if ((c.second.isOutgoing() == false) && (requestContact.zaddrold->text() == c.second.getAddress()) && (c.second.getType() != "Cont"))
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "FileSystem/FileSystem.h"
|
#include "FileSystem/FileSystem.h"
|
||||||
#include "Crypto/passwd.h"
|
#include "Crypto/passwd.h"
|
||||||
#include "Crypto/FileEncryption.h"
|
#include "Crypto/FileEncryption.h"
|
||||||
|
#include "DataStore/DataStore.h"
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
|
||||||
@@ -1362,6 +1363,118 @@ void MainWindow::setupchatTab() {
|
|||||||
|
|
||||||
ui->contactNameMemo->setText("");
|
ui->contactNameMemo->setText("");
|
||||||
|
|
||||||
|
/////Copy Chatmessages
|
||||||
|
|
||||||
|
QMenu* contextMenuChat;
|
||||||
|
QAction* copymessage;
|
||||||
|
QAction* viewexplorer;
|
||||||
|
QAction* copytxid;
|
||||||
|
contextMenuChat = new QMenu(ui->listChat);
|
||||||
|
copymessage = new QAction("Copy message to clipboard",contextMenuChat);
|
||||||
|
viewexplorer = new QAction("View on block explorerr",contextMenuChat);
|
||||||
|
copytxid = new QAction("Copy txid to clipboard ",contextMenuChat);
|
||||||
|
|
||||||
|
QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () {
|
||||||
|
|
||||||
|
ui->listChat->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
|
ui->listChat->addAction(copymessage);
|
||||||
|
ui->listChat->addAction(viewexplorer);
|
||||||
|
ui->listChat->addAction(copytxid);
|
||||||
|
|
||||||
|
QObject::connect(copymessage, &QAction::triggered, [=] {
|
||||||
|
|
||||||
|
|
||||||
|
QModelIndex index = ui->listChat->currentIndex();
|
||||||
|
QString memo_chat = index.data(Qt::DisplayRole).toString();
|
||||||
|
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||||
|
int startPos = memo_chat.indexOf("<p>") + 3;
|
||||||
|
int endPos = memo_chat.indexOf("</p>");
|
||||||
|
int length = endPos - startPos;
|
||||||
|
QString copymemo = memo_chat.mid(startPos, length);
|
||||||
|
|
||||||
|
clipboard->setText(copymemo);
|
||||||
|
ui->statusBar->showMessage(tr("Copied message to clipboard"), 3 * 1000);
|
||||||
|
|
||||||
|
});
|
||||||
|
QObject::connect(copytxid, &QAction::triggered, [=] {
|
||||||
|
|
||||||
|
QModelIndex index = ui->listChat->currentIndex();
|
||||||
|
QString memo_chat = index.data(Qt::DisplayRole).toString();
|
||||||
|
QClipboard *clipboard = QGuiApplication::clipboard();
|
||||||
|
|
||||||
|
int startPos = memo_chat.indexOf("<p>") + 3;
|
||||||
|
int endPos = memo_chat.indexOf("</p>");
|
||||||
|
int length = endPos - startPos;
|
||||||
|
QString copymemo = memo_chat.mid(startPos, length);
|
||||||
|
int startPosT = memo_chat.indexOf("<small>") + 7;
|
||||||
|
int endPosT = memo_chat.indexOf("<b>");
|
||||||
|
int lengthT = endPosT - startPosT;
|
||||||
|
|
||||||
|
QString time = memo_chat.mid(startPosT, lengthT);
|
||||||
|
|
||||||
|
for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){
|
||||||
|
|
||||||
|
if (c.second.getMemo() == copymemo)
|
||||||
|
{
|
||||||
|
int timestamp = c.second.getTimestamp();
|
||||||
|
QDateTime myDateTime;
|
||||||
|
QString lock;
|
||||||
|
myDateTime.setTime_t(timestamp);
|
||||||
|
QString timestamphtml = myDateTime.toString("yyyy-MM-dd hh:mm");
|
||||||
|
|
||||||
|
if(timestamphtml == time)
|
||||||
|
|
||||||
|
{
|
||||||
|
clipboard->setText(c.second.getTxid());
|
||||||
|
ui->statusBar->showMessage(tr("Copied Txid to clipboard"), 3 * 1000);
|
||||||
|
}else{}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(viewexplorer, &QAction::triggered, [=] {
|
||||||
|
|
||||||
|
QModelIndex index = ui->listChat->currentIndex();
|
||||||
|
QString memo_chat = index.data(Qt::DisplayRole).toString();
|
||||||
|
|
||||||
|
int startPos = memo_chat.indexOf("<p>") + 3;
|
||||||
|
int endPos = memo_chat.indexOf("</p>");
|
||||||
|
int length = endPos - startPos;
|
||||||
|
QString copymemo = memo_chat.mid(startPos, length);
|
||||||
|
int startPosT = memo_chat.indexOf("<small>") + 7;
|
||||||
|
int endPosT = memo_chat.indexOf("<b>");
|
||||||
|
int lengthT = endPosT - startPosT;
|
||||||
|
|
||||||
|
QString time = memo_chat.mid(startPosT, lengthT);
|
||||||
|
|
||||||
|
for (auto &c : DataStore::getChatDataStore()->getAllRawChatItems()){
|
||||||
|
|
||||||
|
if (c.second.getMemo() == copymemo)
|
||||||
|
{
|
||||||
|
int timestamp = c.second.getTimestamp();
|
||||||
|
QDateTime myDateTime;
|
||||||
|
QString lock;
|
||||||
|
myDateTime.setTime_t(timestamp);
|
||||||
|
QString timestamphtml = myDateTime.toString("yyyy-MM-dd hh:mm");
|
||||||
|
|
||||||
|
if(timestamphtml == time)
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
Settings::openTxInExplorer(c.second.getTxid());
|
||||||
|
|
||||||
|
}else{}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
///////// Add contextmenu
|
///////// Add contextmenu
|
||||||
QMenu* contextMenu;
|
QMenu* contextMenu;
|
||||||
QAction* requestAction;
|
QAction* requestAction;
|
||||||
|
|||||||
@@ -1602,6 +1602,9 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The locks shows you the status of the message. Red lock = unconfirmed, green lock = min. 1 confirmations, orange lock = message is notarized</string>
|
<string>The locks shows you the status of the message. Red lock = unconfirmed, green lock = min. 1 confirmations, orange lock = message is notarized</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -1638,9 +1641,15 @@
|
|||||||
<property name="movement">
|
<property name="movement">
|
||||||
<enum>QListView::Snap</enum>
|
<enum>QListView::Snap</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="flow">
|
||||||
|
<enum>QListView::TopToBottom</enum>
|
||||||
|
</property>
|
||||||
<property name="resizeMode">
|
<property name="resizeMode">
|
||||||
<enum>QListView::Adjust</enum>
|
<enum>QListView::Adjust</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="layoutMode">
|
||||||
|
<enum>QListView::SinglePass</enum>
|
||||||
|
</property>
|
||||||
<property name="modelColumn">
|
<property name="modelColumn">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
Reference in New Issue
Block a user