| 66 | } |
| 67 | |
| 68 | void ToastManager::repositionToasts() { |
| 69 | if (toasts_.isEmpty()) { |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | const int container_width = container_->width(); |
| 74 | const int container_height = container_->height(); |
| 75 | const int toast_width = max_width_; |
| 76 | const int x = container_width - toast_width - margin_right_; |
| 77 | |
| 78 | // Newest toast (last in the list) sits at the bottom; stack upward from there. |
| 79 | int current_y = container_height - margin_bottom_; |
| 80 | |
| 81 | for (int i = toasts_.size() - 1; i >= 0; --i) { |
| 82 | ToastNotification* toast = toasts_[i]; |
| 83 | |
| 84 | toast->setFixedWidth(toast_width); |
| 85 | toast->layout()->activate(); // Recompute height for the fixed width. |
| 86 | |
| 87 | int toast_height = toast->heightForWidth(toast_width); |
| 88 | if (toast_height < 0) { |
| 89 | toast_height = toast->sizeHint().height(); |
| 90 | } |
| 91 | toast_height = qMax(toast_height, toast->minimumHeight()); |
| 92 | toast->setFixedHeight(toast_height); |
| 93 | |
| 94 | current_y -= toast_height; |
| 95 | toast->updateTargetPosition(QPoint(x, current_y)); |
| 96 | toast->show(); |
| 97 | |
| 98 | current_y -= spacing_; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | } // namespace PJ |
nothing calls this directly
no test coverage detected