chatgui: preserve active channel selection on reload, members sync, profile settings, member list model
This commit is contained in:
1 parent
c3f946fb63
commit
d70cdbb040
28 files changed
+1895
-91
No files matched your search
@@ -1,39 +1,20 @@
|
||||
#include "accountlist.h"
|
||||
#include "memberlistmodel.h"
|
||||
#include "../db/db_manager.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
|
||||
static QPixmap makeAvatar(const QColor &color, const QString &letter) {
|
||||
QPixmap pix(24, 24);
|
||||
pix.fill(Qt::transparent);
|
||||
QPainter p(&pix);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
p.setBrush(color);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawEllipse(0, 0, 24, 24);
|
||||
p.setPen(Qt::white);
|
||||
QFont f = p.font();
|
||||
f.setBold(true);
|
||||
f.setPointSize(10);
|
||||
p.setFont(f);
|
||||
p.drawText(QRect(0, 0, 24, 24), Qt::AlignCenter, letter);
|
||||
p.end();
|
||||
return pix;
|
||||
}
|
||||
|
||||
AccountList::AccountList(DbManager* db, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_listView(new QListView(this))
|
||||
, m_model(new QStandardItemModel(this))
|
||||
, m_model(new MemberListModel(db, this))
|
||||
, m_db(db)
|
||||
{
|
||||
auto *layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
|
||||
auto *header = new QLabel("Accounts", this);
|
||||
auto *header = new QLabel("Members", this);
|
||||
header->setAlignment(Qt::AlignCenter);
|
||||
header->setStyleSheet("font-weight: bold; padding: 8px; background: palette(window);");
|
||||
layout->addWidget(header);
|
||||
@@ -47,15 +28,5 @@ AccountList::AccountList(DbManager* db, QWidget *parent)
|
||||
layout->addWidget(m_listView);
|
||||
}
|
||||
|
||||
void AccountList::loadAccounts() {
|
||||
m_model->clear();
|
||||
if (!m_db || !m_db->isOpen()) return;
|
||||
|
||||
auto accounts = m_db->getAccounts(true);
|
||||
for (const auto& a : accounts) {
|
||||
auto *item = new QStandardItem();
|
||||
item->setText(a.displayName);
|
||||
item->setIcon(QIcon(makeAvatar(QColor(a.avatarColor), a.avatarLetter)));
|
||||
m_model->appendRow(item);
|
||||
}
|
||||
}
|
||||
void AccountList::setChannel(const QString& channelId) { m_model->setChannel(channelId); }
|
||||
void AccountList::refresh() { m_model->refresh(); }
|
||||
Reference in new issue
Block a user