mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
clear chat area
This commit is contained in:
parent
2ede886c7d
commit
6860790205
|
@ -162,3 +162,24 @@ void ChatAreaWidget::setNameColWidth(int w)
|
|||
|
||||
nameWidth = w;
|
||||
}
|
||||
|
||||
void ChatAreaWidget::clearChatArea()
|
||||
{
|
||||
QList<ChatAction*> newMsgs;
|
||||
for (ChatAction* message : messages)
|
||||
{
|
||||
if (message->isInteractive())
|
||||
{
|
||||
newMsgs.append(message);
|
||||
} else {
|
||||
delete message;
|
||||
}
|
||||
}
|
||||
messages.clear();
|
||||
this->clear();
|
||||
|
||||
for (ChatAction* message : newMsgs)
|
||||
{
|
||||
insertMessage(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ public:
|
|||
int nameColWidth() {return nameWidth;}
|
||||
void setNameColWidth(int w);
|
||||
|
||||
public slots:
|
||||
void clearChatArea();
|
||||
|
||||
signals:
|
||||
void onFileTranfertInterract(QString widgetName, QString buttonName);
|
||||
|
||||
|
|
|
@ -124,6 +124,8 @@ GenericChatForm::GenericChatForm(QWidget *parent) :
|
|||
emoteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
|
||||
menu.addAction(tr("Save chat log"), this, SLOT(onSaveLogClicked()));
|
||||
menu.addAction(tr("Clear displayed messages"), this, SLOT(clearChatArea()));
|
||||
menu.addSeparator();
|
||||
|
||||
connect(emoteButton, SIGNAL(clicked()), this, SLOT(onEmoteButtonClicked()));
|
||||
connect(chatWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint)));
|
||||
|
@ -239,3 +241,10 @@ QString GenericChatForm::getElidedName(const QString& name)
|
|||
|
||||
return fm.elidedText(name, Qt::ElideRight, chatWidget->nameColWidth());
|
||||
}
|
||||
|
||||
void GenericChatForm::clearChatArea()
|
||||
{
|
||||
chatWidget->clearChatArea();
|
||||
previousName = "";
|
||||
addSystemInfoMessage(tr("Cleared"), "green");
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ protected slots:
|
|||
void onSaveLogClicked();
|
||||
void onEmoteButtonClicked();
|
||||
void onEmoteInsertRequested(QString str);
|
||||
void clearChatArea();
|
||||
|
||||
protected:
|
||||
QString getElidedName(const QString& name);
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
virtual QString getName();
|
||||
virtual QString getMessage() = 0;
|
||||
virtual QString getDate();
|
||||
virtual bool isInteractive(){return false;}
|
||||
|
||||
protected:
|
||||
QString toHtmlChars(const QString &str);
|
||||
|
|
|
@ -86,3 +86,14 @@ void FileTransferAction::updateHtml()
|
|||
cur = QTextCursor();
|
||||
}
|
||||
}
|
||||
|
||||
bool FileTransferAction::isInteractive()
|
||||
{
|
||||
if (w->getState() == FileTransferInstance::TransfState::tsCanceled
|
||||
|| w->getState() == FileTransferInstance::TransfState::tsFinished)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
virtual ~FileTransferAction();
|
||||
virtual QString getMessage();
|
||||
virtual void setup(QTextCursor cursor, QTextEdit* textEdit) override;
|
||||
virtual bool isInteractive();
|
||||
|
||||
private slots:
|
||||
void updateHtml();
|
||||
|
|
Loading…
Reference in New Issue
Block a user