mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: remove unnecessary methods
"isEmpty" method is just completely redundant, while "fontToCss" and "resolveToxId" don't relate to "GenericChatForm" class
This commit is contained in:
parent
27f65be289
commit
2598973c76
|
@ -735,7 +735,7 @@ void ChatForm::loadHistory(const QDateTime& since, bool processUndelivered)
|
|||
auto msg = ChatMessage::createChatMessage(authorStr, messageText, type, isSelf, dateTime);
|
||||
|
||||
uint prev = prevMsgDateTime.secsTo(msgDateTime);
|
||||
if (!isAction && prevId == authorPk && prev < getChatLog()->repNameAfter) {
|
||||
if (!isAction && prevId == authorPk && prev < chatWidget->repNameAfter) {
|
||||
msg->hideSender();
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,34 @@ static const short MAIN_FOOT_LAYOUT_SPACING = 5;
|
|||
static const short MIC_BUTTONS_LAYOUT_SPACING = 4;
|
||||
static const short HEAD_LAYOUT_SPACING = 5;
|
||||
static const short BUTTONS_LAYOUT_HOR_SPACING = 4;
|
||||
static const QString styleType[]{"normal", "italic", "oblique"};
|
||||
|
||||
QString fontToCss(const QFont& font, const QString& name)
|
||||
{
|
||||
QString result{"%1{"
|
||||
"font-family: \"%2\"; "
|
||||
"font-size: %3px; "
|
||||
"font-style: \"%4\"; "
|
||||
"font-weight: normal;}"};
|
||||
return result.arg(name).arg(font.family()).arg(font.pixelSize()).arg(styleType[font.style()]);
|
||||
}
|
||||
|
||||
QString resolveToxId(const ToxPk& id)
|
||||
{
|
||||
Friend* f = FriendList::findFriend(id);
|
||||
if (f) {
|
||||
return f->getDisplayedName();
|
||||
}
|
||||
|
||||
for (Group* it : GroupList::getAllGroups()) {
|
||||
QString res = it->resolveToxId(id);
|
||||
if (!res.isEmpty()) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
return QString{};
|
||||
}
|
||||
|
||||
GenericChatForm::GenericChatForm(QWidget* parent)
|
||||
: QWidget(parent, Qt::Window)
|
||||
|
@ -275,16 +303,6 @@ void GenericChatForm::hideFileMenu()
|
|||
fileFlyout->animateHide();
|
||||
}
|
||||
|
||||
bool GenericChatForm::isEmpty()
|
||||
{
|
||||
return chatWidget->isEmpty();
|
||||
}
|
||||
|
||||
ChatLog* GenericChatForm::getChatLog() const
|
||||
{
|
||||
return chatWidget;
|
||||
}
|
||||
|
||||
QDate GenericChatForm::getLatestDate() const
|
||||
{
|
||||
ChatLine::Ptr chatLine = chatWidget->getLatestLine();
|
||||
|
@ -377,7 +395,7 @@ ChatMessage::Ptr GenericChatForm::addMessage(const ToxPk& author, const QString&
|
|||
msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::NORMAL,
|
||||
authorIsActiveProfile);
|
||||
if ((author == previousId)
|
||||
&& (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter))
|
||||
&& (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < chatWidget->repNameAfter))
|
||||
msg->hideSender();
|
||||
|
||||
previousId = author;
|
||||
|
@ -408,7 +426,7 @@ void GenericChatForm::addAlertMessage(const ToxPk& author, QString message, QDat
|
|||
insertChatMessage(msg);
|
||||
|
||||
if ((author == previousId)
|
||||
&& (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter))
|
||||
&& (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < chatWidget->repNameAfter))
|
||||
msg->hideSender();
|
||||
|
||||
previousId = author;
|
||||
|
@ -526,21 +544,6 @@ void GenericChatForm::onSelectAllClicked()
|
|||
chatWidget->selectAll();
|
||||
}
|
||||
|
||||
QString GenericChatForm::resolveToxId(const ToxPk& id)
|
||||
{
|
||||
Friend* f = FriendList::findFriend(id);
|
||||
if (f)
|
||||
return f->getDisplayedName();
|
||||
|
||||
for (Group* it : GroupList::getAllGroups()) {
|
||||
QString res = it->resolveToxId(id);
|
||||
if (res.size())
|
||||
return res;
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
void GenericChatForm::insertChatMessage(ChatMessage::Ptr msg)
|
||||
{
|
||||
chatWidget->insertChatlineAtBottom(std::static_pointer_cast<ChatLine>(msg));
|
||||
|
@ -682,17 +685,6 @@ void GenericChatForm::retranslateUi()
|
|||
copyLinkAction->setText(tr("Copy link address"));
|
||||
}
|
||||
|
||||
QString GenericChatForm::fontToCss(const QFont& font, const char* name)
|
||||
{
|
||||
return QString("%1{font-family: \"%2\"; font-size: %3px; font-style: \"%4\"; font-weight: normal;}")
|
||||
.arg(name)
|
||||
.arg(font.family())
|
||||
.arg(font.pixelSize())
|
||||
.arg(font.style() == QFont::StyleNormal ? "normal" : font.style() == QFont::StyleItalic
|
||||
? "italic"
|
||||
: "oblique");
|
||||
}
|
||||
|
||||
void GenericChatForm::showNetcam()
|
||||
{
|
||||
if (!netcam)
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
* @note Why the hell is this a thing? surely the different font is enough?
|
||||
* - Even a different font is not enough – TODO #1307 ~~zetok
|
||||
*/
|
||||
#define AUTHOR_CHANGE_SPACING 5
|
||||
|
||||
QString resolveToxId(const ToxPk& id);
|
||||
|
||||
class QLabel;
|
||||
class QVBoxLayout;
|
||||
|
@ -75,9 +76,6 @@ public:
|
|||
void addSystemInfoMessage(const QString& message, ChatMessage::SystemMessageType type,
|
||||
const QDateTime& datetime);
|
||||
void addAlertMessage(const ToxPk& author, QString message, QDateTime datetime);
|
||||
bool isEmpty();
|
||||
|
||||
ChatLog* getChatLog() const;
|
||||
QDate getLatestDate() const;
|
||||
|
||||
signals:
|
||||
|
@ -108,13 +106,11 @@ protected slots:
|
|||
|
||||
private:
|
||||
void retranslateUi();
|
||||
static QString fontToCss(const QFont& font, const char* name);
|
||||
|
||||
protected:
|
||||
void showNetcam();
|
||||
void hideNetcam();
|
||||
virtual GenericNetCamView* createNetcam() = 0;
|
||||
QString resolveToxId(const ToxPk& id);
|
||||
virtual void insertChatMessage(ChatMessage::Ptr msg);
|
||||
void adjustFileMenuPosition();
|
||||
virtual void hideEvent(QHideEvent* event) override;
|
||||
|
|
Loading…
Reference in New Issue
Block a user