From fac593b803cf7f8c45e5608e81221971d8503e4f Mon Sep 17 00:00:00 2001 From: arm64v8a <48624112+arm64v8a@users.noreply.github.com> Date: Fri, 5 Aug 2022 17:13:59 +0800 Subject: [PATCH] show subscription update time --- db/Database.cpp | 1 + db/Group.hpp | 1 + sub/GroupUpdater.cpp | 1 + translations/zh_CN.ts | 4 ++++ ui/widget/GroupItem.cpp | 11 +++++++++-- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/db/Database.cpp b/db/Database.cpp index 07b0fb4..052f323 100644 --- a/db/Database.cpp +++ b/db/Database.cpp @@ -182,6 +182,7 @@ namespace NekoRay { _add(new configItem("order", &order, itemType::integerList)); _add(new configItem("url", &url, itemType::string)); _add(new configItem("info", &info, itemType::string)); + _add(new configItem("lastup", &last_update, itemType::integer64)); } QSharedPointer ProfileManager::LoadGroup(const QString &jsonPath) { diff --git a/db/Group.hpp b/db/Group.hpp index 7de92c3..48bfd5f 100644 --- a/db/Group.hpp +++ b/db/Group.hpp @@ -12,6 +12,7 @@ namespace NekoRay { QList order; QString url = ""; QString info = ""; + qint64 last_update = 0; Group(); diff --git a/sub/GroupUpdater.cpp b/sub/GroupUpdater.cpp index 316d062..295ba94 100644 --- a/sub/GroupUpdater.cpp +++ b/sub/GroupUpdater.cpp @@ -306,6 +306,7 @@ namespace NekoRay::sub { // 订阅解析前 if (group != nullptr) { in = group->Profiles(); + group->last_update = QDateTime::currentSecsSinceEpoch(); group->info = sub_user_info; group->order.clear(); group->Save(); diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 29e7db4..d0bc9cd 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -634,6 +634,10 @@ Update %1? 更新 %1 ? + + Last update: %1 + 最后更新 %1 + JsonEditor diff --git a/ui/widget/GroupItem.cpp b/ui/widget/GroupItem.cpp index 8feca6f..c96e058 100644 --- a/ui/widget/GroupItem.cpp +++ b/ui/widget/GroupItem.cpp @@ -73,12 +73,19 @@ void GroupItem::refresh_data() { ui->update_sub->hide(); } else { ui->url->setText(ent->url); + QStringList info; + if (ent->last_update != 0) { + info << tr("Last update: %1").arg(DisplayTime(ent->last_update, QLocale::ShortFormat)); + } auto subinfo = ParseSubInfo(ent->info); - if (subinfo.isEmpty()) { + if (!ent->info.isEmpty()) { + info << subinfo; + } + if (info.isEmpty()) { ui->subinfo->hide(); } else { ui->subinfo->show(); - ui->subinfo->setText(subinfo); + ui->subinfo->setText(info.join(" | ")); } } runOnUiThread([=] {