diff --git a/application.qrc b/application.qrc
index e4cd3d2..42f093b 100644
--- a/application.qrc
+++ b/application.qrc
@@ -11,6 +11,17 @@
res/darkwing.png
res/sdlogo.png
res/sdlogo2.png
+ res/Berg.png
+ res/denio.png
+ res/duke.png
+ res/sharpee.png
+ res/yoda.png
+ res/mickey.png
+ res/snoopy.png
+ res/popey.png
+ res/garfield.png
+ res/pinguin.png
+ res/hirsch.png
res/hushdlogo.gif
diff --git a/res/Berg.png b/res/Berg.png
new file mode 100644
index 0000000..0aab208
Binary files /dev/null and b/res/Berg.png differ
diff --git a/res/Unbenannt-4 Kopie.png b/res/Unbenannt-4 Kopie.png
new file mode 100644
index 0000000..e9d0d54
Binary files /dev/null and b/res/Unbenannt-4 Kopie.png differ
diff --git a/res/denio.png b/res/denio.png
new file mode 100644
index 0000000..00c043a
Binary files /dev/null and b/res/denio.png differ
diff --git a/res/duke.png b/res/duke.png
new file mode 100644
index 0000000..4310cef
Binary files /dev/null and b/res/duke.png differ
diff --git a/res/garfield.png b/res/garfield.png
new file mode 100644
index 0000000..c9bf3fc
Binary files /dev/null and b/res/garfield.png differ
diff --git a/res/hirsch.png b/res/hirsch.png
new file mode 100644
index 0000000..e2b8dbd
Binary files /dev/null and b/res/hirsch.png differ
diff --git a/res/mickey.png b/res/mickey.png
new file mode 100644
index 0000000..e278799
Binary files /dev/null and b/res/mickey.png differ
diff --git a/res/pinguin.png b/res/pinguin.png
new file mode 100644
index 0000000..f8083b6
Binary files /dev/null and b/res/pinguin.png differ
diff --git a/res/popey.png b/res/popey.png
new file mode 100644
index 0000000..9b986af
Binary files /dev/null and b/res/popey.png differ
diff --git a/res/sharpee.png b/res/sharpee.png
new file mode 100644
index 0000000..00b392e
Binary files /dev/null and b/res/sharpee.png differ
diff --git a/res/snoopy.png b/res/snoopy.png
new file mode 100644
index 0000000..38f8fac
Binary files /dev/null and b/res/snoopy.png differ
diff --git a/res/yoda.png b/res/yoda.png
new file mode 100644
index 0000000..74a4d8f
Binary files /dev/null and b/res/yoda.png differ
diff --git a/silentdragon-lite.pro b/silentdragon-lite.pro
index c76b209..5e745f4 100644
--- a/silentdragon-lite.pro
+++ b/silentdragon-lite.pro
@@ -12,6 +12,7 @@ PRECOMPILED_HEADER = src/precompiled.h
QT += widgets
QT += websockets
+QT += qml quick
TARGET = SilentDragonLite
@@ -33,6 +34,7 @@ mac: LIBS+= -Wl,-bind_at_load
RESOURCES = application.qrc
+
MOC_DIR = bin
OBJECTS_DIR = bin
UI_DIR = src
@@ -105,6 +107,7 @@ HEADERS += \
src/contactmodel.h
FORMS += \
+ src/contactrequest.ui \
src/encryption.ui \
src/mainwindow.ui \
src/migration.ui \
diff --git a/src/addressbook.cpp b/src/addressbook.cpp
index 1a2bad3..70df68e 100644
--- a/src/addressbook.cpp
+++ b/src/addressbook.cpp
@@ -8,7 +8,7 @@
AddressBookModel::AddressBookModel(QTableView *parent) : QAbstractTableModel(parent)
{
- headers << tr("Label") << tr("Address") << tr("HushChatAddress") << tr("cid");
+ headers << tr("Avatar")<< tr("Label") << tr("Address") << tr("HushChatAddress") << tr("CID");
this->parent = parent;
loadData();
}
@@ -38,10 +38,10 @@ void AddressBookModel::loadData()
);
}
-void AddressBookModel::addNewLabel(QString label, QString addr, QString myAddr, QString cid)
+void AddressBookModel::addNewLabel(QString label, QString addr, QString myAddr, QString cid, QString avatar)
{
//labels.push_back(QPair(label, addr));
- AddressBook::getInstance()->addAddressLabel(label, addr, myAddr, cid);
+ AddressBook::getInstance()->addAddressLabel(label, addr, myAddr, cid, avatar);
updateUi();
}
@@ -59,7 +59,7 @@ void AddressBookModel::removeItemAt(int row)
if (row >= labels.size())
return;
- AddressBook::getInstance()->removeAddressLabel(labels[row].getName(), labels[row].getPartnerAddress(), labels[row].getMyAddress(),labels[row].getCid());
+ AddressBook::getInstance()->removeAddressLabel(labels[row].getName(), labels[row].getPartnerAddress(), labels[row].getMyAddress(),labels[row].getCid(),labels[row].getAvatar());
labels.clear();
labels = AddressBook::getInstance()->getAllAddressLabels();
dataChanged(index(0, 0), index(labels.size()-1, columnCount(index(0,0))-1));
@@ -70,7 +70,7 @@ ContactItem AddressBookModel::itemAt(int row)
{
if (row >= labels.size())
{
- ContactItem item = ContactItem("", "", "", "");
+ ContactItem item = ContactItem("", "", "", "","");
return item;
}
@@ -97,10 +97,11 @@ QVariant AddressBookModel::data(const QModelIndex &index, int role) const
{
switch(index.column())
{
- case 0: return labels.at(index.row()).getName();
- case 1: return labels.at(index.row()).getPartnerAddress();
- case 2: return labels.at(index.row()).getMyAddress();
- case 3: return labels.at(index.row()).getCid();
+ case 0: return labels.at(index.row()).getAvatar();
+ case 1: return labels.at(index.row()).getName();
+ case 2: return labels.at(index.row()).getPartnerAddress();
+ case 3: return labels.at(index.row()).getMyAddress();
+ case 4: return labels.at(index.row()).getCid();
}
}
@@ -168,6 +169,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
auto myAddr = ab.addr_chat->text().trimmed();
QString newLabel = ab.label->text();
QString cid = ab.cid->text();
+ QString avatar = "res/yoda.png";
if (addr.isEmpty() || newLabel.isEmpty())
{
@@ -204,7 +206,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
}
////// We need a better popup here.
- AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid);
+ AddressBook::getInstance()->addAddressLabel(newLabel, addr, myAddr, cid,avatar);
QMessageBox::critical(
parent,
QObject::tr("Add Successfully"),
@@ -256,7 +258,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
continue;
// Add label, address.
- model.addNewLabel(items.at(1), items.at(0), "", "");
+ model.addNewLabel(items.at(1), items.at(0), "", "", "");
numImported++;
}
@@ -267,7 +269,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
);
});
- auto fnSetTargetLabelAddr = [=] (QLineEdit* target, QString label, QString addr, QString myAddr, QString cid) {
+ auto fnSetTargetLabelAddr = [=] (QLineEdit* target, QString label, QString addr, QString myAddr, QString cid, QString avatar) {
target->setText(label % "/" % addr % myAddr);
};
@@ -284,8 +286,9 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
QString addr = model.itemAt(index.row()).getPartnerAddress();
QString myAddr = model.itemAt(index.row()).getMyAddress();
QString cid = model.itemAt(index.row()).getCid();
+ QString avatar = model.itemAt(index.row()).getCid();
d.accept();
- fnSetTargetLabelAddr(target, lbl, addr, myAddr, cid);
+ fnSetTargetLabelAddr(target, lbl, addr, myAddr, cid, avatar);
});
// Right-Click
@@ -299,13 +302,14 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
QString addr = model.itemAt(index.row()).getPartnerAddress();
QString myAddr = model.itemAt(index.row()).getMyAddress();
QString cid = model.itemAt(index.row()).getCid();
+ QString avatar = model.itemAt(index.row()).getAvatar();
QMenu menu(parent);
if (target != nullptr)
menu.addAction("Pick", [&] () {
d.accept();
- fnSetTargetLabelAddr(target, lbl, addr, myAddr, cid);
+ fnSetTargetLabelAddr(target, lbl, addr, myAddr, cid, avatar);
});
menu.addAction(QObject::tr("Copy address"), [&] () {
@@ -324,7 +328,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target)
auto selection = ab.addresses->selectionModel();
if (selection && selection->hasSelection() && selection->selectedRows().size() > 0) {
auto item = model.itemAt(selection->selectedRows().at(0).row());
- fnSetTargetLabelAddr(target, item.getName(), item.getMyAddress(), item.getPartnerAddress(), item.getCid());
+ fnSetTargetLabelAddr(target, item.getName(), item.getMyAddress(), item.getPartnerAddress(), item.getCid(), item.getAvatar());
}
};
@@ -370,7 +374,7 @@ void AddressBook::readFromStorage()
//qDebug() << "0:" << stuff[i][0];
//qDebug() << "1:" << stuff[i][1];
//qDebug() << "2:" << stuff[i][2];
- ContactItem contact = ContactItem(stuff[i][0],stuff[i][1], stuff[i][2], stuff[i][3]);
+ ContactItem contact = ContactItem(stuff[i][0],stuff[i][1], stuff[i][2], stuff[i][3],stuff[i][4]);
//qDebug() << "contact=" << contact.toQTString();
allLabels.push_back(contact);
}
@@ -406,6 +410,7 @@ void AddressBook::writeToStorage()
c.push_back(item.getPartnerAddress());
c.push_back(item.getMyAddress());
c.push_back(item.getCid());
+ c.push_back(item.getAvatar());
contacts.push_back(c);
}
out << QString("v1") << contacts;
@@ -428,22 +433,22 @@ QString AddressBook::writeableFile()
// Add a new address/label to the database
-void AddressBook::addAddressLabel(QString label, QString address, QString myAddr, QString cid)
+void AddressBook::addAddressLabel(QString label, QString address, QString myAddr, QString cid, QString avatar)
{
Q_ASSERT(Settings::isValidAddress(address));
// getName(), remove any existing label
// Iterate over the list and remove the label/address
for (int i=0; i < allLabels.size(); i++)
if (allLabels[i].getName() == label)
- removeAddressLabel(allLabels[i].getName(), allLabels[i].getPartnerAddress(),allLabels[i].getMyAddress(), allLabels[i].getCid());
+ removeAddressLabel(allLabels[i].getName(), allLabels[i].getPartnerAddress(),allLabels[i].getMyAddress(), allLabels[i].getCid(), allLabels[i].getAvatar());
- ContactItem item = ContactItem(label, address, myAddr, cid);
+ ContactItem item = ContactItem(label, address, myAddr, cid, avatar);
allLabels.push_back(item);
writeToStorage();
}
// Remove a new address/label from the database
-void AddressBook::removeAddressLabel(QString label, QString address, QString myAddr, QString cid)
+void AddressBook::removeAddressLabel(QString label, QString address, QString myAddr, QString cid, QString avatar)
{
// Iterate over the list and remove the label/address
for (int i=0; i < allLabels.size(); i++)
diff --git a/src/addressbook.h b/src/addressbook.h
index 6f8308b..6c7a450 100644
--- a/src/addressbook.h
+++ b/src/addressbook.h
@@ -12,7 +12,7 @@ public:
AddressBookModel(QTableView* parent);
~AddressBookModel();
- void addNewLabel(QString label, QString address, QString myAddr, QString cid);
+ void addNewLabel(QString label, QString address, QString myAddr, QString cid, QString avatar);
void updateUi();
void removeItemAt(int row);
//QPair itemAt(int row);
@@ -43,10 +43,10 @@ public:
static QString addressFromAddressLabel(const QString& lblAddr);
// Add a new address/label to the database
- void addAddressLabel(QString label, QString address, QString myAddr, QString cid);
+ void addAddressLabel(QString label, QString address, QString myAddr, QString cid, QString avatar);
// Remove a new address/label from the database
- void removeAddressLabel(QString label, QString address, QString myAddr, QString cid);
+ void removeAddressLabel(QString label, QString address, QString myAddr, QString cid, QString avatar);
// Update a label/address
void updateLabel(QString oldlabel, QString address, QString newlabel);
diff --git a/src/addressbook.ui b/src/addressbook.ui
index c2d255d..6f3015d 100644
--- a/src/addressbook.ui
+++ b/src/addressbook.ui
@@ -30,7 +30,7 @@
-
- Nickname
+ <html><head/><body><p align="right">Nickname :</p></body></html>
@@ -51,9 +51,130 @@
+ -
+
+
+ <html><head/><body><p align="right">Avatar :</p></body></html>
+
+
+
-
+ -
+
+
-
+
+ Stag
+
+
+
+ :/icons/res/hirsch.png
+
+
+
+ -
+
+ Denio
+
+
+
+ :/icons/res/denio.png
+
+
+
+ -
+
+ Duke
+
+
+
+ :/icons/res/duke.png
+
+
+
+ -
+
+ Yoda
+
+
+
+ :/icons/res/yoda.png
+
+
+
+ -
+
+ Berg
+
+
+
+ :/icons/res/Berg.png
+
+
+
+ -
+
+ Sharpee
+
+
+
+ :/icons/res/sharpee.png
+
+
+
+ -
+
+ Garflied
+
+
+
+ :/icons/res/garfield.png
+
+
+
+ -
+
+ Snoopy
+
+
+
+ :/icons/res/snoopy.png
+
+
+
+ -
+
+ Popey
+
+
+
+ :/icons/res/popey.png
+
+
+
+ -
+
+ Pinguin
+
+
+
+ :/icons/res/pinguin.png
+
+
+
+ -
+
+ SDLogo
+
+
+
+ :/icons/res/sdlogo2.png
+
+
+
+
+
-
diff --git a/src/contactmodel.cpp b/src/contactmodel.cpp
index 956bd63..6131485 100644
--- a/src/contactmodel.cpp
+++ b/src/contactmodel.cpp
@@ -3,32 +3,27 @@
#include "mainwindow.h"
void ContactModel::renderContactList(QListView* view)
-{ // QStandardItem(const QIcon & icon, const QString & text)
+{
QStandardItemModel* contact = new QStandardItemModel();
- //}
+
for(auto &c : AddressBook::getInstance()->getAllAddressLabels())
{
- //QStandardItem* Items = new QStandardItem();
auto theme = Settings::getInstance()->get_theme_name();
- if ((theme == "dark" || theme == "midnight")) {
- QStandardItem* Items1 = new QStandardItem(QIcon("res/sdlogo.png"),c.getName());
- contact->appendRow(Items1);
- view->setModel(contact);
- view->setIconSize(QSize(60,70));
- view->setUniformItemSizes(true);
- view->setDragDropMode(QAbstractItemView::DropOnly);;
- }
- if (theme == "default" || theme == "blue"){
+ if ((theme == "dark" || theme == "midnight")) {
+
+ // QIcon avatar = c.getAvatar();
+ QString avatar = "res/yoda.png";
- QStandardItem* Items1 = new QStandardItem(QIcon("res/sdlogo2.png"),c.getName());
- contact->appendRow(Items1);
- view->setModel(contact);
- view->setIconSize(QSize(60,70));
- view->setUniformItemSizes(true);
- view->setDragDropMode(QAbstractItemView::DropOnly);;
+ QStandardItem* Items1 = new QStandardItem(QIcon(avatar) ,c.getName());
+ contact->appendRow(Items1);
+ view->setModel(contact);
+ view->setIconSize(QSize(60,70));
+ view->setUniformItemSizes(true);
+ view->setDragDropMode(QAbstractItemView::DropOnly);
}
+
diff --git a/src/contactmodel.h b/src/contactmodel.h
index 2bf3fe3..b643bdb 100644
--- a/src/contactmodel.h
+++ b/src/contactmodel.h
@@ -14,15 +14,17 @@ class ContactItem
QString _partnerAddress;
QString _name;
QString _cid;
+ QString _avatar;
public:
ContactItem();
- ContactItem(QString name, QString partnerAddress, QString myAddress, QString cid)
+ ContactItem(QString name, QString partnerAddress, QString myAddress, QString cid, QString avatar)
{
_name = name;
_myAddress = myAddress;
_partnerAddress = partnerAddress;
_cid = cid;
+ _avatar = avatar;
}
QString getName() const
@@ -45,6 +47,11 @@ class ContactItem
return _cid;
}
+ QString getAvatar() const
+ {
+ return _avatar;
+ }
+
void setName(QString name)
{
_name = name;
@@ -64,10 +71,14 @@ class ContactItem
{
_cid = cid;
}
+ void setAvatar(QString avatar)
+ {
+ _avatar = avatar;
+ }
QString toQTString()
{
- return _name + "|" + _partnerAddress + "|" + _myAddress + "|" + _cid;
+ return _name + "|" + _partnerAddress + "|" + _myAddress + "|" + _cid + "|"+ _avatar;
}
};
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index d685005..05126f8 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1319,6 +1319,7 @@ void MainWindow::setupReceiveTab() {
// Receive tab add/update label
QObject::connect(ui->rcvUpdateLabel, &QPushButton::clicked, [=]() {
QString addr = ui->listReceiveAddresses->currentText();
+
if (addr.isEmpty())
return;
@@ -1332,7 +1333,7 @@ void MainWindow::setupReceiveTab() {
if (!curLabel.isEmpty() && label.isEmpty()) {
info = "Removed Label '" % curLabel % "'";
- AddressBook::getInstance()->removeAddressLabel(curLabel, addr, "", "");
+ AddressBook::getInstance()->removeAddressLabel(curLabel, addr, "", "","" );
}
else if (!curLabel.isEmpty() && !label.isEmpty()) {
info = "Updated Label '" % curLabel % "' to '" % label % "'";
@@ -1340,7 +1341,7 @@ void MainWindow::setupReceiveTab() {
}
else if (curLabel.isEmpty() && !label.isEmpty()) {
info = "Added Label '" % label % "'";
- AddressBook::getInstance()->addAddressLabel(label, addr, "", "");
+ AddressBook::getInstance()->addAddressLabel(label, addr, "", "", "");
}
// Update labels everywhere on the UI