| 97 | } |
| 98 | |
| 99 | void ProgressDialog::updateSize(bool recenterParent) |
| 100 | { |
| 101 | QSize lastSize = this->size(); |
| 102 | QPoint lastPos = this->pos(); |
| 103 | int minHeight = ui->globalStatusDetailsLabel->minimumSize().height() + (ui->verticalLayout->spacing() * 2); |
| 104 | minHeight += ui->globalProgressBar->minimumSize().height() + ui->verticalLayout->spacing(); |
| 105 | if (!ui->taskProgressScrollArea->isHidden()) |
| 106 | minHeight += ui->taskProgressScrollArea->minimumSizeHint().height() + ui->verticalLayout->spacing(); |
| 107 | if (ui->skipButton->isVisible()) |
| 108 | minHeight += ui->skipButton->height() + ui->verticalLayout->spacing(); |
| 109 | minHeight = std::max(minHeight, 60); |
| 110 | QSize minSize = QSize(480, minHeight); |
| 111 | |
| 112 | setMinimumSize(minSize); |
| 113 | adjustSize(); |
| 114 | |
| 115 | QSize newSize = this->size(); |
| 116 | // if the current window is a different size |
| 117 | auto parent = this->parentWidget(); |
| 118 | if (recenterParent && parent) { |
| 119 | auto newX = std::max(0, parent->x() + ((parent->width() - newSize.width()) / 2)); |
| 120 | auto newY = std::max(0, parent->y() + ((parent->height() - newSize.height()) / 2)); |
| 121 | this->move(newX, newY); |
| 122 | } else if (lastSize != newSize) { |
| 123 | // center on old position after resize |
| 124 | QSize sizeDiff = lastSize - newSize; // last size was smaller, the results should be negative |
| 125 | auto newX = std::max(0, lastPos.x() + (sizeDiff.width() / 2)); |
| 126 | auto newY = std::max(0, lastPos.y() + (sizeDiff.height() / 2)); |
| 127 | this->move(newX, newY); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | int ProgressDialog::execWithTask(Task* task) |
| 132 | { |