| 119 | } |
| 120 | |
| 121 | void ErrorWidget::paintEvent(QPaintEvent *) |
| 122 | { |
| 123 | QPainter painter(this); |
| 124 | painter.setRenderHint(QPainter::Antialiasing); |
| 125 | painter.setRenderHint(QPainter::TextAntialiasing); |
| 126 | |
| 127 | // Draw background with border |
| 128 | QColor bgColor = m_backgroundColor; |
| 129 | if (m_isHovered) { |
| 130 | bgColor = bgColor.lighter(110); |
| 131 | } |
| 132 | |
| 133 | QPainterPath path; |
| 134 | path.addRoundedRect(rect().adjusted(1, 1, -1, -1), 4, 4); |
| 135 | |
| 136 | painter.fillPath(path, bgColor); |
| 137 | painter.setPen(QPen(m_errorColor.lighter(150), 1)); |
| 138 | painter.drawPath(path); |
| 139 | |
| 140 | const int iconSize = 18; |
| 141 | const int padding = 8; |
| 142 | const int margin = 12; |
| 143 | |
| 144 | // Draw error icon |
| 145 | if (!m_errorIcon.isNull()) { |
| 146 | QRect iconRect(margin, margin, iconSize, iconSize); |
| 147 | painter.drawPixmap(iconRect, m_errorIcon); |
| 148 | } |
| 149 | |
| 150 | // Draw error message with word wrap |
| 151 | painter.setPen(m_textColor); |
| 152 | QRect textRect = rect().adjusted( |
| 153 | margin + iconSize + padding, // left |
| 154 | margin, // top |
| 155 | -margin, // right |
| 156 | -margin // bottom |
| 157 | ); |
| 158 | |
| 159 | painter.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap, m_errorMessage); |
| 160 | } |
| 161 | |
| 162 | void ErrorWidget::mousePressEvent(QMouseEvent *event) |
| 163 | { |
nothing calls this directly
no outgoing calls
no test coverage detected