VirtualBox

Ticket #7814: UIProgressDialog-timerEvent-progress-estimate.patch

File UIProgressDialog-timerEvent-progress-estimate.patch, 3.7 KB (added by timeless, 14 years ago)

this patch is under the MIT license

  • src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.cpp

     
    210210        /* Update the progress dialog */
    211211        /* First ETA */
    212212        long newTime = m_progress.GetTimeRemaining();
    213         QDateTime time;
    214         time.setTime_t(newTime);
    215         QDateTime refTime;
    216         refTime.setTime_t(0);
    217 
    218         int days = refTime.daysTo(time);
    219         int hours = time.addDays(-days).time().hour();
    220         int minutes = time.addDays(-days).time().minute();
    221         int seconds = time.addDays(-days).time().second();
    222 
     213        long seconds = newTime < 0 ? 0 : newTime;
     214        long minutes = seconds / 60;
     215        seconds -= minutes * 60;
     216        long hours = minutes / 60;
     217        minutes -= hours * 60;
     218        long days = hours / 24;
     219        hours -= days * 24;
     220       
    223221        QString strDays = VBoxGlobal::daysToString(days);
    224222        QString strHours = VBoxGlobal::hoursToString(hours);
    225223        QString strMinutes = VBoxGlobal::minutesToString(minutes);
     
    228226        QString strTwoComp = tr("%1, %2 remaining", "You may wish to translate this more like \"Time remaining: %1, %2\"");
    229227        QString strOneComp = tr("%1 remaining", "You may wish to translate this more like \"Time remaining: %1\"");
    230228
    231         if (newTime > VBOX_DAY * 2 + VBOX_HOUR)
     229        if (days > 1 && hours)
    232230            m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strHours));
    233         else if (newTime > VBOX_DAY * 2 + VBOX_MINUTE * 5)
     231        else if (days > 1 && minutes >= 5)
    234232            m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strMinutes));
    235         else if (newTime > VBOX_DAY * 2)
     233        else if (days > 1)
    236234            m_pEtaLbl->setText(strOneComp.arg(strDays));
    237         else if (newTime > VBOX_DAY + VBOX_HOUR)
     235        else if (days && hours)
    238236            m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strHours));
    239         else if (newTime > VBOX_DAY + VBOX_MINUTE * 5)
     237        else if (days && minutes >= 5)
    240238            m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strMinutes));
    241         else if (newTime > VBOX_HOUR * 23 + VBOX_MINUTE * 55)
     239        else if (days)
    242240            m_pEtaLbl->setText(strOneComp.arg(strDays));
    243         else if (newTime >= VBOX_HOUR * 2)
     241        else if (hours > 1 && minutes)
    244242            m_pEtaLbl->setText(strTwoComp.arg(strHours).arg(strMinutes));
    245         else if (newTime > VBOX_HOUR + VBOX_MINUTE * 5)
     243        else if (hours > 1)
     244            m_pEtaLbl->setText(strOneComp.arg(strHours));
     245        else if (hours && minutes >= 5)
    246246            m_pEtaLbl->setText(strTwoComp.arg(strHours).arg(strMinutes));
    247         else if (newTime > VBOX_MINUTE * 55)
     247        else if (hours)
    248248            m_pEtaLbl->setText(strOneComp.arg(strHours));
    249         else if (newTime > VBOX_MINUTE * 2)
     249        else if (minutes > 1)
    250250            m_pEtaLbl->setText(strOneComp.arg(strMinutes));
    251         else if (newTime > VBOX_MINUTE + VBOX_SECOND * 5)
     251        else if (minutes && seconds >= 5)
    252252            m_pEtaLbl->setText(strTwoComp.arg(strMinutes).arg(strSeconds));
    253         else if (newTime > VBOX_SECOND * 55)
     253        else if (minutes)
    254254            m_pEtaLbl->setText(strOneComp.arg(strMinutes));
    255         else if (newTime > VBOX_SECOND * 5)
     255        else if (seconds >= 5)
    256256            m_pEtaLbl->setText(strOneComp.arg(strSeconds));
    257         else if (newTime >= 0)
     257        else if (seconds)
    258258            m_pEtaLbl->setText(tr("A few seconds remaining"));
    259259        else
    260260            m_pEtaLbl->clear();

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy