| 128 | } |
| 129 | |
| 130 | void VersionListView::paintInfoLabel(QPaintEvent* event) const |
| 131 | { |
| 132 | QString emptyString = currentEmptyString(); |
| 133 | |
| 134 | // calculate the rect for the overlay |
| 135 | QPainter painter(viewport()); |
| 136 | painter.setRenderHint(QPainter::Antialiasing, true); |
| 137 | QFont font("sans", 20); |
| 138 | font.setBold(true); |
| 139 | |
| 140 | QRect bounds = viewport()->geometry(); |
| 141 | bounds.moveTop(0); |
| 142 | auto innerBounds = bounds; |
| 143 | innerBounds.adjust(10, 10, -10, -10); |
| 144 | |
| 145 | QColor background = QApplication::palette().color(QPalette::WindowText); |
| 146 | QColor foreground = QApplication::palette().color(QPalette::Base); |
| 147 | foreground.setAlpha(190); |
| 148 | painter.setFont(font); |
| 149 | auto fontMetrics = painter.fontMetrics(); |
| 150 | auto textRect = fontMetrics.boundingRect(innerBounds, Qt::AlignHCenter | Qt::TextWordWrap, emptyString); |
| 151 | textRect.moveCenter(bounds.center()); |
| 152 | |
| 153 | auto wrapRect = textRect; |
| 154 | wrapRect.adjust(-10, -10, 10, 10); |
| 155 | |
| 156 | // check if we are allowed to draw in our area |
| 157 | if (!event->rect().intersects(wrapRect)) { |
| 158 | return; |
| 159 | } |
| 160 | |
| 161 | painter.setBrush(QBrush(background)); |
| 162 | painter.setPen(foreground); |
| 163 | painter.drawRoundedRect(wrapRect, 5.0, 5.0); |
| 164 | |
| 165 | painter.setPen(foreground); |
| 166 | painter.setFont(font); |
| 167 | painter.drawText(textRect, Qt::AlignHCenter | Qt::TextWordWrap, emptyString); |
| 168 | } |