aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2023-03-30 23:50:29 -0700
committerRachel Powers <508861+Ryex@users.noreply.github.com>2023-05-01 10:47:20 -0700
commit9d2f0e4dc8fc3995052770c6a7948cb0372fdcbb (patch)
tree4daee3300ac1b7ad650e715395434d5277027bdf /launcher/ui
parentf997529cd4fb077b06d05da9c6ff0c23b85b4ebb (diff)
downloadPrismLauncher-9d2f0e4dc8fc3995052770c6a7948cb0372fdcbb.tar.gz
PrismLauncher-9d2f0e4dc8fc3995052770c6a7948cb0372fdcbb.tar.bz2
PrismLauncher-9d2f0e4dc8fc3995052770c6a7948cb0372fdcbb.zip
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>
Diffstat (limited to 'launcher/ui')
-rw-r--r--launcher/ui/dialogs/ProgressDialog.cpp65
-rw-r--r--launcher/ui/dialogs/ProgressDialog.h4
-rw-r--r--launcher/ui/dialogs/ProgressDialog.ui108
-rw-r--r--launcher/ui/widgets/SubTaskProgressBar.ui31
4 files changed, 152 insertions, 56 deletions
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<typename T>
int map_int_range(T value)
{
- auto type_min = std::numeric_limits<T>::min();
+ // auto type_min = std::numeric_limits<T>::min();
+ auto type_min = 0;
auto type_max = std::numeric_limits<T>::max();
- auto int_min = std::numeric_limits<int>::min();
+ // auto int_min = std::numeric_limits<int>::min();
+ auto int_min = 0;
auto int_max = std::numeric_limits<int>::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<TaskStepProgress> 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<qint64>(tp.total));
+ task_bar->setRange(0, map_int_range<qint64>(tp->total));
}
- task_bar->setValue(map_int_range<qint64>(tp.current));
- task_bar->setStatus(tp.status);
- task_bar->setDetails(tp.details);
+ task_bar->setValue(map_int_range<qint64>(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<TaskStepProgress> 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 @@
<rect>
<x>0</x>
<y>0</y>
- <width>400</width>
- <height>109</height>
+ <width>600</width>
+ <height>260</height>
</rect>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>1</horstretch>
+ <verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
- <width>400</width>
- <height>0</height>
+ <width>600</width>
+ <height>260</height>
</size>
</property>
<property name="maximumSize">
@@ -31,43 +31,109 @@
<property name="windowTitle">
<string>Please wait...</string>
</property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="2" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
+ <item>
+ <widget class="QLabel" name="globalStatusLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Global Task Status...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="globalStatusDetailsLabel">
+ <property name="text">
+ <string>Global Status Details...</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
<widget class="QProgressBar" name="globalProgressBar">
<property name="enabled">
<bool>true</bool>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>24</height>
+ </size>
+ </property>
<property name="value">
<number>24</number>
</property>
</widget>
</item>
- <item row="4" column="0">
- <widget class="QPushButton" name="skipButton">
+ <item>
+ <widget class="QScrollArea" name="taskProgressScrollArea">
<property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="text">
- <string>Skip</string>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>100</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
</property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAsNeeded</enum>
+ </property>
+ <property name="sizeAdjustPolicy">
+ <enum>QAbstractScrollArea::AdjustToContents</enum>
+ </property>
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="taskProgressContainer">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>584</width>
+ <height>146</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="taskProgressLayout">
+ <property name="spacing">
+ <number>2</number>
+ </property>
+ </layout>
+ </widget>
</widget>
</item>
- <item row="3" column="0">
- <layout class="QVBoxLayout" name="taskProgressLayout"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="globalStatusLabel">
+ <item>
+ <widget class="QPushButton" name="skipButton">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
- <string>Global Task Status...</string>
+ <string>Skip</string>
</property>
</widget>
</item>
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 @@
<rect>
<x>0</x>
<y>0</y>
- <width>265</width>
- <height>65</height>
+ <width>597</width>
+ <height>61</height>
</rect>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Ignored">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -20,29 +20,45 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
+ <property name="spacing">
+ <number>0</number>
+ </property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
<item>
<widget class="QLabel" name="statusLabel">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="font">
+ <font>
+ <pointsize>8</pointsize>
+ </font>
+ </property>
<property name="text">
<string>Sub Task Status...</string>
</property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item>
<widget class="QLabel" name="statusDetailsLabel">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="font">
+ <font>
+ <pointsize>8</pointsize>
+ </font>
+ </property>
<property name="text">
<string>Status Details</string>
</property>
@@ -55,6 +71,11 @@
</item>
<item>
<widget class="QProgressBar" name="progressBar">
+ <property name="font">
+ <font>
+ <pointsize>8</pointsize>
+ </font>
+ </property>
<property name="value">
<number>24</number>
</property>