aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRachel Powers <508861+Ryex@users.noreply.github.com>2023-07-02 21:24:43 -0700
committerRachel Powers <508861+Ryex@users.noreply.github.com>2023-07-02 21:24:43 -0700
commit3960eb7d32af6ea776634b9f94e12f8df2397627 (patch)
tree2339b82b5d365ac9786ee027e98e9517728105eb
parent4004e0faeed99b3deb0ffb0b0f469594843ca14b (diff)
downloadPrismLauncher-3960eb7d32af6ea776634b9f94e12f8df2397627.tar.gz
PrismLauncher-3960eb7d32af6ea776634b9f94e12f8df2397627.tar.bz2
PrismLauncher-3960eb7d32af6ea776634b9f94e12f8df2397627.zip
fix: properly calculate min size for progress dialog, apply it at creation
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
-rw-r--r--launcher/ui/dialogs/ProgressDialog.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index 84f9db7e..f70eee49 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -69,6 +69,7 @@ ProgressDialog::ProgressDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Pr
setAttribute(Qt::WidgetAttribute::WA_QuitOnClose, true);
setSkipButton(false);
changeProgress(0, 100);
+ updateSize();
}
void ProgressDialog::setSkipButton(bool present, QString label)
@@ -98,30 +99,28 @@ void ProgressDialog::updateSize()
{
QSize lastSize = this->size();
QPoint lastPos = this->pos();
- int minHeight = minimumSizeHint().height();
- if (ui->taskProgressScrollArea->isHidden())
- minHeight -= ui->taskProgressScrollArea->minimumSizeHint().height();
- QSize labelMinSize = ui->globalStatusLabel->minimumSize();
- int labelHeight = ui->globalStatusLabel->height();
- if (labelHeight > labelMinSize.height())
- minHeight += labelHeight - labelMinSize.height(); // account for multiline label
- minHeight = std::max(minHeight, 0);
+ int minHeight = ui->globalStatusDetailsLabel->minimumSize().height() + (ui->verticalLayout->spacing() * 2);
+ minHeight += ui->globalProgressBar->minimumSize().height() + ui->verticalLayout->spacing();
+ if (!ui->taskProgressScrollArea->isHidden())
+ minHeight += ui->taskProgressScrollArea->minimumSizeHint().height() + ui->verticalLayout->spacing();
+ if (ui->skipButton->isVisible())
+ minHeight += ui->skipButton->height() + ui->verticalLayout->spacing();
+ minHeight = std::max(minHeight, 60);
QSize minSize = QSize(480, minHeight);
+ setMinimumSize(minSize);
+ adjustSize();
+
+ QSize newSize = this->size();
// if the current window is too small
if ((lastSize != minSize) && (lastSize.height() < minSize.height()))
{
- resize(minSize);
-
- QSize newSize = this->size();
QSize sizeDiff = lastSize - newSize; // last size was smaller, the results should be negative
// center on old position after resize
QPoint newPos(lastPos.x() + (sizeDiff.width() / 2), lastPos.y() + (sizeDiff.height() / 2));
this->move(newPos);
}
- setMinimumSize(minSize);
-
}
int ProgressDialog::execWithTask(Task* task)
@@ -211,7 +210,9 @@ void ProgressDialog::onTaskSucceeded()
void ProgressDialog::changeStatus(const QString& status)
{
ui->globalStatusLabel->setText(task->getStatus());
+ ui->globalStatusLabel->adjustSize();
ui->globalStatusDetailsLabel->setText(task->getDetails());
+ ui->globalStatusDetailsLabel->adjustSize();
updateSize();
}