mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
cleanup
This commit is contained in:
parent
2826e83cef
commit
502229a6f2
|
@ -16,19 +16,11 @@
|
|||
|
||||
#include "chatform.h"
|
||||
#include "friend.h"
|
||||
#include "smileypack.h"
|
||||
#include "widget/friendwidget.h"
|
||||
#include "widget/widget.h"
|
||||
#include "widget/filetransfertwidget.h"
|
||||
#include "widget/emoticonswidget.h"
|
||||
#include "style.h"
|
||||
#include <QFont>
|
||||
#include <QTime>
|
||||
#include <QScrollBar>
|
||||
#include <QFileDialog>
|
||||
#include <QMenu>
|
||||
#include <QWidgetAction>
|
||||
#include <QGridLayout>
|
||||
#include <QMessageBox>
|
||||
|
||||
ChatForm::ChatForm(Friend* chatFriend)
|
||||
|
@ -50,8 +42,6 @@ ChatForm::ChatForm(Friend* chatFriend)
|
|||
connect(callButton, &QPushButton::clicked, this, &ChatForm::onCallTriggered);
|
||||
connect(videoButton, &QPushButton::clicked, this, &ChatForm::onVideoCallTriggered);
|
||||
connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered);
|
||||
connect(chatArea->verticalScrollBar(), &QScrollBar::rangeChanged, this, &ChatForm::onSliderRangeChanged);
|
||||
connect(chatArea, &QScrollArea::customContextMenuRequested, this, &ChatForm::onChatContextMenuRequested);
|
||||
connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle()));
|
||||
}
|
||||
|
||||
|
|
|
@ -17,19 +17,7 @@
|
|||
#ifndef CHATFORM_H
|
||||
#define CHATFORM_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QTextEdit>
|
||||
#include <QScrollArea>
|
||||
#include <QTime>
|
||||
#include <QPoint>
|
||||
|
||||
#include "genericchatform.h"
|
||||
#include "widget/tool/chattextedit.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "core.h"
|
||||
#include "widget/netcamview.h"
|
||||
|
||||
|
|
|
@ -147,6 +147,8 @@ GenericChatForm::GenericChatForm(QObject *parent) :
|
|||
emoteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
|
||||
connect(emoteButton, SIGNAL(clicked()), this, SLOT(onEmoteButtonClicked()));
|
||||
connect(chatArea, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint)));
|
||||
connect(chatArea->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged()));
|
||||
}
|
||||
|
||||
void GenericChatForm::setName(const QString &newName)
|
||||
|
@ -214,7 +216,7 @@ void GenericChatForm::onSaveLogClicked()
|
|||
void GenericChatForm::addMessage(QString author, QString message, QString date)
|
||||
{
|
||||
QLabel *authorLabel = new QLabel(author);
|
||||
QLabel *messageLabel = new QLabel(message);
|
||||
QLabel *messageLabel = new QLabel();
|
||||
QLabel *dateLabel = new QLabel(date);
|
||||
|
||||
QScrollBar* scroll = chatArea->verticalScrollBar();
|
||||
|
@ -253,9 +255,9 @@ void GenericChatForm::addMessage(QString author, QString message, QString date)
|
|||
for (QString& s : messageLines)
|
||||
{
|
||||
if (QRegExp("^[ ]*>.*").exactMatch(s))
|
||||
finalMessage += fontTemplate.arg(greentext.name(), s.replace(" ", " "));
|
||||
finalMessage += fontTemplate.arg(greentext.name(), toHtmlChars(s));
|
||||
else
|
||||
finalMessage += s.replace(" ", " ");
|
||||
finalMessage += toHtmlChars(s);
|
||||
finalMessage += "<br>";
|
||||
}
|
||||
messageLabel->setText(finalMessage.left(finalMessage.length()-4));
|
||||
|
@ -308,3 +310,14 @@ void GenericChatForm::onEmoteInsertRequested(QString str)
|
|||
|
||||
msgEdit->setFocus(); // refocus so that we can continue typing
|
||||
}
|
||||
|
||||
QString GenericChatForm::toHtmlChars(const QString &str)
|
||||
{
|
||||
static QList<QPair<QString, QString>> replaceList = {{"&","&"}, {" "," "}, {">",">"}, {"<","<"}};
|
||||
QString res = str;
|
||||
|
||||
for (auto &it : replaceList)
|
||||
res = res.replace(it.first,it.second);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
|
||||
virtual void setName(const QString &newName);
|
||||
virtual void show(Ui::MainWindow &ui);
|
||||
virtual void addMessage(QString author, QString message, QString date=QTime::currentTime().toString("hh:mm"));
|
||||
void addMessage(QString author, QString message, QString date=QTime::currentTime().toString("hh:mm"));
|
||||
|
||||
signals:
|
||||
void sendMessage(int, QString);
|
||||
|
@ -72,6 +72,9 @@ protected:
|
|||
QString previousName;
|
||||
int curRow;
|
||||
bool lockSliderToBottom;
|
||||
|
||||
private:
|
||||
QString toHtmlChars(const QString &str);
|
||||
};
|
||||
|
||||
#endif // GENERICCHATFORM_H
|
||||
|
|
|
@ -18,20 +18,11 @@
|
|||
#include "group.h"
|
||||
#include "widget/groupwidget.h"
|
||||
#include "widget/widget.h"
|
||||
#include "friend.h"
|
||||
#include "friendlist.h"
|
||||
#include "style.h"
|
||||
#include <QFont>
|
||||
#include <QTime>
|
||||
#include <QScrollBar>
|
||||
#include <QMenu>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
|
||||
GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||
: group(chatGroup)
|
||||
{
|
||||
nusers = new QLabel();
|
||||
nusersLabel = new QLabel();
|
||||
namesList = new QLabel();
|
||||
|
||||
fileButton->setEnabled(false);
|
||||
|
@ -44,8 +35,8 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
|||
small.setPixelSize(10);
|
||||
|
||||
nameLabel->setText(group->widget->name.text());
|
||||
nusers->setFont(small);
|
||||
nusers->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size()));
|
||||
nusersLabel->setFont(small);
|
||||
nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size()));
|
||||
avatarLabel->setPixmap(QPixmap(":/img/group_dark.png"));
|
||||
|
||||
QString names;
|
||||
|
@ -60,7 +51,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
|||
mainChatLayout->setColumnStretch(1,1);
|
||||
mainChatLayout->setHorizontalSpacing(10);
|
||||
|
||||
headTextLayout->addWidget(nusers);
|
||||
headTextLayout->addWidget(nusersLabel);
|
||||
headTextLayout->addWidget(namesList);
|
||||
headTextLayout->setMargin(0);
|
||||
headTextLayout->setSpacing(0);
|
||||
|
@ -68,8 +59,6 @@ GroupChatForm::GroupChatForm(Group* chatGroup)
|
|||
|
||||
connect(sendButton, SIGNAL(clicked()), this, SLOT(onSendTriggered()));
|
||||
connect(msgEdit, SIGNAL(enterPressed()), this, SLOT(onSendTriggered()));
|
||||
connect(chatArea->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged()));
|
||||
connect(chatArea, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint)));
|
||||
}
|
||||
|
||||
GroupChatForm::~GroupChatForm()
|
||||
|
@ -99,7 +88,7 @@ void GroupChatForm::addGroupMessage(QString message, int peerId)
|
|||
|
||||
void GroupChatForm::onUserListChanged()
|
||||
{
|
||||
nusers->setText(tr("%1 users in chat").arg(group->nPeers));
|
||||
nusersLabel->setText(tr("%1 users in chat").arg(group->nPeers));
|
||||
QString names;
|
||||
for (QString& s : group->peers)
|
||||
names.append(s+", ");
|
||||
|
|
|
@ -17,15 +17,6 @@
|
|||
#ifndef GROUPCHATFORM_H
|
||||
#define GROUPCHATFORM_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QTextEdit>
|
||||
#include <QScrollArea>
|
||||
#include <QTime>
|
||||
|
||||
#include "genericchatform.h"
|
||||
#include "widget/tool/chattextedit.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
@ -46,7 +37,7 @@ private slots:
|
|||
|
||||
private:
|
||||
Group* group;
|
||||
QLabel *nusers, *namesList;
|
||||
QLabel *nusersLabel, *namesList;
|
||||
};
|
||||
|
||||
#endif // GROUPCHATFORM_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user