pal resourse sticking, notifications of unread messages, new message icons
This commit is contained in:
parent
4c5efad9dc
commit
b44873d587
12 changed files with 119 additions and 95 deletions
|
@ -71,15 +71,14 @@ Shared::Message Chat::createMessage() const
|
|||
return msg;
|
||||
}
|
||||
|
||||
// TODO
|
||||
// void Chat::addMessage(const Shared::Message& data)
|
||||
// {
|
||||
// Conversation::addMessage(data);
|
||||
//
|
||||
// if (!data.getOutgoing()) { //TODO need to check if that was the last message
|
||||
// const QString& res = data.getPenPalResource();
|
||||
// if (res.size() > 0) {
|
||||
// setPalResource(res);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
void Chat::onMessage(const Shared::Message& data)
|
||||
{
|
||||
Conversation::onMessage(data);
|
||||
|
||||
if (!data.getOutgoing()) {
|
||||
const QString& res = data.getPenPalResource();
|
||||
if (res.size() > 0) {
|
||||
setPalResource(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,14 +34,13 @@ class Chat : public Conversation
|
|||
public:
|
||||
Chat(Models::Account* acc, Models::Contact* p_contact, QWidget* parent = 0);
|
||||
~Chat();
|
||||
|
||||
//void addMessage(const Shared::Message & data) override;
|
||||
|
||||
protected slots:
|
||||
void onContactChanged(Models::Item* item, int row, int col);
|
||||
|
||||
protected:
|
||||
Shared::Message createMessage() const override;
|
||||
void onMessage(const Shared::Message& msg) override;
|
||||
|
||||
private:
|
||||
void updateState();
|
||||
|
|
|
@ -48,8 +48,6 @@ Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el,
|
|||
delegate(new MessageDelegate(this)),
|
||||
scroll(down),
|
||||
manualSliderChange(false),
|
||||
requestingHistory(false),
|
||||
everShown(false),
|
||||
tsb(QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient) == 1)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
@ -57,8 +55,11 @@ Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el,
|
|||
feed->setItemDelegate(delegate);
|
||||
delegate->initializeFonts(feed->getFont());
|
||||
feed->setModel(el->feed);
|
||||
el->feed->incrementObservers();
|
||||
m_ui->widget->layout()->addWidget(feed);
|
||||
|
||||
connect(el->feed, &Models::MessageFeed::newMessage, this, &Conversation::onFeedMessage);
|
||||
|
||||
connect(acc, &Models::Account::childChanged, this, &Conversation::onAccountChanged);
|
||||
|
||||
filesLayout = new FlowLayout(m_ui->filesPanel, 0);
|
||||
|
@ -69,9 +70,6 @@ Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el,
|
|||
|
||||
connect(&ker, &KeyEnterReceiver::enterPressed, this, &Conversation::onEnterPressed);
|
||||
connect(m_ui->sendButton, &QPushButton::clicked, this, &Conversation::onEnterPressed);
|
||||
//connect(line, &MessageLine::downloadFile, this, &Conversation::downloadFile);
|
||||
//connect(line, &MessageLine::uploadFile, this, qOverload<const Shared::Message&, const QString&>(&Conversation::sendMessage));
|
||||
//connect(line, &MessageLine::requestLocalFile, this, &Conversation::requestLocalFile);
|
||||
connect(m_ui->attachButton, &QPushButton::clicked, this, &Conversation::onAttach);
|
||||
connect(m_ui->clearButton, &QPushButton::clicked, this, &Conversation::onClearButton);
|
||||
connect(m_ui->messageEditor->document()->documentLayout(), &QAbstractTextDocumentLayout::documentSizeChanged,
|
||||
|
@ -121,18 +119,19 @@ Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el,
|
|||
|
||||
Conversation::~Conversation()
|
||||
{
|
||||
element->feed->decrementObservers();
|
||||
}
|
||||
|
||||
void Conversation::onAccountChanged(Models::Item* item, int row, int col)
|
||||
{
|
||||
if (item == account) {
|
||||
if (col == 2 && account->getState() == Shared::ConnectionState::connected) {
|
||||
if (!requestingHistory) {
|
||||
requestingHistory = true;
|
||||
if (col == 2 && account->getState() == Shared::ConnectionState::connected) { //to request the history when we're back online after reconnect
|
||||
//if (!requestingHistory) {
|
||||
//requestingHistory = true;
|
||||
//line->showBusyIndicator();
|
||||
//emit requestArchive("");
|
||||
//scroll = down;
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,21 +222,6 @@ void Conversation::onEnterPressed()
|
|||
}
|
||||
}
|
||||
|
||||
void Conversation::showEvent(QShowEvent* event)
|
||||
{
|
||||
if (!everShown) {
|
||||
everShown = true;
|
||||
// line->showBusyIndicator();
|
||||
requestingHistory = true;
|
||||
scroll = keep;
|
||||
emit requestArchive("");
|
||||
}
|
||||
emit shown();
|
||||
|
||||
QWidget::showEvent(event);
|
||||
|
||||
}
|
||||
|
||||
void Conversation::onAttach()
|
||||
{
|
||||
QFileDialog* d = new QFileDialog(this, tr("Chose a file to send"));
|
||||
|
@ -265,21 +249,6 @@ void Conversation::setStatus(const QString& status)
|
|||
statusLabel->setText(Shared::processMessageBody(status));
|
||||
}
|
||||
|
||||
void Conversation::responseFileProgress(const QString& messageId, qreal progress)
|
||||
{
|
||||
// line->fileProgress(messageId, progress);
|
||||
}
|
||||
|
||||
void Conversation::fileError(const QString& messageId, const QString& error)
|
||||
{
|
||||
// line->fileError(messageId, error);
|
||||
}
|
||||
|
||||
void Conversation::responseLocalFile(const QString& messageId, const QString& path)
|
||||
{
|
||||
// line->responseLocalFile(messageId, path);
|
||||
}
|
||||
|
||||
Models::Roster::ElId Conversation::getId() const
|
||||
{
|
||||
return {getAccount(), getJid()};
|
||||
|
@ -416,3 +385,18 @@ Shared::Message Conversation::createMessage() const
|
|||
return msg;
|
||||
}
|
||||
|
||||
void Conversation::onFeedMessage(const Shared::Message& msg)
|
||||
{
|
||||
this->onMessage(msg);
|
||||
}
|
||||
|
||||
void Conversation::onMessage(const Shared::Message& msg)
|
||||
{
|
||||
qDebug() << window()->windowState();
|
||||
if (!msg.getForwarded()) {
|
||||
QApplication::alert(this);
|
||||
if (window()->windowState().testFlag(Qt::WindowMinimized)) {
|
||||
emit notifyableMessage(getAccount(), msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,10 +68,6 @@ public:
|
|||
Models::Roster::ElId getId() const;
|
||||
|
||||
void setPalResource(const QString& res);
|
||||
void showEvent(QShowEvent * event) override;
|
||||
void responseLocalFile(const QString& messageId, const QString& path);
|
||||
void fileError(const QString& messageId, const QString& error);
|
||||
void responseFileProgress(const QString& messageId, qreal progress);
|
||||
virtual void setAvatar(const QString& path);
|
||||
void setFeedFrames(bool top, bool right, bool bottom, bool left);
|
||||
|
||||
|
@ -81,6 +77,7 @@ signals:
|
|||
void shown();
|
||||
void requestLocalFile(const QString& messageId, const QString& url);
|
||||
void downloadFile(const QString& messageId, const QString& url);
|
||||
void notifyableMessage(const QString& account, const Shared::Message& msg);
|
||||
|
||||
protected:
|
||||
virtual void setName(const QString& name);
|
||||
|
@ -93,6 +90,7 @@ protected:
|
|||
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||
void dragLeaveEvent(QDragLeaveEvent* event) override;
|
||||
void dropEvent(QDropEvent* event) override;
|
||||
virtual void onMessage(const Shared::Message& msg);
|
||||
|
||||
protected slots:
|
||||
void onEnterPressed();
|
||||
|
@ -102,6 +100,7 @@ protected slots:
|
|||
void onClearButton();
|
||||
void onTextEditDocSizeChanged(const QSizeF& size);
|
||||
void onAccountChanged(Models::Item* item, int row, int col);
|
||||
void onFeedMessage(const Shared::Message& msg);
|
||||
|
||||
public:
|
||||
const bool isMuc;
|
||||
|
@ -128,8 +127,6 @@ protected:
|
|||
MessageDelegate* delegate;
|
||||
Scroll scroll;
|
||||
bool manualSliderChange;
|
||||
bool requestingHistory;
|
||||
bool everShown;
|
||||
bool tsb; //transient scroll bars
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue