chatgui: invite link dialogs, zxing-cpp QR code, crypto transport, channel improvements; msg_transport: chat protocol support
This commit is contained in:
1 parent
d8c8c1c5b0
commit
22c24d135e
2206 files changed
+33191
-257
No files matched your search
@@ -1,4 +1,5 @@
|
||||
#include "accountlist.h"
|
||||
#include "../db/db_manager.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPainter>
|
||||
@@ -22,10 +23,11 @@ static QPixmap makeAvatar(const QColor &color, const QString &letter) {
|
||||
return pix;
|
||||
}
|
||||
|
||||
AccountList::AccountList(QWidget *parent)
|
||||
AccountList::AccountList(DbManager* db, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_listView(new QListView(this))
|
||||
, m_model(new QStandardItemModel(this))
|
||||
, m_db(db)
|
||||
{
|
||||
auto *layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
@@ -43,27 +45,17 @@ AccountList::AccountList(QWidget *parent)
|
||||
m_listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
m_listView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||
layout->addWidget(m_listView);
|
||||
|
||||
populateStubData();
|
||||
}
|
||||
|
||||
void AccountList::populateStubData() {
|
||||
struct {
|
||||
const char *name;
|
||||
QColor color;
|
||||
const char *letter;
|
||||
} accounts[] = {
|
||||
{"Alice", QColor(74, 144, 226), "A"},
|
||||
{"Bob", QColor(126, 211, 33), "B"},
|
||||
{"Carol", QColor(245, 166, 35), "C"},
|
||||
{"Dave", QColor(144, 19, 254), "D"},
|
||||
{"Eve", QColor(0, 184, 148), "E"},
|
||||
};
|
||||
void AccountList::loadAccounts() {
|
||||
m_model->clear();
|
||||
if (!m_db || !m_db->isOpen()) return;
|
||||
|
||||
for (const auto &a : accounts) {
|
||||
auto accounts = m_db->getAccounts(true);
|
||||
for (const auto& a : accounts) {
|
||||
auto *item = new QStandardItem();
|
||||
item->setText(a.name);
|
||||
item->setIcon(QIcon(makeAvatar(a.color, a.letter)));
|
||||
item->setText(a.displayName);
|
||||
item->setIcon(QIcon(makeAvatar(QColor(a.avatarColor), a.avatarLetter)));
|
||||
m_model->appendRow(item);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user