fix: properly calculate min size for progress dialog, apply it at creation
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
4004e0faee
commit
3960eb7d32
@ -69,6 +69,7 @@ ProgressDialog::ProgressDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Pr
|
|||||||
setAttribute(Qt::WidgetAttribute::WA_QuitOnClose, true);
|
setAttribute(Qt::WidgetAttribute::WA_QuitOnClose, true);
|
||||||
setSkipButton(false);
|
setSkipButton(false);
|
||||||
changeProgress(0, 100);
|
changeProgress(0, 100);
|
||||||
|
updateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgressDialog::setSkipButton(bool present, QString label)
|
void ProgressDialog::setSkipButton(bool present, QString label)
|
||||||
@ -98,30 +99,28 @@ void ProgressDialog::updateSize()
|
|||||||
{
|
{
|
||||||
QSize lastSize = this->size();
|
QSize lastSize = this->size();
|
||||||
QPoint lastPos = this->pos();
|
QPoint lastPos = this->pos();
|
||||||
int minHeight = minimumSizeHint().height();
|
int minHeight = ui->globalStatusDetailsLabel->minimumSize().height() + (ui->verticalLayout->spacing() * 2);
|
||||||
if (ui->taskProgressScrollArea->isHidden())
|
minHeight += ui->globalProgressBar->minimumSize().height() + ui->verticalLayout->spacing();
|
||||||
minHeight -= ui->taskProgressScrollArea->minimumSizeHint().height();
|
if (!ui->taskProgressScrollArea->isHidden())
|
||||||
QSize labelMinSize = ui->globalStatusLabel->minimumSize();
|
minHeight += ui->taskProgressScrollArea->minimumSizeHint().height() + ui->verticalLayout->spacing();
|
||||||
int labelHeight = ui->globalStatusLabel->height();
|
if (ui->skipButton->isVisible())
|
||||||
if (labelHeight > labelMinSize.height())
|
minHeight += ui->skipButton->height() + ui->verticalLayout->spacing();
|
||||||
minHeight += labelHeight - labelMinSize.height(); // account for multiline label
|
minHeight = std::max(minHeight, 60);
|
||||||
minHeight = std::max(minHeight, 0);
|
|
||||||
QSize minSize = QSize(480, minHeight);
|
QSize minSize = QSize(480, minHeight);
|
||||||
|
|
||||||
|
setMinimumSize(minSize);
|
||||||
|
adjustSize();
|
||||||
|
|
||||||
|
QSize newSize = this->size();
|
||||||
// if the current window is too small
|
// if the current window is too small
|
||||||
if ((lastSize != minSize) && (lastSize.height() < minSize.height()))
|
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
|
QSize sizeDiff = lastSize - newSize; // last size was smaller, the results should be negative
|
||||||
// center on old position after resize
|
// center on old position after resize
|
||||||
QPoint newPos(lastPos.x() + (sizeDiff.width() / 2), lastPos.y() + (sizeDiff.height() / 2));
|
QPoint newPos(lastPos.x() + (sizeDiff.width() / 2), lastPos.y() + (sizeDiff.height() / 2));
|
||||||
this->move(newPos);
|
this->move(newPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMinimumSize(minSize);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ProgressDialog::execWithTask(Task* task)
|
int ProgressDialog::execWithTask(Task* task)
|
||||||
@ -211,7 +210,9 @@ void ProgressDialog::onTaskSucceeded()
|
|||||||
void ProgressDialog::changeStatus(const QString& status)
|
void ProgressDialog::changeStatus(const QString& status)
|
||||||
{
|
{
|
||||||
ui->globalStatusLabel->setText(task->getStatus());
|
ui->globalStatusLabel->setText(task->getStatus());
|
||||||
|
ui->globalStatusLabel->adjustSize();
|
||||||
ui->globalStatusDetailsLabel->setText(task->getDetails());
|
ui->globalStatusDetailsLabel->setText(task->getDetails());
|
||||||
|
ui->globalStatusDetailsLabel->adjustSize();
|
||||||
|
|
||||||
updateSize();
|
updateSize();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user