Skip to content

Commit

Permalink
修改缩回时间处理逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
beiklive authored Mar 1, 2023
1 parent a55996d commit 2325237
Showing 1 changed file with 51 additions and 102 deletions.
153 changes: 51 additions & 102 deletions src/traymenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void TrayMenu::animationShowToHide(const StateConditionGuard &GUARD)
opacityAnimation->start();
connect(opacityAnimation, &QPropertyAnimation::finished, [=]()
{
delete opacityAnimation;
delete opacityAnimation;
opacityAnimation = nullptr; });
}
}
Expand Down Expand Up @@ -217,7 +217,7 @@ void TrayMenu::animationHideToShow(const StateConditionGuard &GUARD)
opacityAnimation->start();
connect(opacityAnimation, &QPropertyAnimation::finished, [=]()
{
delete opacityAnimation;
delete opacityAnimation;
opacityAnimation = nullptr; });
}
}
Expand Down Expand Up @@ -408,104 +408,60 @@ void TrayMenu::initTime()
HourCloseList->clear();
WeekCloseList->clear();

for (auto i = WeekList->begin(); i != WeekList->end(); i++)
for (auto dayit = WeekList->begin(); dayit != WeekList->end(); dayit++)
{
for (auto j = HourList->begin(); j != HourList->end(); j++)
for (auto hourit = HourList->begin(); hourit != HourList->end(); hourit++)
{
for (auto k = MinuteList->begin(); k != MinuteList->end(); k++)
for (auto minuteit = MinuteList->begin(); minuteit != MinuteList->end(); minuteit++)
{
for (auto l = SecondList->begin(); l != SecondList->end(); l++)
for (auto secondit = SecondList->begin(); secondit != SecondList->end(); secondit++)
{
QString time = *i + " " + *j + ":" + *k + ":" + *l;
logger->info("[initTime] time: " + time.toStdString());
int advanceFlag = 0;
int finalSecond = -1;
int finalMinute = -1;
int finalHour = -1;
int finalDay = -1;
if ("xx" == *l)
{
logger->error("[initTime] second is none ");

auto advanceCharge = [](int num, int advance) -> int {
return num >= advance? 1 : 0;
};

auto advanceRemove = [](int num, int advance) -> int {
return num % advance;
};
auto numberTrans = [](int num) -> QString {
return num == -1 ? "xx" : (num > 9 ? QString::number(num) : ("0" + QString::number(num)));
};

if( *secondit != "xx" ){
finalSecond = (*secondit).toInt() + configInfo.clockMoveInterval;
advanceFlag = advanceCharge(finalSecond, 60);
finalSecond = advanceRemove(finalSecond, 60);
}
else
{
int second = (*l).toInt();
finalSecond = second + configInfo.clockMoveInterval;
if (finalSecond >= 60)
{
finalSecond = finalSecond % 60;
if ("xx" == *k)
{
logger->debug("[initTime] minute is none, do nothing");
}
else
{
int minute = (*k).toInt();
finalMinute = minute + 1;
if (finalMinute >= 60)
{
finalMinute = 0;
if ("xx" == *j)
{
logger->debug("[initTime] hour is none, do nothing");
}
else
{
int hour = (*j).toInt();
finalHour = hour + 1;
if (finalHour >= 24)
{
finalHour = 0;
if ("xx" == *i)
{
logger->debug("[initTime] day is none, do nothing");
}
else
{
int day = (*i).toInt();
finalDay = day + 1;
if (finalDay >= 7)
{
finalDay = finalDay - 7;
}
QString finalTime = findWeekDayName(finalDay) + " " + (finalHour < 10 ? ("0" + QString::number(finalHour)) : QString::number(finalHour)) + ":" + (finalMinute < 10 ? ("0" + QString::number(finalMinute)) : QString::number(finalMinute)) + ":" + (finalSecond < 10 ? ("0" + QString::number(finalSecond)) : QString::number(finalSecond));
logger->info("[initTime] finalTime: " + finalTime.toStdString());
SecondCloseList->append((finalSecond < 10 ? ("0" + QString::number(finalSecond)) : QString::number(finalSecond)));
MinuteCloseList->append((finalMinute < 10 ? ("0" + QString::number(finalMinute)) : QString::number(finalMinute)));
HourCloseList->append((finalHour < 10 ? ("0" + QString::number(finalHour)) : QString::number(finalHour)));
WeekCloseList->append(findWeekDayName(finalDay));
}
}
else
{
QString finalTime = *i + " " + (finalHour < 10 ? ("0" + QString::number(finalHour)) : QString::number(finalHour)) + ":" + (finalMinute < 10 ? ("0" + QString::number(finalMinute)) : QString::number(finalMinute)) + ":" + (finalSecond < 10 ? ("0" + QString::number(finalSecond)) : QString::number(finalSecond));
logger->info("[initTime] finalTime: " + finalTime.toStdString());
SecondCloseList->append((finalSecond < 10 ? ("0" + QString::number(finalSecond)) : QString::number(finalSecond)));
MinuteCloseList->append((finalMinute < 10 ? ("0" + QString::number(finalMinute)) : QString::number(finalMinute)));
HourCloseList->append((finalHour < 10 ? ("0" + QString::number(finalHour)) : QString::number(finalHour)));
WeekCloseList->append(*i);
}
}
}
else
{
QString finalTime = *i + " " + *j + ":" + (finalMinute < 10 ? ("0" + QString::number(finalMinute)) : QString::number(finalMinute)) + ":" + (finalSecond < 10 ? ("0" + QString::number(finalSecond)) : QString::number(finalSecond));
logger->info("[initTime] finalTime: " + finalTime.toStdString());
SecondCloseList->append((finalSecond < 10 ? ("0" + QString::number(finalSecond)) : QString::number(finalSecond)));
MinuteCloseList->append((finalMinute < 10 ? ("0" + QString::number(finalMinute)) : QString::number(finalMinute)));
HourCloseList->append(*j);
}
}
}
else
{
QString finalTime = *i + " " + *j + ":" + *k + ":" + (finalSecond < 10 ? ("0" + QString::number(finalSecond)) : QString::number(finalSecond));
logger->info("[initTime] finalTime: " + finalTime.toStdString());
SecondCloseList->append((finalSecond < 10 ? ("0" + QString::number(finalSecond)) : QString::number(finalSecond)));
MinuteCloseList->append(*k);
HourCloseList->append(*j);
WeekCloseList->append(*i);
}
if( *minuteit != "xx" ){
finalMinute = (*minuteit).toInt() + advanceFlag;
advanceFlag = advanceCharge(finalMinute, 60);
finalMinute = advanceRemove(finalMinute, 60);
}
if( *hourit != "xx" ){
finalHour = (*hourit).toInt() + advanceFlag;
advanceFlag = advanceCharge(finalHour, 24);
finalHour = advanceRemove(finalHour, 24);
}

if( *dayit != "xx" ){
finalDay = (*dayit).toInt() + advanceFlag;
advanceFlag = advanceCharge(finalDay, 7);
finalDay = advanceRemove(finalDay, 7);
}

logger->info("[initTime] startTime: {} {}:{}:{}", findWeekDayName(finalDay).toStdString(), (*hourit).toStdString(), (*minuteit).toStdString(), (*secondit).toStdString());
QString finalTime = findWeekDayName(finalDay) + " " + numberTrans(finalHour) + ":" + numberTrans(finalMinute) + ":" + numberTrans(finalSecond);
logger->info("[initTime] finalTime: " + finalTime.toStdString());
SecondCloseList->append(numberTrans(finalSecond));
MinuteCloseList->append(numberTrans(finalMinute));
HourCloseList->append(numberTrans(finalHour));
WeekCloseList->append(numberTrans(finalDay));
}
}
}
Expand All @@ -526,7 +482,7 @@ void TrayMenu::timeStringToTimeList(QString timeString, QList<QString> *timeList
{
if (7 == maxNum) // 如果是星期列表,则将数字转换为星期名称
{
timeList->append(findWeekDayName(i));
timeList->append(QString::number(i));
}
else
{
Expand All @@ -540,14 +496,7 @@ void TrayMenu::timeStringToTimeList(QString timeString, QList<QString> *timeList
QStringList timeListString = timeString.split(" ");
for (auto i = timeListString.begin(); i != timeListString.end(); i++)
{
if (7 == maxNum)
{
timeList->append(findWeekDayName((*i).toInt()));
}
else
{
timeList->push_back(*i);
}
timeList->append(*i);
}
}
}
Expand All @@ -572,7 +521,7 @@ void TrayMenu::CheckTimeToCtrlClock()
for (auto k = WeekList->begin(); k != WeekList->end(); k++)
{
logger->debug("current_week = {}, find = {}", current_week.toStdString(), findWeekDayName((*k).toInt()).toStdString());
if (current_week == *k)
if (current_week == findWeekDayName((*k).toInt()))
{
for (auto j = HourList->begin(); j != HourList->end(); j++)
{
Expand Down Expand Up @@ -603,7 +552,7 @@ void TrayMenu::CheckTimeToCtrlClock()
{
for (auto k = WeekCloseList->begin(); k != WeekCloseList->end(); k++)
{
if (current_week == *k)
if (current_week == findWeekDayName((*k).toInt()))
{
for (auto j = HourCloseList->begin(); j != HourCloseList->end(); j++)
{
Expand Down Expand Up @@ -648,4 +597,4 @@ const ClockBodyState TrayMenu::GetClockBodyCurState()
const ClockBodyState TrayMenu::GetClockBodyTargetState()
{
return m_clockBodyStateMachine.targetState;
}
}

0 comments on commit 2325237

Please sign in to comment.