mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 15:06:08 +03:00
Changed the time estimate string to be more textual, also added lower limit to the estimate to prevents starting estimation jittering
This commit is contained in:
parent
35b3ddd61f
commit
219098c182
5 changed files with 23 additions and 27 deletions
|
@ -616,10 +616,10 @@ void AccountSettings::slotSetProgress(const QString& folder, const Progress::Inf
|
|||
QString s1 = Utility::octetsToString( curItemProgress );
|
||||
QString s2 = Utility::octetsToString( curItem._size );
|
||||
//: Example text: "uploading foobar.png (1MB of 2MB)"
|
||||
fileProgressString = tr("%1 %2 (%3 of %4) , Time left : %5 at a rate of %6/s")
|
||||
fileProgressString = tr("%1 %2 (%3 of %4) time left %5 , at a rate of %6")
|
||||
.arg(kindString, itemFileName, s1, s2,
|
||||
Utility::timeConversion(progress.getFileEstimate(curItem).getEtaEstimate()),
|
||||
Utility::octetsToString(progress.getFileEstimate(curItem).getEstimatedBandwidth()) );
|
||||
Utility::timeToDescriptiveString(progress.getFileEstimate(curItem).getEtaEstimate()),
|
||||
Utility::octetsToString(progress.getFileEstimate(curItem).getEstimatedBandwidth()) );
|
||||
} else {
|
||||
//: Example text: "uploading foobar.png"
|
||||
fileProgressString = tr("%1 %2").arg(kindString, itemFileName);
|
||||
|
@ -631,10 +631,10 @@ void AccountSettings::slotSetProgress(const QString& folder, const Progress::Inf
|
|||
quint64 currentFile = progress._completedFileCount + progress._currentItems.count();
|
||||
QString s1 = Utility::octetsToString( completedSize );
|
||||
QString s2 = Utility::octetsToString( progress._totalSize );
|
||||
QString overallSyncString = tr("%1 of %2, file %3 of %4\n%5")
|
||||
QString overallSyncString = tr("%1 of %2, file %3 of %4\nTime left %5")
|
||||
.arg(s1, s2)
|
||||
.arg(currentFile).arg(progress._totalFileCount)
|
||||
.arg( Utility::timeConversion(progress.totalEstimate().getEtaEstimate()) );
|
||||
.arg( Utility::timeToDescriptiveString(progress.totalEstimate().getEtaEstimate()) );
|
||||
|
||||
item->setData( overallSyncString, FolderStatusDelegate::SyncProgressOverallString );
|
||||
|
||||
|
|
|
@ -286,7 +286,6 @@ void ownCloudGui::setupContextMenu()
|
|||
_contextMenu->addAction(_actionQuota);
|
||||
_contextMenu->addSeparator();
|
||||
_contextMenu->addAction(_actionStatus);
|
||||
_contextMenu->addAction(_actionEstimate);
|
||||
_contextMenu->addMenu(_recentActionsMenu);
|
||||
_contextMenu->addSeparator();
|
||||
}
|
||||
|
@ -353,8 +352,6 @@ void ownCloudGui::setupActions()
|
|||
_actionQuota->setEnabled( false );
|
||||
_actionStatus = new QAction(tr("Unknown status"), this);
|
||||
_actionStatus->setEnabled( false );
|
||||
_actionEstimate = new QAction(tr("Calculating ETA ..."), this);
|
||||
_actionEstimate->setEnabled( false );
|
||||
_actionSettings = new QAction(tr("Settings..."), this);
|
||||
_actionRecent = new QAction(tr("Details..."), this);
|
||||
_actionRecent->setEnabled( true );
|
||||
|
@ -411,12 +408,9 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const Progress::Info
|
|||
QString s1 = Utility::octetsToString( completedSize );
|
||||
QString s2 = Utility::octetsToString( progress._totalSize );
|
||||
|
||||
_actionStatus->setText( tr("Syncing %1 of %2 (%3 of %4)")
|
||||
.arg(currentFile).arg(progress._totalFileCount).arg(s1, s2));
|
||||
|
||||
_actionEstimate->setVisible(progress.completedSize() > 0);
|
||||
_actionEstimate->setText( tr("ETA : %5 , %6/s").arg( Utility::timeConversion(progress.totalEstimate().getEtaEstimate()),
|
||||
Utility::octetsToString(progress.totalEstimate().getEstimatedBandwidth())) );
|
||||
_actionStatus->setText( tr("Syncing %1 of %2 (%3 of %4) %5 left")
|
||||
.arg(currentFile).arg(progress._totalFileCount).arg(s1, s2)
|
||||
.arg( Utility::timeToDescriptiveString(progress.totalEstimate().getEtaEstimate()) ) );
|
||||
|
||||
|
||||
_actionRecent->setIcon( QIcon() ); // Fixme: Set a "in-progress"-item eventually.
|
||||
|
@ -459,7 +453,6 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const Progress::Info
|
|||
void ownCloudGui::slotDisplayIdle()
|
||||
{
|
||||
_actionStatus->setText(tr("Up to date"));
|
||||
_actionEstimate->setVisible(false);
|
||||
}
|
||||
|
||||
void ownCloudGui::slotShowGuiMessage(const QString &title, const QString &message)
|
||||
|
|
|
@ -48,6 +48,7 @@ namespace Progress
|
|||
EtaEstimate() : _startedTime(QDateTime::currentMSecsSinceEpoch()), _agvEtaMSecs(0),_effectivProgressPerSec(0) {}
|
||||
|
||||
static const int AVG_DIVIDER=10;
|
||||
static const int INITAL_WAIT_TIME=5;
|
||||
|
||||
quint64 _startedTime ;
|
||||
quint64 _agvEtaMSecs;
|
||||
|
@ -67,8 +68,9 @@ namespace Progress
|
|||
* @param quint64 total the total amout that should be completed.
|
||||
*/
|
||||
void updateTime(quint64 completed, quint64 total) {
|
||||
if(total != 0 && completed != 0) {
|
||||
quint64 elapsedTime = QDateTime::currentMSecsSinceEpoch() - this->_startedTime ;
|
||||
quint64 elapsedTime = QDateTime::currentMSecsSinceEpoch() - this->_startedTime ;
|
||||
//don't start until you have some good data to process, prevents jittring estiamtes at the start of the syncing process
|
||||
if(total != 0 && completed != 0 && elapsedTime > INITAL_WAIT_TIME ) {
|
||||
// (elapsedTime-1) is an hack to avoid float "rounding" issue (ie. 0.99999999999999999999....)
|
||||
_agvEtaMSecs = _agvEtaMSecs + (((static_cast<float>(total) / completed) * elapsedTime) - (elapsedTime-1)) - this->getEtaEstimate();
|
||||
_effectivProgressPerSec = ( total - completed ) / (1+this->getEtaEstimate()/1000);
|
||||
|
|
|
@ -452,16 +452,17 @@ qint64 Utility::qDateTimeToTime_t(const QDateTime& t)
|
|||
return t.toMSecsSinceEpoch() / 1000;
|
||||
}
|
||||
|
||||
QString Utility::timeConversion(quint64 msecs)
|
||||
QString Utility::timeToDescriptiveString(quint64 msecs)
|
||||
{
|
||||
msecs = msecs / 1000;
|
||||
int hours = msecs/(3600);
|
||||
int minutes = (msecs-(hours*3600))/(60);
|
||||
int seconds = (msecs-(minutes*60)-(hours*3600));
|
||||
|
||||
return (hours > 0 ? QString("%1h ").arg(hours): QString())
|
||||
.append(minutes > 0 ? QString("%1m ").arg(minutes, 2, 10, QChar('0')) : QString())
|
||||
.append(QString("%1s").arg(seconds, 2, 10, QChar('0')) );
|
||||
msecs = msecs / 1000;
|
||||
int hours = msecs/(3600);
|
||||
int minutes = (msecs-(hours*3600))/(60);
|
||||
int seconds = (msecs-(minutes*60)-(hours*3600));
|
||||
|
||||
QString units = (hours > 0 ? " hours" : (minutes > 0 ? " minutes" : " seconds") );
|
||||
|
||||
return (hours > 0 ? QString("%1:").arg(hours): QString())
|
||||
.append(minutes > 0 ? QString("%1").arg(minutes, 2, 10, QChar(hours > 0 ? '0' : ' ')) : QString("%1").arg(seconds, 2, 10, QChar('0')) ).append(units);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace Utility
|
|||
* @param quint64 msecs the milliseconds to convert to string
|
||||
* @return an HMS representation of the milliseconds value.
|
||||
*/
|
||||
QString timeConversion(quint64 msecs);
|
||||
QString timeToDescriptiveString(quint64 msecs);
|
||||
|
||||
// convinience OS detection methods
|
||||
bool isWindows();
|
||||
|
|
Loading…
Reference in a new issue