diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-08-27 23:40:32 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-08-27 23:40:32 +0300 |
commit | 07d8598638247d8dfb2fcd2e38c4498e90570f6e (patch) | |
tree | fbd817babfbbf98aac018757e1f153c5f87dfb92 /launcher/ui/themes | |
parent | 9110fbf2829a48c36fe37cabfb438e165956bbcf (diff) | |
download | PrismLauncher-07d8598638247d8dfb2fcd2e38c4498e90570f6e.tar.gz PrismLauncher-07d8598638247d8dfb2fcd2e38c4498e90570f6e.tar.bz2 PrismLauncher-07d8598638247d8dfb2fcd2e38c4498e90570f6e.zip |
added catpacks tests
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/ui/themes')
-rw-r--r-- | launcher/ui/themes/CatPack.cpp | 10 | ||||
-rw-r--r-- | launcher/ui/themes/CatPack.h | 9 |
2 files changed, 12 insertions, 7 deletions
diff --git a/launcher/ui/themes/CatPack.cpp b/launcher/ui/themes/CatPack.cpp index f0d8ddd5..bbcb58bc 100644 --- a/launcher/ui/themes/CatPack.cpp +++ b/launcher/ui/themes/CatPack.cpp @@ -99,18 +99,22 @@ QDate ensureDay(int year, int month, int day) QString JsonCatPack::path() { - const QDate now = QDate::currentDate(); + return path(QDate::currentDate()); +} + +QString JsonCatPack::path(QDate now) +{ for (auto var : m_variants) { QDate startDate = ensureDay(now.year(), var.startTime.month, var.startTime.day); QDate endDate = ensureDay(now.year(), var.endTime.month, var.endTime.day); if (startDate > endDate) { // it's spans over multiple years - if (endDate <= now) // end date is in the past so jump one year into the future for endDate + if (endDate < now) // end date is in the past so jump one year into the future for endDate endDate = endDate.addYears(1); else // end date is in the future so jump one year into the past for startDate startDate = startDate.addYears(-1); } - if (startDate >= now && now >= endDate) + if (startDate <= now && now <= endDate) return var.path; } return m_defaultPath; diff --git a/launcher/ui/themes/CatPack.h b/launcher/ui/themes/CatPack.h index fdd117a7..1d310e79 100644 --- a/launcher/ui/themes/CatPack.h +++ b/launcher/ui/themes/CatPack.h @@ -52,9 +52,9 @@ class BasicCatPack : public CatPack { public: BasicCatPack(QString id, QString name) : m_id(id), m_name(name) {} BasicCatPack(QString id) : BasicCatPack(id, id) {} - virtual QString id() { return m_id; } - virtual QString name() { return m_name; } - virtual QString path(); + virtual QString id() override { return m_id; } + virtual QString name() override { return m_name; } + virtual QString path() override; protected: QString m_id; @@ -83,7 +83,8 @@ class JsonCatPack : public BasicCatPack { PartialDate endTime; }; JsonCatPack(QFileInfo& manifestInfo); - virtual QString path(); + virtual QString path() override; + QString path(QDate now); private: QString m_defaultPath; |