mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix #671
This commit is contained in:
parent
1c952f280a
commit
e1b95105bc
@ -28,6 +28,7 @@ ChatAreaWidget::ChatAreaWidget(QWidget *parent)
|
|||||||
: QTextBrowser(parent)
|
: QTextBrowser(parent)
|
||||||
, tableFrmt(nullptr)
|
, tableFrmt(nullptr)
|
||||||
, nameWidth(75)
|
, nameWidth(75)
|
||||||
|
, empty{true}
|
||||||
{
|
{
|
||||||
setReadOnly(true);
|
setReadOnly(true);
|
||||||
viewport()->setCursor(Qt::ArrowCursor);
|
viewport()->setCursor(Qt::ArrowCursor);
|
||||||
@ -114,11 +115,13 @@ void ChatAreaWidget::insertMessage(ChatActionPtr msgAction, QTextCursor::MoveOpe
|
|||||||
|
|
||||||
if (msgAction->isInteractive())
|
if (msgAction->isInteractive())
|
||||||
messages.append(msgAction);
|
messages.append(msgAction);
|
||||||
|
|
||||||
|
empty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ChatAreaWidget::getNumberOfMessages()
|
bool ChatAreaWidget::isEmpty()
|
||||||
{
|
{
|
||||||
return messages.size();
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatAreaWidget::onSliderRangeChanged()
|
void ChatAreaWidget::onSliderRangeChanged()
|
||||||
@ -179,6 +182,7 @@ void ChatAreaWidget::clearChatArea()
|
|||||||
}
|
}
|
||||||
messages.clear();
|
messages.clear();
|
||||||
this->clear();
|
this->clear();
|
||||||
|
empty = true;
|
||||||
|
|
||||||
for (ChatActionPtr message : newMsgs)
|
for (ChatActionPtr message : newMsgs)
|
||||||
{
|
{
|
||||||
@ -194,4 +198,6 @@ void ChatAreaWidget::insertMessagesTop(QList<ChatActionPtr> &list)
|
|||||||
{
|
{
|
||||||
insertMessage(it, QTextCursor::Start);
|
insertMessage(it, QTextCursor::Start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
empty = false;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public:
|
|||||||
|
|
||||||
int nameColWidth() {return nameWidth;}
|
int nameColWidth() {return nameWidth;}
|
||||||
void setNameColWidth(int w);
|
void setNameColWidth(int w);
|
||||||
int getNumberOfMessages();
|
bool isEmpty();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clearChatArea();
|
void clearChatArea();
|
||||||
@ -59,6 +59,7 @@ private:
|
|||||||
int sliderPosition;
|
int sliderPosition;
|
||||||
int nameWidth;
|
int nameWidth;
|
||||||
QTextBlockFormat nameFormat, dateFormat;
|
QTextBlockFormat nameFormat, dateFormat;
|
||||||
|
bool empty;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHATAREAWIDGET_H
|
#endif // CHATAREAWIDGET_H
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
#include "src/friendlist.h"
|
#include "src/friendlist.h"
|
||||||
#include "src/friend.h"
|
#include "src/friend.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
GenericChatForm::GenericChatForm(QWidget *parent) :
|
GenericChatForm::GenericChatForm(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
earliestMessage(nullptr)
|
earliestMessage(nullptr)
|
||||||
@ -151,9 +153,9 @@ GenericChatForm::GenericChatForm(QWidget *parent) :
|
|||||||
headWidget->setStyleSheet(Style::getStylesheet(":/ui/chatArea/chatHead.css"));
|
headWidget->setStyleSheet(Style::getStylesheet(":/ui/chatArea/chatHead.css"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int GenericChatForm::getNumberOfMessages()
|
bool GenericChatForm::isEmpty()
|
||||||
{
|
{
|
||||||
return chatWidget->getNumberOfMessages();
|
return chatWidget->isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericChatForm::setName(const QString &newName)
|
void GenericChatForm::setName(const QString &newName)
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
void addSystemInfoMessage(const QString &message, const QString &type, const QDateTime &datetime);
|
void addSystemInfoMessage(const QString &message, const QString &type, const QDateTime &datetime);
|
||||||
void addAlertMessage(const QString& author, QString message, QDateTime datetime); ///< Deprecated
|
void addAlertMessage(const QString& author, QString message, QDateTime datetime); ///< Deprecated
|
||||||
void addAlertMessage(const ToxID& author, QString message, QDateTime datetime);
|
void addAlertMessage(const ToxID& author, QString message, QDateTime datetime);
|
||||||
int getNumberOfMessages();
|
bool isEmpty();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sendMessage(int, QString);
|
void sendMessage(int, QString);
|
||||||
|
@ -665,7 +665,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status)
|
|||||||
f->getFriendWidget()->updateStatusLight();
|
f->getFriendWidget()->updateStatusLight();
|
||||||
|
|
||||||
//won't print the message if there were no messages before
|
//won't print the message if there were no messages before
|
||||||
if(f->getChatForm()->getNumberOfMessages() != 0
|
if(!f->getChatForm()->isEmpty()
|
||||||
&& Settings::getInstance().getStatusChangeNotificationEnabled() == true)
|
&& Settings::getInstance().getStatusChangeNotificationEnabled() == true)
|
||||||
{
|
{
|
||||||
QString fStatus = "";
|
QString fStatus = "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user