Browse Source

dont delete unsent message when switching tab, add more contextmenu

pull/130/head
DenioD 4 years ago
parent
commit
56cc89a918
  1. 1
      src/Model/ChatItem.h
  2. 37
      src/contactmodel.cpp
  3. 3
      src/contactmodel.h
  4. 3
      src/controller.cpp
  5. 22
      src/mainwindow.cpp
  6. 1
      src/mainwindow.h
  7. 13
      src/mainwindow.ui

1
src/Model/ChatItem.h

@ -36,6 +36,7 @@ class ChatItem
QString getTxid();
int getConfirmations();
bool isOutgoing();
bool isdouble();
bool isNotarized();
void setTimestamp(long timestamp);
void setAddress(QString address);

37
src/contactmodel.cpp

@ -5,20 +5,17 @@
#include "addressbook.h"
#include "mainwindow.h"
#include "chatmodel.h"
#include "requestdialog.h"
#include "ui_requestdialog.h"
#include "settings.h"
#include "controller.h"
void ContactModel::renderContactList(QListView* view)
{
QStandardItemModel* contact = new QStandardItemModel();
QMenu* contextMenu;
QAction* requestAction;
QAction* editAction;
contextMenu = new QMenu(view);
requestAction = new QAction("Send a contact request",contextMenu);
editAction = new QAction("Edit this contact",contextMenu);
// QObject::connect(requestAction,SIGNAL(customContextMenuRequested(const QModelIndex)),this, SLOT(&ContactModel::requestActionClickedSlot));
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
{
@ -34,9 +31,25 @@ void ContactModel::renderContactList(QListView* view)
view->setUniformItemSizes(true);
view->setDragDropMode(QAbstractItemView::DropOnly);
view->show();
view->setContextMenuPolicy(Qt::ActionsContextMenu);
view->addAction(requestAction);
view->addAction(editAction);
}
}
void MainWindow::showRequesthush() {
Ui_RequestDialog req;
QDialog d(this);
req.setupUi(&d);
Settings::saveRestore(&d);
// setupDialog(main, &d, &req);
// Setup the Label completer for the Address
d.exec();
}

3
src/contactmodel.h

@ -5,14 +5,17 @@
#include "Model/ContactItem.h"
#include <QListWidget>
#include "mainwindow.h"
class ContactModel
{
public:
ContactModel() {}
void renderContactList(QListView* view);
};
#endif

3
src/controller.cpp

@ -943,8 +943,7 @@ void Controller::refreshTransactions() {
}
// this->refresh(true);
items.push_back(TransactionItemDetail{address, amount, memo});
total_amount = total_amount + amount;
}

22
src/mainwindow.cpp

@ -1358,13 +1358,33 @@ void MainWindow::setupchatTab() {
// ui->ContactZaddr->setText(p.getPartnerAddress());
// ui->MyZaddr->setText(p.getMyAddress());
ui->contactNameMemo->setText(p.getName());
ui->memoTxtChat->clear();
// ui->memoTxtChat->clear();
rpc->refresh(true);
// updateChat();
}
});
QMenu* contextMenu;
QAction* requestAction;
QAction* editAction;
QAction* HushAction;
QAction* requestHushAction;
contextMenu = new QMenu(ui->listContactWidget);
requestAction = new QAction("Send a contact request",contextMenu);
editAction = new QAction("Delete this contact",contextMenu);
HushAction = new QAction("Send a friend some Hush",contextMenu);
requestHushAction = new QAction("Request some Hush",contextMenu);
ui->listContactWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
ui->listContactWidget->addAction(requestAction);
ui->listContactWidget->addAction(editAction);
ui->listContactWidget->addAction(HushAction);
ui->listContactWidget->addAction(requestHushAction);
QObject::connect(requestHushAction, &QAction::triggered, [=]() {
MainWindow::showRequesthush();
});
ui->memoTxtChat->setLenDisplayLabelChat(ui->memoSizeChat);
}

1
src/mainwindow.h

@ -60,6 +60,7 @@ public:
void stopWebsocket();
void saveContact();
void saveandsendContact();
void showRequesthush();
// void setmaxlenChat(int len);
// void updateDisplay();

13
src/mainwindow.ui

@ -1389,6 +1389,9 @@
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectItems</enum>
</property>
</widget>
<widget class="QLabel" name="label_39">
<property name="geometry">
@ -1422,10 +1425,16 @@
<set>QTextEdit::AutoNone</set>
</property>
<property name="lineWrapMode">
<enum>QTextEdit::FixedColumnWidth</enum>
<enum>QTextEdit::FixedPixelWidth</enum>
</property>
<property name="lineWrapColumnOrWidth">
<number>80</number>
<number>600</number>
</property>
<property name="readOnly">
<bool>false</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextEditorInteraction</set>
</property>
</widget>
<widget class="QLabel" name="contactNameMemo">

Loading…
Cancel
Save