VirtualBox

Changeset 36122 in vbox


Ignore:
Timestamp:
Mar 1, 2011 3:36:22 PM (14 years ago)
Author:
vboxsync
Message:

FE/Qt: fixed remaining progress time (public ticket #7814)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIProgressDialog.cpp

    r35516 r36122  
    3737#include <QTimer>
    3838#include <QVBoxLayout>
    39 
    40 #define VBOX_SECOND 1
    41 #define VBOX_MINUTE VBOX_SECOND * 60
    42 #define VBOX_HOUR VBOX_MINUTE * 60
    43 #define VBOX_DAY VBOX_HOUR * 24
    4439
    4540const char *UIProgressDialog::m_spcszOpDescTpl = "%1 ... (%2/%3)";
     
    221216        /* First ETA */
    222217        long newTime = m_progress.GetTimeRemaining();
    223         QDateTime time;
    224         time.setTime_t(newTime);
    225         QDateTime refTime;
    226         refTime.setTime_t(0);
    227 
    228         int days = refTime.daysTo(time);
    229         int hours = time.addDays(-days).time().hour();
    230         int minutes = time.addDays(-days).time().minute();
    231         int seconds = time.addDays(-days).time().second();
     218        long seconds;
     219        long minutes;
     220        long hours;
     221        long days;
     222
     223        seconds  = newTime < 0 ? 0 : newTime;
     224        minutes  = seconds / 60;
     225        seconds -= minutes * 60;
     226        hours    = minutes / 60;
     227        minutes -= hours   * 60;
     228        days     = hours   / 24;
     229        hours   -= days    * 24;
    232230
    233231        QString strDays = VBoxGlobal::daysToString(days);
     
    239237        QString strOneComp = tr("%1 remaining", "You may wish to translate this more like \"Time remaining: %1\"");
    240238
    241         if (newTime > VBOX_DAY * 2 + VBOX_HOUR)
     239        if      (days > 1 && hours > 0)
    242240            m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strHours));
    243         else if (newTime > VBOX_DAY * 2 + VBOX_MINUTE * 5)
     241        else if (days > 1)
     242            m_pEtaLbl->setText(strOneComp.arg(strDays));
     243        else if (days > 0 && hours > 0)
     244            m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strHours));
     245        else if (days > 0 && minutes > 5)
    244246            m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strMinutes));
    245         else if (newTime > VBOX_DAY * 2)
     247        else if (days > 0)
    246248            m_pEtaLbl->setText(strOneComp.arg(strDays));
    247         else if (newTime > VBOX_DAY + VBOX_HOUR)
    248             m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strHours));
    249         else if (newTime > VBOX_DAY + VBOX_MINUTE * 5)
    250             m_pEtaLbl->setText(strTwoComp.arg(strDays).arg(strMinutes));
    251         else if (newTime > VBOX_HOUR * 23 + VBOX_MINUTE * 55)
    252             m_pEtaLbl->setText(strOneComp.arg(strDays));
    253         else if (newTime >= VBOX_HOUR * 2)
     249        else if (hours > 2)
     250            m_pEtaLbl->setText(strTwoComp.arg(strHours));
     251        else if (hours > 0 && minutes > 0)
    254252            m_pEtaLbl->setText(strTwoComp.arg(strHours).arg(strMinutes));
    255         else if (newTime > VBOX_HOUR + VBOX_MINUTE * 5)
    256             m_pEtaLbl->setText(strTwoComp.arg(strHours).arg(strMinutes));
    257         else if (newTime > VBOX_MINUTE * 55)
     253        else if (hours > 0)
    258254            m_pEtaLbl->setText(strOneComp.arg(strHours));
    259         else if (newTime > VBOX_MINUTE * 2)
     255        else if (minutes > 2)
    260256            m_pEtaLbl->setText(strOneComp.arg(strMinutes));
    261         else if (newTime > VBOX_MINUTE + VBOX_SECOND * 5)
     257        else if (minutes > 0 && seconds > 5)
    262258            m_pEtaLbl->setText(strTwoComp.arg(strMinutes).arg(strSeconds));
    263         else if (newTime > VBOX_SECOND * 55)
     259        else if (minutes > 0)
    264260            m_pEtaLbl->setText(strOneComp.arg(strMinutes));
    265         else if (newTime > VBOX_SECOND * 5)
     261        else if (seconds > 5)
    266262            m_pEtaLbl->setText(strOneComp.arg(strSeconds));
    267         else if (newTime >= 0)
     263        else if (seconds > 0)
    268264            m_pEtaLbl->setText(tr("A few seconds remaining"));
    269265        else
Note: See TracChangeset for help on using the changeset viewer.

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