diff --git a/message.cpp b/message.cpp index 16bc7a9..b50d86b 100644 --- a/message.cpp +++ b/message.cpp @@ -17,7 +17,7 @@ message::message(QWidget *parent) : void message::update(int progress,float money){ //更新进度条 - ui->labelMoney->setText("预计今日一共挣"+QString::number(money,'f',1)+"元"); + ui->labelMoney->setText("您当前已经挣了"+QString::number(money*progress/1000,'f',1)+"元"); ui->progressBar->setValue(progress); } diff --git a/moneyprogress.cpp b/moneyprogress.cpp index 1adad3b..5b287c7 100644 --- a/moneyprogress.cpp +++ b/moneyprogress.cpp @@ -181,12 +181,19 @@ void MoneyProgress::update() qDebug("update"); int second = (workUp.secsTo(workDown) - sleepUp.secsTo(sleepDown)); float hours = second / 3600.0; - + int progress = 0; float moneyday = money / days; float moneysecond = moneyday / second; + + if (QTime::currentTime() < sleepUp) //判断当前使是午休之前还是之后 + progress = workUp.secsTo(QTime::currentTime()) * 1000 / second; + else + progress = (workUp.secsTo(QTime::currentTime()) - sleepUp.secsTo(sleepDown)) * 1000 / second; + // 判断两个界面是否可见 if (this->isVisible()) { + ui->labelMoneyNow->setText("您当前已经挣了"+QString::number(moneyday*progress/1000,'f',1)+"元;"); ui->labelDay->setText("您一月工作" + QString::number(days) + "天;"); ui->labelMoneyDay->setText("您一天能挣" + QString::number(moneyday, 'f', 1) + "元;"); ui->labelHourDay->setText("您一天工作" + QString::number(hours, 'f', 1) + "小时;"); @@ -194,11 +201,8 @@ void MoneyProgress::update() } if (iconmessage.isVisible()) { - int progress = 0; - if (QTime::currentTime() < sleepUp) - progress = workUp.secsTo(QTime::currentTime()) * 1000 / second; - else - progress = (workUp.secsTo(QTime::currentTime()) - sleepUp.secsTo(sleepDown)) * 1000 / second; + + iconmessage.update(progress, moneyday); qDebug() << progress; } @@ -212,17 +216,18 @@ void MoneyProgress::updateM() float moneyday = money / days; float moneysecond = moneyday / second; - // 判断两个界面是否可见 - - ui->labelDay->setText("您一月工作" + QString::number(days) + "天;"); - ui->labelMoneyDay->setText("您一天能挣" + QString::number(moneyday, 'f', 1) + "元;"); - ui->labelHourDay->setText("您一天工作" + QString::number(hours, 'f', 1) + "小时;"); - ui->labelMoneySecond->setText("您一秒钟能挣" + QString::number(moneysecond, 'f', 6) + "元;"); int progress = 0; if (QTime::currentTime() < sleepUp) progress = workUp.secsTo(QTime::currentTime()) * 1000 / second; else progress = (workUp.secsTo(QTime::currentTime()) - sleepUp.secsTo(sleepDown)) * 1000 / second; + // 判断两个界面是否可见 + ui->labelMoneyNow->setText("您当前已经挣了"+QString::number(moneyday*progress/1000,'f',1)+"元;"); + ui->labelDay->setText("您一月工作" + QString::number(days) + "天;"); + ui->labelMoneyDay->setText("您一天能挣" + QString::number(moneyday, 'f', 1) + "元;"); + ui->labelHourDay->setText("您一天工作" + QString::number(hours, 'f', 1) + "小时;"); + ui->labelMoneySecond->setText("您一秒钟能挣" + QString::number(moneysecond, 'f', 6) + "元;"); + qDebug() << progress; iconmessage.update(progress, moneyday); } diff --git a/moneyprogress.ui b/moneyprogress.ui index 49cfda8..715ddbc 100644 --- a/moneyprogress.ui +++ b/moneyprogress.ui @@ -23,159 +23,90 @@ - - - - 350 - 70 - 100 - 100 - - - - border-image: url(:/img/avatar.png); - - - - - - - - - - - - - - 382 - 180 - 41 - 31 - - - - - Microsoft YaHei UI - 16 - true - - - - 钱条 - - - - - - 260 - 210 - 281 - 21 - - - - - Microsoft YaHei UI - 13 - true - - - - 挣钱的进度条,得是老板给我的欠条 - - - - - - 350 - 420 - 101 - 31 - - - - background-color: rgb(255, 216, 58); - - - 开始计价 - - - false - - - false - - - false - - - - - - 30 - 510 - 171 - 16 - - - - 天数 - - - - - - 30 - 530 - 151 - 16 - - - - 日金额 - - - - - - 30 - 550 - 191 - 16 - - - - 日小时 - - - - - - 30 - 570 - 191 - 16 - - - - 秒钱 - - 250 - 250 - 291 - 151 + 50 + 292 + 376 - + QLayout::SetMinimumSize - + + 10 + + + + + + Microsoft YaHei UI + 12 + true + + + + Qt::AlignCenter + + + QAbstractSpinBox::NoButtons + + + + 17 + 0 + 0 + 2000 + 1 + 1 + + + + Qt::LocalTime + + + + + + + + Microsoft YaHei UI + 12 + true + + + + Qt::AlignCenter + + + QAbstractSpinBox::NoButtons + + + + 12 + 0 + 0 + 2000 + 1 + 1 + + + + Qt::LocalTime + + + + + + + 80 + 20 + + Microsoft YaHei UI @@ -186,6 +117,9 @@ + + Qt::AlignCenter + QAbstractSpinBox::NoButtons @@ -214,22 +148,25 @@ - - + + Microsoft YaHei UI - 12 + 16 true - 午休 + 钱条 + + + Qt::AlignCenter - - + + Microsoft YaHei UI @@ -238,11 +175,14 @@ - 月薪 + 上班 + + + Qt::AlignCenter - + @@ -254,10 +194,13 @@ 人民币 + + Qt::AlignCenter + - - + + Microsoft YaHei UI @@ -266,33 +209,32 @@ - 上班 + 天/月 + + + Qt::AlignCenter - - + + Microsoft YaHei UI 12 true - false - - false - - - background-color: rgb(255, 216, 58); - - 300 + 工作 + + + Qt::AlignCenter - - + + Microsoft YaHei UI @@ -300,12 +242,15 @@ true + + Qt::AlignCenter + QAbstractSpinBox::NoButtons - 17 + 13 0 0 2000 @@ -318,8 +263,8 @@ - - + + Microsoft YaHei UI @@ -327,26 +272,16 @@ true - - QAbstractSpinBox::NoButtons - - - - 12 - 0 - 0 - 2000 - 1 - 1 - + + 午休 - - Qt::LocalTime + + Qt::AlignCenter - - + + Microsoft YaHei UI @@ -354,39 +289,64 @@ true - - QAbstractSpinBox::NoButtons - - - - 13 - 0 - 0 - 2000 - 1 - 1 - + + 月薪 - - Qt::LocalTime + + Qt::AlignCenter - - + + Microsoft YaHei UI 12 true + false + + false + + + background-color: rgb(255, 216, 58); + - 工作 + 300 + + + Qt::AlignCenter - + + + + + 60 + 40 + + + + background-color: rgb(255, 216, 58); + + + 开始计价 + + + false + + + false + + + false + + + + @@ -412,22 +372,83 @@ true + + Qt::AlignCenter + - - + + Microsoft YaHei UI - 12 + 13 true - 天/月 + 挣钱的进度条,得是老板给我的欠条 + + + Qt::AlignCenter + + + + 0 + + + 20 + + + + + + 74 + 0 + + + + + 80 + 80 + + + + + 50 + 50 + + + + Qt::LeftToRight + + + false + + + border-image: url(:/img/avatar.png); + + + + + + + + + + + Qt::AlignCenter + + + Qt::LinksAccessibleByMouse + + + + + @@ -443,44 +464,83 @@ - + - 700 - 550 - 81 - 20 + 20 + 470 + 171 + 106 - - Esc 隐藏主界面 - + + + + + 天数 + + + + + + + 日金额 + + + + + + + 日小时 + + + + + + + 当前金额 + + + + + + + 秒钱 + + + + - + - 700 - 570 - 61 - 20 + 670 + 540 + 121 + 41 - - A 作者信息 - + + + + + Esc 隐藏主界面 + + + + + + + A 作者信息 + + + + labelAbout - label - labelTitle1 - labelTitle2 - Startcalculate - labelDay - labelMoneyDay - labelHourDay - labelMoneySecond gridLayoutWidget - label_2 - label_3 + verticalLayoutWidget + verticalLayoutWidget_2