1
0
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:
apprb 2014-10-11 01:54:21 +09:00
parent 2ede886c7d
commit 6860790205
No known key found for this signature in database
GPG Key ID: B001911B5B22FB9B
7 changed files with 47 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -34,6 +34,9 @@ public:
int nameColWidth() {return nameWidth;}
void setNameColWidth(int w);
public slots:
void clearChatArea();
signals:
void onFileTranfertInterract(QString widgetName, QString buttonName);

View File

@ -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");
}

View File

@ -60,6 +60,7 @@ protected slots:
void onSaveLogClicked();
void onEmoteButtonClicked();
void onEmoteInsertRequested(QString str);
void clearChatArea();
protected:
QString getElidedName(const QString& name);

View File

@ -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);

View File

@ -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;
}

View File

@ -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();