Apply suggestions from code review
Co-authored-by: flow <flowlnlnln@gmail.com> Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
733619ca74
commit
b266068644
@ -170,7 +170,6 @@ void JavaListLoadTask::executeTask()
|
||||
m_job.reset(new JavaCheckerJob("Java detection"));
|
||||
connect(m_job.get(), &Task::finished, this, &JavaListLoadTask::javaCheckerFinished);
|
||||
connect(m_job.get(), &Task::progress, this, &Task::setProgress);
|
||||
// stepProgress?
|
||||
|
||||
qDebug() << "Probing the following Java paths: ";
|
||||
int id = 0;
|
||||
|
@ -247,19 +247,20 @@ void Download::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
|
||||
|
||||
// use milliseconds for speed precision
|
||||
auto elapsed_ms = std::chrono::duration_cast<std::chrono::milliseconds>(elapsed);
|
||||
auto bytes_recived_since = bytesReceived - m_last_progress_bytes;
|
||||
auto dl_speed_bps = (double)bytes_recived_since / elapsed_ms.count() * 1000;
|
||||
auto bytes_received_since = bytesReceived - m_last_progress_bytes;
|
||||
auto dl_speed_bps = (double)bytes_received_since / elapsed_ms.count() * 1000;
|
||||
auto remaing_time_s = (bytesTotal - bytesReceived) / dl_speed_bps;
|
||||
|
||||
// current bytes out of total bytes
|
||||
//: Current amount of bytes downloaded, out of the total amount of bytes in the download
|
||||
QString dl_progress = tr("%1 / %2").arg(humanReadableFileSize(bytesReceived)).arg(humanReadableFileSize(bytesTotal));
|
||||
|
||||
QString dl_speed_str;
|
||||
if (elapsed_ms.count() > 0) {
|
||||
// bytes per second
|
||||
dl_speed_str = tr("%1/s (%2)").arg(humanReadableFileSize(dl_speed_bps)).arg(humanReadableDuration(remaing_time_s));
|
||||
//: Download speed, in bytes per second (remaining download time in parenthesis)
|
||||
dl_speed_str = tr("%1 /s (%2)").arg(humanReadableFileSize(dl_speed_bps)).arg(humanReadableDuration(remaing_time_s));
|
||||
} else {
|
||||
dl_speed_str = tr("0 b/s");
|
||||
//: Download speed at 0 bytes per second
|
||||
dl_speed_str = tr("0 B/s");
|
||||
}
|
||||
|
||||
setDetails(dl_progress + "\n" + dl_speed_str);
|
||||
|
@ -44,8 +44,8 @@
|
||||
#include "QObjectPtr.h"
|
||||
#include "tasks/Task.h"
|
||||
|
||||
static const QStringList s_units_si {"kb", "MB", "GB", "TB"};
|
||||
static const QStringList s_units_kibi {"kiB", "MiB", "Gib", "TiB"};
|
||||
static const QStringList s_units_si {"kB", "MB", "GB", "TB"};
|
||||
static const QStringList s_units_kibi {"KiB", "MiB", "Gib", "TiB"};
|
||||
|
||||
inline QString humanReadableFileSize(double bytes, bool use_si = false, int decimal_points = 1) {
|
||||
const QStringList units = use_si ? s_units_si : s_units_kibi;
|
||||
|
@ -65,7 +65,7 @@ void ConcurrentTask::addTask(Task::Ptr task)
|
||||
|
||||
void ConcurrentTask::executeTask()
|
||||
{
|
||||
// Start One task, startNext hadels starting the up to the m_total_max_size
|
||||
// Start one task, startNext handles starting the up to the m_total_max_size
|
||||
// while tracking the number currently being done
|
||||
QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection);
|
||||
}
|
||||
@ -293,9 +293,9 @@ void ConcurrentTask::updateState()
|
||||
.arg(QString::number(m_doing.count()), QString::number(m_done.count()), QString::number(totalSize())));
|
||||
} else {
|
||||
setProgress(m_stepProgress, m_stepTotalProgress);
|
||||
QString status = tr("Please wait ...");
|
||||
QString status = tr("Please wait...");
|
||||
if (m_queue.size() > 0) {
|
||||
status = tr("Waiting for 1 task to start ...");
|
||||
status = tr("Waiting for a task to start...");
|
||||
} else if (m_doing.size() > 0) {
|
||||
status = tr("Executing 1 task:");
|
||||
} else if (m_done.size() > 0) {
|
||||
|
@ -130,7 +130,7 @@ class Task : public QObject, public QRunnable {
|
||||
void failed(QString reason);
|
||||
void status(QString status);
|
||||
void details(QString details);
|
||||
void stepProgress(TaskStepProgress const& task_progress); //
|
||||
void stepProgress(TaskStepProgress const& task_progress);
|
||||
|
||||
/** Emitted when the canAbort() status has changed.
|
||||
*/
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include "ui/widgets/SubTaskProgressBar.h"
|
||||
|
||||
|
||||
// map a value in a numaric range of an arbatray type to between 0 and INT_MAX
|
||||
// map a value in a numeric range of an arbitrary type to between 0 and INT_MAX
|
||||
// for getting the best precision out of the qt progress bar
|
||||
template<typename T, std::enable_if_t<std::is_arithmetic_v<T>, bool> = true>
|
||||
std::tuple<int, int> map_int_zero_max(T current, T range_max, T range_min)
|
||||
|
@ -18,8 +18,6 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <qobjectdefs.h>
|
||||
#include <qwidget.h>
|
||||
#include <QWidget>
|
||||
#include "QObjectPtr.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user