1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #5532

TriKriSta (1):
      feat: show date in chat log
This commit is contained in:
sudden6 2019-02-24 11:59:14 +01:00
commit 4fe6addb04
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
4 changed files with 25 additions and 0 deletions

View File

@ -700,6 +700,10 @@ void ChatLog::checkVisibility()
// if (!visibleLines.empty()) // if (!visibleLines.empty())
// qDebug() << "visible from " << visibleLines.first()->getRow() << "to " << // qDebug() << "visible from " << visibleLines.first()->getRow() << "to " <<
// visibleLines.last()->getRow() << " total " << visibleLines.size(); // visibleLines.last()->getRow() << " total " << visibleLines.size();
if (!visibleLines.isEmpty()) {
emit firstVisibleLineChanged(visibleLines.at(0));
}
} }
void ChatLog::scrollContentsBy(int dx, int dy) void ChatLog::scrollContentsBy(int dx, int dy)

View File

@ -69,6 +69,7 @@ public:
signals: signals:
void selectionChanged(); void selectionChanged();
void workerTimeoutFinished(); void workerTimeoutFinished();
void firstVisibleLineChanged(const ChatLine::Ptr&);
public slots: public slots:
void forceRelayout(); void forceRelayout();

View File

@ -138,9 +138,12 @@ GenericChatForm::GenericChatForm(const Contact* contact, QWidget* parent)
curRow = 0; curRow = 0;
headWidget = new ChatFormHeader(); headWidget = new ChatFormHeader();
searchForm = new SearchForm(); searchForm = new SearchForm();
dateInfo = new QLabel(this);
chatWidget = new ChatLog(this); chatWidget = new ChatLog(this);
chatWidget->setBusyNotification(ChatMessage::createBusyNotification()); chatWidget->setBusyNotification(ChatMessage::createBusyNotification());
searchForm->hide(); searchForm->hide();
dateInfo->setAlignment(Qt::AlignHCenter);
dateInfo->setVisible(false);
// settings // settings
const Settings& s = Settings::getInstance(); const Settings& s = Settings::getInstance();
@ -200,6 +203,7 @@ GenericChatForm::GenericChatForm(const Contact* contact, QWidget* parent)
QVBoxLayout* contentLayout = new QVBoxLayout(contentWidget); QVBoxLayout* contentLayout = new QVBoxLayout(contentWidget);
contentLayout->addWidget(searchForm); contentLayout->addWidget(searchForm);
contentLayout->addWidget(dateInfo);
contentLayout->addWidget(chatWidget); contentLayout->addWidget(chatWidget);
contentLayout->addLayout(mainFootLayout); contentLayout->addLayout(mainFootLayout);
@ -229,6 +233,7 @@ GenericChatForm::GenericChatForm(const Contact* contact, QWidget* parent)
connect(chatWidget, &ChatLog::customContextMenuRequested, this, connect(chatWidget, &ChatLog::customContextMenuRequested, this,
&GenericChatForm::onChatContextMenuRequested); &GenericChatForm::onChatContextMenuRequested);
connect(chatWidget, &ChatLog::firstVisibleLineChanged, this, &GenericChatForm::updateShowDateInfo);
connect(searchForm, &SearchForm::searchInBegin, this, &GenericChatForm::searchInBegin); connect(searchForm, &SearchForm::searchInBegin, this, &GenericChatForm::searchInBegin);
connect(searchForm, &SearchForm::searchUp, this, &GenericChatForm::onSearchUp); connect(searchForm, &SearchForm::searchUp, this, &GenericChatForm::onSearchUp);
@ -978,6 +983,19 @@ void GenericChatForm::onSearchTriggered()
} }
} }
void GenericChatForm::updateShowDateInfo(const ChatLine::Ptr& line)
{
const auto date = getDate(line);
if (date.isValid() && date != QDate::currentDate()) {
const auto dateText = QStringLiteral("<b>%1<\b>").arg(date.toString(Settings::getInstance().getDateFormat()));
dateInfo->setText(dateText);
dateInfo->setVisible(true);
} else {
dateInfo->setVisible(false);
}
}
void GenericChatForm::onContinueSearch() void GenericChatForm::onContinueSearch()
{ {
const QString phrase = searchForm->getSearchPhrase(); const QString phrase = searchForm->getSearchPhrase();

View File

@ -114,6 +114,7 @@ protected slots:
void copyLink(); void copyLink();
void searchFormShow(); void searchFormShow();
void onSearchTriggered(); void onSearchTriggered();
void updateShowDateInfo(const ChatLine::Ptr& line);
virtual void searchInBegin(const QString& phrase, const ParameterSearch& parameter) = 0; virtual void searchInBegin(const QString& phrase, const ParameterSearch& parameter) = 0;
virtual void onSearchUp(const QString& phrase, const ParameterSearch& parameter) = 0; virtual void onSearchUp(const QString& phrase, const ParameterSearch& parameter) = 0;
@ -173,6 +174,7 @@ protected:
ChatFormHeader* headWidget; ChatFormHeader* headWidget;
SearchForm *searchForm; SearchForm *searchForm;
QLabel *dateInfo;
ChatLog* chatWidget; ChatLog* chatWidget;
ChatTextEdit* msgEdit; ChatTextEdit* msgEdit;
#ifdef SPELL_CHECKING #ifdef SPELL_CHECKING