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/dialogs/ProgressDialog.cpp | 109 ++++++++++++++++++++++++-----
launcher/ui/dialogs/ProgressDialog.h | 54 +++++++++++---
launcher/ui/dialogs/ProgressDialog.ui | 61 ++++++++--------
launcher/ui/widgets/SubTaskProgressBar.cpp | 58 +++++++++++++++
launcher/ui/widgets/SubTaskProgressBar.h | 50 +++++++++++++
launcher/ui/widgets/SubTaskProgressBar.ui | 70 ++++++++++++++++++
6 files changed, 341 insertions(+), 61 deletions(-)
create mode 100644 launcher/ui/widgets/SubTaskProgressBar.cpp
create mode 100644 launcher/ui/widgets/SubTaskProgressBar.h
create mode 100644 launcher/ui/widgets/SubTaskProgressBar.ui
(limited to 'launcher/ui')
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index da73a449..da627af3 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -1,26 +1,66 @@
-/* Copyright 2013-2021 MultiMC Contributors
+/// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PrismLaucher - Minecraft Launcher
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#include "ProgressDialog.h"
#include "ui_ProgressDialog.h"
+#include
#include
#include
#include "tasks/Task.h"
+#include "ui/widgets/SubTaskProgressBar.h"
+
+
+template
+int map_int_range(T value)
+{
+ auto type_min = std::numeric_limits::min();
+ auto type_max = std::numeric_limits::max();
+
+ auto int_min = std::numeric_limits::min();
+ auto int_max = std::numeric_limits::max();
+
+ auto type_range = type_max - type_min;
+ auto int_range = int_max - int_min;
+
+ return static_cast((value - type_min) * int_range / type_range + int_min);
+}
+
+
ProgressDialog::ProgressDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ProgressDialog)
{
ui->setupUi(this);
@@ -79,7 +119,7 @@ int ProgressDialog::execWithTask(Task* task)
connect(task, &Task::failed, this, &ProgressDialog::onTaskFailed);
connect(task, &Task::succeeded, this, &ProgressDialog::onTaskSucceeded);
connect(task, &Task::status, this, &ProgressDialog::changeStatus);
- connect(task, &Task::stepStatus, this, &ProgressDialog::changeStatus);
+ connect(task, &Task::stepProgress, this, &ProgressDialog::changeStepProgress);
connect(task, &Task::progress, this, &ProgressDialog::changeProgress);
connect(task, &Task::aborted, this, &ProgressDialog::hide);
@@ -149,23 +189,54 @@ void ProgressDialog::onTaskSucceeded()
void ProgressDialog::changeStatus(const QString& status)
{
ui->globalStatusLabel->setText(task->getStatus());
- ui->statusLabel->setText(task->getStepStatus());
+ // ui->statusLabel->setText(task->getStepStatus());
updateSize();
}
+void ProgressDialog::addTaskProgress(TaskStepProgress progress)
+{
+ SubTaskProgressBar* task_bar = new SubTaskProgressBar(this);
+ taskProgress.insert(progress.uid, task_bar);
+ ui->taskProgressLayout->addWidget(task_bar);
+}
+
+void ProgressDialog::changeStepProgress(QList task_progress)
+{
+ for (auto tp : task_progress) {
+ if (!taskProgress.contains(tp.uid))
+ addTaskProgress(tp);
+ auto task_bar = taskProgress.value(tp.uid);
+
+ if (tp.total < 0) {
+ task_bar->setRange(0, 0);
+ } else {
+ task_bar->setRange(0, map_int_range(tp.total));
+ }
+
+ task_bar->setValue(map_int_range(tp.current));
+ task_bar->setStatus(tp.status);
+ task_bar->setDetails(tp.details);
+
+ if (tp.isDone()) {
+ task_bar->setVisible(false);
+ }
+
+ }
+}
+
void ProgressDialog::changeProgress(qint64 current, qint64 total)
{
ui->globalProgressBar->setMaximum(total);
ui->globalProgressBar->setValue(current);
- if (!m_is_multi_step) {
- ui->taskProgressBar->setMaximum(total);
- ui->taskProgressBar->setValue(current);
- } else {
- ui->taskProgressBar->setMaximum(task->getStepProgress());
- ui->taskProgressBar->setValue(task->getStepTotalProgress());
- }
+ // if (!m_is_multi_step) {
+ // ui->taskProgressBar->setMaximum(total);
+ // ui->taskProgressBar->setValue(current);
+ // } else {
+ // ui->taskProgressBar->setMaximum(task->getStepProgress());
+ // ui->taskProgressBar->setValue(task->getStepTotalProgress());
+ // }
}
void ProgressDialog::keyPressEvent(QKeyEvent* e)
diff --git a/launcher/ui/dialogs/ProgressDialog.h b/launcher/ui/dialogs/ProgressDialog.h
index 0b4b78a4..a7e203fb 100644
--- a/launcher/ui/dialogs/ProgressDialog.h
+++ b/launcher/ui/dialogs/ProgressDialog.h
@@ -1,22 +1,50 @@
-/* Copyright 2013-2021 MultiMC Contributors
+/// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PrismLaucher - Minecraft Launcher
+ * Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
+
#pragma once
#include
#include
+#include
+#include
+
+#include "QObjectPtr.h"
+#include "tasks/Task.h"
+
+#include "ui/widgets/SubTaskProgressBar.h"
class Task;
class SequentialTask;
@@ -52,6 +80,7 @@ slots:
void changeStatus(const QString &status);
void changeProgress(qint64 current, qint64 total);
+ void changeStepProgress(QList task_progress);
private
@@ -64,6 +93,7 @@ protected:
private:
bool handleImmediateResult(QDialog::DialogCode &result);
+ void addTaskProgress(TaskStepProgress progress);
private:
Ui::ProgressDialog *ui;
@@ -71,4 +101,8 @@ private:
Task *task;
bool m_is_multi_step = false;
+ QHash taskProgress;
+
+
};
+
diff --git a/launcher/ui/dialogs/ProgressDialog.ui b/launcher/ui/dialogs/ProgressDialog.ui
index 34ab71e3..0a998987 100644
--- a/launcher/ui/dialogs/ProgressDialog.ui
+++ b/launcher/ui/dialogs/ProgressDialog.ui
@@ -2,6 +2,20 @@
ProgressDialog
+
+
+ 0
+ 0
+ 400
+ 109
+
+
+
+
+ 0
+ 0
+
+
400
@@ -18,6 +32,16 @@
Please wait...
+ -
+
+
+ true
+
+
+ 24
+
+
+
-
@@ -31,15 +55,11 @@
- -
-
-
- Global Task Status...
-
-
+
-
+
- -
-
+
-
+
0
@@ -47,30 +67,7 @@
- Task Status...
-
-
- true
-
-
-
- -
-
-
- 24
-
-
- false
-
-
-
- -
-
-
- true
-
-
- 24
+ Global Task Status...
diff --git a/launcher/ui/widgets/SubTaskProgressBar.cpp b/launcher/ui/widgets/SubTaskProgressBar.cpp
new file mode 100644
index 00000000..84ea5f20
--- /dev/null
+++ b/launcher/ui/widgets/SubTaskProgressBar.cpp
@@ -0,0 +1,58 @@
+// 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 .
+ *
+ */
+
+#include "SubTaskProgressBar.h"
+#include "ui_SubTaskProgressBar.h"
+
+unique_qobject_ptr SubTaskProgressBar::create(QWidget* parent)
+{
+ auto progress_bar = new SubTaskProgressBar(parent);
+ return unique_qobject_ptr(progress_bar);
+}
+
+SubTaskProgressBar::SubTaskProgressBar(QWidget* parent)
+ : ui(new Ui::SubTaskProgressBar)
+{
+ ui->setupUi(this);
+}
+SubTaskProgressBar::~SubTaskProgressBar()
+{
+ delete ui;
+}
+
+void SubTaskProgressBar::setRange(int min, int max)
+{
+ ui->progressBar->setRange(min, max);
+}
+
+void SubTaskProgressBar::setValue(int value)
+{
+ ui->progressBar->setValue(value);
+}
+
+void SubTaskProgressBar::setStatus(QString status)
+{
+ ui->statusLabel->setText(status);
+}
+
+void SubTaskProgressBar::setDetails(QString details)
+{
+ ui->statusDetailsLabel->setText(details);
+}
+
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;
+
+};
diff --git a/launcher/ui/widgets/SubTaskProgressBar.ui b/launcher/ui/widgets/SubTaskProgressBar.ui
new file mode 100644
index 00000000..966fdb88
--- /dev/null
+++ b/launcher/ui/widgets/SubTaskProgressBar.ui
@@ -0,0 +1,70 @@
+
+
+ SubTaskProgressBar
+
+
+
+ 0
+ 0
+ 265
+ 65
+
+
+
+
+ 0
+ 0
+
+
+
+ Form
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Sub Task Status...
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Status Details
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+
+
+ -
+
+
+ 24
+
+
+ true
+
+
+
+
+
+
+
+
--
cgit
From 9d2f0e4dc8fc3995052770c6a7948cb0372fdcbb Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Thu, 30 Mar 2023 23:50:29 -0700
Subject: feat: Propogated subtask progress
Oh boy this is big.
> TaskStepProgress struct is now QMetaObject compatabile and can be sent through signals
> Task now has a method to propogates sub task progress it must be signal bound by each task containing a task wishing to report progress of it's children.
> Downloads report speed
> Tasks now have UUIDS to track them
- use when reporting
- use when logging
- use when storeing them or objects related to them
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/ui/dialogs/ProgressDialog.cpp | 65 ++++++++++--------
launcher/ui/dialogs/ProgressDialog.h | 4 +-
launcher/ui/dialogs/ProgressDialog.ui | 108 ++++++++++++++++++++++++------
launcher/ui/widgets/SubTaskProgressBar.ui | 31 +++++++--
4 files changed, 152 insertions(+), 56 deletions(-)
(limited to 'launcher/ui')
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index da627af3..f7a3a862 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -48,10 +48,12 @@
template
int map_int_range(T value)
{
- auto type_min = std::numeric_limits::min();
+ // auto type_min = std::numeric_limits::min();
+ auto type_min = 0;
auto type_max = std::numeric_limits::max();
- auto int_min = std::numeric_limits::min();
+ // auto int_min = std::numeric_limits::min();
+ auto int_min = 0;
auto int_max = std::numeric_limits::max();
auto type_range = type_max - type_min;
@@ -64,6 +66,7 @@ int map_int_range(T value)
ProgressDialog::ProgressDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ProgressDialog)
{
ui->setupUi(this);
+ ui->taskProgressScrollArea->setHidden(true);
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
setAttribute(Qt::WidgetAttribute::WA_QuitOnClose, true);
setSkipButton(false);
@@ -94,10 +97,17 @@ ProgressDialog::~ProgressDialog()
}
void ProgressDialog::updateSize()
-{
+{
+ QSize lastSize = this->size();
QSize qSize = QSize(480, minimumSizeHint().height());
resize(qSize);
setFixedSize(qSize);
+ // keep the dialog in the center after a resize
+ if (lastSize != qSize)
+ this->move(
+ this->parentWidget()->x() + (this->parentWidget()->width() - this->width()) / 2,
+ this->parentWidget()->y() + (this->parentWidget()->height() - this->height()) / 2
+ );
}
int ProgressDialog::execWithTask(Task* task)
@@ -126,10 +136,8 @@ int ProgressDialog::execWithTask(Task* task)
connect(task, &Task::abortStatusChanged, ui->skipButton, &QPushButton::setEnabled);
m_is_multi_step = task->isMultiStep();
- if (!m_is_multi_step) {
- ui->globalStatusLabel->setHidden(true);
- ui->globalProgressBar->setHidden(true);
- }
+ ui->taskProgressScrollArea->setHidden(!m_is_multi_step);
+ updateSize();
// It's a good idea to start the task after we entered the dialog's event loop :^)
if (!task->isRunning()) {
@@ -139,6 +147,9 @@ int ProgressDialog::execWithTask(Task* task)
changeProgress(task->getProgress(), task->getTotalProgress());
}
+ // auto size_hint = ui->verticalLayout->sizeHint();
+ // resize(size_hint.width(), size_hint.height());
+
return QDialog::exec();
}
@@ -189,40 +200,45 @@ void ProgressDialog::onTaskSucceeded()
void ProgressDialog::changeStatus(const QString& status)
{
ui->globalStatusLabel->setText(task->getStatus());
- // ui->statusLabel->setText(task->getStepStatus());
+ ui->globalStatusDetailsLabel->setText(task->getDetails());
updateSize();
}
-void ProgressDialog::addTaskProgress(TaskStepProgress progress)
+void ProgressDialog::addTaskProgress(TaskStepProgress* progress)
{
SubTaskProgressBar* task_bar = new SubTaskProgressBar(this);
- taskProgress.insert(progress.uid, task_bar);
- ui->taskProgressLayout->addWidget(task_bar);
+ taskProgress.insert(progress->uid, task_bar);
+ ui->taskProgressLayout->insertWidget(0, task_bar);
}
-void ProgressDialog::changeStepProgress(QList task_progress)
+void ProgressDialog::changeStepProgress(TaskStepProgressList task_progress)
{
+ m_is_multi_step = true;
+ ui->taskProgressScrollArea->setHidden(false);
+
for (auto tp : task_progress) {
- if (!taskProgress.contains(tp.uid))
- addTaskProgress(tp);
- auto task_bar = taskProgress.value(tp.uid);
+ if (!taskProgress.contains(tp->uid))
+ addTaskProgress(tp.get());
+ auto task_bar = taskProgress.value(tp->uid);
- if (tp.total < 0) {
+ if (tp->total < 0) {
task_bar->setRange(0, 0);
} else {
- task_bar->setRange(0, map_int_range(tp.total));
+ task_bar->setRange(0, map_int_range(tp->total));
}
- task_bar->setValue(map_int_range(tp.current));
- task_bar->setStatus(tp.status);
- task_bar->setDetails(tp.details);
+ task_bar->setValue(map_int_range(tp->current));
+ task_bar->setStatus(tp->status);
+ task_bar->setDetails(tp->details);
- if (tp.isDone()) {
+ if (tp->isDone()) {
task_bar->setVisible(false);
}
}
+
+ updateSize();
}
void ProgressDialog::changeProgress(qint64 current, qint64 total)
@@ -230,13 +246,6 @@ void ProgressDialog::changeProgress(qint64 current, qint64 total)
ui->globalProgressBar->setMaximum(total);
ui->globalProgressBar->setValue(current);
- // if (!m_is_multi_step) {
- // ui->taskProgressBar->setMaximum(total);
- // ui->taskProgressBar->setValue(current);
- // } else {
- // ui->taskProgressBar->setMaximum(task->getStepProgress());
- // ui->taskProgressBar->setValue(task->getStepTotalProgress());
- // }
}
void ProgressDialog::keyPressEvent(QKeyEvent* e)
diff --git a/launcher/ui/dialogs/ProgressDialog.h b/launcher/ui/dialogs/ProgressDialog.h
index a7e203fb..95a4db16 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(QList task_progress);
+ void changeStepProgress(TaskStepProgressList task_progress);
private
@@ -93,7 +93,7 @@ protected:
private:
bool handleImmediateResult(QDialog::DialogCode &result);
- void addTaskProgress(TaskStepProgress progress);
+ void addTaskProgress(TaskStepProgress* progress);
private:
Ui::ProgressDialog *ui;
diff --git a/launcher/ui/dialogs/ProgressDialog.ui b/launcher/ui/dialogs/ProgressDialog.ui
index 0a998987..47597689 100644
--- a/launcher/ui/dialogs/ProgressDialog.ui
+++ b/launcher/ui/dialogs/ProgressDialog.ui
@@ -6,20 +6,20 @@
0
0
- 400
- 109
+ 600
+ 260
-
- 0
- 0
+
+ 1
+ 1
- 400
- 0
+ 600
+ 260
@@ -31,43 +31,109 @@
Please wait...
-
- -
+
+
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 15
+
+
+
+ Global Task Status...
+
+
+
+ -
+
+
+ Global Status Details...
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+
+
+
+ -
true
+
+
+ 0
+ 24
+
+
24
- -
-
+
-
+
-
+
0
0
-
- Skip
+
+
+ 0
+ 100
+
+
+
+ QFrame::StyledPanel
+
+ Qt::ScrollBarAsNeeded
+
+
+ QAbstractScrollArea::AdjustToContents
+
+
+ true
+
+
+
+
+ 0
+ 0
+ 584
+ 146
+
+
+
+
+ 2
+
+
+
- -
-
-
- -
-
+
-
+
-
+
0
0
- Global Task Status...
+ Skip
diff --git a/launcher/ui/widgets/SubTaskProgressBar.ui b/launcher/ui/widgets/SubTaskProgressBar.ui
index 966fdb88..ceae5e26 100644
--- a/launcher/ui/widgets/SubTaskProgressBar.ui
+++ b/launcher/ui/widgets/SubTaskProgressBar.ui
@@ -6,12 +6,12 @@
0
0
- 265
- 65
+ 597
+ 61
-
+
0
0
@@ -20,29 +20,45 @@
Form
+
+ 0
+
-
-
-
+
0
0
+
+
+ 8
+
+
Sub Task Status...
+
+ true
+
-
-
+
0
0
+
+
+ 8
+
+
Status Details
@@ -55,6 +71,11 @@
-
+
+
+ 8
+
+
24
--
cgit
From f1028fa66d556b024765ba4e21ac76d4510a3e3e Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Fri, 31 Mar 2023 12:29:59 -0700
Subject: fix: properly map progress range - doument PCRE used for URL
compacting
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/ui/dialogs/ProgressDialog.cpp | 56 ++++++++++++++++++----------------
launcher/ui/dialogs/ProgressDialog.ui | 21 ++++++-------
2 files changed, 39 insertions(+), 38 deletions(-)
(limited to 'launcher/ui')
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index f7a3a862..7ab766e4 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -45,21 +45,18 @@
#include "ui/widgets/SubTaskProgressBar.h"
-template
-int map_int_range(T value)
+// 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::value, T>::type>
+std::tuple map_int_zero_max(T current, T range_max, T range_min)
{
- // auto type_min = std::numeric_limits::min();
- auto type_min = 0;
- auto type_max = std::numeric_limits::max();
+ int int_max = std::numeric_limits::max();
- // auto int_min = std::numeric_limits::min();
- auto int_min = 0;
- auto int_max = std::numeric_limits::max();
+ auto type_range = range_max - range_min;
+ double percentage = static_cast(current - range_min) / static_cast(type_range);
+ int mapped_current = percentage * int_max;
- auto type_range = type_max - type_min;
- auto int_range = int_max - int_min;
-
- return static_cast((value - type_min) * int_range / type_range + int_min);
+ return {mapped_current, int_max};
}
@@ -100,14 +97,21 @@ void ProgressDialog::updateSize()
{
QSize lastSize = this->size();
QSize qSize = QSize(480, minimumSizeHint().height());
- resize(qSize);
- setFixedSize(qSize);
- // keep the dialog in the center after a resize
- if (lastSize != qSize)
+
+ // if the current window is too small
+ if ((lastSize != qSize) && (lastSize.height() < qSize.height()))
+ {
+ resize(qSize);
+
+ // keep the dialog in the center after a resize
this->move(
this->parentWidget()->x() + (this->parentWidget()->width() - this->width()) / 2,
this->parentWidget()->y() + (this->parentWidget()->height() - this->height()) / 2
);
+ }
+
+ setMinimumSize(qSize);
+
}
int ProgressDialog::execWithTask(Task* task)
@@ -147,9 +151,6 @@ int ProgressDialog::execWithTask(Task* task)
changeProgress(task->getProgress(), task->getTotalProgress());
}
- // auto size_hint = ui->verticalLayout->sizeHint();
- // resize(size_hint.width(), size_hint.height());
-
return QDialog::exec();
}
@@ -209,26 +210,31 @@ void ProgressDialog::addTaskProgress(TaskStepProgress* progress)
{
SubTaskProgressBar* task_bar = new SubTaskProgressBar(this);
taskProgress.insert(progress->uid, task_bar);
- ui->taskProgressLayout->insertWidget(0, task_bar);
+ ui->taskProgressLayout->addWidget(task_bar);
}
void ProgressDialog::changeStepProgress(TaskStepProgressList task_progress)
{
m_is_multi_step = true;
- ui->taskProgressScrollArea->setHidden(false);
+ if(ui->taskProgressScrollArea->isHidden()) {
+ ui->taskProgressScrollArea->setHidden(false);
+ updateSize();
+ }
for (auto tp : task_progress) {
if (!taskProgress.contains(tp->uid))
addTaskProgress(tp.get());
auto task_bar = taskProgress.value(tp->uid);
- if (tp->total < 0) {
+
+ auto const [mapped_current, mapped_total] = map_int_zero_max(tp->current, tp->total, 0);
+ if (tp->total <= 0) {
task_bar->setRange(0, 0);
} else {
- task_bar->setRange(0, map_int_range(tp->total));
+ task_bar->setRange(0, mapped_total);
}
- task_bar->setValue(map_int_range(tp->current));
+ task_bar->setValue(mapped_current);
task_bar->setStatus(tp->status);
task_bar->setDetails(tp->details);
@@ -237,8 +243,6 @@ void ProgressDialog::changeStepProgress(TaskStepProgressList task_progress)
}
}
-
- updateSize();
}
void ProgressDialog::changeProgress(qint64 current, qint64 total)
diff --git a/launcher/ui/dialogs/ProgressDialog.ui b/launcher/ui/dialogs/ProgressDialog.ui
index 47597689..a4d08124 100644
--- a/launcher/ui/dialogs/ProgressDialog.ui
+++ b/launcher/ui/dialogs/ProgressDialog.ui
@@ -6,8 +6,8 @@
0
0
- 600
- 260
+ 480
+ 210
@@ -18,19 +18,16 @@
- 600
- 260
-
-
-
-
- 600
- 16777215
+ 480
+ 210
Please wait...
+
+ true
+
-
@@ -112,8 +109,8 @@
0
0
- 584
- 146
+ 464
+ 96
--
cgit
From b6452215c16f6b1ee45fea746f9498767e48d049 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Fri, 31 Mar 2023 19:25:01 -0700
Subject: feat: add `details` signal to `Task` feat: add details to mod pack
downloading feat: add logging rule sloading form `ligging.ini at data path
root feat: add `launcher.task` `launcher.task.net` and
`launcher.task.net.[down|up]load` logging categories fix: add new subtask
progress to the end of the lay out not the beginning (cuts down on
flickering)
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/ui/dialogs/ProgressDialog.cpp | 2 +-
launcher/ui/widgets/ProgressWidget.cpp | 1 +
launcher/ui/widgets/SubTaskProgressBar.ui | 7 +++++--
3 files changed, 7 insertions(+), 3 deletions(-)
(limited to 'launcher/ui')
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index 7ab766e4..1937c553 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -133,9 +133,9 @@ int ProgressDialog::execWithTask(Task* task)
connect(task, &Task::failed, this, &ProgressDialog::onTaskFailed);
connect(task, &Task::succeeded, this, &ProgressDialog::onTaskSucceeded);
connect(task, &Task::status, this, &ProgressDialog::changeStatus);
+ connect(task, &Task::details, this, &ProgressDialog::changeStatus);
connect(task, &Task::stepProgress, this, &ProgressDialog::changeStepProgress);
connect(task, &Task::progress, this, &ProgressDialog::changeProgress);
-
connect(task, &Task::aborted, this, &ProgressDialog::hide);
connect(task, &Task::abortStatusChanged, ui->skipButton, &QPushButton::setEnabled);
diff --git a/launcher/ui/widgets/ProgressWidget.cpp b/launcher/ui/widgets/ProgressWidget.cpp
index f736af08..9181de7f 100644
--- a/launcher/ui/widgets/ProgressWidget.cpp
+++ b/launcher/ui/widgets/ProgressWidget.cpp
@@ -51,6 +51,7 @@ void ProgressWidget::watch(const Task* task)
connect(m_task, &Task::finished, this, &ProgressWidget::handleTaskFinish);
connect(m_task, &Task::status, this, &ProgressWidget::handleTaskStatus);
+ // TODO: should we connect &Task::details
connect(m_task, &Task::progress, this, &ProgressWidget::handleTaskProgress);
connect(m_task, &Task::destroyed, this, &ProgressWidget::taskDestroyed);
diff --git a/launcher/ui/widgets/SubTaskProgressBar.ui b/launcher/ui/widgets/SubTaskProgressBar.ui
index ceae5e26..5431eab6 100644
--- a/launcher/ui/widgets/SubTaskProgressBar.ui
+++ b/launcher/ui/widgets/SubTaskProgressBar.ui
@@ -6,8 +6,8 @@
0
0
- 597
- 61
+ 312
+ 86
@@ -25,6 +25,9 @@
-
+
+ 8
+
-
--
cgit
From 0fb6a2836be2fe51e27a47595950923dca329006 Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Sun, 2 Apr 2023 21:51:07 -0700
Subject: refactor: propogate only only one StepProgress at a time
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/ui/dialogs/ProgressDialog.cpp | 38 ++++++++++++++++------------------
launcher/ui/dialogs/ProgressDialog.h | 2 +-
2 files changed, 19 insertions(+), 21 deletions(-)
(limited to 'launcher/ui')
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::value, T>::type>
+// 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)
{
int int_max = std::numeric_limits::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(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(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
--
cgit
From 236764adf6cb985dfc6d00b9cbcba8eb176510ed Mon Sep 17 00:00:00 2001
From: Rachel Powers <508861+Ryex@users.noreply.github.com>
Date: Fri, 7 Apr 2023 19:44:57 -0700
Subject: refactor: Qt can handle const& in signals and slots
While most Qt types cna use implicit data sharing
pasing our own structs means copies. const& ensure
it's only copied as needed by Qt.
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
---
launcher/ui/dialogs/ProgressDialog.cpp | 8 ++++----
launcher/ui/dialogs/ProgressDialog.h | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
(limited to 'launcher/ui')
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index 7594484e..94feee44 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -206,14 +206,14 @@ void ProgressDialog::changeStatus(const QString& status)
updateSize();
}
-void ProgressDialog::addTaskProgress(TaskStepProgress* progress)
+void ProgressDialog::addTaskProgress(TaskStepProgress const& progress)
{
SubTaskProgressBar* task_bar = new SubTaskProgressBar(this);
- taskProgress.insert(progress->uid, task_bar);
+ taskProgress.insert(progress.uid, task_bar);
ui->taskProgressLayout->addWidget(task_bar);
}
-void ProgressDialog::changeStepProgress(TaskStepProgress task_progress)
+void ProgressDialog::changeStepProgress(TaskStepProgress const& task_progress)
{
m_is_multi_step = true;
if(ui->taskProgressScrollArea->isHidden()) {
@@ -222,7 +222,7 @@ void ProgressDialog::changeStepProgress(TaskStepProgress task_progress)
}
if (!taskProgress.contains(task_progress.uid))
- addTaskProgress(&task_progress);
+ addTaskProgress(task_progress);
auto task_bar = taskProgress.value(task_progress.uid);
diff --git a/launcher/ui/dialogs/ProgressDialog.h b/launcher/ui/dialogs/ProgressDialog.h
index 6779b949..fc9a0fbc 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(TaskStepProgress task_progress);
+ void changeStepProgress(TaskStepProgress const& task_progress);
private
@@ -93,7 +93,7 @@ protected:
private:
bool handleImmediateResult(QDialog::DialogCode &result);
- void addTaskProgress(TaskStepProgress* progress);
+ void addTaskProgress(TaskStepProgress const& progress);
private:
Ui::ProgressDialog *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/ui/dialogs/ProgressDialog.cpp | 2 +-
launcher/ui/widgets/SubTaskProgressBar.h | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
(limited to 'launcher/ui')
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