mirror of
https://gitlab.com/comunic/comunicmessages
synced 2024-12-04 19:24:11 +00:00
Scroll to the bottom of the conversation when receive new messages.
This commit is contained in:
parent
aa334d0110
commit
22eec97796
@ -17,7 +17,7 @@ public:
|
|||||||
ConversationMessagesList();
|
ConversationMessagesList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ID of the oldest message of
|
* Get the ID of the newest message of
|
||||||
* the conversation
|
* the conversation
|
||||||
*
|
*
|
||||||
* @return The ID of the message / -1 in case of failure
|
* @return The ID of the message / -1 in case of failure
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QScrollBar>
|
||||||
|
|
||||||
#include "conversationwidget.h"
|
#include "conversationwidget.h"
|
||||||
#include "ui_conversationwidget.h"
|
#include "ui_conversationwidget.h"
|
||||||
@ -136,6 +137,16 @@ void ConversationWidget::getMessagesCallback(bool success, QList<ConversationMes
|
|||||||
|
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Scroll to the end of the widget if required
|
||||||
|
if(list.at(list.count()-1).iD() == mMessages.getLastMessageID())
|
||||||
|
QTimer::singleShot(1000, this, &ConversationWidget::scrollToBottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConversationWidget::scrollToBottom()
|
||||||
|
{
|
||||||
|
ui->scrollArea->verticalScrollBar()->setValue(
|
||||||
|
ui->scrollArea->verticalScrollBar()->maximum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConversationWidget::sendMessageCallback(bool success)
|
void ConversationWidget::sendMessageCallback(bool success)
|
||||||
|
@ -59,6 +59,11 @@ private slots:
|
|||||||
*/
|
*/
|
||||||
void getMessagesCallback(bool success, QList<ConversationMessage> list);
|
void getMessagesCallback(bool success, QList<ConversationMessage> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scroll to the bottom of the conversation
|
||||||
|
*/
|
||||||
|
void scrollToBottom();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called once the server replied to a send conversation
|
* Method called once the server replied to a send conversation
|
||||||
* message request
|
* message request
|
||||||
|
Loading…
Reference in New Issue
Block a user