aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/dialogs
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2023-04-02 21:51:07 -0700
committerRachel Powers <508861+Ryex@users.noreply.github.com>2023-05-01 10:48:00 -0700
commit0fb6a2836be2fe51e27a47595950923dca329006 (patch)
treea9ed6fd2fe97b9a8d2c2405b6f10bbe3ddfac842 /launcher/ui/dialogs
parentfe36471b8dfad6156b735f9393072b9111a12547 (diff)
downloadPrismLauncher-0fb6a2836be2fe51e27a47595950923dca329006.tar.gz
PrismLauncher-0fb6a2836be2fe51e27a47595950923dca329006.tar.bz2
PrismLauncher-0fb6a2836be2fe51e27a47595950923dca329006.zip
refactor: propogate only only one StepProgress at a time
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
Diffstat (limited to 'launcher/ui/dialogs')
-rw-r--r--launcher/ui/dialogs/ProgressDialog.cpp38
-rw-r--r--launcher/ui/dialogs/ProgressDialog.h2
2 files changed, 19 insertions, 21 deletions
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index 1937c553..7594484e 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -46,8 +46,8 @@
// map a value in a numaric range of an arbatray type to between 0 and INT_MAX
-// for getting the best percision out of the qt progress bar
-template<typename T, typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
+// 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)
{
int int_max = std::numeric_limits<int>::max();
@@ -213,7 +213,7 @@ void ProgressDialog::addTaskProgress(TaskStepProgress* progress)
ui->taskProgressLayout->addWidget(task_bar);
}
-void ProgressDialog::changeStepProgress(TaskStepProgressList task_progress)
+void ProgressDialog::changeStepProgress(TaskStepProgress task_progress)
{
m_is_multi_step = true;
if(ui->taskProgressScrollArea->isHidden()) {
@@ -221,28 +221,26 @@ void ProgressDialog::changeStepProgress(TaskStepProgressList task_progress)
updateSize();
}
- for (auto tp : task_progress) {
- if (!taskProgress.contains(tp->uid))
- addTaskProgress(tp.get());
- auto task_bar = taskProgress.value(tp->uid);
+ if (!taskProgress.contains(task_progress.uid))
+ addTaskProgress(&task_progress);
+ auto task_bar = taskProgress.value(task_progress.uid);
- auto const [mapped_current, mapped_total] = map_int_zero_max<qint64>(tp->current, tp->total, 0);
- if (tp->total <= 0) {
- task_bar->setRange(0, 0);
- } else {
- task_bar->setRange(0, mapped_total);
- }
-
- task_bar->setValue(mapped_current);
- task_bar->setStatus(tp->status);
- task_bar->setDetails(tp->details);
+ auto const [mapped_current, mapped_total] = map_int_zero_max<qint64>(task_progress.current, task_progress.total, 0);
+ if (task_progress.total <= 0) {
+ task_bar->setRange(0, 0);
+ } else {
+ task_bar->setRange(0, mapped_total);
+ }
- if (tp->isDone()) {
- task_bar->setVisible(false);
- }
+ task_bar->setValue(mapped_current);
+ task_bar->setStatus(task_progress.status);
+ task_bar->setDetails(task_progress.details);
+ if (task_progress.isDone()) {
+ task_bar->setVisible(false);
}
+
}
void ProgressDialog::changeProgress(qint64 current, qint64 total)
diff --git a/launcher/ui/dialogs/ProgressDialog.h b/launcher/ui/dialogs/ProgressDialog.h
index 95a4db16..6779b949 100644
--- a/launcher/ui/dialogs/ProgressDialog.h
+++ b/launcher/ui/dialogs/ProgressDialog.h
@@ -80,7 +80,7 @@ slots:
void changeStatus(const QString &status);
void changeProgress(qint64 current, qint64 total);
- void changeStepProgress(TaskStepProgressList task_progress);
+ void changeStepProgress(TaskStepProgress task_progress);
private