improve some UI elements
This commit is contained in:
@@ -97,21 +97,39 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView &view)
|
||||
|
||||
void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
|
||||
{
|
||||
// QStandardItemModel mymodel;
|
||||
// QStandardItem* Items = new QStandardItem(myString);
|
||||
QStandardItemModel* myModel = new QStandardItemModel();
|
||||
for(auto &c : this->chatItems)
|
||||
|
||||
|
||||
QStandardItemModel* myModel = new QStandardItemModel();
|
||||
|
||||
|
||||
for (auto &c : this->chatItems)
|
||||
for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
||||
{
|
||||
|
||||
|
||||
|
||||
//////Render only Memos for selected contacts. Do not render empty Memos //// Render only memos where cid=cid
|
||||
|
||||
///
|
||||
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()) &&
|
||||
(c.second.getMemo().startsWith("{") == false) &&
|
||||
(c.second.getMemo().isEmpty() == false) &&
|
||||
(p.getPartnerAddress() == c.second.getAddress())
|
||||
|
||||
)
|
||||
{
|
||||
{
|
||||
|
||||
// for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
||||
|
||||
|
||||
// {
|
||||
// if ((ui->checkBox->isChecked() == true) && (p.getCid() != c.second.getCid()))
|
||||
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
|
||||
QStandardItem* Items = new QStandardItem(c.second.toChatLine());
|
||||
Items->setData("Incoming", Qt::UserRole +1);
|
||||
myModel->appendRow(Items);
|
||||
@@ -120,14 +138,14 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
|
||||
ui->listChat->setMinimumSize(200,350);
|
||||
ui->listChat->setItemDelegate(new ListViewDelegate());
|
||||
ui->listChat->show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (
|
||||
(ui->MyZaddr->text().trimmed() == c.second.getAddress()) &&
|
||||
(ui->contactNameMemo->text().trimmed() == c.second.getContact()) &&
|
||||
(c.second.getMemo().startsWith("{") == false) &&
|
||||
(c.second.getMemo().isEmpty() == false)
|
||||
(c.second.getMemo().isEmpty() == false) &&
|
||||
(p.getMyAddress() == c.second.getAddress())
|
||||
|
||||
)
|
||||
{
|
||||
@@ -141,22 +159,9 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
|
||||
ui->listChat->setMinimumSize(200,350);
|
||||
ui->listChat->setItemDelegate(new ListViewDelegate());
|
||||
ui->listChat->show();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////Render only when CID=CID?
|
||||
|
||||
// for(auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
||||
// {
|
||||
|
||||
// if ((ui->checkBox->isChecked() == true) && (p.getCid() != c.second.getCid()))
|
||||
// {
|
||||
|
||||
|
||||
//}
|
||||
//
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +228,7 @@ Tx MainWindow::createTxFromChatPage() {
|
||||
|
||||
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 myAddr = c.getMyAddress();
|
||||
@@ -233,6 +238,7 @@ Tx MainWindow::createTxFromChatPage() {
|
||||
|
||||
QString hmemo= createHeaderMemo(type,cid,myAddr);
|
||||
QString memo = ui->memoTxtChat->toPlainText().trimmed();
|
||||
|
||||
// ui->memoSizeChat->setLenDisplayLabel();// Todo -> activate lendisplay for chat
|
||||
|
||||
tx.toAddrs.push_back(ToFields{addr, amt, hmemo}) ;
|
||||
@@ -261,7 +267,7 @@ void MainWindow::sendChatButton() {
|
||||
// Memos can only be used with zAddrs. So check that first
|
||||
// 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 = "";
|
||||
// if (! Settings::isZAddress(AddressBook::addressFromAddressLabel(addr->text()))) {
|
||||
@@ -397,7 +403,7 @@ Tx MainWindow::createTxForSafeContactRequest() {
|
||||
|
||||
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 myAddr = c.getMyAddress(); // this should be a new HushChat zaddr
|
||||
@@ -426,9 +432,6 @@ Tx MainWindow::createTxForSafeContactRequest() {
|
||||
//////////////////De-activated for now///////////////////
|
||||
void MainWindow::safeContactRequest() {
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////Todo: Check if its a zaddr//////////
|
||||
|
||||
// Create a Tx from the values on the send tab. Note that this Tx object
|
||||
|
||||
@@ -881,24 +881,34 @@ void Controller::refreshTransactions() {
|
||||
memo = QString::fromStdString(o["memo"]);
|
||||
|
||||
QString cid;
|
||||
QString contact;
|
||||
|
||||
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();
|
||||
}else {cid = "";}
|
||||
}else {cid = "";}
|
||||
|
||||
if (address == c.getPartnerAddress()){
|
||||
contact = c.getName();
|
||||
}else{ contact = "";}
|
||||
|
||||
|
||||
ChatItem item = ChatItem(
|
||||
datetime,
|
||||
address,
|
||||
QString(""),
|
||||
contact,
|
||||
memo,
|
||||
cid, // we have to set the cid here, its included in our Addressbook for this contact
|
||||
txid,
|
||||
true // is an outgoing message
|
||||
);
|
||||
chatModel->addMessage(item);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
items.push_back(TransactionItemDetail{address, amount, memo});
|
||||
total_amount = total_amount + amount;
|
||||
@@ -912,7 +922,6 @@ void Controller::refreshTransactions() {
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
addresses.push_back(item.address); }
|
||||
|
||||
}
|
||||
@@ -957,19 +966,34 @@ void Controller::refreshTransactions() {
|
||||
else
|
||||
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(
|
||||
datetime,
|
||||
address,
|
||||
QString(""),
|
||||
contact,
|
||||
memo,
|
||||
cid, // we have to set the cid here, its included in the headermemo
|
||||
txid,
|
||||
false
|
||||
);
|
||||
// qDebug()<< "Message CID: " << cid;
|
||||
chatModel->addMessage(item);
|
||||
// qDebug()<< "KontaktName: " << contact;
|
||||
|
||||
// qDebug()<< "Addressbuch Addresse: " << c.getMyAddress();
|
||||
|
||||
chatModel->addMessage(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,8 +39,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->checkBox->setChecked(true);
|
||||
// ui->checkBox->setChecked(true);
|
||||
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
|
||||
setupStatusBar();
|
||||
@@ -994,109 +998,22 @@ void MainWindow::setupchatTab() {
|
||||
|
||||
QObject::connect(ui->listContactWidget, &QTableView::clicked, [=] () {
|
||||
|
||||
QStandardItemModel mymodel;
|
||||
|
||||
// for(auto &c : this->chatItems)
|
||||
//{
|
||||
//////Render only Memos for selected contacts. Do not render empty Memos //// Render only memos where cid=cid
|
||||
|
||||
///
|
||||
// if (
|
||||
// (ui->ContactZaddr->text().trimmed() == c.second.getAddress()) &&
|
||||
// (c.second.getMemo().startsWith("{") == false) &&
|
||||
// (c.second.getMemo().isEmpty() == false)
|
||||
// )
|
||||
// {
|
||||
// if (c.second.getMemo.find())
|
||||
|
||||
//view->addItem(line);
|
||||
|
||||
// QStandardItem *item1 = new QStandardItem(c.second.toChatLine());
|
||||
// item1->setData("Incoming", Qt::UserRole + 1);
|
||||
// model.appendRow(item1);
|
||||
|
||||
QStandardItem *item1 = new QStandardItem("Kacke Hier");
|
||||
item1->setData("Incoming", Qt::UserRole +1);
|
||||
mymodel.appendRow(item1);
|
||||
qDebug()<<item1->text();
|
||||
|
||||
|
||||
QStandardItem *item2 = new QStandardItem("This is item one");
|
||||
item2->setData("Outgoing", Qt::UserRole +1);
|
||||
mymodel.appendRow(item2);
|
||||
qDebug()<<item2->text();
|
||||
|
||||
QStandardItem *item3 = new QStandardItem("This is item one");
|
||||
item3->setData("Outgoing", Qt::UserRole +1);
|
||||
mymodel.appendRow(item3);
|
||||
qDebug()<<item3->text();
|
||||
|
||||
// QStandardItem *item2 = new QStandardItem("Hallo");
|
||||
// item1->setData("Outgoing", Qt::UserRole + 1);
|
||||
// mymodel.appendRow(item2);
|
||||
// qDebug()<<item2->text();
|
||||
|
||||
////////////////////////////////// Todo : Render green checkmark for contacts if cid = cid - We have to search for cid in txid/cid list
|
||||
// QString cid = c.second.getCid();
|
||||
|
||||
// }
|
||||
|
||||
// if (
|
||||
// (ui->MyZaddr->text().trimmed() == c.second.getAddress()) &&
|
||||
// (c.second.getMemo().startsWith("{") == false) &&
|
||||
// (c.second.getMemo().isEmpty() == false)
|
||||
// )
|
||||
// {
|
||||
|
||||
|
||||
// for(auto &p : AddressBook::getInstance()->getAllAddressLabels())
|
||||
// {
|
||||
|
||||
// if ((ui->checkBox->isChecked() == true) && (p.getCid() != c.second.getCid()))
|
||||
// {
|
||||
|
||||
|
||||
//}
|
||||
// else
|
||||
// {
|
||||
// line+= QString("[") + "Warning. Not verified!" + QString("]");
|
||||
// QStandardItem *item = new QStandardItem(c.second.toChatLine());
|
||||
//view->addItem(line);
|
||||
// model.appendRow(item);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
ui->listChat->setModel(&mymodel);
|
||||
ui->listChat->setItemDelegate(new ListViewDelegate());
|
||||
ui->listChat->show();
|
||||
//ui->listChat->update();
|
||||
|
||||
|
||||
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->ContactZaddr->setText(p.getPartnerAddress());
|
||||
ui->MyZaddr->setText(p.getMyAddress());
|
||||
// ui->ContactZaddr->setText(p.getPartnerAddress());
|
||||
// ui->MyZaddr->setText(p.getMyAddress());
|
||||
ui->contactNameMemo->setText(p.getName());
|
||||
ui->contactCid->setText(p.getCid());
|
||||
ui->memoTxtChat->clear();
|
||||
|
||||
rpc->refresh(true);
|
||||
updateChat();
|
||||
// updateChat();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ChatMemoEdit::ChatMemoEdit(QWidget* parent) : QPlainTextEdit(parent) {
|
||||
|
||||
@@ -1351,21 +1351,24 @@
|
||||
<string><html><head/><body><p align="center">Hushchat Contactlist</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="MemoEdit" name="memoTxtChat">
|
||||
<widget class="QTextEdit" name="memoTxtChat">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>410</y>
|
||||
<y>460</y>
|
||||
<width>921</width>
|
||||
<height>128</height>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">font: 11pt "Noto Color Emoji";</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="memoSizeChat">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1200</x>
|
||||
<y>540</y>
|
||||
<x>1190</x>
|
||||
<y>610</y>
|
||||
<width>47</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
@@ -1393,8 +1396,8 @@
|
||||
<widget class="QPushButton" name="sendChatButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1130</x>
|
||||
<y>590</y>
|
||||
<x>710</x>
|
||||
<y>610</y>
|
||||
<width>114</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
@@ -1412,45 +1415,6 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</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><html><head/><body><p>My zaddr :</p></body></html></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">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@@ -1473,58 +1437,6 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</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><html><head/><body><p align="center"><br/></p></body></html></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><html><head/><body><p align="center">Conversation ID:</p></body></html></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">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@@ -1544,7 +1456,7 @@
|
||||
<x>340</x>
|
||||
<y>40</y>
|
||||
<width>921</width>
|
||||
<height>371</height>
|
||||
<height>421</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
@@ -1572,6 +1484,19 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>430</y>
|
||||
<width>911</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -1743,11 +1668,6 @@
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>MemoEdit</class>
|
||||
<extends>QPlainTextEdit</extends>
|
||||
<header>memoedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AddressCombo</class>
|
||||
<extends>QComboBox</extends>
|
||||
|
||||
Reference in New Issue
Block a user