| 43 | } |
| 44 | |
| 45 | void TextTip::configure(const QPoint &pos) |
| 46 | { |
| 47 | setText(tipText); |
| 48 | |
| 49 | QFontMetrics fm(font()); |
| 50 | int extraHeight = 0; |
| 51 | if (fm.descent() == 2 && fm.ascent() >= 11) |
| 52 | ++extraHeight; |
| 53 | |
| 54 | setWordWrap(false); |
| 55 | int tipWidth = sizeHint().width(); |
| 56 | |
| 57 | QScreen *screen = QGuiApplication::screenAt(pos); |
| 58 | if (!screen) |
| 59 | screen = QGuiApplication::primaryScreen(); |
| 60 | |
| 61 | const int screenWidth = screen->availableGeometry().width(); |
| 62 | const int maxDesiredWidth = int(screenWidth * .5); |
| 63 | if (tipWidth > maxDesiredWidth) { |
| 64 | setWordWrap(true); |
| 65 | tipWidth = maxDesiredWidth; |
| 66 | } |
| 67 | |
| 68 | resize(tipWidth, heightForWidth(tipWidth) + extraHeight); |
| 69 | } |
| 70 | |
| 71 | bool TextTip::canHandleContentReplacement(ContentType type) const |
| 72 | { |