Add the possibility to show a recently added/updated indicator

This commit is contained in:
Luis Ángel San Martín
2023-05-20 16:17:40 +02:00
parent 11df4a9b42
commit 6a6a239cc7
25 changed files with 234 additions and 59 deletions

View File

@ -91,4 +91,25 @@ void YACReaderFoldersViewItemDeletegate::paint(QPainter *painter, const QStyleOp
}
QStyledItemDelegate::paint(painter, option, index);
auto showRecent = index.data(FolderModel::ShowRecentRole).toBool();
if (showRecent) {
auto now = QDateTime::currentSecsSinceEpoch();
auto added = index.data(FolderModel::AddedRole).toLongLong();
auto updated = index.data(FolderModel::UpdatedRole).toLongLong();
auto dayInSeconds = 86400;
if (now - added < dayInSeconds || now - updated < dayInSeconds) {
painter->save();
#ifdef Q_OS_MAC
painter->setBrush(QBrush(QColor(85, 95, 127)));
#else
painter->setBrush(QBrush(QColor(237, 197, 24)));
#endif
painter->setPen(QPen(QBrush(), 0));
painter->drawEllipse(option.rect.x() + 13, option.rect.y() + 2, 7, 7);
painter->restore();
}
}
}