Added more options for variants planing

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2023-07-02 13:34:04 +03:00
parent 7ac2a23bc8
commit 7579fff532
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
3 changed files with 9 additions and 7 deletions

View File

@ -99,11 +99,13 @@ JsonCatPack::JsonCatPack(QFileInfo& manifestInfo) : BasicCatPack(manifestInfo.di
QString JsonCatPack::path()
{
const QDateTime now = QDateTime::currentDateTime();
const QDate now = QDate::currentDate();
for (auto var : m_variants) {
QDateTime startDate(QDate(now.date().year(), var.startTime.mounth, var.startTime.day), QTime(0, 0));
QDateTime endDate(QDate(now.date().year(), var.endTime.mounth, var.endTime.day), QTime(0, 0));
if (startDate.daysTo(now) > 0 && now.daysTo(endDate) > 0)
QDate startDate(now.year(), var.startTime.month, var.startTime.day);
QDate endDate(now.year(), var.endTime.month, var.endTime.day);
if (startDate.daysTo(endDate) < 0) // in this case end date should be next year
endDate = endDate.addYears(1);
if (startDate.daysTo(now) >= 0 && now.daysTo(endDate) >= 0)
return var.path;
}
return m_defaultPath;

View File

@ -79,9 +79,9 @@ class JsonCatPack : public BasicCatPack {
auto sp = d.split("-");
day = sp[0].toInt();
if (sp.length() >= 2)
mounth = sp[1].toInt();
month = sp[1].toInt();
}
int mounth;
int month;
int day;
};
struct Variant {

View File

@ -189,7 +189,7 @@ void ThemeManager::initializeCatPacks()
while (ImageFileIterator.hasNext()) {
QFile customCatFile(ImageFileIterator.next());
QFileInfo customCatFileInfo(customCatFile);
themeDebugLog() << "Loading QSS Theme from:" << customCatFileInfo.absoluteFilePath();
themeDebugLog() << "Loading CatPack from:" << customCatFileInfo.absoluteFilePath();
addCatPack(std::unique_ptr<CatPack>(new FileCatPack(customCatFileInfo)));
}
};