From f997529cd4fb077b06d05da9c6ff0c23b85b4ebb Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Thu, 30 Mar 2023 11:22:55 -0700
Subject: feat: better task tracking
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/ui/widgets/SubTaskProgressBar.h | 50 ++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 launcher/ui/widgets/SubTaskProgressBar.h
(limited to 'launcher/ui/widgets/SubTaskProgressBar.h')
diff --git a/launcher/ui/widgets/SubTaskProgressBar.h b/launcher/ui/widgets/SubTaskProgressBar.h
new file mode 100644
index 00000000..3375a0bc
--- /dev/null
+++ b/launcher/ui/widgets/SubTaskProgressBar.h
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PrismLaucher - Minecraft Launcher
+ * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+#pragma once
+
+#include
+#include
+#include
+#include "QObjectPtr.h"
+
+namespace Ui {
+class SubTaskProgressBar;
+}
+
+class SubTaskProgressBar : public QWidget
+{
+ Q_OBJECT
+
+public:
+ static unique_qobject_ptr create(QWidget* parent = nullptr);
+
+ SubTaskProgressBar(QWidget* parent = nullptr);
+ ~SubTaskProgressBar();
+
+ void setRange(int min, int max);
+ void setValue(int value);
+ void setStatus(QString status);
+ void setDetails(QString details);
+
+
+
+private:
+ Ui::SubTaskProgressBar* ui;
+
+};
--
cgit
From b266068644d2caab4f103b0adf7a491b95f52369 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Fri, 5 May 2023 14:07:10 -0700
Subject: Apply suggestions from code review
Co-authored-by: flow
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/java/JavaInstallList.cpp | 1 -
launcher/net/Download.cpp | 13 +++++++------
launcher/net/NetAction.h | 4 ++--
launcher/tasks/ConcurrentTask.cpp | 6 +++---
launcher/tasks/Task.h | 2 +-
launcher/ui/dialogs/ProgressDialog.cpp | 2 +-
launcher/ui/widgets/SubTaskProgressBar.h | 2 --
7 files changed, 14 insertions(+), 16 deletions(-)
(limited to 'launcher/ui/widgets/SubTaskProgressBar.h')
diff --git a/launcher/java/JavaInstallList.cpp b/launcher/java/JavaInstallList.cpp
index 5f133622..b29af857 100644
--- a/launcher/java/JavaInstallList.cpp
+++ b/launcher/java/JavaInstallList.cpp
@@ -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;
diff --git a/launcher/net/Download.cpp b/launcher/net/Download.cpp
index bf0e5c26..082f963d 100644
--- a/launcher/net/Download.cpp
+++ b/launcher/net/Download.cpp
@@ -247,19 +247,20 @@ void Download::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
// use milliseconds for speed precision
auto elapsed_ms = std::chrono::duration_cast(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);
diff --git a/launcher/net/NetAction.h b/launcher/net/NetAction.h
index df6ed995..a13d115f 100644
--- a/launcher/net/NetAction.h
+++ b/launcher/net/NetAction.h
@@ -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;
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index dbb4d94d..fae2f3dc 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -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) {
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h
index 04a09187..799ed945 100644
--- a/launcher/tasks/Task.h
+++ b/launcher/tasks/Task.h
@@ -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.
*/
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index 94feee44..246a0fd4 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -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, bool> = true>
std::tuple map_int_zero_max(T current, T range_max, T range_min)
diff --git a/launcher/ui/widgets/SubTaskProgressBar.h b/launcher/ui/widgets/SubTaskProgressBar.h
index 3375a0bc..8f8aeea2 100644
--- a/launcher/ui/widgets/SubTaskProgressBar.h
+++ b/launcher/ui/widgets/SubTaskProgressBar.h
@@ -18,8 +18,6 @@
*/
#pragma once
-#include
-#include
#include
#include "QObjectPtr.h"
--
cgit