Browse Source

Merge pull request #13 from DenioD/chat

Chat
pull/130/head
Strider 4 years ago
committed by GitHub
parent
commit
111cd81999
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      silentdragon-lite.pro
  2. 9
      src/addressbook.cpp
  3. 31
      src/chatmodel.cpp
  4. 3
      src/contactmodel.cpp
  5. 25
      src/mainwindow.cpp
  6. 2
      src/mainwindow.h
  7. 296
      src/mainwindow.ui

2
silentdragon-lite.pro

@ -12,7 +12,7 @@ PRECOMPILED_HEADER = src/precompiled.h
QT += widgets
QT += websockets
QT += qml quick
TARGET = SilentDragonLite

9
src/addressbook.cpp

@ -173,7 +173,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
QString cid = ab.cid->text();
QString avatar = QString("res/") + ab.comboBoxAvatar->currentText() + QString(".png");
QString avatar = QString(":/icons/res/") + ab.comboBoxAvatar->currentText() + QString(".png");
qDebug()<<"AVATAR NAME : " << avatar;
if (addr.isEmpty() || newLabel.isEmpty())
@ -212,10 +212,11 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
////// We need a better popup here.
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid,avatar);
QMessageBox::critical(
QMessageBox::information(
parent,
QObject::tr("Add Successfully"),
QObject::tr("juhu").arg(newLabel),
QObject::tr("Added Contact"),
QObject::tr("successfully added your new contact").arg(newLabel),
QMessageBox::Ok
);
return;

31
src/chatmodel.cpp

@ -105,9 +105,9 @@ void ChatModel::renderChatBox(Ui::MainWindow* ui, QListView *view)
});
QStandardItemModel* chat = new QStandardItemModel();
ui->lcdNumber->setStyleSheet("background-color: red");
ui->lcdNumber->setPalette(Qt::red);
ui->lcdNumber->display("1");
// ui->lcdNumber->setStyleSheet("background-color: red");
// ui->lcdNumber->setPalette(Qt::red);
// ui->lcdNumber->display("1");
for (auto &c : this->chatItems)
for (auto &p : AddressBook::getInstance()->getAllAddressLabels())
@ -155,12 +155,12 @@ void ChatModel::renderContactRequest(){
requestContact.setupUi(&dialog);
Settings::saveRestore(&dialog);
/* {
{
QStandardItemModel* contactRequest = new QStandardItemModel();
for (auto &c : this->chatItems)
for (auto &p : AddressBook::getInstance()->getAllAddressLabels()) {
{
if ((c.second.getType() == "cont") && (c.second.isOutgoing() == false) && (c.second.getMemo().startsWith("{"))) {
@ -222,12 +222,17 @@ void ChatModel::renderContactRequest(){
QString newLabel = requestContact.requestLabel->text().trimmed();
auto myAddr = requestContact.requestMyAddr->text().trimmed();
QString avatar = QString("res/") + requestContact.comboBoxAvatar->currentText() + QString(".png");
QString avatar = QString(":/icons/res/") + requestContact.comboBoxAvatar->currentText() + QString(".png");
qDebug()<<"Beginn kopiert" <<cid << addr << newLabel << myAddr;
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
QMessageBox::information(main, "Added Contact","successfully added your new contact. You can now Chat with this contact");
});
*/
dialog.exec();
}
@ -510,7 +515,7 @@ void::MainWindow::addContact() {
QString newLabel = request.labelRequest->text().trimmed();
auto myAddr = request.myzaddr->text().trimmed();
QString avatar = QString("res/") + request.comboBoxAvatar->currentText() + QString(".png");
QString avatar = QString(":/icons/res/") + request.comboBoxAvatar->currentText() + QString(".png");
if (addr.isEmpty() || newLabel.isEmpty())
{
@ -535,12 +540,14 @@ void::MainWindow::addContact() {
return;
}
////// We need a better popup here.
///////Todo: Test if label allready exist!
////// Success, so show it
AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid, avatar);
QMessageBox::critical(
QMessageBox::information(
this,
QObject::tr("Add Successfully"),
QObject::tr("juhu").arg(newLabel),
QObject::tr("Added Contact"),
QObject::tr("successfully added your new contact").arg(newLabel),
QMessageBox::Ok
);
return;

3
src/contactmodel.cpp

@ -17,7 +17,8 @@ void ContactModel::renderContactList(QListView* view)
QString avatar = c.getAvatar();
QStandardItem* Items1 = new QStandardItem(QIcon(avatar) ,c.getName());
QStandardItem* Items1 = new QStandardItem(c.getName());
Items1->setData(QIcon(avatar),Qt::DecorationRole);
contact->appendRow(Items1);
view->setModel(contact);
view->setIconSize(QSize(60,70));

25
src/mainwindow.cpp

@ -1022,9 +1022,9 @@ void MainWindow::setupchatTab() {
QIcon addContactIcon(addContact);
ui->safeContactRequest->setIcon(addContactIcon);
/*QPixmap rahmen(":/icons/res/rahmen-message.png");
QIcon addRahmenIcon(rahmen);
ui->lcdNumber->setIcon(addRahmenIcon);*/
QPixmap newAddr(":/icons/res/add_contact.png");
QIcon addnewAddrIcon(newAddr);
ui->givemeZaddr->setIcon(addnewAddrIcon);
QPixmap sendContact(":/icons/res/upload.png");
QIcon addSendContactIcon(sendContact);
@ -1042,9 +1042,9 @@ void MainWindow::setupchatTab() {
QIcon addContactIcon(addContact);
ui->safeContactRequest->setIcon(addContact);
/*QPixmap rahmen(":/icons/res/message-icon.svg");
QIcon addRahmenIcon(rahmen);
ui->lcdNumber->setIcon(addRahmenIcon);*/
QPixmap newAddr(":/icons/res/add_contact.svg");
QIcon addnewAddrIcon(newAddr);
ui->givemeZaddr->setIcon(addnewAddrIcon);
QPixmap sendContact(":/icons/res/upload.svg");
QIcon addSendContactIcon(sendContact);
@ -1554,4 +1554,15 @@ MainWindow::~MainWindow()
delete wsserver;
delete wormhole;
}
}
void MainWindow::on_givemeZaddr_clicked()
{
bool sapling = true;
rpc->createNewZaddr(sapling, [=] (json reply) {
QString hushchataddr = QString::fromStdString(reply.get<json::array_t>()[0]);
QMessageBox::information(this, "Your new Hushchataddress",hushchataddr);
// ui->listReceiveAddresses->insertItem(0, hushchataddr);
// ui->listReceiveAddresses->setCurrentIndex(0);
});
}

2
src/mainwindow.h

@ -95,6 +95,8 @@ public slots:
private slots:
void on_givemeZaddr_clicked();
private:
void closeEvent(QCloseEvent* event);

296
src/mainwindow.ui

@ -1332,9 +1332,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>90</y>
<y>120</y>
<width>341</width>
<height>551</height>
<height>521</height>
</rect>
</property>
<property name="mouseTracking">
@ -1354,7 +1354,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>60</y>
<y>100</y>
<width>341</width>
<height>20</height>
</rect>
@ -1379,12 +1379,18 @@
<widget class="QLabel" name="contactNameMemo">
<property name="geometry">
<rect>
<x>450</x>
<x>460</x>
<y>20</y>
<width>161</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
@ -1543,28 +1549,6 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLCDNumber" name="lcdNumber">
<property name="geometry">
<rect>
<x>30</x>
<y>20</y>
<width>31</width>
<height>21</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="digitCount">
<number>1</number>
</property>
<property name="segmentStyle">
<enum>QLCDNumber::Flat</enum>
</property>
<property name="value" stdset="0">
<double>0.000000000000000</double>
</property>
</widget>
<widget class="QPushButton" name="sendContact">
<property name="geometry">
<rect>
@ -1598,17 +1582,255 @@
<bool>true</bool>
</property>
</widget>
<zorder>lcdNumber</zorder>
<zorder>listContactWidget</zorder>
<zorder>label_39</zorder>
<zorder>memoTxtChat</zorder>
<zorder>contactNameMemo</zorder>
<zorder>sendChatButton</zorder>
<zorder>contactNameMemo_3</zorder>
<zorder>listChat</zorder>
<zorder>safeContactRequest</zorder>
<zorder>pushContact</zorder>
<zorder>sendContact</zorder>
<widget class="QPushButton" name="givemeZaddr">
<property name="geometry">
<rect>
<x>60</x>
<y>30</y>
<width>111</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string> New Addr</string>
</property>
<property name="icon">
<iconset resource="../application.qrc">
<normaloff>:/icons/res/add_contact.png</normaloff>:/icons/res/add_contact.png</iconset>
</property>
<property name="iconSize">
<size>
<width>33</width>
<height>35</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_40">
<property name="geometry">
<rect>
<x>40</x>
<y>20</y>
<width>21</width>
<height>16</height>
</rect>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>239</red>
<green>41</green>
<blue>41</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="LinkVisited">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="SolidPattern">
<color alpha="128">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>239</red>
<green>41</green>
<blue>41</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="LinkVisited">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="SolidPattern">
<color alpha="128">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>190</red>
<green>190</green>
<blue>190</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>190</red>
<green>190</green>
<blue>190</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>239</red>
<green>41</green>
<blue>41</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>190</red>
<green>190</green>
<blue>190</blue>
</color>
</brush>
</colorrole>
<colorrole role="LinkVisited">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="SolidPattern">
<color alpha="128">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>1</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
</widget>
</widget>
</widget>
</item>

Loading…
Cancel
Save