Add desktop poll creation, voting and live result dialogs
This commit is contained in:
1 parent
ebc96712a2
commit
cf869770fb
3 files changed
+208
-6
No files matched your search
@@ -41,6 +41,7 @@ static std::vector<std::unique_ptr<LottieIcon>> s_icons;
|
||||
extern "C" {
|
||||
#include "../transport/gui_bridge.h"
|
||||
#include "chat/chat_core.h"
|
||||
#include "chat/chat_poll.h"
|
||||
#include "dm/dm_core.h"
|
||||
#include "dm/dm_media.h"
|
||||
#include "video/video.h"
|
||||
@@ -374,6 +375,9 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent
|
||||
m_channelTitle->setStyleSheet("font-weight: bold; font-size: 14px;");
|
||||
m_channelTitle->setText(QCoreApplication::translate("ChatGui", "Channel"));
|
||||
hl->addWidget(m_channelTitle, 1);
|
||||
m_pollBtn = new QPushButton(QCoreApplication::translate("ChatGui", "Create poll"), header);
|
||||
hl->addWidget(m_pollBtn);
|
||||
connect(m_pollBtn, &QPushButton::clicked, this, &MessageList::createPoll);
|
||||
|
||||
m_talkingLabel = new QLabel(header);
|
||||
m_talkingLabel->setStyleSheet("color: #27ae60; font-size: 12px;");
|
||||
@@ -663,7 +667,9 @@ void MessageList::loadChannel(const QString& channelId) {
|
||||
|
||||
m_model->clear();
|
||||
m_avatarCache.clear();
|
||||
if (m_currentChannelId != channelId) { m_feedback.clear(); m_pendingPoll.clear(); }
|
||||
m_currentChannelId = channelId;
|
||||
m_pollBtn->setVisible(!isDmChannel(channelId));
|
||||
clearDmCallRoute();
|
||||
m_callBtn->setVisible(isDmChannel(channelId));
|
||||
m_inviteBtn->setVisible(isDmChannel(channelId));
|
||||
@@ -739,6 +745,7 @@ void MessageList::loadChannel(const QString& channelId) {
|
||||
setVoiceMessageRoles(item, m.data, m.contentType,
|
||||
m_db ? m_db->dbPath() + "/media" : QString(), channelId, m.localAttrs);
|
||||
m_model->appendRow(item);
|
||||
setupFeedback(item, m, channelId);
|
||||
}
|
||||
|
||||
if (sameChannel) {
|
||||
@@ -780,12 +787,9 @@ void MessageList::refresh() {
|
||||
|
||||
if (!m_db || !m_db->isOpen()) return;
|
||||
|
||||
qint64 maxId = 0;
|
||||
for (int r = 0; r < m_model->rowCount(); r++)
|
||||
if (m_model->item(r)->data(MsgIdRole).toLongLong() > maxId)
|
||||
maxId = m_model->item(r)->data(MsgIdRole).toLongLong();
|
||||
|
||||
auto newMsgs = m_db->getMessagesSince(m_currentChannelId, maxId);
|
||||
QSet<QString> present;
|
||||
for (int row = 0; row < m_model->rowCount(); row++) present.insert(m_model->item(row)->data(MsgMessageKeyRole).toString());
|
||||
auto newMsgs = m_db->getMessages(m_currentChannelId, 200);
|
||||
if (newMsgs.isEmpty()) return;
|
||||
|
||||
m_localNicks = m_db->getLocalNicknames(m_currentChannelId);
|
||||
@@ -794,6 +798,7 @@ void MessageList::refresh() {
|
||||
bool wasAtBottom = sb && (sb->value() >= sb->maximum());
|
||||
|
||||
for (const auto& m : newMsgs) {
|
||||
if (present.contains(QString::fromLatin1(m.messageId.toHex()))) continue;
|
||||
AccountRow acc = m_db->getAccount(m.authorNodeId);
|
||||
QString author = authorName(m.authorNodeId);
|
||||
QString letter = acc.avatarLetter.isEmpty() ? author.mid(0, 1) : acc.avatarLetter;
|
||||
@@ -815,10 +820,12 @@ void MessageList::refresh() {
|
||||
setVoiceMessageRoles(item, m.data, m.contentType,
|
||||
m_db ? m_db->dbPath() + "/media" : QString(), m_currentChannelId, m.localAttrs);
|
||||
m_model->appendRow(item);
|
||||
setupFeedback(item, m, m_currentChannelId);
|
||||
while (m_model->rowCount() > 200)
|
||||
m_model->removeRow(0);
|
||||
}
|
||||
|
||||
m_model->setSortRole(MsgRawTimestampRole); m_model->sort(0);
|
||||
if (wasAtBottom) m_view->scrollToBottom();
|
||||
m_readDebounce->start();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user