diff --git a/mainwindow.ui b/mainwindow.ui index ccd54aa..63de6cb 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -146,6 +146,9 @@ 查找 + + Ctrl+S + diff --git a/recvtextedit.cpp b/recvtextedit.cpp index 118ece5..376ef86 100644 --- a/recvtextedit.cpp +++ b/recvtextedit.cpp @@ -27,33 +27,45 @@ void RecvTextEdit::mouseReleaseEvent(QMouseEvent *e) void RecvTextEdit::addFellowContent(const Content *content, long long msSinceEpoch) { + addContent(content, msSinceEpoch, false); +} + +void RecvTextEdit::addMyContent(const Content *content, long long msSinceEpoch) +{ + addContent(content, msSinceEpoch, true); +} + +void RecvTextEdit::addContent(const Content *content, long long msSinceEpoch, bool mySelf) +{ drawDaySeperatorIfNewDay(msSinceEpoch); - QString hint = ""; - if (mFellow) - hint = mFellow->getName().c_str(); - else - hint = "匿名"; - hint = hint+" "+ timeStr(msSinceEpoch)+""; - moveCursor(QTextCursor::End); - insertHtml(hint); - append(""); - showContent(content, false); + showHint(msSinceEpoch, mySelf); + + showContent(content, mySelf); append("\n"); moveCursor(QTextCursor::End); } -void RecvTextEdit::addMyContent(const Content *content, long long msSinceEpoch) +void RecvTextEdit::showHint(long long msSinceEpoch, bool mySelf) { - drawDaySeperatorIfNewDay(msSinceEpoch); + QString name(""); + QString color("black"); + if (mySelf) + { + name = "我"; + color = "blue"; + } + else + { + name = mFellow == nullptr ? "匿名" : mFellow->getName().c_str(); + color = "green"; + } + + QString hint = ""+ name+" "+timeStr(msSinceEpoch)+""; - QString hint = "我 "+timeStr(msSinceEpoch)+""; moveCursor(QTextCursor::End); insertHtml(hint); append(""); - showContent(content, true); - append("\n"); - moveCursor(QTextCursor::End); } void RecvTextEdit::setCurFellow(const Fellow *fellow) diff --git a/recvtextedit.h b/recvtextedit.h index 958703b..508d705 100644 --- a/recvtextedit.h +++ b/recvtextedit.h @@ -31,6 +31,8 @@ signals: private: QString timeStr(long long msSinceEpoch); + void addContent(const Content* content, long long msSinceEpoch, bool mySelf); + void showHint(long long msSinceEpoch, bool mySelf); void showContent(const Content* content, bool mySelf); void showFile(const FileContent* content, bool fromMySelf); void showImage(const ImageContent* content);