mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
moved typing notifications to ChatLog
This commit is contained in:
parent
d9e15fb0ba
commit
904627e50a
5
res.qrc
5
res.qrc
|
@ -151,7 +151,7 @@
|
|||
<file>ui/chatArea/innerStyle.css</file>
|
||||
<file>ui/chatArea/spinner.png</file>
|
||||
<file>ui/chatArea/info.png</file>
|
||||
<file>ui/chatArea/error.png</file>
|
||||
<file>ui/chatArea/error.png</file>
|
||||
<file>ui/chatArea/scrollBarDownArrow.png</file>
|
||||
<file>ui/chatArea/scrollBarDownArrowHover.png</file>
|
||||
<file>ui/chatArea/scrollBarDownArrowPressed.png</file>
|
||||
|
@ -224,7 +224,7 @@
|
|||
<file>ui/fileTransferInstance/no_2x.png</file>
|
||||
<file>ui/fileTransferInstance/yes_2x.png</file>
|
||||
<file>ui/fileTransferInstance/arrow_white_2x.png</file>
|
||||
<file>ui/fileTransferInstance/browse_path.png</file>
|
||||
<file>ui/fileTransferInstance/browse_path.png</file>
|
||||
<file>ui/volButton/volButton.png</file>
|
||||
<file>ui/volButton/volButtonHover.png</file>
|
||||
<file>ui/volButton/volButtonPressed.png</file>
|
||||
|
@ -232,5 +232,6 @@
|
|||
<file>ui/window/applicationIcon.png</file>
|
||||
<file>ui/window/statusPanel.css</file>
|
||||
<file>ui/window/window.css</file>
|
||||
<file>ui/chatArea/typing.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -101,6 +101,12 @@ void ChatLine::addToScene(QGraphicsScene *scene)
|
|||
scene->addItem(c);
|
||||
}
|
||||
|
||||
void ChatLine::setVisible(bool visible)
|
||||
{
|
||||
for(ChatLineContent* c : content)
|
||||
c->setVisible(visible);
|
||||
}
|
||||
|
||||
void ChatLine::selectionCleared()
|
||||
{
|
||||
for(ChatLineContent* c : content)
|
||||
|
|
|
@ -83,6 +83,8 @@ public:
|
|||
void removeFromScene();
|
||||
void addToScene(QGraphicsScene* scene);
|
||||
|
||||
void setVisible(bool visible);
|
||||
|
||||
protected:
|
||||
QPointF mapToContent(ChatLineContent* c, QPointF pos);
|
||||
void addColumn(ChatLineContent* item, ColumnFormat fmt);
|
||||
|
|
|
@ -144,7 +144,12 @@ QRect ChatLog::getVisibleRect() const
|
|||
|
||||
void ChatLog::updateSceneRect()
|
||||
{
|
||||
setSceneRect(QRectF(-margins.left(), -margins.top(), useableWidth(), (lines.empty() ? 0.0 : lines.last()->boundingSceneRect().bottom()) + margins.bottom() + margins.top()));
|
||||
qreal bottom = (lines.empty() ? 0.0 : lines.last()->boundingSceneRect().bottom());
|
||||
|
||||
if(typingNotification.get() != nullptr)
|
||||
bottom += typingNotification->boundingSceneRect().height() + lineSpacing;
|
||||
|
||||
setSceneRect(QRectF(-margins.left(), -margins.top(), useableWidth(), bottom + margins.bottom() + margins.top()));
|
||||
}
|
||||
|
||||
qreal ChatLog::layout(int start, int end, qreal width)
|
||||
|
@ -530,6 +535,11 @@ bool ChatLog::hasTextToBeCopied() const
|
|||
return selectionMode != None;
|
||||
}
|
||||
|
||||
ChatLine::Ptr ChatLog::getTypingNotification() const
|
||||
{
|
||||
return typingNotification;
|
||||
}
|
||||
|
||||
void ChatLog::clear()
|
||||
{
|
||||
clearSelection();
|
||||
|
@ -551,6 +561,24 @@ void ChatLog::copySelectedText() const
|
|||
clipboard->setText(text);
|
||||
}
|
||||
|
||||
void ChatLog::setTypingNotification(ChatLine::Ptr notification)
|
||||
{
|
||||
typingNotification = notification;
|
||||
typingNotification->visibilityChanged(true);
|
||||
typingNotification->setVisible(false);
|
||||
typingNotification->addToScene(scene);
|
||||
updateTypingNotification();
|
||||
}
|
||||
|
||||
void ChatLog::setTypingNotificationVisible(bool visible)
|
||||
{
|
||||
if(typingNotification.get() != nullptr)
|
||||
{
|
||||
typingNotification->setVisible(visible);
|
||||
updateTypingNotification();
|
||||
}
|
||||
}
|
||||
|
||||
void ChatLog::checkVisibility()
|
||||
{
|
||||
if(lines.empty())
|
||||
|
@ -643,6 +671,20 @@ void ChatLog::updateMultiSelectionRect()
|
|||
}
|
||||
}
|
||||
|
||||
void ChatLog::updateTypingNotification()
|
||||
{
|
||||
ChatLine* notification = typingNotification.get();
|
||||
if(!notification)
|
||||
return;
|
||||
|
||||
qreal posY = 0.0;
|
||||
|
||||
if(!lines.empty())
|
||||
posY = lines.last()->boundingSceneRect().bottom() + lineSpacing;
|
||||
|
||||
notification->layout(useableWidth(), QPointF(0.0, posY));
|
||||
}
|
||||
|
||||
void ChatLog::onSelectionTimerTimeout()
|
||||
{
|
||||
const int scrollSpeed = 10;
|
||||
|
|
|
@ -43,12 +43,16 @@ public:
|
|||
void clearSelection();
|
||||
void clear();
|
||||
void copySelectedText() const;
|
||||
void setTypingNotification(ChatLine::Ptr notification);
|
||||
void setTypingNotificationVisible(bool visible);
|
||||
QString getSelectedText() const;
|
||||
QString toPlainText() const;
|
||||
|
||||
bool isEmpty() const;
|
||||
bool hasTextToBeCopied() const;
|
||||
|
||||
ChatLine::Ptr getTypingNotification() const;
|
||||
|
||||
protected:
|
||||
QRect getVisibleRect() const;
|
||||
ChatLineContent* getContentFromPos(QPointF scenePos) const;
|
||||
|
@ -73,6 +77,7 @@ protected:
|
|||
virtual void resizeEvent(QResizeEvent *ev);
|
||||
|
||||
void updateMultiSelectionRect();
|
||||
void updateTypingNotification();
|
||||
|
||||
private slots:
|
||||
void onSelectionTimerTimeout();
|
||||
|
@ -93,6 +98,7 @@ private:
|
|||
QGraphicsScene* scene = nullptr;
|
||||
QVector<ChatLine::Ptr> lines;
|
||||
QList<ChatLine::Ptr> visibleLines;
|
||||
ChatLine::Ptr typingNotification;
|
||||
|
||||
bool multiLineInsert = false;
|
||||
bool stickToBtm = false;
|
||||
|
|
|
@ -71,8 +71,9 @@ ChatMessage::Ptr ChatMessage::createChatInfoMessage(const QString &rawMessage, S
|
|||
QString img;
|
||||
switch(type)
|
||||
{
|
||||
case INFO: img = ":/ui/chatArea/info.png"; break;
|
||||
case ERROR: img = ":/ui/chatArea/error.png"; break;
|
||||
case INFO: img = ":/ui/chatArea/info.png"; break;
|
||||
case ERROR: img = ":/ui/chatArea/error.png"; break;
|
||||
case TYPING: img = ":/ui/chatArea/typing.png"; break;
|
||||
}
|
||||
|
||||
msg->addColumn(new Image(QSizeF(16, 16), img), ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
{
|
||||
INFO,
|
||||
ERROR,
|
||||
TYPING,
|
||||
};
|
||||
|
||||
ChatMessage();
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "src/misc/cstring.h"
|
||||
#include "src/chatlog/chatmessage.h"
|
||||
#include "src/chatlog/content/filetransferwidget.h"
|
||||
#include "src/chatlog/content/text.h"
|
||||
#include "src/chatlog/chatlog.h"
|
||||
|
||||
ChatForm::ChatForm(Friend* chatFriend)
|
||||
|
@ -55,18 +56,11 @@ ChatForm::ChatForm(Friend* chatFriend)
|
|||
statusMessageLabel->setFont(Style::getFont(Style::Medium));
|
||||
statusMessageLabel->setMinimumHeight(Style::getFont(Style::Medium).pixelSize());
|
||||
|
||||
isTypingLabel = new QLabel();
|
||||
QFont font = isTypingLabel->font();
|
||||
font.setItalic(true);
|
||||
font.setPixelSize(8);
|
||||
isTypingLabel->setFont(font);
|
||||
|
||||
QVBoxLayout* mainLayout = dynamic_cast<QVBoxLayout*>(layout());
|
||||
mainLayout->insertWidget(1, isTypingLabel);
|
||||
|
||||
netcam = new NetCamView();
|
||||
timer = nullptr;
|
||||
|
||||
chatWidget->setTypingNotification(ChatMessage::createChatInfoMessage("", ChatMessage::TYPING, QDateTime()));
|
||||
|
||||
headTextLayout->addWidget(statusMessageLabel);
|
||||
headTextLayout->addStretch();
|
||||
callDuration = new QLabel();
|
||||
|
@ -883,10 +877,12 @@ void ChatForm::dischargeReceipt(int receipt)
|
|||
|
||||
void ChatForm::setFriendTyping(bool isTyping)
|
||||
{
|
||||
if (isTyping)
|
||||
isTypingLabel->setText(f->getDisplayedName() + " " + tr("is typing..."));
|
||||
else
|
||||
isTypingLabel->clear();
|
||||
chatWidget->setTypingNotificationVisible(isTyping);
|
||||
|
||||
Text* text = dynamic_cast<Text*>(chatWidget->getTypingNotification()->getContent(1));
|
||||
|
||||
if(text)
|
||||
text->setText("<div class=typing>" + tr("%1 is typing...").arg(f->getDisplayedName()) + "</div>");
|
||||
}
|
||||
|
||||
void ChatForm::clearReciepts()
|
||||
|
|
|
@ -101,7 +101,6 @@ private:
|
|||
QLabel *callDuration;
|
||||
QTimer *timer;
|
||||
QElapsedTimer timeElapsed;
|
||||
QLabel *isTypingLabel;
|
||||
|
||||
QHash<uint, FileTransferInstance*> ftransWidgets;
|
||||
void startCounter();
|
||||
|
|
|
@ -8,6 +8,11 @@ div.action {
|
|||
font: @big;
|
||||
}
|
||||
|
||||
div.typing {
|
||||
color: @black;
|
||||
font: @bigBold;
|
||||
}
|
||||
|
||||
span.quote {
|
||||
color: #279419;
|
||||
}
|
||||
|
|
|
@ -110,4 +110,27 @@
|
|||
style="fill:#1c1c1c;fill-opacity:1" /></flowRegion><flowPara
|
||||
id="flowPara2994-4-0"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:Aller;-inkscape-font-specification:Aller">i</flowPara></flowRoot> </g>
|
||||
<g
|
||||
id="g3028">
|
||||
<path
|
||||
d="m 578.61101,583.89197 -151.31581,0"
|
||||
id="path3020"
|
||||
style="fill:none;stroke:#000000;stroke-width:22.62518883;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
<rect
|
||||
width="56.114246"
|
||||
height="165.16646"
|
||||
x="744.20551"
|
||||
y="12.56288"
|
||||
transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)"
|
||||
id="rect3024"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
<rect
|
||||
width="23.292706"
|
||||
height="27.527742"
|
||||
x="759.55756"
|
||||
y="174.55305"
|
||||
transform="matrix(0.8660254,0.5,-0.5,0.8660254,0,0)"
|
||||
id="rect3026"
|
||||
style="fill:#000000;fill-opacity:1;stroke:none" />
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.9 KiB |
BIN
ui/chatArea/typing.png
Normal file
BIN
ui/chatArea/typing.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 580 B |
Loading…
Reference in New Issue
Block a user