| 24 | } |
| 25 | |
| 26 | void IconLabel::paintEvent(QPaintEvent *) |
| 27 | { |
| 28 | QPainter p(this); |
| 29 | QRect rect = contentsRect(); |
| 30 | int width = rect.width(); |
| 31 | int height = rect.height(); |
| 32 | if(width < height) |
| 33 | { |
| 34 | rect.setHeight(width); |
| 35 | rect.translate(0, (height - width) / 2); |
| 36 | } |
| 37 | else if (width > height) |
| 38 | { |
| 39 | rect.setWidth(height); |
| 40 | rect.translate((width - height) / 2, 0); |
| 41 | } |
| 42 | m_icon.paint(&p, rect); |
| 43 | } |